babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. 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>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. 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;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. 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;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. 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;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * 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".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * 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"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * 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"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignored for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @returns the current unchanged quaternion
  3895. */
  3896. toEulerAnglesToRef(result: Vector3): Quaternion;
  3897. /**
  3898. * Updates the given rotation matrix with the current quaternion values
  3899. * @param result defines the target matrix
  3900. * @returns the current unchanged quaternion
  3901. */
  3902. toRotationMatrix(result: Matrix): Quaternion;
  3903. /**
  3904. * Updates the current quaternion from the given rotation matrix values
  3905. * @param matrix defines the source matrix
  3906. * @returns the current updated quaternion
  3907. */
  3908. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from a rotation matrix
  3911. * @param matrix defines the source matrix
  3912. * @returns a new quaternion created from the given rotation matrix values
  3913. */
  3914. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3915. /**
  3916. * Updates the given quaternion with the given rotation matrix values
  3917. * @param matrix defines the source matrix
  3918. * @param result defines the target quaternion
  3919. */
  3920. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3921. /**
  3922. * Returns the dot product (float) between the quaternions "left" and "right"
  3923. * @param left defines the left operand
  3924. * @param right defines the right operand
  3925. * @returns the dot product
  3926. */
  3927. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3928. /**
  3929. * Checks if the two quaternions are close to each other
  3930. * @param quat0 defines the first quaternion to check
  3931. * @param quat1 defines the second quaternion to check
  3932. * @returns true if the two quaternions are close to each other
  3933. */
  3934. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3935. /**
  3936. * Creates an empty quaternion
  3937. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3938. */
  3939. static Zero(): Quaternion;
  3940. /**
  3941. * Inverse a given quaternion
  3942. * @param q defines the source quaternion
  3943. * @returns a new quaternion as the inverted current quaternion
  3944. */
  3945. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3946. /**
  3947. * Inverse a given quaternion
  3948. * @param q defines the source quaternion
  3949. * @param result the quaternion the result will be stored in
  3950. * @returns the result quaternion
  3951. */
  3952. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates an identity quaternion
  3955. * @returns the identity quaternion
  3956. */
  3957. static Identity(): Quaternion;
  3958. /**
  3959. * Gets a boolean indicating if the given quaternion is identity
  3960. * @param quaternion defines the quaternion to check
  3961. * @returns true if the quaternion is identity
  3962. */
  3963. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3964. /**
  3965. * Creates a quaternion from a rotation around an axis
  3966. * @param axis defines the axis to use
  3967. * @param angle defines the angle to use
  3968. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3969. */
  3970. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3971. /**
  3972. * Creates a rotation around an axis and stores it into the given quaternion
  3973. * @param axis defines the axis to use
  3974. * @param angle defines the angle to use
  3975. * @param result defines the target quaternion
  3976. * @returns the target quaternion
  3977. */
  3978. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3979. /**
  3980. * Creates a new quaternion from data stored into an array
  3981. * @param array defines the data source
  3982. * @param offset defines the offset in the source array where the data starts
  3983. * @returns a new quaternion
  3984. */
  3985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3986. /**
  3987. * Updates the given quaternion "result" from the starting index of the given array.
  3988. * @param array the array to pull values from
  3989. * @param offset the offset into the array to start at
  3990. * @param result the quaternion to store the result in
  3991. */
  3992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3993. /**
  3994. * Create a quaternion from Euler rotation angles
  3995. * @param x Pitch
  3996. * @param y Yaw
  3997. * @param z Roll
  3998. * @returns the new Quaternion
  3999. */
  4000. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4001. /**
  4002. * Updates a quaternion from Euler rotation angles
  4003. * @param x Pitch
  4004. * @param y Yaw
  4005. * @param z Roll
  4006. * @param result the quaternion to store the result
  4007. * @returns the updated quaternion
  4008. */
  4009. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4010. /**
  4011. * Create a quaternion from Euler rotation vector
  4012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4013. * @returns the new Quaternion
  4014. */
  4015. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4016. /**
  4017. * Updates a quaternion from Euler rotation vector
  4018. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4019. * @param result the quaternion to store the result
  4020. * @returns the updated quaternion
  4021. */
  4022. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4025. * @param yaw defines the rotation around Y axis
  4026. * @param pitch defines the rotation around X axis
  4027. * @param roll defines the rotation around Z axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4031. /**
  4032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4033. * @param yaw defines the rotation around Y axis
  4034. * @param pitch defines the rotation around X axis
  4035. * @param roll defines the rotation around Z axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4041. * @param alpha defines the rotation around first axis
  4042. * @param beta defines the rotation around second axis
  4043. * @param gamma defines the rotation around third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4049. * @param alpha defines the rotation around first axis
  4050. * @param beta defines the rotation around second axis
  4051. * @param gamma defines the rotation around third axis
  4052. * @param result defines the target quaternion
  4053. */
  4054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4055. /**
  4056. * 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)
  4057. * @param axis1 defines the first axis
  4058. * @param axis2 defines the second axis
  4059. * @param axis3 defines the third axis
  4060. * @returns the new quaternion
  4061. */
  4062. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4063. /**
  4064. * 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
  4065. * @param axis1 defines the first axis
  4066. * @param axis2 defines the second axis
  4067. * @param axis3 defines the third axis
  4068. * @param ref defines the target quaternion
  4069. */
  4070. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4071. /**
  4072. * Interpolates between two quaternions
  4073. * @param left defines first quaternion
  4074. * @param right defines second quaternion
  4075. * @param amount defines the gradient to use
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. /**
  4080. * Interpolates between two quaternions and stores it into a target quaternion
  4081. * @param left defines first quaternion
  4082. * @param right defines second quaternion
  4083. * @param amount defines the gradient to use
  4084. * @param result defines the target quaternion
  4085. */
  4086. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4087. /**
  4088. * Interpolate between two quaternions using Hermite interpolation
  4089. * @param value1 defines first quaternion
  4090. * @param tangent1 defines the incoming tangent
  4091. * @param value2 defines second quaternion
  4092. * @param tangent2 defines the outgoing tangent
  4093. * @param amount defines the target quaternion
  4094. * @returns the new interpolated quaternion
  4095. */
  4096. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4097. }
  4098. /**
  4099. * Class used to store matrix data (4x4)
  4100. */
  4101. export class Matrix {
  4102. /**
  4103. * Gets the precision of matrix computations
  4104. */
  4105. static get Use64Bits(): boolean;
  4106. private static _updateFlagSeed;
  4107. private static _identityReadOnly;
  4108. private _isIdentity;
  4109. private _isIdentityDirty;
  4110. private _isIdentity3x2;
  4111. private _isIdentity3x2Dirty;
  4112. /**
  4113. * Gets the update flag of the matrix which is an unique number for the matrix.
  4114. * It will be incremented every time the matrix data change.
  4115. * You can use it to speed the comparison between two versions of the same matrix.
  4116. */
  4117. updateFlag: number;
  4118. private readonly _m;
  4119. /**
  4120. * Gets the internal data of the matrix
  4121. */
  4122. get m(): DeepImmutable<Float32Array | Array<number>>;
  4123. /** @hidden */
  4124. _markAsUpdated(): void;
  4125. /** @hidden */
  4126. private _updateIdentityStatus;
  4127. /**
  4128. * Creates an empty matrix (filled with zeros)
  4129. */
  4130. constructor();
  4131. /**
  4132. * Check if the current matrix is identity
  4133. * @returns true is the matrix is the identity matrix
  4134. */
  4135. isIdentity(): boolean;
  4136. /**
  4137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4138. * @returns true is the matrix is the identity matrix
  4139. */
  4140. isIdentityAs3x2(): boolean;
  4141. /**
  4142. * Gets the determinant of the matrix
  4143. * @returns the matrix determinant
  4144. */
  4145. determinant(): number;
  4146. /**
  4147. * Returns the matrix as a Float32Array or Array<number>
  4148. * @returns the matrix underlying array
  4149. */
  4150. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4151. /**
  4152. * Returns the matrix as a Float32Array or Array<number>
  4153. * @returns the matrix underlying array.
  4154. */
  4155. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4156. /**
  4157. * Inverts the current matrix in place
  4158. * @returns the current inverted matrix
  4159. */
  4160. invert(): Matrix;
  4161. /**
  4162. * Sets all the matrix elements to zero
  4163. * @returns the current matrix
  4164. */
  4165. reset(): Matrix;
  4166. /**
  4167. * Adds the current matrix with a second one
  4168. * @param other defines the matrix to add
  4169. * @returns a new matrix as the addition of the current matrix and the given one
  4170. */
  4171. add(other: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4174. * @param other defines the matrix to add
  4175. * @param result defines the target matrix
  4176. * @returns the current matrix
  4177. */
  4178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4179. /**
  4180. * Adds in place the given matrix to the current matrix
  4181. * @param other defines the second operand
  4182. * @returns the current updated matrix
  4183. */
  4184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4185. /**
  4186. * Sets the given matrix to the current inverted Matrix
  4187. * @param other defines the target matrix
  4188. * @returns the unmodified current matrix
  4189. */
  4190. invertToRef(other: Matrix): Matrix;
  4191. /**
  4192. * add a value at the specified position in the current Matrix
  4193. * @param index the index of the value within the matrix. between 0 and 15.
  4194. * @param value the value to be added
  4195. * @returns the current updated matrix
  4196. */
  4197. addAtIndex(index: number, value: number): Matrix;
  4198. /**
  4199. * mutiply the specified position in the current Matrix by a value
  4200. * @param index the index of the value within the matrix. between 0 and 15.
  4201. * @param value the value to be added
  4202. * @returns the current updated matrix
  4203. */
  4204. multiplyAtIndex(index: number, value: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector (using 3 floats) in the current matrix
  4207. * @param x defines the 1st component of the translation
  4208. * @param y defines the 2nd component of the translation
  4209. * @param z defines the 3rd component of the translation
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4213. /**
  4214. * Adds the translation vector (using 3 floats) in the current matrix
  4215. * @param x defines the 1st component of the translation
  4216. * @param y defines the 2nd component of the translation
  4217. * @param z defines the 3rd component of the translation
  4218. * @returns the current updated matrix
  4219. */
  4220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4221. /**
  4222. * Inserts the translation vector in the current matrix
  4223. * @param vector3 defines the translation to insert
  4224. * @returns the current updated matrix
  4225. */
  4226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4227. /**
  4228. * Gets the translation value of the current matrix
  4229. * @returns a new Vector3 as the extracted translation from the matrix
  4230. */
  4231. getTranslation(): Vector3;
  4232. /**
  4233. * Fill a Vector3 with the extracted translation from the matrix
  4234. * @param result defines the Vector3 where to store the translation
  4235. * @returns the current matrix
  4236. */
  4237. getTranslationToRef(result: Vector3): Matrix;
  4238. /**
  4239. * Remove rotation and scaling part from the matrix
  4240. * @returns the updated matrix
  4241. */
  4242. removeRotationAndScaling(): Matrix;
  4243. /**
  4244. * Multiply two matrices
  4245. * @param other defines the second operand
  4246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4247. */
  4248. multiply(other: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Copy the current matrix from the given one
  4251. * @param other defines the source matrix
  4252. * @returns the current updated matrix
  4253. */
  4254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Populates the given array from the starting index with the current matrix values
  4257. * @param array defines the target array
  4258. * @param offset defines the offset in the target array where to start storing values
  4259. * @returns the current matrix
  4260. */
  4261. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4262. /**
  4263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4264. * @param other defines the second operand
  4265. * @param result defines the matrix where to store the multiplication
  4266. * @returns the current matrix
  4267. */
  4268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4269. /**
  4270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4271. * @param other defines the second operand
  4272. * @param result defines the array where to store the multiplication
  4273. * @param offset defines the offset in the target array where to start storing values
  4274. * @returns the current matrix
  4275. */
  4276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4277. /**
  4278. * Check equality between this matrix and a second one
  4279. * @param value defines the second matrix to compare
  4280. * @returns true is the current matrix and the given one values are strictly equal
  4281. */
  4282. equals(value: DeepImmutable<Matrix>): boolean;
  4283. /**
  4284. * Clone the current matrix
  4285. * @returns a new matrix from the current matrix
  4286. */
  4287. clone(): Matrix;
  4288. /**
  4289. * Returns the name of the current matrix class
  4290. * @returns the string "Matrix"
  4291. */
  4292. getClassName(): string;
  4293. /**
  4294. * Gets the hash code of the current matrix
  4295. * @returns the hash code
  4296. */
  4297. getHashCode(): number;
  4298. /**
  4299. * Decomposes the current Matrix into a translation, rotation and scaling components
  4300. * @param scale defines the scale vector3 given as a reference to update
  4301. * @param rotation defines the rotation quaternion given as a reference to update
  4302. * @param translation defines the translation vector3 given as a reference to update
  4303. * @returns true if operation was successful
  4304. */
  4305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4306. /**
  4307. * Gets specific row of the matrix
  4308. * @param index defines the number of the row to get
  4309. * @returns the index-th row of the current matrix as a new Vector4
  4310. */
  4311. getRow(index: number): Nullable<Vector4>;
  4312. /**
  4313. * Sets the index-th row of the current matrix to the vector4 values
  4314. * @param index defines the number of the row to set
  4315. * @param row defines the target vector4
  4316. * @returns the updated current matrix
  4317. */
  4318. setRow(index: number, row: Vector4): Matrix;
  4319. /**
  4320. * Compute the transpose of the matrix
  4321. * @returns the new transposed matrix
  4322. */
  4323. transpose(): Matrix;
  4324. /**
  4325. * Compute the transpose of the matrix and store it in a given matrix
  4326. * @param result defines the target matrix
  4327. * @returns the current matrix
  4328. */
  4329. transposeToRef(result: Matrix): Matrix;
  4330. /**
  4331. * Sets the index-th row of the current matrix with the given 4 x float values
  4332. * @param index defines the row index
  4333. * @param x defines the x component to set
  4334. * @param y defines the y component to set
  4335. * @param z defines the z component to set
  4336. * @param w defines the w component to set
  4337. * @returns the updated current matrix
  4338. */
  4339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4340. /**
  4341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4342. * @param scale defines the scale factor
  4343. * @returns a new matrix
  4344. */
  4345. scale(scale: number): Matrix;
  4346. /**
  4347. * Scale the current matrix values by a factor to a given result matrix
  4348. * @param scale defines the scale factor
  4349. * @param result defines the matrix to store the result
  4350. * @returns the current matrix
  4351. */
  4352. scaleToRef(scale: number, result: Matrix): Matrix;
  4353. /**
  4354. * Scale the current matrix values by a factor and add the result to a given matrix
  4355. * @param scale defines the scale factor
  4356. * @param result defines the Matrix to store the result
  4357. * @returns the current matrix
  4358. */
  4359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4360. /**
  4361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4362. * @param ref matrix to store the result
  4363. */
  4364. toNormalMatrix(ref: Matrix): void;
  4365. /**
  4366. * Gets only rotation part of the current matrix
  4367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4368. */
  4369. getRotationMatrix(): Matrix;
  4370. /**
  4371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4372. * @param result defines the target matrix to store data to
  4373. * @returns the current matrix
  4374. */
  4375. getRotationMatrixToRef(result: Matrix): Matrix;
  4376. /**
  4377. * Toggles model matrix from being right handed to left handed in place and vice versa
  4378. */
  4379. toggleModelMatrixHandInPlace(): void;
  4380. /**
  4381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleProjectionMatrixHandInPlace(): void;
  4384. /**
  4385. * Creates a matrix from an array
  4386. * @param array defines the source array
  4387. * @param offset defines an offset in the source array
  4388. * @returns a new Matrix set from the starting index of the given array
  4389. */
  4390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4391. /**
  4392. * Copy the content of an array into a given matrix
  4393. * @param array defines the source array
  4394. * @param offset defines an offset in the source array
  4395. * @param result defines the target matrix
  4396. */
  4397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4398. /**
  4399. * Stores an array into a matrix after having multiplied each component by a given factor
  4400. * @param array defines the source array
  4401. * @param offset defines the offset in the source array
  4402. * @param scale defines the scaling factor
  4403. * @param result defines the target matrix
  4404. */
  4405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4406. /**
  4407. * Gets an identity matrix that must not be updated
  4408. */
  4409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4410. /**
  4411. * Stores a list of values (16) inside a given matrix
  4412. * @param initialM11 defines 1st value of 1st row
  4413. * @param initialM12 defines 2nd value of 1st row
  4414. * @param initialM13 defines 3rd value of 1st row
  4415. * @param initialM14 defines 4th value of 1st row
  4416. * @param initialM21 defines 1st value of 2nd row
  4417. * @param initialM22 defines 2nd value of 2nd row
  4418. * @param initialM23 defines 3rd value of 2nd row
  4419. * @param initialM24 defines 4th value of 2nd row
  4420. * @param initialM31 defines 1st value of 3rd row
  4421. * @param initialM32 defines 2nd value of 3rd row
  4422. * @param initialM33 defines 3rd value of 3rd row
  4423. * @param initialM34 defines 4th value of 3rd row
  4424. * @param initialM41 defines 1st value of 4th row
  4425. * @param initialM42 defines 2nd value of 4th row
  4426. * @param initialM43 defines 3rd value of 4th row
  4427. * @param initialM44 defines 4th value of 4th row
  4428. * @param result defines the target matrix
  4429. */
  4430. 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;
  4431. /**
  4432. * Creates new matrix from a list of values (16)
  4433. * @param initialM11 defines 1st value of 1st row
  4434. * @param initialM12 defines 2nd value of 1st row
  4435. * @param initialM13 defines 3rd value of 1st row
  4436. * @param initialM14 defines 4th value of 1st row
  4437. * @param initialM21 defines 1st value of 2nd row
  4438. * @param initialM22 defines 2nd value of 2nd row
  4439. * @param initialM23 defines 3rd value of 2nd row
  4440. * @param initialM24 defines 4th value of 2nd row
  4441. * @param initialM31 defines 1st value of 3rd row
  4442. * @param initialM32 defines 2nd value of 3rd row
  4443. * @param initialM33 defines 3rd value of 3rd row
  4444. * @param initialM34 defines 4th value of 3rd row
  4445. * @param initialM41 defines 1st value of 4th row
  4446. * @param initialM42 defines 2nd value of 4th row
  4447. * @param initialM43 defines 3rd value of 4th row
  4448. * @param initialM44 defines 4th value of 4th row
  4449. * @returns the new matrix
  4450. */
  4451. 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;
  4452. /**
  4453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4454. * @param scale defines the scale vector3
  4455. * @param rotation defines the rotation quaternion
  4456. * @param translation defines the translation vector3
  4457. * @returns a new matrix
  4458. */
  4459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4460. /**
  4461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4462. * @param scale defines the scale vector3
  4463. * @param rotation defines the rotation quaternion
  4464. * @param translation defines the translation vector3
  4465. * @param result defines the target matrix
  4466. */
  4467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4468. /**
  4469. * Creates a new identity matrix
  4470. * @returns a new identity matrix
  4471. */
  4472. static Identity(): Matrix;
  4473. /**
  4474. * Creates a new identity matrix and stores the result in a given matrix
  4475. * @param result defines the target matrix
  4476. */
  4477. static IdentityToRef(result: Matrix): void;
  4478. /**
  4479. * Creates a new zero matrix
  4480. * @returns a new zero matrix
  4481. */
  4482. static Zero(): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the X axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationX(angle: number): Matrix;
  4489. /**
  4490. * Creates a new matrix as the invert of a given matrix
  4491. * @param source defines the source matrix
  4492. * @returns the new matrix
  4493. */
  4494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4497. * @param angle defines the angle (in radians) to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static RotationXToRef(angle: number, result: Matrix): void;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Y axis
  4503. * @param angle defines the angle (in radians) to use
  4504. * @return the new matrix
  4505. */
  4506. static RotationY(angle: number): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationYToRef(angle: number, result: Matrix): void;
  4513. /**
  4514. * Creates a new rotation matrix for "angle" radians around the Z axis
  4515. * @param angle defines the angle (in radians) to use
  4516. * @return the new matrix
  4517. */
  4518. static RotationZ(angle: number): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationZToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the given axis
  4527. * @param axis defines the axis to use
  4528. * @param angle defines the angle (in radians) to use
  4529. * @return the new matrix
  4530. */
  4531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4532. /**
  4533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4534. * @param axis defines the axis to use
  4535. * @param angle defines the angle (in radians) to use
  4536. * @param result defines the target matrix
  4537. */
  4538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4539. /**
  4540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4542. * @param from defines the vector to align
  4543. * @param to defines the vector to align to
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4547. /**
  4548. * Creates a rotation matrix
  4549. * @param yaw defines the yaw angle in radians (Y axis)
  4550. * @param pitch defines the pitch angle in radians (X axis)
  4551. * @param roll defines the roll angle in radians (Z axis)
  4552. * @returns the new rotation matrix
  4553. */
  4554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4555. /**
  4556. * Creates a rotation matrix and stores it in a given matrix
  4557. * @param yaw defines the yaw angle in radians (Y axis)
  4558. * @param pitch defines the pitch angle in radians (X axis)
  4559. * @param roll defines the roll angle in radians (Z axis)
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4563. /**
  4564. * Creates a scaling matrix
  4565. * @param x defines the scale factor on X axis
  4566. * @param y defines the scale factor on Y axis
  4567. * @param z defines the scale factor on Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Scaling(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a scaling matrix and stores it in a given matrix
  4573. * @param x defines the scale factor on X axis
  4574. * @param y defines the scale factor on Y axis
  4575. * @param z defines the scale factor on Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Creates a translation matrix
  4581. * @param x defines the translation on X axis
  4582. * @param y defines the translation on Y axis
  4583. * @param z defines the translationon Z axis
  4584. * @returns the new matrix
  4585. */
  4586. static Translation(x: number, y: number, z: number): Matrix;
  4587. /**
  4588. * Creates a translation matrix and stores it in a given matrix
  4589. * @param x defines the translation on X axis
  4590. * @param y defines the translation on Y axis
  4591. * @param z defines the translationon Z axis
  4592. * @param result defines the target matrix
  4593. */
  4594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4595. /**
  4596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4597. * @param startValue defines the start value
  4598. * @param endValue defines the end value
  4599. * @param gradient defines the gradient factor
  4600. * @returns the new matrix
  4601. */
  4602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4603. /**
  4604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4605. * @param startValue defines the start value
  4606. * @param endValue defines the end value
  4607. * @param gradient defines the gradient factor
  4608. * @param result defines the Matrix object where to store data
  4609. */
  4610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4611. /**
  4612. * Builds a new matrix whose values are computed by:
  4613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4616. * @param startValue defines the first matrix
  4617. * @param endValue defines the second matrix
  4618. * @param gradient defines the gradient between the two matrices
  4619. * @returns the new matrix
  4620. */
  4621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4622. /**
  4623. * Update a matrix to values which are computed by:
  4624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4627. * @param startValue defines the first matrix
  4628. * @param endValue defines the second matrix
  4629. * @param gradient defines the gradient between the two matrices
  4630. * @param result defines the target matrix
  4631. */
  4632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in left handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in left handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * 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"
  4653. * This function works in right handed mode
  4654. * @param eye defines the final position of the entity
  4655. * @param target defines where the entity should look at
  4656. * @param up defines the up vector for the entity
  4657. * @returns the new matrix
  4658. */
  4659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4660. /**
  4661. * 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".
  4662. * This function works in right handed mode
  4663. * @param eye defines the final position of the entity
  4664. * @param target defines where the entity should look at
  4665. * @param up defines the up vector for the entity
  4666. * @param result defines the target matrix
  4667. */
  4668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param width defines the viewport width
  4672. * @param height defines the viewport height
  4673. * @param znear defines the near clip plane
  4674. * @param zfar defines the far clip plane
  4675. * @returns a new matrix as a left-handed orthographic projection matrix
  4676. */
  4677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4678. /**
  4679. * Store a left-handed orthographic projection to a given matrix
  4680. * @param width defines the viewport width
  4681. * @param height defines the viewport height
  4682. * @param znear defines the near clip plane
  4683. * @param zfar defines the far clip plane
  4684. * @param result defines the target matrix
  4685. */
  4686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4687. /**
  4688. * Create a left-handed orthographic projection matrix
  4689. * @param left defines the viewport left coordinate
  4690. * @param right defines the viewport right coordinate
  4691. * @param bottom defines the viewport bottom coordinate
  4692. * @param top defines the viewport top coordinate
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Stores a left-handed orthographic projection into a given matrix
  4700. * @param left defines the viewport left coordinate
  4701. * @param right defines the viewport right coordinate
  4702. * @param bottom defines the viewport bottom coordinate
  4703. * @param top defines the viewport top coordinate
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Creates a right-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a right-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a left-handed perspective projection matrix
  4733. * @param width defines the viewport width
  4734. * @param height defines the viewport height
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a left-handed perspective projection matrix
  4738. */
  4739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Creates a left-handed perspective projection matrix
  4742. * @param fov defines the horizontal field of view
  4743. * @param aspect defines the aspect ratio
  4744. * @param znear defines the near clip plane
  4745. * @param zfar defines the far clip plane
  4746. * @returns a new matrix as a left-handed perspective projection matrix
  4747. */
  4748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4749. /**
  4750. * Stores a left-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 defines the far clip plane
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar not used as infinity is used as far clip
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Creates a right-handed perspective projection matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @returns a new matrix as a right-handed perspective projection matrix
  4776. */
  4777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4778. /**
  4779. * Stores a right-handed perspective projection into a given matrix
  4780. * @param fov defines the horizontal field of view
  4781. * @param aspect defines the aspect ratio
  4782. * @param znear defines the near clip plane
  4783. * @param zfar defines the far clip plane
  4784. * @param result defines the target matrix
  4785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4786. */
  4787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar not used as infinity is used as far clip
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a perspective projection for WebVR info a given matrix
  4800. * @param fov defines the field of view
  4801. * @param znear defines the near clip plane
  4802. * @param zfar defines the far clip plane
  4803. * @param result defines the target matrix
  4804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4805. */
  4806. static PerspectiveFovWebVRToRef(fov: {
  4807. upDegrees: number;
  4808. downDegrees: number;
  4809. leftDegrees: number;
  4810. rightDegrees: number;
  4811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4812. /**
  4813. * Computes a complete transformation matrix
  4814. * @param viewport defines the viewport to use
  4815. * @param world defines the world matrix
  4816. * @param view defines the view matrix
  4817. * @param projection defines the projection matrix
  4818. * @param zmin defines the near clip plane
  4819. * @param zmax defines the far clip plane
  4820. * @returns the transformation matrix
  4821. */
  4822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4823. /**
  4824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4825. * @param matrix defines the matrix to use
  4826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4827. */
  4828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4829. /**
  4830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4831. * @param matrix defines the matrix to use
  4832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4833. */
  4834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4835. /**
  4836. * Compute the transpose of a given matrix
  4837. * @param matrix defines the matrix to transpose
  4838. * @returns the new matrix
  4839. */
  4840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4841. /**
  4842. * Compute the transpose of a matrix and store it in a target matrix
  4843. * @param matrix defines the matrix to transpose
  4844. * @param result defines the target matrix
  4845. */
  4846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4847. /**
  4848. * Computes a reflection matrix from a plane
  4849. * @param plane defines the reflection plane
  4850. * @returns a new matrix
  4851. */
  4852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4853. /**
  4854. * Computes a reflection matrix from a plane
  4855. * @param plane defines the reflection plane
  4856. * @param result defines the target matrix
  4857. */
  4858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4859. /**
  4860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4861. * @param xaxis defines the value of the 1st axis
  4862. * @param yaxis defines the value of the 2nd axis
  4863. * @param zaxis defines the value of the 3rd axis
  4864. * @param result defines the target matrix
  4865. */
  4866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4867. /**
  4868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4869. * @param quat defines the quaternion to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4873. }
  4874. /**
  4875. * @hidden
  4876. */
  4877. export class TmpVectors {
  4878. static Vector2: Vector2[];
  4879. static Vector3: Vector3[];
  4880. static Vector4: Vector4[];
  4881. static Quaternion: Quaternion[];
  4882. static Matrix: Matrix[];
  4883. }
  4884. }
  4885. declare module "babylonjs/Maths/math.path" {
  4886. import { DeepImmutable, Nullable } from "babylonjs/types";
  4887. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4888. /**
  4889. * Defines potential orientation for back face culling
  4890. */
  4891. export enum Orientation {
  4892. /**
  4893. * Clockwise
  4894. */
  4895. CW = 0,
  4896. /** Counter clockwise */
  4897. CCW = 1
  4898. }
  4899. /** Class used to represent a Bezier curve */
  4900. export class BezierCurve {
  4901. /**
  4902. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4903. * @param t defines the time
  4904. * @param x1 defines the left coordinate on X axis
  4905. * @param y1 defines the left coordinate on Y axis
  4906. * @param x2 defines the right coordinate on X axis
  4907. * @param y2 defines the right coordinate on Y axis
  4908. * @returns the interpolated value
  4909. */
  4910. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4911. }
  4912. /**
  4913. * Defines angle representation
  4914. */
  4915. export class Angle {
  4916. private _radians;
  4917. /**
  4918. * Creates an Angle object of "radians" radians (float).
  4919. * @param radians the angle in radians
  4920. */
  4921. constructor(radians: number);
  4922. /**
  4923. * Get value in degrees
  4924. * @returns the Angle value in degrees (float)
  4925. */
  4926. degrees(): number;
  4927. /**
  4928. * Get value in radians
  4929. * @returns the Angle value in radians (float)
  4930. */
  4931. radians(): number;
  4932. /**
  4933. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4934. * @param a defines first point as the origin
  4935. * @param b defines point
  4936. * @returns a new Angle
  4937. */
  4938. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4939. /**
  4940. * Gets a new Angle object from the given float in radians
  4941. * @param radians defines the angle value in radians
  4942. * @returns a new Angle
  4943. */
  4944. static FromRadians(radians: number): Angle;
  4945. /**
  4946. * Gets a new Angle object from the given float in degrees
  4947. * @param degrees defines the angle value in degrees
  4948. * @returns a new Angle
  4949. */
  4950. static FromDegrees(degrees: number): Angle;
  4951. }
  4952. /**
  4953. * This represents an arc in a 2d space.
  4954. */
  4955. export class Arc2 {
  4956. /** Defines the start point of the arc */
  4957. startPoint: Vector2;
  4958. /** Defines the mid point of the arc */
  4959. midPoint: Vector2;
  4960. /** Defines the end point of the arc */
  4961. endPoint: Vector2;
  4962. /**
  4963. * Defines the center point of the arc.
  4964. */
  4965. centerPoint: Vector2;
  4966. /**
  4967. * Defines the radius of the arc.
  4968. */
  4969. radius: number;
  4970. /**
  4971. * Defines the angle of the arc (from mid point to end point).
  4972. */
  4973. angle: Angle;
  4974. /**
  4975. * Defines the start angle of the arc (from start point to middle point).
  4976. */
  4977. startAngle: Angle;
  4978. /**
  4979. * Defines the orientation of the arc (clock wise/counter clock wise).
  4980. */
  4981. orientation: Orientation;
  4982. /**
  4983. * Creates an Arc object from the three given points : start, middle and end.
  4984. * @param startPoint Defines the start point of the arc
  4985. * @param midPoint Defines the midlle point of the arc
  4986. * @param endPoint Defines the end point of the arc
  4987. */
  4988. constructor(
  4989. /** Defines the start point of the arc */
  4990. startPoint: Vector2,
  4991. /** Defines the mid point of the arc */
  4992. midPoint: Vector2,
  4993. /** Defines the end point of the arc */
  4994. endPoint: Vector2);
  4995. }
  4996. /**
  4997. * Represents a 2D path made up of multiple 2D points
  4998. */
  4999. export class Path2 {
  5000. private _points;
  5001. private _length;
  5002. /**
  5003. * If the path start and end point are the same
  5004. */
  5005. closed: boolean;
  5006. /**
  5007. * Creates a Path2 object from the starting 2D coordinates x and y.
  5008. * @param x the starting points x value
  5009. * @param y the starting points y value
  5010. */
  5011. constructor(x: number, y: number);
  5012. /**
  5013. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5014. * @param x the added points x value
  5015. * @param y the added points y value
  5016. * @returns the updated Path2.
  5017. */
  5018. addLineTo(x: number, y: number): Path2;
  5019. /**
  5020. * 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.
  5021. * @param midX middle point x value
  5022. * @param midY middle point y value
  5023. * @param endX end point x value
  5024. * @param endY end point y value
  5025. * @param numberOfSegments (default: 36)
  5026. * @returns the updated Path2.
  5027. */
  5028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5029. /**
  5030. * Closes the Path2.
  5031. * @returns the Path2.
  5032. */
  5033. close(): Path2;
  5034. /**
  5035. * Gets the sum of the distance between each sequential point in the path
  5036. * @returns the Path2 total length (float).
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Gets the points which construct the path
  5041. * @returns the Path2 internal array of points.
  5042. */
  5043. getPoints(): Vector2[];
  5044. /**
  5045. * Retreives the point at the distance aways from the starting point
  5046. * @param normalizedLengthPosition the length along the path to retreive the point from
  5047. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5048. */
  5049. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5050. /**
  5051. * Creates a new path starting from an x and y position
  5052. * @param x starting x value
  5053. * @param y starting y value
  5054. * @returns a new Path2 starting at the coordinates (x, y).
  5055. */
  5056. static StartingAt(x: number, y: number): Path2;
  5057. }
  5058. /**
  5059. * Represents a 3D path made up of multiple 3D points
  5060. */
  5061. export class Path3D {
  5062. /**
  5063. * an array of Vector3, the curve axis of the Path3D
  5064. */
  5065. path: Vector3[];
  5066. private _curve;
  5067. private _distances;
  5068. private _tangents;
  5069. private _normals;
  5070. private _binormals;
  5071. private _raw;
  5072. private _alignTangentsWithPath;
  5073. private readonly _pointAtData;
  5074. /**
  5075. * new Path3D(path, normal, raw)
  5076. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5077. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5078. * @param path an array of Vector3, the curve axis of the Path3D
  5079. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5080. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5081. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5082. */
  5083. constructor(
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5088. /**
  5089. * Returns the Path3D array of successive Vector3 designing its curve.
  5090. * @returns the Path3D array of successive Vector3 designing its curve.
  5091. */
  5092. getCurve(): Vector3[];
  5093. /**
  5094. * Returns the Path3D array of successive Vector3 designing its curve.
  5095. * @returns the Path3D array of successive Vector3 designing its curve.
  5096. */
  5097. getPoints(): Vector3[];
  5098. /**
  5099. * @returns the computed length (float) of the path.
  5100. */
  5101. length(): number;
  5102. /**
  5103. * Returns an array populated with tangent vectors on each Path3D curve point.
  5104. * @returns an array populated with tangent vectors on each Path3D curve point.
  5105. */
  5106. getTangents(): Vector3[];
  5107. /**
  5108. * Returns an array populated with normal vectors on each Path3D curve point.
  5109. * @returns an array populated with normal vectors on each Path3D curve point.
  5110. */
  5111. getNormals(): Vector3[];
  5112. /**
  5113. * Returns an array populated with binormal vectors on each Path3D curve point.
  5114. * @returns an array populated with binormal vectors on each Path3D curve point.
  5115. */
  5116. getBinormals(): Vector3[];
  5117. /**
  5118. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5119. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. */
  5121. getDistances(): number[];
  5122. /**
  5123. * Returns an interpolated point along this path
  5124. * @param position the position of the point along this path, from 0.0 to 1.0
  5125. * @returns a new Vector3 as the point
  5126. */
  5127. getPointAt(position: number): Vector3;
  5128. /**
  5129. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5130. * @param position the position of the point along this path, from 0.0 to 1.0
  5131. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5132. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5133. */
  5134. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5135. /**
  5136. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5137. * @param position the position of the point along this path, from 0.0 to 1.0
  5138. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5139. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5140. */
  5141. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5142. /**
  5143. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5146. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5147. */
  5148. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5149. /**
  5150. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5151. * @param position the position of the point along this path, from 0.0 to 1.0
  5152. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5153. */
  5154. getDistanceAt(position: number): number;
  5155. /**
  5156. * Returns the array index of the previous point of an interpolated point along this path
  5157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5158. * @returns the array index
  5159. */
  5160. getPreviousPointIndexAt(position: number): number;
  5161. /**
  5162. * 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)
  5163. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5164. * @returns the sub position
  5165. */
  5166. getSubPositionAt(position: number): number;
  5167. /**
  5168. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5169. * @param target the vector of which to get the closest position to
  5170. * @returns the position of the closest virtual point on this path to the target vector
  5171. */
  5172. getClosestPositionTo(target: Vector3): number;
  5173. /**
  5174. * Returns a sub path (slice) of this path
  5175. * @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
  5176. * @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
  5177. * @returns a sub path (slice) of this path
  5178. */
  5179. slice(start?: number, end?: number): Path3D;
  5180. /**
  5181. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5182. * @param path path which all values are copied into the curves points
  5183. * @param firstNormal which should be projected onto the curve
  5184. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5185. * @returns the same object updated.
  5186. */
  5187. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5188. private _compute;
  5189. private _getFirstNonNullVector;
  5190. private _getLastNonNullVector;
  5191. private _normalVector;
  5192. /**
  5193. * Updates the point at data for an interpolated point along this curve
  5194. * @param position the position of the point along this curve, from 0.0 to 1.0
  5195. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5196. * @returns the (updated) point at data
  5197. */
  5198. private _updatePointAtData;
  5199. /**
  5200. * Updates the point at data from the specified parameters
  5201. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5202. * @param point the interpolated point
  5203. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5204. */
  5205. private _setPointAtData;
  5206. /**
  5207. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5208. */
  5209. private _updateInterpolationMatrix;
  5210. }
  5211. /**
  5212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5213. * A Curve3 is designed from a series of successive Vector3.
  5214. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5215. */
  5216. export class Curve3 {
  5217. private _points;
  5218. private _length;
  5219. /**
  5220. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5221. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5222. * @param v1 (Vector3) the control point
  5223. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5224. * @param nbPoints (integer) the wanted number of points in the curve
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5228. /**
  5229. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5230. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5231. * @param v1 (Vector3) the first control point
  5232. * @param v2 (Vector3) the second control point
  5233. * @param v3 (Vector3) the end point of the Cubic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5240. * @param p1 (Vector3) the origin point of the Hermite Spline
  5241. * @param t1 (Vector3) the tangent vector at the origin point
  5242. * @param p2 (Vector3) the end point of the Hermite Spline
  5243. * @param t2 (Vector3) the tangent vector at the end point
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a CatmullRom Spline curve :
  5250. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5251. * @param nbPoints (integer) the wanted number of points between each curve control points
  5252. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5253. * @returns the created Curve3
  5254. */
  5255. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5256. /**
  5257. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5258. * A Curve3 is designed from a series of successive Vector3.
  5259. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5260. * @param points points which make up the curve
  5261. */
  5262. constructor(points: Vector3[]);
  5263. /**
  5264. * @returns the Curve3 stored array of successive Vector3
  5265. */
  5266. getPoints(): Vector3[];
  5267. /**
  5268. * @returns the computed length (float) of the curve.
  5269. */
  5270. length(): number;
  5271. /**
  5272. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5273. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5274. * curveA and curveB keep unchanged.
  5275. * @param curve the curve to continue from this curve
  5276. * @returns the newly constructed curve
  5277. */
  5278. continue(curve: DeepImmutable<Curve3>): Curve3;
  5279. private _computeLength;
  5280. }
  5281. }
  5282. declare module "babylonjs/Animations/easing" {
  5283. /**
  5284. * This represents the main contract an easing function should follow.
  5285. * Easing functions are used throughout the animation system.
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export interface IEasingFunction {
  5289. /**
  5290. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5291. * of the easing function.
  5292. * The link below provides some of the most common examples of easing functions.
  5293. * @see https://easings.net/
  5294. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5295. * @returns the corresponding value on the curve defined by the easing function
  5296. */
  5297. ease(gradient: number): number;
  5298. }
  5299. /**
  5300. * Base class used for every default easing function.
  5301. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5302. */
  5303. export class EasingFunction implements IEasingFunction {
  5304. /**
  5305. * Interpolation follows the mathematical formula associated with the easing function.
  5306. */
  5307. static readonly EASINGMODE_EASEIN: number;
  5308. /**
  5309. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEOUT: number;
  5312. /**
  5313. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5314. */
  5315. static readonly EASINGMODE_EASEINOUT: number;
  5316. private _easingMode;
  5317. /**
  5318. * Sets the easing mode of the current function.
  5319. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5320. */
  5321. setEasingMode(easingMode: number): void;
  5322. /**
  5323. * Gets the current easing mode.
  5324. * @returns the easing mode
  5325. */
  5326. getEasingMode(): number;
  5327. /**
  5328. * @hidden
  5329. */
  5330. easeInCore(gradient: number): number;
  5331. /**
  5332. * Given an input gradient between 0 and 1, this returns the corresponding value
  5333. * of the easing function.
  5334. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5335. * @returns the corresponding value on the curve defined by the easing function
  5336. */
  5337. ease(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a circle shape (see link below).
  5341. * @see https://easings.net/#easeInCirc
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class CircleEase extends EasingFunction implements IEasingFunction {
  5345. /** @hidden */
  5346. easeInCore(gradient: number): number;
  5347. }
  5348. /**
  5349. * Easing function with a ease back shape (see link below).
  5350. * @see https://easings.net/#easeInBack
  5351. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5352. */
  5353. export class BackEase extends EasingFunction implements IEasingFunction {
  5354. /** Defines the amplitude of the function */
  5355. amplitude: number;
  5356. /**
  5357. * Instantiates a back ease easing
  5358. * @see https://easings.net/#easeInBack
  5359. * @param amplitude Defines the amplitude of the function
  5360. */
  5361. constructor(
  5362. /** Defines the amplitude of the function */
  5363. amplitude?: number);
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a bouncing shape (see link below).
  5369. * @see https://easings.net/#easeInBounce
  5370. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class BounceEase extends EasingFunction implements IEasingFunction {
  5373. /** Defines the number of bounces */
  5374. bounces: number;
  5375. /** Defines the amplitude of the bounce */
  5376. bounciness: number;
  5377. /**
  5378. * Instantiates a bounce easing
  5379. * @see https://easings.net/#easeInBounce
  5380. * @param bounces Defines the number of bounces
  5381. * @param bounciness Defines the amplitude of the bounce
  5382. */
  5383. constructor(
  5384. /** Defines the number of bounces */
  5385. bounces?: number,
  5386. /** Defines the amplitude of the bounce */
  5387. bounciness?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a power of 3 shape (see link below).
  5393. * @see https://easings.net/#easeInCubic
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class CubicEase extends EasingFunction implements IEasingFunction {
  5397. /** @hidden */
  5398. easeInCore(gradient: number): number;
  5399. }
  5400. /**
  5401. * Easing function with an elastic shape (see link below).
  5402. * @see https://easings.net/#easeInElastic
  5403. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5404. */
  5405. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5406. /** Defines the number of oscillations*/
  5407. oscillations: number;
  5408. /** Defines the amplitude of the oscillations*/
  5409. springiness: number;
  5410. /**
  5411. * Instantiates an elastic easing function
  5412. * @see https://easings.net/#easeInElastic
  5413. * @param oscillations Defines the number of oscillations
  5414. * @param springiness Defines the amplitude of the oscillations
  5415. */
  5416. constructor(
  5417. /** Defines the number of oscillations*/
  5418. oscillations?: number,
  5419. /** Defines the amplitude of the oscillations*/
  5420. springiness?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an exponential shape (see link below).
  5426. * @see https://easings.net/#easeInExpo
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the exponent of the function */
  5431. exponent: number;
  5432. /**
  5433. * Instantiates an exponential easing function
  5434. * @see https://easings.net/#easeInExpo
  5435. * @param exponent Defines the exponent of the function
  5436. */
  5437. constructor(
  5438. /** Defines the exponent of the function */
  5439. exponent?: number);
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power shape (see link below).
  5445. * @see https://easings.net/#easeInQuad
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class PowerEase extends EasingFunction implements IEasingFunction {
  5449. /** Defines the power of the function */
  5450. power: number;
  5451. /**
  5452. * Instantiates an power base easing function
  5453. * @see https://easings.net/#easeInQuad
  5454. * @param power Defines the power of the function
  5455. */
  5456. constructor(
  5457. /** Defines the power of the function */
  5458. power?: number);
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 2 shape (see link below).
  5464. * @see https://easings.net/#easeInQuad
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a power of 4 shape (see link below).
  5473. * @see https://easings.net/#easeInQuart
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a power of 5 shape (see link below).
  5482. * @see https://easings.net/#easeInQuint
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5486. /** @hidden */
  5487. easeInCore(gradient: number): number;
  5488. }
  5489. /**
  5490. * Easing function with a sin shape (see link below).
  5491. * @see https://easings.net/#easeInSine
  5492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5493. */
  5494. export class SineEase extends EasingFunction implements IEasingFunction {
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. /**
  5499. * Easing function with a bezier shape (see link below).
  5500. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5501. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5502. */
  5503. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5504. /** Defines the x component of the start tangent in the bezier curve */
  5505. x1: number;
  5506. /** Defines the y component of the start tangent in the bezier curve */
  5507. y1: number;
  5508. /** Defines the x component of the end tangent in the bezier curve */
  5509. x2: number;
  5510. /** Defines the y component of the end tangent in the bezier curve */
  5511. y2: number;
  5512. /**
  5513. * Instantiates a bezier function
  5514. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5515. * @param x1 Defines the x component of the start tangent in the bezier curve
  5516. * @param y1 Defines the y component of the start tangent in the bezier curve
  5517. * @param x2 Defines the x component of the end tangent in the bezier curve
  5518. * @param y2 Defines the y component of the end tangent in the bezier curve
  5519. */
  5520. constructor(
  5521. /** Defines the x component of the start tangent in the bezier curve */
  5522. x1?: number,
  5523. /** Defines the y component of the start tangent in the bezier curve */
  5524. y1?: number,
  5525. /** Defines the x component of the end tangent in the bezier curve */
  5526. x2?: number,
  5527. /** Defines the y component of the end tangent in the bezier curve */
  5528. y2?: number);
  5529. /** @hidden */
  5530. easeInCore(gradient: number): number;
  5531. }
  5532. }
  5533. declare module "babylonjs/Maths/math.color" {
  5534. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5535. /**
  5536. * Class used to hold a RBG color
  5537. */
  5538. export class Color3 {
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r: number;
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g: number;
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b: number;
  5551. /**
  5552. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5553. * @param r defines the red component (between 0 and 1, default is 0)
  5554. * @param g defines the green component (between 0 and 1, default is 0)
  5555. * @param b defines the blue component (between 0 and 1, default is 0)
  5556. */
  5557. constructor(
  5558. /**
  5559. * Defines the red component (between 0 and 1, default is 0)
  5560. */
  5561. r?: number,
  5562. /**
  5563. * Defines the green component (between 0 and 1, default is 0)
  5564. */
  5565. g?: number,
  5566. /**
  5567. * Defines the blue component (between 0 and 1, default is 0)
  5568. */
  5569. b?: number);
  5570. /**
  5571. * Creates a string with the Color3 current values
  5572. * @returns the string representation of the Color3 object
  5573. */
  5574. toString(): string;
  5575. /**
  5576. * Returns the string "Color3"
  5577. * @returns "Color3"
  5578. */
  5579. getClassName(): string;
  5580. /**
  5581. * Compute the Color3 hash code
  5582. * @returns an unique number that can be used to hash Color3 objects
  5583. */
  5584. getHashCode(): number;
  5585. /**
  5586. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5587. * @param array defines the array where to store the r,g,b components
  5588. * @param index defines an optional index in the target array to define where to start storing values
  5589. * @returns the current Color3 object
  5590. */
  5591. toArray(array: FloatArray, index?: number): Color3;
  5592. /**
  5593. * Update the current color with values stored in an array from the starting index of the given array
  5594. * @param array defines the source array
  5595. * @param offset defines an offset in the source array
  5596. * @returns the current Color3 object
  5597. */
  5598. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5599. /**
  5600. * Returns a new Color4 object from the current Color3 and the given alpha
  5601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5602. * @returns a new Color4 object
  5603. */
  5604. toColor4(alpha?: number): Color4;
  5605. /**
  5606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5607. * @returns the new array
  5608. */
  5609. asArray(): number[];
  5610. /**
  5611. * Returns the luminance value
  5612. * @returns a float value
  5613. */
  5614. toLuminance(): number;
  5615. /**
  5616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5617. * @param otherColor defines the second operand
  5618. * @returns the new Color3 object
  5619. */
  5620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5621. /**
  5622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5623. * @param otherColor defines the second operand
  5624. * @param result defines the Color3 object where to store the result
  5625. * @returns the current Color3
  5626. */
  5627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5628. /**
  5629. * Determines equality between Color3 objects
  5630. * @param otherColor defines the second operand
  5631. * @returns true if the rgb values are equal to the given ones
  5632. */
  5633. equals(otherColor: DeepImmutable<Color3>): boolean;
  5634. /**
  5635. * Determines equality between the current Color3 object and a set of r,b,g values
  5636. * @param r defines the red component to check
  5637. * @param g defines the green component to check
  5638. * @param b defines the blue component to check
  5639. * @returns true if the rgb values are equal to the given ones
  5640. */
  5641. equalsFloats(r: number, g: number, b: number): boolean;
  5642. /**
  5643. * Multiplies in place each rgb value by scale
  5644. * @param scale defines the scaling factor
  5645. * @returns the updated Color3
  5646. */
  5647. scale(scale: number): Color3;
  5648. /**
  5649. * Multiplies the rgb values by scale and stores the result into "result"
  5650. * @param scale defines the scaling factor
  5651. * @param result defines the Color3 object where to store the result
  5652. * @returns the unmodified current Color3
  5653. */
  5654. scaleToRef(scale: number, result: Color3): Color3;
  5655. /**
  5656. * Scale the current Color3 values by a factor and add the result to a given Color3
  5657. * @param scale defines the scale factor
  5658. * @param result defines color to store the result into
  5659. * @returns the unmodified current Color3
  5660. */
  5661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5662. /**
  5663. * Clamps the rgb values by the min and max values and stores the result into "result"
  5664. * @param min defines minimum clamping value (default is 0)
  5665. * @param max defines maximum clamping value (default is 1)
  5666. * @param result defines color to store the result into
  5667. * @returns the original Color3
  5668. */
  5669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5670. /**
  5671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5672. * @param otherColor defines the second operand
  5673. * @returns the new Color3
  5674. */
  5675. add(otherColor: DeepImmutable<Color3>): Color3;
  5676. /**
  5677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5678. * @param otherColor defines the second operand
  5679. * @param result defines Color3 object to store the result into
  5680. * @returns the unmodified current Color3
  5681. */
  5682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5683. /**
  5684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5685. * @param otherColor defines the second operand
  5686. * @returns the new Color3
  5687. */
  5688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5691. * @param otherColor defines the second operand
  5692. * @param result defines Color3 object to store the result into
  5693. * @returns the unmodified current Color3
  5694. */
  5695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5696. /**
  5697. * Copy the current object
  5698. * @returns a new Color3 copied the current one
  5699. */
  5700. clone(): Color3;
  5701. /**
  5702. * Copies the rgb values from the source in the current Color3
  5703. * @param source defines the source Color3 object
  5704. * @returns the updated Color3 object
  5705. */
  5706. copyFrom(source: DeepImmutable<Color3>): Color3;
  5707. /**
  5708. * Updates the Color3 rgb values from the given floats
  5709. * @param r defines the red component to read from
  5710. * @param g defines the green component to read from
  5711. * @param b defines the blue component to read from
  5712. * @returns the current Color3 object
  5713. */
  5714. copyFromFloats(r: number, g: number, b: number): Color3;
  5715. /**
  5716. * Updates the Color3 rgb values from the given floats
  5717. * @param r defines the red component to read from
  5718. * @param g defines the green component to read from
  5719. * @param b defines the blue component to read from
  5720. * @returns the current Color3 object
  5721. */
  5722. set(r: number, g: number, b: number): Color3;
  5723. /**
  5724. * Compute the Color3 hexadecimal code as a string
  5725. * @returns a string containing the hexadecimal representation of the Color3 object
  5726. */
  5727. toHexString(): string;
  5728. /**
  5729. * Computes a new Color3 converted from the current one to linear space
  5730. * @returns a new Color3 object
  5731. */
  5732. toLinearSpace(): Color3;
  5733. /**
  5734. * Converts current color in rgb space to HSV values
  5735. * @returns a new color3 representing the HSV values
  5736. */
  5737. toHSV(): Color3;
  5738. /**
  5739. * Converts current color in rgb space to HSV values
  5740. * @param result defines the Color3 where to store the HSV values
  5741. */
  5742. toHSVToRef(result: Color3): void;
  5743. /**
  5744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5745. * @param convertedColor defines the Color3 object where to store the linear space version
  5746. * @returns the unmodified Color3
  5747. */
  5748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5749. /**
  5750. * Computes a new Color3 converted from the current one to gamma space
  5751. * @returns a new Color3 object
  5752. */
  5753. toGammaSpace(): Color3;
  5754. /**
  5755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5756. * @param convertedColor defines the Color3 object where to store the gamma space version
  5757. * @returns the unmodified Color3
  5758. */
  5759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5760. private static _BlackReadOnly;
  5761. /**
  5762. * Convert Hue, saturation and value to a Color3 (RGB)
  5763. * @param hue defines the hue
  5764. * @param saturation defines the saturation
  5765. * @param value defines the value
  5766. * @param result defines the Color3 where to store the RGB values
  5767. */
  5768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5769. /**
  5770. * Creates a new Color3 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color3 object
  5773. */
  5774. static FromHexString(hex: string): Color3;
  5775. /**
  5776. * Creates a new Color3 from the starting index of the given array
  5777. * @param array defines the source array
  5778. * @param offset defines an offset in the source array
  5779. * @returns a new Color3 object
  5780. */
  5781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5782. /**
  5783. * Creates a new Color3 from the starting index element of the given array
  5784. * @param array defines the source array to read from
  5785. * @param offset defines the offset in the source array
  5786. * @param result defines the target Color3 object
  5787. */
  5788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from integer values (< 256)
  5791. * @param r defines the red component to read from (value between 0 and 255)
  5792. * @param g defines the green component to read from (value between 0 and 255)
  5793. * @param b defines the blue component to read from (value between 0 and 255)
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromInts(r: number, g: number, b: number): Color3;
  5797. /**
  5798. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5799. * @param start defines the start Color3 value
  5800. * @param end defines the end Color3 value
  5801. * @param amount defines the gradient value between start and end
  5802. * @returns a new Color3 object
  5803. */
  5804. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5805. /**
  5806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5807. * @param left defines the start value
  5808. * @param right defines the end value
  5809. * @param amount defines the gradient factor
  5810. * @param result defines the Color3 object where to store the result
  5811. */
  5812. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5813. /**
  5814. * Returns a Color3 value containing a red color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Red(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a green color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Green(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a blue color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Blue(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a black color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Black(): Color3;
  5833. /**
  5834. * Gets a Color3 value containing a black color that must not be updated
  5835. */
  5836. static get BlackReadOnly(): DeepImmutable<Color3>;
  5837. /**
  5838. * Returns a Color3 value containing a white color
  5839. * @returns a new Color3 object
  5840. */
  5841. static White(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a purple color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Purple(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a magenta color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Magenta(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a yellow color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Yellow(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a gray color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Gray(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a teal color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Teal(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a random color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Random(): Color3;
  5872. }
  5873. /**
  5874. * Class used to hold a RBGA color
  5875. */
  5876. export class Color4 {
  5877. /**
  5878. * Defines the red component (between 0 and 1, default is 0)
  5879. */
  5880. r: number;
  5881. /**
  5882. * Defines the green component (between 0 and 1, default is 0)
  5883. */
  5884. g: number;
  5885. /**
  5886. * Defines the blue component (between 0 and 1, default is 0)
  5887. */
  5888. b: number;
  5889. /**
  5890. * Defines the alpha component (between 0 and 1, default is 1)
  5891. */
  5892. a: number;
  5893. /**
  5894. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5895. * @param r defines the red component (between 0 and 1, default is 0)
  5896. * @param g defines the green component (between 0 and 1, default is 0)
  5897. * @param b defines the blue component (between 0 and 1, default is 0)
  5898. * @param a defines the alpha component (between 0 and 1, default is 1)
  5899. */
  5900. constructor(
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r?: number,
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g?: number,
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b?: number,
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a?: number);
  5917. /**
  5918. * Adds in place the given Color4 values to the current Color4 object
  5919. * @param right defines the second operand
  5920. * @returns the current updated Color4 object
  5921. */
  5922. addInPlace(right: DeepImmutable<Color4>): Color4;
  5923. /**
  5924. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5925. * @returns the new array
  5926. */
  5927. asArray(): number[];
  5928. /**
  5929. * Stores from the starting index in the given array the Color4 successive values
  5930. * @param array defines the array where to store the r,g,b components
  5931. * @param index defines an optional index in the target array to define where to start storing values
  5932. * @returns the current Color4 object
  5933. */
  5934. toArray(array: number[], index?: number): Color4;
  5935. /**
  5936. * Update the current color with values stored in an array from the starting index of the given array
  5937. * @param array defines the source array
  5938. * @param offset defines an offset in the source array
  5939. * @returns the current Color4 object
  5940. */
  5941. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5942. /**
  5943. * Determines equality between Color4 objects
  5944. * @param otherColor defines the second operand
  5945. * @returns true if the rgba values are equal to the given ones
  5946. */
  5947. equals(otherColor: DeepImmutable<Color4>): boolean;
  5948. /**
  5949. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5950. * @param right defines the second operand
  5951. * @returns a new Color4 object
  5952. */
  5953. add(right: DeepImmutable<Color4>): Color4;
  5954. /**
  5955. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5956. * @param right defines the second operand
  5957. * @returns a new Color4 object
  5958. */
  5959. subtract(right: DeepImmutable<Color4>): Color4;
  5960. /**
  5961. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5962. * @param right defines the second operand
  5963. * @param result defines the Color4 object where to store the result
  5964. * @returns the current Color4 object
  5965. */
  5966. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5967. /**
  5968. * Creates a new Color4 with the current Color4 values multiplied by scale
  5969. * @param scale defines the scaling factor to apply
  5970. * @returns a new Color4 object
  5971. */
  5972. scale(scale: number): Color4;
  5973. /**
  5974. * Multiplies the current Color4 values by scale and stores the result in "result"
  5975. * @param scale defines the scaling factor to apply
  5976. * @param result defines the Color4 object where to store the result
  5977. * @returns the current unmodified Color4
  5978. */
  5979. scaleToRef(scale: number, result: Color4): Color4;
  5980. /**
  5981. * Scale the current Color4 values by a factor and add the result to a given Color4
  5982. * @param scale defines the scale factor
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the unmodified current Color4
  5985. */
  5986. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5987. /**
  5988. * Clamps the rgb values by the min and max values and stores the result into "result"
  5989. * @param min defines minimum clamping value (default is 0)
  5990. * @param max defines maximum clamping value (default is 1)
  5991. * @param result defines color to store the result into.
  5992. * @returns the cuurent Color4
  5993. */
  5994. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5995. /**
  5996. * Multipy an Color4 value by another and return a new Color4 object
  5997. * @param color defines the Color4 value to multiply by
  5998. * @returns a new Color4 object
  5999. */
  6000. multiply(color: Color4): Color4;
  6001. /**
  6002. * Multipy a Color4 value by another and push the result in a reference value
  6003. * @param color defines the Color4 value to multiply by
  6004. * @param result defines the Color4 to fill the result in
  6005. * @returns the result Color4
  6006. */
  6007. multiplyToRef(color: Color4, result: Color4): Color4;
  6008. /**
  6009. * Creates a string with the Color4 current values
  6010. * @returns the string representation of the Color4 object
  6011. */
  6012. toString(): string;
  6013. /**
  6014. * Returns the string "Color4"
  6015. * @returns "Color4"
  6016. */
  6017. getClassName(): string;
  6018. /**
  6019. * Compute the Color4 hash code
  6020. * @returns an unique number that can be used to hash Color4 objects
  6021. */
  6022. getHashCode(): number;
  6023. /**
  6024. * Creates a new Color4 copied from the current one
  6025. * @returns a new Color4 object
  6026. */
  6027. clone(): Color4;
  6028. /**
  6029. * Copies the given Color4 values into the current one
  6030. * @param source defines the source Color4 object
  6031. * @returns the current updated Color4 object
  6032. */
  6033. copyFrom(source: Color4): Color4;
  6034. /**
  6035. * Copies the given float values into the current one
  6036. * @param r defines the red component to read from
  6037. * @param g defines the green component to read from
  6038. * @param b defines the blue component to read from
  6039. * @param a defines the alpha component to read from
  6040. * @returns the current updated Color4 object
  6041. */
  6042. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6043. /**
  6044. * Copies the given float values into the current one
  6045. * @param r defines the red component to read from
  6046. * @param g defines the green component to read from
  6047. * @param b defines the blue component to read from
  6048. * @param a defines the alpha component to read from
  6049. * @returns the current updated Color4 object
  6050. */
  6051. set(r: number, g: number, b: number, a: number): Color4;
  6052. /**
  6053. * Compute the Color4 hexadecimal code as a string
  6054. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6055. * @returns a string containing the hexadecimal representation of the Color4 object
  6056. */
  6057. toHexString(returnAsColor3?: boolean): string;
  6058. /**
  6059. * Computes a new Color4 converted from the current one to linear space
  6060. * @returns a new Color4 object
  6061. */
  6062. toLinearSpace(): Color4;
  6063. /**
  6064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6065. * @param convertedColor defines the Color4 object where to store the linear space version
  6066. * @returns the unmodified Color4
  6067. */
  6068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6069. /**
  6070. * Computes a new Color4 converted from the current one to gamma space
  6071. * @returns a new Color4 object
  6072. */
  6073. toGammaSpace(): Color4;
  6074. /**
  6075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6076. * @param convertedColor defines the Color4 object where to store the gamma space version
  6077. * @returns the unmodified Color4
  6078. */
  6079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6080. /**
  6081. * Creates a new Color4 from the string containing valid hexadecimal values
  6082. * @param hex defines a string containing valid hexadecimal values
  6083. * @returns a new Color4 object
  6084. */
  6085. static FromHexString(hex: string): Color4;
  6086. /**
  6087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6088. * @param left defines the start value
  6089. * @param right defines the end value
  6090. * @param amount defines the gradient factor
  6091. * @returns a new Color4 object
  6092. */
  6093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6094. /**
  6095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6096. * @param left defines the start value
  6097. * @param right defines the end value
  6098. * @param amount defines the gradient factor
  6099. * @param result defines the Color4 object where to store data
  6100. */
  6101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6102. /**
  6103. * Creates a new Color4 from a Color3 and an alpha value
  6104. * @param color3 defines the source Color3 to read from
  6105. * @param alpha defines the alpha component (1.0 by default)
  6106. * @returns a new Color4 object
  6107. */
  6108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6109. /**
  6110. * Creates a new Color4 from the starting index element of the given array
  6111. * @param array defines the source array to read from
  6112. * @param offset defines the offset in the source array
  6113. * @returns a new Color4 object
  6114. */
  6115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6116. /**
  6117. * Creates a new Color4 from the starting index element of the given array
  6118. * @param array defines the source array to read from
  6119. * @param offset defines the offset in the source array
  6120. * @param result defines the target Color4 object
  6121. */
  6122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6123. /**
  6124. * Creates a new Color3 from integer values (< 256)
  6125. * @param r defines the red component to read from (value between 0 and 255)
  6126. * @param g defines the green component to read from (value between 0 and 255)
  6127. * @param b defines the blue component to read from (value between 0 and 255)
  6128. * @param a defines the alpha component to read from (value between 0 and 255)
  6129. * @returns a new Color3 object
  6130. */
  6131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6132. /**
  6133. * Check the content of a given array and convert it to an array containing RGBA data
  6134. * If the original array was already containing count * 4 values then it is returned directly
  6135. * @param colors defines the array to check
  6136. * @param count defines the number of RGBA data to expect
  6137. * @returns an array containing count * 4 values (RGBA)
  6138. */
  6139. static CheckColors4(colors: number[], count: number): number[];
  6140. }
  6141. /**
  6142. * @hidden
  6143. */
  6144. export class TmpColors {
  6145. static Color3: Color3[];
  6146. static Color4: Color4[];
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationKey" {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module "babylonjs/Animations/animationRange" {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module "babylonjs/Animations/animationEvent" {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module "babylonjs/Behaviors/behavior" {
  6249. import { Nullable } from "babylonjs/types";
  6250. /**
  6251. * Interface used to define a behavior
  6252. */
  6253. export interface Behavior<T> {
  6254. /** gets or sets behavior's name */
  6255. name: string;
  6256. /**
  6257. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6258. */
  6259. init(): void;
  6260. /**
  6261. * Called when the behavior is attached to a target
  6262. * @param target defines the target where the behavior is attached to
  6263. */
  6264. attach(target: T): void;
  6265. /**
  6266. * Called when the behavior is detached from its target
  6267. */
  6268. detach(): void;
  6269. }
  6270. /**
  6271. * Interface implemented by classes supporting behaviors
  6272. */
  6273. export interface IBehaviorAware<T> {
  6274. /**
  6275. * Attach a behavior
  6276. * @param behavior defines the behavior to attach
  6277. * @returns the current host
  6278. */
  6279. addBehavior(behavior: Behavior<T>): T;
  6280. /**
  6281. * Remove a behavior from the current object
  6282. * @param behavior defines the behavior to detach
  6283. * @returns the current host
  6284. */
  6285. removeBehavior(behavior: Behavior<T>): T;
  6286. /**
  6287. * Gets a behavior using its name to search
  6288. * @param name defines the name to search
  6289. * @returns the behavior or null if not found
  6290. */
  6291. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6292. }
  6293. }
  6294. declare module "babylonjs/Misc/smartArray" {
  6295. /**
  6296. * Defines an array and its length.
  6297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6298. */
  6299. export interface ISmartArrayLike<T> {
  6300. /**
  6301. * The data of the array.
  6302. */
  6303. data: Array<T>;
  6304. /**
  6305. * The active length of the array.
  6306. */
  6307. length: number;
  6308. }
  6309. /**
  6310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6311. */
  6312. export class SmartArray<T> implements ISmartArrayLike<T> {
  6313. /**
  6314. * The full set of data from the array.
  6315. */
  6316. data: Array<T>;
  6317. /**
  6318. * The active length of the array.
  6319. */
  6320. length: number;
  6321. protected _id: number;
  6322. /**
  6323. * Instantiates a Smart Array.
  6324. * @param capacity defines the default capacity of the array.
  6325. */
  6326. constructor(capacity: number);
  6327. /**
  6328. * Pushes a value at the end of the active data.
  6329. * @param value defines the object to push in the array.
  6330. */
  6331. push(value: T): void;
  6332. /**
  6333. * Iterates over the active data and apply the lambda to them.
  6334. * @param func defines the action to apply on each value.
  6335. */
  6336. forEach(func: (content: T) => void): void;
  6337. /**
  6338. * Sorts the full sets of data.
  6339. * @param compareFn defines the comparison function to apply.
  6340. */
  6341. sort(compareFn: (a: T, b: T) => number): void;
  6342. /**
  6343. * Resets the active data to an empty array.
  6344. */
  6345. reset(): void;
  6346. /**
  6347. * Releases all the data from the array as well as the array.
  6348. */
  6349. dispose(): void;
  6350. /**
  6351. * Concats the active data with a given array.
  6352. * @param array defines the data to concatenate with.
  6353. */
  6354. concat(array: any): void;
  6355. /**
  6356. * Returns the position of a value in the active data.
  6357. * @param value defines the value to find the index for
  6358. * @returns the index if found in the active data otherwise -1
  6359. */
  6360. indexOf(value: T): number;
  6361. /**
  6362. * Returns whether an element is part of the active data.
  6363. * @param value defines the value to look for
  6364. * @returns true if found in the active data otherwise false
  6365. */
  6366. contains(value: T): boolean;
  6367. private static _GlobalId;
  6368. }
  6369. /**
  6370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6371. * The data in this array can only be present once
  6372. */
  6373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6374. private _duplicateId;
  6375. /**
  6376. * Pushes a value at the end of the active data.
  6377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6378. * @param value defines the object to push in the array.
  6379. */
  6380. push(value: T): void;
  6381. /**
  6382. * Pushes a value at the end of the active data.
  6383. * If the data is already present, it won t be added again
  6384. * @param value defines the object to push in the array.
  6385. * @returns true if added false if it was already present
  6386. */
  6387. pushNoDuplicate(value: T): boolean;
  6388. /**
  6389. * Resets the active data to an empty array.
  6390. */
  6391. reset(): void;
  6392. /**
  6393. * Concats the active data with a given array.
  6394. * This ensures no dupplicate will be present in the result.
  6395. * @param array defines the data to concatenate with.
  6396. */
  6397. concatWithNoDuplicate(array: any): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Cameras/cameraInputsManager" {
  6401. import { Nullable } from "babylonjs/types";
  6402. import { Camera } from "babylonjs/Cameras/camera";
  6403. /**
  6404. * @ignore
  6405. * This is a list of all the different input types that are available in the application.
  6406. * Fo instance: ArcRotateCameraGamepadInput...
  6407. */
  6408. export var CameraInputTypes: {};
  6409. /**
  6410. * This is the contract to implement in order to create a new input class.
  6411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6412. */
  6413. export interface ICameraInput<TCamera extends Camera> {
  6414. /**
  6415. * Defines the camera the input is attached to.
  6416. */
  6417. camera: Nullable<TCamera>;
  6418. /**
  6419. * Gets the class name of the current intput.
  6420. * @returns the class name
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * Get the friendly name associated with the input class.
  6425. * @returns the input friendly name
  6426. */
  6427. getSimpleName(): string;
  6428. /**
  6429. * Attach the input controls to a specific dom element to get the input from.
  6430. * @param element Defines the element the controls should be listened from
  6431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6432. */
  6433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6434. /**
  6435. * Detach the current controls from the specified dom element.
  6436. * @param element Defines the element to stop listening the inputs from
  6437. */
  6438. detachControl(element: Nullable<HTMLElement>): void;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs?: () => void;
  6444. }
  6445. /**
  6446. * Represents a map of input types to input instance or input index to input instance.
  6447. */
  6448. export interface CameraInputsMap<TCamera extends Camera> {
  6449. /**
  6450. * Accessor to the input by input type.
  6451. */
  6452. [name: string]: ICameraInput<TCamera>;
  6453. /**
  6454. * Accessor to the input by input index.
  6455. */
  6456. [idx: number]: ICameraInput<TCamera>;
  6457. }
  6458. /**
  6459. * This represents the input manager used within a camera.
  6460. * It helps dealing with all the different kind of input attached to a camera.
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. */
  6463. export class CameraInputsManager<TCamera extends Camera> {
  6464. /**
  6465. * Defines the list of inputs attahed to the camera.
  6466. */
  6467. attached: CameraInputsMap<TCamera>;
  6468. /**
  6469. * Defines the dom element the camera is collecting inputs from.
  6470. * This is null if the controls have not been attached.
  6471. */
  6472. attachedElement: Nullable<HTMLElement>;
  6473. /**
  6474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6475. */
  6476. noPreventDefault: boolean;
  6477. /**
  6478. * Defined the camera the input manager belongs to.
  6479. */
  6480. camera: TCamera;
  6481. /**
  6482. * Update the current camera state depending on the inputs that have been used this frame.
  6483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6484. */
  6485. checkInputs: () => void;
  6486. /**
  6487. * Instantiate a new Camera Input Manager.
  6488. * @param camera Defines the camera the input manager blongs to
  6489. */
  6490. constructor(camera: TCamera);
  6491. /**
  6492. * Add an input method to a camera
  6493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6494. * @param input camera input method
  6495. */
  6496. add(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Remove a specific input method from a camera
  6499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6500. * @param inputToRemove camera input method
  6501. */
  6502. remove(inputToRemove: ICameraInput<TCamera>): void;
  6503. /**
  6504. * Remove a specific input type from a camera
  6505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6506. * @param inputType the type of the input to remove
  6507. */
  6508. removeByType(inputType: string): void;
  6509. private _addCheckInputs;
  6510. /**
  6511. * Attach the input controls to the currently attached dom element to listen the events from.
  6512. * @param input Defines the input to attach
  6513. */
  6514. attachInput(input: ICameraInput<TCamera>): void;
  6515. /**
  6516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6517. * @param element Defines the dom element to collect the events from
  6518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6519. */
  6520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6521. /**
  6522. * Detach the current manager inputs controls from a specific dom element.
  6523. * @param element Defines the dom element to collect the events from
  6524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6525. */
  6526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6527. /**
  6528. * Rebuild the dynamic inputCheck function from the current list of
  6529. * defined inputs in the manager.
  6530. */
  6531. rebuildInputCheck(): void;
  6532. /**
  6533. * Remove all attached input methods from a camera
  6534. */
  6535. clear(): void;
  6536. /**
  6537. * Serialize the current input manager attached to a camera.
  6538. * This ensures than once parsed,
  6539. * the input associated to the camera will be identical to the current ones
  6540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6541. */
  6542. serialize(serializedCamera: any): void;
  6543. /**
  6544. * Parses an input manager serialized JSON to restore the previous list of inputs
  6545. * and states associated to a camera.
  6546. * @param parsedCamera Defines the JSON to parse
  6547. */
  6548. parse(parsedCamera: any): void;
  6549. }
  6550. }
  6551. declare module "babylonjs/Meshes/buffer" {
  6552. import { Nullable, DataArray } from "babylonjs/types";
  6553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6554. /**
  6555. * Class used to store data that will be store in GPU memory
  6556. */
  6557. export class Buffer {
  6558. private _engine;
  6559. private _buffer;
  6560. /** @hidden */
  6561. _data: Nullable<DataArray>;
  6562. private _updatable;
  6563. private _instanced;
  6564. private _divisor;
  6565. /**
  6566. * Gets the byte stride.
  6567. */
  6568. readonly byteStride: number;
  6569. /**
  6570. * Constructor
  6571. * @param engine the engine
  6572. * @param data the data to use for this buffer
  6573. * @param updatable whether the data is updatable
  6574. * @param stride the stride (optional)
  6575. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6576. * @param instanced whether the buffer is instanced (optional)
  6577. * @param useBytes set to true if the stride in in bytes (optional)
  6578. * @param divisor sets an optional divisor for instances (1 by default)
  6579. */
  6580. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6581. /**
  6582. * Create a new VertexBuffer based on the current buffer
  6583. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6584. * @param offset defines offset in the buffer (0 by default)
  6585. * @param size defines the size in floats of attributes (position is 3 for instance)
  6586. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6587. * @param instanced defines if the vertex buffer contains indexed data
  6588. * @param useBytes defines if the offset and stride are in bytes *
  6589. * @param divisor sets an optional divisor for instances (1 by default)
  6590. * @returns the new vertex buffer
  6591. */
  6592. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6593. /**
  6594. * Gets a boolean indicating if the Buffer is updatable?
  6595. * @returns true if the buffer is updatable
  6596. */
  6597. isUpdatable(): boolean;
  6598. /**
  6599. * Gets current buffer's data
  6600. * @returns a DataArray or null
  6601. */
  6602. getData(): Nullable<DataArray>;
  6603. /**
  6604. * Gets underlying native buffer
  6605. * @returns underlying native buffer
  6606. */
  6607. getBuffer(): Nullable<DataBuffer>;
  6608. /**
  6609. * Gets the stride in float32 units (i.e. byte stride / 4).
  6610. * May not be an integer if the byte stride is not divisible by 4.
  6611. * @returns the stride in float32 units
  6612. * @deprecated Please use byteStride instead.
  6613. */
  6614. getStrideSize(): number;
  6615. /**
  6616. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6617. * @param data defines the data to store
  6618. */
  6619. create(data?: Nullable<DataArray>): void;
  6620. /** @hidden */
  6621. _rebuild(): void;
  6622. /**
  6623. * Update current buffer data
  6624. * @param data defines the data to store
  6625. */
  6626. update(data: DataArray): void;
  6627. /**
  6628. * Updates the data directly.
  6629. * @param data the new data
  6630. * @param offset the new offset
  6631. * @param vertexCount the vertex count (optional)
  6632. * @param useBytes set to true if the offset is in bytes
  6633. */
  6634. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6635. /**
  6636. * Release all resources
  6637. */
  6638. dispose(): void;
  6639. }
  6640. /**
  6641. * Specialized buffer used to store vertex data
  6642. */
  6643. export class VertexBuffer {
  6644. /** @hidden */
  6645. _buffer: Buffer;
  6646. private _kind;
  6647. private _size;
  6648. private _ownsBuffer;
  6649. private _instanced;
  6650. private _instanceDivisor;
  6651. /**
  6652. * The byte type.
  6653. */
  6654. static readonly BYTE: number;
  6655. /**
  6656. * The unsigned byte type.
  6657. */
  6658. static readonly UNSIGNED_BYTE: number;
  6659. /**
  6660. * The short type.
  6661. */
  6662. static readonly SHORT: number;
  6663. /**
  6664. * The unsigned short type.
  6665. */
  6666. static readonly UNSIGNED_SHORT: number;
  6667. /**
  6668. * The integer type.
  6669. */
  6670. static readonly INT: number;
  6671. /**
  6672. * The unsigned integer type.
  6673. */
  6674. static readonly UNSIGNED_INT: number;
  6675. /**
  6676. * The float type.
  6677. */
  6678. static readonly FLOAT: number;
  6679. /**
  6680. * Gets or sets the instance divisor when in instanced mode
  6681. */
  6682. get instanceDivisor(): number;
  6683. set instanceDivisor(value: number);
  6684. /**
  6685. * Gets the byte stride.
  6686. */
  6687. readonly byteStride: number;
  6688. /**
  6689. * Gets the byte offset.
  6690. */
  6691. readonly byteOffset: number;
  6692. /**
  6693. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6694. */
  6695. readonly normalized: boolean;
  6696. /**
  6697. * Gets the data type of each component in the array.
  6698. */
  6699. readonly type: number;
  6700. /**
  6701. * Constructor
  6702. * @param engine the engine
  6703. * @param data the data to use for this vertex buffer
  6704. * @param kind the vertex buffer kind
  6705. * @param updatable whether the data is updatable
  6706. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6707. * @param stride the stride (optional)
  6708. * @param instanced whether the buffer is instanced (optional)
  6709. * @param offset the offset of the data (optional)
  6710. * @param size the number of components (optional)
  6711. * @param type the type of the component (optional)
  6712. * @param normalized whether the data contains normalized data (optional)
  6713. * @param useBytes set to true if stride and offset are in bytes (optional)
  6714. * @param divisor defines the instance divisor to use (1 by default)
  6715. */
  6716. 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);
  6717. /** @hidden */
  6718. _rebuild(): void;
  6719. /**
  6720. * Returns the kind of the VertexBuffer (string)
  6721. * @returns a string
  6722. */
  6723. getKind(): string;
  6724. /**
  6725. * Gets a boolean indicating if the VertexBuffer is updatable?
  6726. * @returns true if the buffer is updatable
  6727. */
  6728. isUpdatable(): boolean;
  6729. /**
  6730. * Gets current buffer's data
  6731. * @returns a DataArray or null
  6732. */
  6733. getData(): Nullable<DataArray>;
  6734. /**
  6735. * Gets underlying native buffer
  6736. * @returns underlying native buffer
  6737. */
  6738. getBuffer(): Nullable<DataBuffer>;
  6739. /**
  6740. * Gets the stride in float32 units (i.e. byte stride / 4).
  6741. * May not be an integer if the byte stride is not divisible by 4.
  6742. * @returns the stride in float32 units
  6743. * @deprecated Please use byteStride instead.
  6744. */
  6745. getStrideSize(): number;
  6746. /**
  6747. * Returns the offset as a multiple of the type byte length.
  6748. * @returns the offset in bytes
  6749. * @deprecated Please use byteOffset instead.
  6750. */
  6751. getOffset(): number;
  6752. /**
  6753. * Returns the number of components per vertex attribute (integer)
  6754. * @returns the size in float
  6755. */
  6756. getSize(): number;
  6757. /**
  6758. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6759. * @returns true if this buffer is instanced
  6760. */
  6761. getIsInstanced(): boolean;
  6762. /**
  6763. * Returns the instancing divisor, zero for non-instanced (integer).
  6764. * @returns a number
  6765. */
  6766. getInstanceDivisor(): number;
  6767. /**
  6768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6769. * @param data defines the data to store
  6770. */
  6771. create(data?: DataArray): void;
  6772. /**
  6773. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6774. * This function will create a new buffer if the current one is not updatable
  6775. * @param data defines the data to store
  6776. */
  6777. update(data: DataArray): void;
  6778. /**
  6779. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6780. * Returns the directly updated WebGLBuffer.
  6781. * @param data the new data
  6782. * @param offset the new offset
  6783. * @param useBytes set to true if the offset is in bytes
  6784. */
  6785. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6786. /**
  6787. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6788. */
  6789. dispose(): void;
  6790. /**
  6791. * Enumerates each value of this vertex buffer as numbers.
  6792. * @param count the number of values to enumerate
  6793. * @param callback the callback function called for each value
  6794. */
  6795. forEach(count: number, callback: (value: number, index: number) => void): void;
  6796. /**
  6797. * Positions
  6798. */
  6799. static readonly PositionKind: string;
  6800. /**
  6801. * Normals
  6802. */
  6803. static readonly NormalKind: string;
  6804. /**
  6805. * Tangents
  6806. */
  6807. static readonly TangentKind: string;
  6808. /**
  6809. * Texture coordinates
  6810. */
  6811. static readonly UVKind: string;
  6812. /**
  6813. * Texture coordinates 2
  6814. */
  6815. static readonly UV2Kind: string;
  6816. /**
  6817. * Texture coordinates 3
  6818. */
  6819. static readonly UV3Kind: string;
  6820. /**
  6821. * Texture coordinates 4
  6822. */
  6823. static readonly UV4Kind: string;
  6824. /**
  6825. * Texture coordinates 5
  6826. */
  6827. static readonly UV5Kind: string;
  6828. /**
  6829. * Texture coordinates 6
  6830. */
  6831. static readonly UV6Kind: string;
  6832. /**
  6833. * Colors
  6834. */
  6835. static readonly ColorKind: string;
  6836. /**
  6837. * Matrix indices (for bones)
  6838. */
  6839. static readonly MatricesIndicesKind: string;
  6840. /**
  6841. * Matrix weights (for bones)
  6842. */
  6843. static readonly MatricesWeightsKind: string;
  6844. /**
  6845. * Additional matrix indices (for bones)
  6846. */
  6847. static readonly MatricesIndicesExtraKind: string;
  6848. /**
  6849. * Additional matrix weights (for bones)
  6850. */
  6851. static readonly MatricesWeightsExtraKind: string;
  6852. /**
  6853. * Deduces the stride given a kind.
  6854. * @param kind The kind string to deduce
  6855. * @returns The deduced stride
  6856. */
  6857. static DeduceStride(kind: string): number;
  6858. /**
  6859. * Gets the byte length of the given type.
  6860. * @param type the type
  6861. * @returns the number of bytes
  6862. */
  6863. static GetTypeByteLength(type: number): number;
  6864. /**
  6865. * Enumerates each value of the given parameters as numbers.
  6866. * @param data the data to enumerate
  6867. * @param byteOffset the byte offset of the data
  6868. * @param byteStride the byte stride of the data
  6869. * @param componentCount the number of components per element
  6870. * @param componentType the type of the component
  6871. * @param count the number of values to enumerate
  6872. * @param normalized whether the data is normalized
  6873. * @param callback the callback function called for each value
  6874. */
  6875. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6876. private static _GetFloatValue;
  6877. }
  6878. }
  6879. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6880. import { Vector3 } from "babylonjs/Maths/math.vector";
  6881. import { Mesh } from "babylonjs/Meshes/mesh";
  6882. /**
  6883. * The options Interface for creating a Capsule Mesh
  6884. */
  6885. export interface ICreateCapsuleOptions {
  6886. /** The Orientation of the capsule. Default : Vector3.Up() */
  6887. orientation?: Vector3;
  6888. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6889. subdivisions: number;
  6890. /** Number of cylindrical segments on the capsule. */
  6891. tessellation: number;
  6892. /** Height or Length of the capsule. */
  6893. height: number;
  6894. /** Radius of the capsule. */
  6895. radius: number;
  6896. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6897. capSubdivisions: number;
  6898. /** Overwrite for the top radius. */
  6899. radiusTop?: number;
  6900. /** Overwrite for the bottom radius. */
  6901. radiusBottom?: number;
  6902. /** Overwrite for the top capSubdivisions. */
  6903. topCapSubdivisions?: number;
  6904. /** Overwrite for the bottom capSubdivisions. */
  6905. bottomCapSubdivisions?: number;
  6906. }
  6907. /**
  6908. * Class containing static functions to help procedurally build meshes
  6909. */
  6910. export class CapsuleBuilder {
  6911. /**
  6912. * Creates a capsule or a pill mesh
  6913. * @param name defines the name of the mesh
  6914. * @param options The constructors options.
  6915. * @param scene The scene the mesh is scoped to.
  6916. * @returns Capsule Mesh
  6917. */
  6918. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6919. }
  6920. }
  6921. declare module "babylonjs/Collisions/intersectionInfo" {
  6922. import { Nullable } from "babylonjs/types";
  6923. /**
  6924. * @hidden
  6925. */
  6926. export class IntersectionInfo {
  6927. bu: Nullable<number>;
  6928. bv: Nullable<number>;
  6929. distance: number;
  6930. faceId: number;
  6931. subMeshId: number;
  6932. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingSphere" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6938. import { Plane } from "babylonjs/Maths/math.plane";
  6939. /**
  6940. * Class used to store bounding sphere information
  6941. */
  6942. export class BoundingSphere {
  6943. /**
  6944. * Gets the center of the bounding sphere in local space
  6945. */
  6946. readonly center: Vector3;
  6947. /**
  6948. * Radius of the bounding sphere in local space
  6949. */
  6950. radius: number;
  6951. /**
  6952. * Gets the center of the bounding sphere in world space
  6953. */
  6954. readonly centerWorld: Vector3;
  6955. /**
  6956. * Radius of the bounding sphere in world space
  6957. */
  6958. radiusWorld: number;
  6959. /**
  6960. * Gets the minimum vector in local space
  6961. */
  6962. readonly minimum: Vector3;
  6963. /**
  6964. * Gets the maximum vector in local space
  6965. */
  6966. readonly maximum: Vector3;
  6967. private _worldMatrix;
  6968. private static readonly TmpVector3;
  6969. /**
  6970. * Creates a new bounding sphere
  6971. * @param min defines the minimum vector (in local space)
  6972. * @param max defines the maximum vector (in local space)
  6973. * @param worldMatrix defines the new world matrix
  6974. */
  6975. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6976. /**
  6977. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6978. * @param min defines the new minimum vector (in local space)
  6979. * @param max defines the new maximum vector (in local space)
  6980. * @param worldMatrix defines the new world matrix
  6981. */
  6982. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Scale the current bounding sphere by applying a scale factor
  6985. * @param factor defines the scale factor to apply
  6986. * @returns the current bounding box
  6987. */
  6988. scale(factor: number): BoundingSphere;
  6989. /**
  6990. * Gets the world matrix of the bounding box
  6991. * @returns a matrix
  6992. */
  6993. getWorldMatrix(): DeepImmutable<Matrix>;
  6994. /** @hidden */
  6995. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Tests if the bounding sphere is intersecting the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if the bounding sphere center is in between the frustum planes.
  7004. * Used for optimistic fast inclusion.
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if the sphere center is in between the frustum planes
  7007. */
  7008. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding sphere
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding sphere
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Checks if two sphere intersct
  7017. * @param sphere0 sphere 0
  7018. * @param sphere1 sphere 1
  7019. * @returns true if the speres intersect
  7020. */
  7021. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7022. }
  7023. }
  7024. declare module "babylonjs/Culling/boundingBox" {
  7025. import { DeepImmutable } from "babylonjs/types";
  7026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7027. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7028. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding box information
  7032. */
  7033. export class BoundingBox implements ICullable {
  7034. /**
  7035. * Gets the 8 vectors representing the bounding box in local space
  7036. */
  7037. readonly vectors: Vector3[];
  7038. /**
  7039. * Gets the center of the bounding box in local space
  7040. */
  7041. readonly center: Vector3;
  7042. /**
  7043. * Gets the center of the bounding box in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Gets the extend size in local space
  7048. */
  7049. readonly extendSize: Vector3;
  7050. /**
  7051. * Gets the extend size in world space
  7052. */
  7053. readonly extendSizeWorld: Vector3;
  7054. /**
  7055. * Gets the OBB (object bounding box) directions
  7056. */
  7057. readonly directions: Vector3[];
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in world space
  7060. */
  7061. readonly vectorsWorld: Vector3[];
  7062. /**
  7063. * Gets the minimum vector in world space
  7064. */
  7065. readonly minimumWorld: Vector3;
  7066. /**
  7067. * Gets the maximum vector in world space
  7068. */
  7069. readonly maximumWorld: Vector3;
  7070. /**
  7071. * Gets the minimum vector in local space
  7072. */
  7073. readonly minimum: Vector3;
  7074. /**
  7075. * Gets the maximum vector in local space
  7076. */
  7077. readonly maximum: Vector3;
  7078. private _worldMatrix;
  7079. private static readonly TmpVector3;
  7080. /**
  7081. * @hidden
  7082. */
  7083. _tag: number;
  7084. /**
  7085. * Creates a new bounding box
  7086. * @param min defines the minimum vector (in local space)
  7087. * @param max defines the maximum vector (in local space)
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Scale the current bounding box by applying a scale factor
  7100. * @param factor defines the scale factor to apply
  7101. * @returns the current bounding box
  7102. */
  7103. scale(factor: number): BoundingBox;
  7104. /**
  7105. * Gets the world matrix of the bounding box
  7106. * @returns a matrix
  7107. */
  7108. getWorldMatrix(): DeepImmutable<Matrix>;
  7109. /** @hidden */
  7110. _update(world: DeepImmutable<Matrix>): void;
  7111. /**
  7112. * Tests if the bounding box is intersecting the frustum planes
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. /**
  7118. * Tests if the bounding box is entirely inside the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an inclusion
  7121. */
  7122. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if a point is inside the bounding box
  7125. * @param point defines the point to test
  7126. * @returns true if the point is inside the bounding box
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Tests if the bounding box intersects with a bounding sphere
  7131. * @param sphere defines the sphere to test
  7132. * @returns true if there is an intersection
  7133. */
  7134. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7135. /**
  7136. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7137. * @param min defines the min vector to use
  7138. * @param max defines the max vector to use
  7139. * @returns true if there is an intersection
  7140. */
  7141. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7142. /**
  7143. * Tests if two bounding boxes are intersections
  7144. * @param box0 defines the first box to test
  7145. * @param box1 defines the second box to test
  7146. * @returns true if there is an intersection
  7147. */
  7148. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7149. /**
  7150. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7151. * @param minPoint defines the minimum vector of the bounding box
  7152. * @param maxPoint defines the maximum vector of the bounding box
  7153. * @param sphereCenter defines the sphere center
  7154. * @param sphereRadius defines the sphere radius
  7155. * @returns true if there is an intersection
  7156. */
  7157. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7158. /**
  7159. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7161. * @param frustumPlanes defines the frustum planes to test
  7162. * @return true if there is an inclusion
  7163. */
  7164. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /**
  7166. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7167. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7168. * @param frustumPlanes defines the frustum planes to test
  7169. * @return true if there is an intersection
  7170. */
  7171. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. }
  7173. }
  7174. declare module "babylonjs/Collisions/collider" {
  7175. import { Nullable, IndicesArray } from "babylonjs/types";
  7176. import { Vector3 } from "babylonjs/Maths/math.vector";
  7177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7178. import { Plane } from "babylonjs/Maths/math.plane";
  7179. /** @hidden */
  7180. export class Collider {
  7181. /** Define if a collision was found */
  7182. collisionFound: boolean;
  7183. /**
  7184. * Define last intersection point in local space
  7185. */
  7186. intersectionPoint: Vector3;
  7187. /**
  7188. * Define last collided mesh
  7189. */
  7190. collidedMesh: Nullable<AbstractMesh>;
  7191. private _collisionPoint;
  7192. private _planeIntersectionPoint;
  7193. private _tempVector;
  7194. private _tempVector2;
  7195. private _tempVector3;
  7196. private _tempVector4;
  7197. private _edge;
  7198. private _baseToVertex;
  7199. private _destinationPoint;
  7200. private _slidePlaneNormal;
  7201. private _displacementVector;
  7202. /** @hidden */
  7203. _radius: Vector3;
  7204. /** @hidden */
  7205. _retry: number;
  7206. private _velocity;
  7207. private _basePoint;
  7208. private _epsilon;
  7209. /** @hidden */
  7210. _velocityWorldLength: number;
  7211. /** @hidden */
  7212. _basePointWorld: Vector3;
  7213. private _velocityWorld;
  7214. private _normalizedVelocity;
  7215. /** @hidden */
  7216. _initialVelocity: Vector3;
  7217. /** @hidden */
  7218. _initialPosition: Vector3;
  7219. private _nearestDistance;
  7220. private _collisionMask;
  7221. get collisionMask(): number;
  7222. set collisionMask(mask: number);
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. get slidePlaneNormal(): Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Plane } from "babylonjs/Maths/math.plane";
  7247. import { Collider } from "babylonjs/Collisions/collider";
  7248. /**
  7249. * Interface for cullable objects
  7250. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7251. */
  7252. export interface ICullable {
  7253. /**
  7254. * Checks if the object or part of the object is in the frustum
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isInFrustum(frustumPlanes: Plane[]): boolean;
  7259. /**
  7260. * Checks if a cullable object (mesh...) is in the camera frustum
  7261. * Unlike isInFrustum this cheks the full bounding box
  7262. * @param frustumPlanes Camera near/planes
  7263. * @returns true if the object is in frustum otherwise false
  7264. */
  7265. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7266. }
  7267. /**
  7268. * Info for a bounding data of a mesh
  7269. */
  7270. export class BoundingInfo implements ICullable {
  7271. /**
  7272. * Bounding box for the mesh
  7273. */
  7274. readonly boundingBox: BoundingBox;
  7275. /**
  7276. * Bounding sphere for the mesh
  7277. */
  7278. readonly boundingSphere: BoundingSphere;
  7279. private _isLocked;
  7280. private static readonly TmpVector3;
  7281. /**
  7282. * Constructs bounding info
  7283. * @param minimum min vector of the bounding box/sphere
  7284. * @param maximum max vector of the bounding box/sphere
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * min vector of the bounding box/sphere
  7297. */
  7298. get minimum(): Vector3;
  7299. /**
  7300. * max vector of the bounding box/sphere
  7301. */
  7302. get maximum(): Vector3;
  7303. /**
  7304. * If the info is locked and won't be updated to avoid perf overhead
  7305. */
  7306. get isLocked(): boolean;
  7307. set isLocked(value: boolean);
  7308. /**
  7309. * Updates the bounding sphere and box
  7310. * @param world world matrix to be used to update
  7311. */
  7312. update(world: DeepImmutable<Matrix>): void;
  7313. /**
  7314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7315. * @param center New center of the bounding info
  7316. * @param extend New extend of the bounding info
  7317. * @returns the current bounding info
  7318. */
  7319. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7320. /**
  7321. * Scale the current bounding info by applying a scale factor
  7322. * @param factor defines the scale factor to apply
  7323. * @returns the current bounding info
  7324. */
  7325. scale(factor: number): BoundingInfo;
  7326. /**
  7327. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7328. * @param frustumPlanes defines the frustum to test
  7329. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7330. * @returns true if the bounding info is in the frustum planes
  7331. */
  7332. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7333. /**
  7334. * Gets the world distance between the min and max points of the bounding box
  7335. */
  7336. get diagonalLength(): number;
  7337. /**
  7338. * Checks if a cullable object (mesh...) is in the camera frustum
  7339. * Unlike isInFrustum this cheks the full bounding box
  7340. * @param frustumPlanes Camera near/planes
  7341. * @returns true if the object is in frustum otherwise false
  7342. */
  7343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7344. /** @hidden */
  7345. _checkCollision(collider: Collider): boolean;
  7346. /**
  7347. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param point the point to check intersection with
  7350. * @returns if the point intersects
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7355. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7356. * @param boundingInfo the bounding info to check intersection with
  7357. * @param precise if the intersection should be done using OBB
  7358. * @returns if the bounding info intersects
  7359. */
  7360. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7361. }
  7362. }
  7363. declare module "babylonjs/Maths/math.functions" {
  7364. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7365. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7366. /**
  7367. * Extracts minimum and maximum values from a list of indexed positions
  7368. * @param positions defines the positions to use
  7369. * @param indices defines the indices to the positions
  7370. * @param indexStart defines the start index
  7371. * @param indexCount defines the end index
  7372. * @param bias defines bias value to add to the result
  7373. * @return minimum and maximum values
  7374. */
  7375. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7376. minimum: Vector3;
  7377. maximum: Vector3;
  7378. };
  7379. /**
  7380. * Extracts minimum and maximum values from a list of positions
  7381. * @param positions defines the positions to use
  7382. * @param start defines the start index in the positions array
  7383. * @param count defines the number of positions to handle
  7384. * @param bias defines bias value to add to the result
  7385. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7386. * @return minimum and maximum values
  7387. */
  7388. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7389. minimum: Vector3;
  7390. maximum: Vector3;
  7391. };
  7392. }
  7393. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7395. /** @hidden */
  7396. export class WebGLDataBuffer extends DataBuffer {
  7397. private _buffer;
  7398. constructor(resource: WebGLBuffer);
  7399. get underlyingResource(): any;
  7400. }
  7401. }
  7402. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7403. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7404. import { Nullable } from "babylonjs/types";
  7405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7406. /** @hidden */
  7407. export class WebGLPipelineContext implements IPipelineContext {
  7408. engine: ThinEngine;
  7409. program: Nullable<WebGLProgram>;
  7410. context?: WebGLRenderingContext;
  7411. vertexShader?: WebGLShader;
  7412. fragmentShader?: WebGLShader;
  7413. isParallelCompiled: boolean;
  7414. onCompiled?: () => void;
  7415. transformFeedback?: WebGLTransformFeedback | null;
  7416. vertexCompilationError: Nullable<string>;
  7417. fragmentCompilationError: Nullable<string>;
  7418. programLinkError: Nullable<string>;
  7419. programValidationError: Nullable<string>;
  7420. get isAsync(): boolean;
  7421. get isReady(): boolean;
  7422. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7423. _getVertexShaderCode(): string | null;
  7424. _getFragmentShaderCode(): string | null;
  7425. }
  7426. }
  7427. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7428. import { FloatArray, Nullable } from "babylonjs/types";
  7429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7431. module "babylonjs/Engines/thinEngine" {
  7432. interface ThinEngine {
  7433. /**
  7434. * Create an uniform buffer
  7435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7436. * @param elements defines the content of the uniform buffer
  7437. * @returns the webGL uniform buffer
  7438. */
  7439. createUniformBuffer(elements: FloatArray): DataBuffer;
  7440. /**
  7441. * Create a dynamic uniform buffer
  7442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7443. * @param elements defines the content of the uniform buffer
  7444. * @returns the webGL uniform buffer
  7445. */
  7446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7447. /**
  7448. * Update an existing uniform buffer
  7449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7450. * @param uniformBuffer defines the target uniform buffer
  7451. * @param elements defines the content to update
  7452. * @param offset defines the offset in the uniform buffer where update should start
  7453. * @param count defines the size of the data to update
  7454. */
  7455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7456. /**
  7457. * Bind an uniform buffer to the current webGL context
  7458. * @param buffer defines the buffer to bind
  7459. */
  7460. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7461. /**
  7462. * Bind a buffer to the current webGL context at a given location
  7463. * @param buffer defines the buffer to bind
  7464. * @param location defines the index where to bind the buffer
  7465. */
  7466. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7467. /**
  7468. * Bind a specific block at a given index in a specific shader program
  7469. * @param pipelineContext defines the pipeline context to use
  7470. * @param blockName defines the block name
  7471. * @param index defines the index where to bind the block
  7472. */
  7473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7474. }
  7475. }
  7476. }
  7477. declare module "babylonjs/Materials/uniformBuffer" {
  7478. import { Nullable, FloatArray } from "babylonjs/types";
  7479. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7480. import { Engine } from "babylonjs/Engines/engine";
  7481. import { Effect } from "babylonjs/Materials/effect";
  7482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7484. import { Color3 } from "babylonjs/Maths/math.color";
  7485. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7486. /**
  7487. * Uniform buffer objects.
  7488. *
  7489. * Handles blocks of uniform on the GPU.
  7490. *
  7491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7492. *
  7493. * For more information, please refer to :
  7494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7495. */
  7496. export class UniformBuffer {
  7497. private _engine;
  7498. private _buffer;
  7499. private _data;
  7500. private _bufferData;
  7501. private _dynamic?;
  7502. private _uniformLocations;
  7503. private _uniformSizes;
  7504. private _uniformLocationPointer;
  7505. private _needSync;
  7506. private _noUBO;
  7507. private _currentEffect;
  7508. /** @hidden */
  7509. _alreadyBound: boolean;
  7510. private static _MAX_UNIFORM_SIZE;
  7511. private static _tempBuffer;
  7512. /**
  7513. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7518. /**
  7519. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7524. /**
  7525. * Lambda to Update a single float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat: (name: string, x: number) => void;
  7530. /**
  7531. * Lambda to Update a vec2 of float in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7536. /**
  7537. * Lambda to Update a vec3 of float in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7542. /**
  7543. * Lambda to Update a vec4 of float in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7548. /**
  7549. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateMatrix: (name: string, mat: Matrix) => void;
  7554. /**
  7555. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateVector3: (name: string, vector: Vector3) => void;
  7560. /**
  7561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateVector4: (name: string, vector: Vector4) => void;
  7566. /**
  7567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7578. /**
  7579. * Instantiates a new Uniform buffer objects.
  7580. *
  7581. * Handles blocks of uniform on the GPU.
  7582. *
  7583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7584. *
  7585. * For more information, please refer to :
  7586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7587. * @param engine Define the engine the buffer is associated with
  7588. * @param data Define the data contained in the buffer
  7589. * @param dynamic Define if the buffer is updatable
  7590. */
  7591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7592. /**
  7593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7594. * or just falling back on setUniformXXX calls.
  7595. */
  7596. get useUbo(): boolean;
  7597. /**
  7598. * Indicates if the WebGL underlying uniform buffer is in sync
  7599. * with the javascript cache data.
  7600. */
  7601. get isSync(): boolean;
  7602. /**
  7603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7604. * Also, a dynamic UniformBuffer will disable cache verification and always
  7605. * update the underlying WebGL uniform buffer to the GPU.
  7606. * @returns if Dynamic, otherwise false
  7607. */
  7608. isDynamic(): boolean;
  7609. /**
  7610. * The data cache on JS side.
  7611. * @returns the underlying data as a float array
  7612. */
  7613. getData(): Float32Array;
  7614. /**
  7615. * The underlying WebGL Uniform buffer.
  7616. * @returns the webgl buffer
  7617. */
  7618. getBuffer(): Nullable<DataBuffer>;
  7619. /**
  7620. * std140 layout specifies how to align data within an UBO structure.
  7621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7622. * for specs.
  7623. */
  7624. private _fillAlignment;
  7625. /**
  7626. * Adds an uniform in the buffer.
  7627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7628. * for the layout to be correct !
  7629. * @param name Name of the uniform, as used in the uniform block in the shader.
  7630. * @param size Data size, or data directly.
  7631. */
  7632. addUniform(name: string, size: number | number[]): void;
  7633. /**
  7634. * Adds a Matrix 4x4 to the uniform buffer.
  7635. * @param name Name of the uniform, as used in the uniform block in the shader.
  7636. * @param mat A 4x4 matrix.
  7637. */
  7638. addMatrix(name: string, mat: Matrix): void;
  7639. /**
  7640. * Adds a vec2 to the uniform buffer.
  7641. * @param name Name of the uniform, as used in the uniform block in the shader.
  7642. * @param x Define the x component value of the vec2
  7643. * @param y Define the y component value of the vec2
  7644. */
  7645. addFloat2(name: string, x: number, y: number): void;
  7646. /**
  7647. * Adds a vec3 to the uniform buffer.
  7648. * @param name Name of the uniform, as used in the uniform block in the shader.
  7649. * @param x Define the x component value of the vec3
  7650. * @param y Define the y component value of the vec3
  7651. * @param z Define the z component value of the vec3
  7652. */
  7653. addFloat3(name: string, x: number, y: number, z: number): void;
  7654. /**
  7655. * Adds a vec3 to the uniform buffer.
  7656. * @param name Name of the uniform, as used in the uniform block in the shader.
  7657. * @param color Define the vec3 from a Color
  7658. */
  7659. addColor3(name: string, color: Color3): void;
  7660. /**
  7661. * Adds a vec4 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. * @param color Define the rgb components from a Color
  7664. * @param alpha Define the a component of the vec4
  7665. */
  7666. addColor4(name: string, color: Color3, alpha: number): void;
  7667. /**
  7668. * Adds a vec3 to the uniform buffer.
  7669. * @param name Name of the uniform, as used in the uniform block in the shader.
  7670. * @param vector Define the vec3 components from a Vector
  7671. */
  7672. addVector3(name: string, vector: Vector3): void;
  7673. /**
  7674. * Adds a Matrix 3x3 to the uniform buffer.
  7675. * @param name Name of the uniform, as used in the uniform block in the shader.
  7676. */
  7677. addMatrix3x3(name: string): void;
  7678. /**
  7679. * Adds a Matrix 2x2 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. */
  7682. addMatrix2x2(name: string): void;
  7683. /**
  7684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7685. */
  7686. create(): void;
  7687. /** @hidden */
  7688. _rebuild(): void;
  7689. /**
  7690. * Updates the WebGL Uniform Buffer on the GPU.
  7691. * If the `dynamic` flag is set to true, no cache comparison is done.
  7692. * Otherwise, the buffer will be updated only if the cache differs.
  7693. */
  7694. update(): void;
  7695. /**
  7696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7698. * @param data Define the flattened data
  7699. * @param size Define the size of the data.
  7700. */
  7701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7702. private _valueCache;
  7703. private _cacheMatrix;
  7704. private _updateMatrix3x3ForUniform;
  7705. private _updateMatrix3x3ForEffect;
  7706. private _updateMatrix2x2ForEffect;
  7707. private _updateMatrix2x2ForUniform;
  7708. private _updateFloatForEffect;
  7709. private _updateFloatForUniform;
  7710. private _updateFloat2ForEffect;
  7711. private _updateFloat2ForUniform;
  7712. private _updateFloat3ForEffect;
  7713. private _updateFloat3ForUniform;
  7714. private _updateFloat4ForEffect;
  7715. private _updateFloat4ForUniform;
  7716. private _updateMatrixForEffect;
  7717. private _updateMatrixForUniform;
  7718. private _updateVector3ForEffect;
  7719. private _updateVector3ForUniform;
  7720. private _updateVector4ForEffect;
  7721. private _updateVector4ForUniform;
  7722. private _updateColor3ForEffect;
  7723. private _updateColor3ForUniform;
  7724. private _updateColor4ForEffect;
  7725. private _updateColor4ForUniform;
  7726. /**
  7727. * Sets a sampler uniform on the effect.
  7728. * @param name Define the name of the sampler.
  7729. * @param texture Define the texture to set in the sampler
  7730. */
  7731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7732. /**
  7733. * Directly updates the value of the uniform in the cache AND on the GPU.
  7734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7735. * @param data Define the flattened data
  7736. */
  7737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7738. /**
  7739. * Binds this uniform buffer to an effect.
  7740. * @param effect Define the effect to bind the buffer to
  7741. * @param name Name of the uniform block in the shader.
  7742. */
  7743. bindToEffect(effect: Effect, name: string): void;
  7744. /**
  7745. * Disposes the uniform buffer.
  7746. */
  7747. dispose(): void;
  7748. }
  7749. }
  7750. declare module "babylonjs/Misc/iInspectable" {
  7751. /**
  7752. * Enum that determines the text-wrapping mode to use.
  7753. */
  7754. export enum InspectableType {
  7755. /**
  7756. * Checkbox for booleans
  7757. */
  7758. Checkbox = 0,
  7759. /**
  7760. * Sliders for numbers
  7761. */
  7762. Slider = 1,
  7763. /**
  7764. * Vector3
  7765. */
  7766. Vector3 = 2,
  7767. /**
  7768. * Quaternions
  7769. */
  7770. Quaternion = 3,
  7771. /**
  7772. * Color3
  7773. */
  7774. Color3 = 4,
  7775. /**
  7776. * String
  7777. */
  7778. String = 5
  7779. }
  7780. /**
  7781. * Interface used to define custom inspectable properties.
  7782. * This interface is used by the inspector to display custom property grids
  7783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7784. */
  7785. export interface IInspectable {
  7786. /**
  7787. * Gets the label to display
  7788. */
  7789. label: string;
  7790. /**
  7791. * Gets the name of the property to edit
  7792. */
  7793. propertyName: string;
  7794. /**
  7795. * Gets the type of the editor to use
  7796. */
  7797. type: InspectableType;
  7798. /**
  7799. * Gets the minimum value of the property when using in "slider" mode
  7800. */
  7801. min?: number;
  7802. /**
  7803. * Gets the maximum value of the property when using in "slider" mode
  7804. */
  7805. max?: number;
  7806. /**
  7807. * Gets the setp to use when using in "slider" mode
  7808. */
  7809. step?: number;
  7810. }
  7811. }
  7812. declare module "babylonjs/Misc/timingTools" {
  7813. /**
  7814. * Class used to provide helper for timing
  7815. */
  7816. export class TimingTools {
  7817. /**
  7818. * Polyfill for setImmediate
  7819. * @param action defines the action to execute after the current execution block
  7820. */
  7821. static SetImmediate(action: () => void): void;
  7822. }
  7823. }
  7824. declare module "babylonjs/Misc/instantiationTools" {
  7825. /**
  7826. * Class used to enable instatition of objects by class name
  7827. */
  7828. export class InstantiationTools {
  7829. /**
  7830. * Use this object to register external classes like custom textures or material
  7831. * to allow the laoders to instantiate them
  7832. */
  7833. static RegisteredExternalClasses: {
  7834. [key: string]: Object;
  7835. };
  7836. /**
  7837. * Tries to instantiate a new object from a given class name
  7838. * @param className defines the class name to instantiate
  7839. * @returns the new object or null if the system was not able to do the instantiation
  7840. */
  7841. static Instantiate(className: string): any;
  7842. }
  7843. }
  7844. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7845. /**
  7846. * Define options used to create a depth texture
  7847. */
  7848. export class DepthTextureCreationOptions {
  7849. /** Specifies whether or not a stencil should be allocated in the texture */
  7850. generateStencil?: boolean;
  7851. /** Specifies whether or not bilinear filtering is enable on the texture */
  7852. bilinearFiltering?: boolean;
  7853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7854. comparisonFunction?: number;
  7855. /** Specifies if the created texture is a cube texture */
  7856. isCube?: boolean;
  7857. }
  7858. }
  7859. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7861. import { Nullable } from "babylonjs/types";
  7862. import { Scene } from "babylonjs/scene";
  7863. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7864. module "babylonjs/Engines/thinEngine" {
  7865. interface ThinEngine {
  7866. /**
  7867. * Creates a depth stencil cube texture.
  7868. * This is only available in WebGL 2.
  7869. * @param size The size of face edge in the cube texture.
  7870. * @param options The options defining the cube texture.
  7871. * @returns The cube texture
  7872. */
  7873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7874. /**
  7875. * Creates a cube texture
  7876. * @param rootUrl defines the url where the files to load is located
  7877. * @param scene defines the current scene
  7878. * @param files defines the list of files to load (1 per face)
  7879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7880. * @param onLoad defines an optional callback raised when the texture is loaded
  7881. * @param onError defines an optional callback raised if there is an issue to load the texture
  7882. * @param format defines the format of the data
  7883. * @param forcedExtension defines the extension to use to pick the right loader
  7884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7888. * @returns the cube texture as an InternalTexture
  7889. */
  7890. 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;
  7891. /**
  7892. * Creates a cube texture
  7893. * @param rootUrl defines the url where the files to load is located
  7894. * @param scene defines the current scene
  7895. * @param files defines the list of files to load (1 per face)
  7896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7897. * @param onLoad defines an optional callback raised when the texture is loaded
  7898. * @param onError defines an optional callback raised if there is an issue to load the texture
  7899. * @param format defines the format of the data
  7900. * @param forcedExtension defines the extension to use to pick the right loader
  7901. * @returns the cube texture as an InternalTexture
  7902. */
  7903. 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;
  7904. /**
  7905. * Creates a cube texture
  7906. * @param rootUrl defines the url where the files to load is located
  7907. * @param scene defines the current scene
  7908. * @param files defines the list of files to load (1 per face)
  7909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7910. * @param onLoad defines an optional callback raised when the texture is loaded
  7911. * @param onError defines an optional callback raised if there is an issue to load the texture
  7912. * @param format defines the format of the data
  7913. * @param forcedExtension defines the extension to use to pick the right loader
  7914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7917. * @returns the cube texture as an InternalTexture
  7918. */
  7919. 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;
  7920. /** @hidden */
  7921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7922. /** @hidden */
  7923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7924. /** @hidden */
  7925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7926. /** @hidden */
  7927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7928. /**
  7929. * @hidden
  7930. */
  7931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7932. }
  7933. }
  7934. }
  7935. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7936. import { Nullable } from "babylonjs/types";
  7937. import { Scene } from "babylonjs/scene";
  7938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7941. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7942. import { Observable } from "babylonjs/Misc/observable";
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * Observable triggered once the texture has been loaded.
  7950. */
  7951. onLoadObservable: Observable<CubeTexture>;
  7952. /**
  7953. * The url of the texture
  7954. */
  7955. url: string;
  7956. /**
  7957. * Gets or sets the center of the bounding box associated with the cube texture.
  7958. * It must define where the camera used to render the texture was set
  7959. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7960. */
  7961. boundingBoxPosition: Vector3;
  7962. private _boundingBoxSize;
  7963. /**
  7964. * Gets or sets the size of the bounding box associated with the cube texture
  7965. * When defined, the cubemap will switch to local mode
  7966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7967. * @example https://www.babylonjs-playground.com/#RNASML
  7968. */
  7969. set boundingBoxSize(value: Vector3);
  7970. /**
  7971. * Returns the bounding box size
  7972. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7973. */
  7974. get boundingBoxSize(): Vector3;
  7975. protected _rotationY: number;
  7976. /**
  7977. * Sets texture matrix rotation angle around Y axis in radians.
  7978. */
  7979. set rotationY(value: number);
  7980. /**
  7981. * Gets texture matrix rotation angle around Y axis radians.
  7982. */
  7983. get rotationY(): number;
  7984. /**
  7985. * Are mip maps generated for this texture or not.
  7986. */
  7987. get noMipmap(): boolean;
  7988. private _noMipmap;
  7989. private _files;
  7990. protected _forcedExtension: Nullable<string>;
  7991. private _extensions;
  7992. private _textureMatrix;
  7993. private _format;
  7994. private _createPolynomials;
  7995. /**
  7996. * Creates a cube texture from an array of image urls
  7997. * @param files defines an array of image urls
  7998. * @param scene defines the hosting scene
  7999. * @param noMipmap specifies if mip maps are not used
  8000. * @returns a cube texture
  8001. */
  8002. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8003. /**
  8004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8005. * @param url defines the url of the prefiltered texture
  8006. * @param scene defines the scene the texture is attached to
  8007. * @param forcedExtension defines the extension of the file if different from the url
  8008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8009. * @return the prefiltered texture
  8010. */
  8011. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8012. /**
  8013. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8014. * as prefiltered data.
  8015. * @param rootUrl defines the url of the texture or the root name of the six images
  8016. * @param null defines the scene or engine the texture is attached to
  8017. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8018. * @param noMipmap defines if mipmaps should be created or not
  8019. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8020. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8021. * @param onError defines a callback triggered in case of error during load
  8022. * @param format defines the internal format to use for the texture once loaded
  8023. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8024. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8025. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8028. * @return the cube texture
  8029. */
  8030. 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);
  8031. /**
  8032. * Get the current class name of the texture useful for serialization or dynamic coding.
  8033. * @returns "CubeTexture"
  8034. */
  8035. getClassName(): string;
  8036. /**
  8037. * Update the url (and optional buffer) of this texture if url was null during construction.
  8038. * @param url the url of the texture
  8039. * @param forcedExtension defines the extension to use
  8040. * @param onLoad callback called when the texture is loaded (defaults to null)
  8041. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8042. */
  8043. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8044. /**
  8045. * Delays loading of the cube texture
  8046. * @param forcedExtension defines the extension to use
  8047. */
  8048. delayLoad(forcedExtension?: string): void;
  8049. /**
  8050. * Returns the reflection texture matrix
  8051. * @returns the reflection texture matrix
  8052. */
  8053. getReflectionTextureMatrix(): Matrix;
  8054. /**
  8055. * Sets the reflection texture matrix
  8056. * @param value Reflection texture matrix
  8057. */
  8058. setReflectionTextureMatrix(value: Matrix): void;
  8059. /**
  8060. * Parses text to create a cube texture
  8061. * @param parsedTexture define the serialized text to read from
  8062. * @param scene defines the hosting scene
  8063. * @param rootUrl defines the root url of the cube texture
  8064. * @returns a cube texture
  8065. */
  8066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8067. /**
  8068. * Makes a clone, or deep copy, of the cube texture
  8069. * @returns a new cube texture
  8070. */
  8071. clone(): CubeTexture;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/materialDefines" {
  8075. /**
  8076. * Manages the defines for the Material
  8077. */
  8078. export class MaterialDefines {
  8079. /** @hidden */
  8080. protected _keys: string[];
  8081. private _isDirty;
  8082. /** @hidden */
  8083. _renderId: number;
  8084. /** @hidden */
  8085. _areLightsDirty: boolean;
  8086. /** @hidden */
  8087. _areLightsDisposed: boolean;
  8088. /** @hidden */
  8089. _areAttributesDirty: boolean;
  8090. /** @hidden */
  8091. _areTexturesDirty: boolean;
  8092. /** @hidden */
  8093. _areFresnelDirty: boolean;
  8094. /** @hidden */
  8095. _areMiscDirty: boolean;
  8096. /** @hidden */
  8097. _areImageProcessingDirty: boolean;
  8098. /** @hidden */
  8099. _normals: boolean;
  8100. /** @hidden */
  8101. _uvs: boolean;
  8102. /** @hidden */
  8103. _needNormals: boolean;
  8104. /** @hidden */
  8105. _needUVs: boolean;
  8106. [id: string]: any;
  8107. /**
  8108. * Specifies if the material needs to be re-calculated
  8109. */
  8110. get isDirty(): boolean;
  8111. /**
  8112. * Marks the material to indicate that it has been re-calculated
  8113. */
  8114. markAsProcessed(): void;
  8115. /**
  8116. * Marks the material to indicate that it needs to be re-calculated
  8117. */
  8118. markAsUnprocessed(): void;
  8119. /**
  8120. * Marks the material to indicate all of its defines need to be re-calculated
  8121. */
  8122. markAllAsDirty(): void;
  8123. /**
  8124. * Marks the material to indicate that image processing needs to be re-calculated
  8125. */
  8126. markAsImageProcessingDirty(): void;
  8127. /**
  8128. * Marks the material to indicate the lights need to be re-calculated
  8129. * @param disposed Defines whether the light is dirty due to dispose or not
  8130. */
  8131. markAsLightDirty(disposed?: boolean): void;
  8132. /**
  8133. * Marks the attribute state as changed
  8134. */
  8135. markAsAttributesDirty(): void;
  8136. /**
  8137. * Marks the texture state as changed
  8138. */
  8139. markAsTexturesDirty(): void;
  8140. /**
  8141. * Marks the fresnel state as changed
  8142. */
  8143. markAsFresnelDirty(): void;
  8144. /**
  8145. * Marks the misc state as changed
  8146. */
  8147. markAsMiscDirty(): void;
  8148. /**
  8149. * Rebuilds the material defines
  8150. */
  8151. rebuild(): void;
  8152. /**
  8153. * Specifies if two material defines are equal
  8154. * @param other - A material define instance to compare to
  8155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8156. */
  8157. isEqual(other: MaterialDefines): boolean;
  8158. /**
  8159. * Clones this instance's defines to another instance
  8160. * @param other - material defines to clone values to
  8161. */
  8162. cloneTo(other: MaterialDefines): void;
  8163. /**
  8164. * Resets the material define values
  8165. */
  8166. reset(): void;
  8167. /**
  8168. * Converts the material define values to a string
  8169. * @returns - String of material define information
  8170. */
  8171. toString(): string;
  8172. }
  8173. }
  8174. declare module "babylonjs/Materials/colorCurves" {
  8175. import { Effect } from "babylonjs/Materials/effect";
  8176. /**
  8177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8179. * 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;
  8180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8181. */
  8182. export class ColorCurves {
  8183. private _dirty;
  8184. private _tempColor;
  8185. private _globalCurve;
  8186. private _highlightsCurve;
  8187. private _midtonesCurve;
  8188. private _shadowsCurve;
  8189. private _positiveCurve;
  8190. private _negativeCurve;
  8191. private _globalHue;
  8192. private _globalDensity;
  8193. private _globalSaturation;
  8194. private _globalExposure;
  8195. /**
  8196. * Gets the global Hue value.
  8197. * 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).
  8198. */
  8199. get globalHue(): number;
  8200. /**
  8201. * Sets the global Hue value.
  8202. * 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).
  8203. */
  8204. set globalHue(value: number);
  8205. /**
  8206. * Gets the global Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get globalDensity(): number;
  8211. /**
  8212. * Sets the global Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set globalDensity(value: number);
  8217. /**
  8218. * Gets the global Saturation value.
  8219. * 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.
  8220. */
  8221. get globalSaturation(): number;
  8222. /**
  8223. * Sets the global Saturation value.
  8224. * 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.
  8225. */
  8226. set globalSaturation(value: number);
  8227. /**
  8228. * Gets the global Exposure value.
  8229. * 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.
  8230. */
  8231. get globalExposure(): number;
  8232. /**
  8233. * Sets the global Exposure value.
  8234. * 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.
  8235. */
  8236. set globalExposure(value: number);
  8237. private _highlightsHue;
  8238. private _highlightsDensity;
  8239. private _highlightsSaturation;
  8240. private _highlightsExposure;
  8241. /**
  8242. * Gets the highlights Hue value.
  8243. * 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).
  8244. */
  8245. get highlightsHue(): number;
  8246. /**
  8247. * Sets the highlights Hue value.
  8248. * 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).
  8249. */
  8250. set highlightsHue(value: number);
  8251. /**
  8252. * Gets the highlights Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. get highlightsDensity(): number;
  8257. /**
  8258. * Sets the highlights Density value.
  8259. * 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.
  8260. * Values less than zero provide a filter of opposite hue.
  8261. */
  8262. set highlightsDensity(value: number);
  8263. /**
  8264. * Gets the highlights Saturation value.
  8265. * 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.
  8266. */
  8267. get highlightsSaturation(): number;
  8268. /**
  8269. * Sets the highlights Saturation value.
  8270. * 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.
  8271. */
  8272. set highlightsSaturation(value: number);
  8273. /**
  8274. * Gets the highlights Exposure value.
  8275. * 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.
  8276. */
  8277. get highlightsExposure(): number;
  8278. /**
  8279. * Sets the highlights Exposure value.
  8280. * 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.
  8281. */
  8282. set highlightsExposure(value: number);
  8283. private _midtonesHue;
  8284. private _midtonesDensity;
  8285. private _midtonesSaturation;
  8286. private _midtonesExposure;
  8287. /**
  8288. * Gets the midtones Hue value.
  8289. * 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).
  8290. */
  8291. get midtonesHue(): number;
  8292. /**
  8293. * Sets the midtones Hue value.
  8294. * 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).
  8295. */
  8296. set midtonesHue(value: number);
  8297. /**
  8298. * Gets the midtones Density value.
  8299. * 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.
  8300. * Values less than zero provide a filter of opposite hue.
  8301. */
  8302. get midtonesDensity(): number;
  8303. /**
  8304. * Sets the midtones Density value.
  8305. * 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.
  8306. * Values less than zero provide a filter of opposite hue.
  8307. */
  8308. set midtonesDensity(value: number);
  8309. /**
  8310. * Gets the midtones Saturation value.
  8311. * 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.
  8312. */
  8313. get midtonesSaturation(): number;
  8314. /**
  8315. * Sets the midtones Saturation value.
  8316. * 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.
  8317. */
  8318. set midtonesSaturation(value: number);
  8319. /**
  8320. * Gets the midtones Exposure value.
  8321. * 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.
  8322. */
  8323. get midtonesExposure(): number;
  8324. /**
  8325. * Sets the midtones Exposure value.
  8326. * 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.
  8327. */
  8328. set midtonesExposure(value: number);
  8329. private _shadowsHue;
  8330. private _shadowsDensity;
  8331. private _shadowsSaturation;
  8332. private _shadowsExposure;
  8333. /**
  8334. * Gets the shadows Hue value.
  8335. * 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).
  8336. */
  8337. get shadowsHue(): number;
  8338. /**
  8339. * Sets the shadows Hue value.
  8340. * 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).
  8341. */
  8342. set shadowsHue(value: number);
  8343. /**
  8344. * Gets the shadows Density value.
  8345. * 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.
  8346. * Values less than zero provide a filter of opposite hue.
  8347. */
  8348. get shadowsDensity(): number;
  8349. /**
  8350. * Sets the shadows Density value.
  8351. * 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.
  8352. * Values less than zero provide a filter of opposite hue.
  8353. */
  8354. set shadowsDensity(value: number);
  8355. /**
  8356. * Gets the shadows Saturation value.
  8357. * 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.
  8358. */
  8359. get shadowsSaturation(): number;
  8360. /**
  8361. * Sets the shadows Saturation value.
  8362. * 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.
  8363. */
  8364. set shadowsSaturation(value: number);
  8365. /**
  8366. * Gets the shadows Exposure value.
  8367. * 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.
  8368. */
  8369. get shadowsExposure(): number;
  8370. /**
  8371. * Sets the shadows Exposure value.
  8372. * 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.
  8373. */
  8374. set shadowsExposure(value: number);
  8375. /**
  8376. * Returns the class name
  8377. * @returns The class name
  8378. */
  8379. getClassName(): string;
  8380. /**
  8381. * Binds the color curves to the shader.
  8382. * @param colorCurves The color curve to bind
  8383. * @param effect The effect to bind to
  8384. * @param positiveUniform The positive uniform shader parameter
  8385. * @param neutralUniform The neutral uniform shader parameter
  8386. * @param negativeUniform The negative uniform shader parameter
  8387. */
  8388. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8389. /**
  8390. * Prepare the list of uniforms associated with the ColorCurves effects.
  8391. * @param uniformsList The list of uniforms used in the effect
  8392. */
  8393. static PrepareUniforms(uniformsList: string[]): void;
  8394. /**
  8395. * Returns color grading data based on a hue, density, saturation and exposure value.
  8396. * @param filterHue The hue of the color filter.
  8397. * @param filterDensity The density of the color filter.
  8398. * @param saturation The saturation.
  8399. * @param exposure The exposure.
  8400. * @param result The result data container.
  8401. */
  8402. private getColorGradingDataToRef;
  8403. /**
  8404. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8405. * @param value The input slider value in range [-100,100].
  8406. * @returns Adjusted value.
  8407. */
  8408. private static applyColorGradingSliderNonlinear;
  8409. /**
  8410. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8411. * @param hue The hue (H) input.
  8412. * @param saturation The saturation (S) input.
  8413. * @param brightness The brightness (B) input.
  8414. * @result An RGBA color represented as Vector4.
  8415. */
  8416. private static fromHSBToRef;
  8417. /**
  8418. * Returns a value clamped between min and max
  8419. * @param value The value to clamp
  8420. * @param min The minimum of value
  8421. * @param max The maximum of value
  8422. * @returns The clamped value.
  8423. */
  8424. private static clamp;
  8425. /**
  8426. * Clones the current color curve instance.
  8427. * @return The cloned curves
  8428. */
  8429. clone(): ColorCurves;
  8430. /**
  8431. * Serializes the current color curve instance to a json representation.
  8432. * @return a JSON representation
  8433. */
  8434. serialize(): any;
  8435. /**
  8436. * Parses the color curve from a json representation.
  8437. * @param source the JSON source to parse
  8438. * @return The parsed curves
  8439. */
  8440. static Parse(source: any): ColorCurves;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8444. import { Observable } from "babylonjs/Misc/observable";
  8445. import { Nullable } from "babylonjs/types";
  8446. import { Color4 } from "babylonjs/Maths/math.color";
  8447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8448. import { Effect } from "babylonjs/Materials/effect";
  8449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8450. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8451. /**
  8452. * Interface to follow in your material defines to integrate easily the
  8453. * Image proccessing functions.
  8454. * @hidden
  8455. */
  8456. export interface IImageProcessingConfigurationDefines {
  8457. IMAGEPROCESSING: boolean;
  8458. VIGNETTE: boolean;
  8459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8460. VIGNETTEBLENDMODEOPAQUE: boolean;
  8461. TONEMAPPING: boolean;
  8462. TONEMAPPING_ACES: boolean;
  8463. CONTRAST: boolean;
  8464. EXPOSURE: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. }
  8472. /**
  8473. * @hidden
  8474. */
  8475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8476. IMAGEPROCESSING: boolean;
  8477. VIGNETTE: boolean;
  8478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8479. VIGNETTEBLENDMODEOPAQUE: boolean;
  8480. TONEMAPPING: boolean;
  8481. TONEMAPPING_ACES: boolean;
  8482. CONTRAST: boolean;
  8483. COLORCURVES: boolean;
  8484. COLORGRADING: boolean;
  8485. COLORGRADING3D: boolean;
  8486. SAMPLER3DGREENDEPTH: boolean;
  8487. SAMPLER3DBGRMAP: boolean;
  8488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8489. EXPOSURE: boolean;
  8490. constructor();
  8491. }
  8492. /**
  8493. * This groups together the common properties used for image processing either in direct forward pass
  8494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8495. * or not.
  8496. */
  8497. export class ImageProcessingConfiguration {
  8498. /**
  8499. * Default tone mapping applied in BabylonJS.
  8500. */
  8501. static readonly TONEMAPPING_STANDARD: number;
  8502. /**
  8503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8504. * to other engines rendering to increase portability.
  8505. */
  8506. static readonly TONEMAPPING_ACES: number;
  8507. /**
  8508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8509. */
  8510. colorCurves: Nullable<ColorCurves>;
  8511. private _colorCurvesEnabled;
  8512. /**
  8513. * Gets wether the color curves effect is enabled.
  8514. */
  8515. get colorCurvesEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color curves effect is enabled.
  8518. */
  8519. set colorCurvesEnabled(value: boolean);
  8520. private _colorGradingTexture;
  8521. /**
  8522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8523. */
  8524. get colorGradingTexture(): Nullable<BaseTexture>;
  8525. /**
  8526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8527. */
  8528. set colorGradingTexture(value: Nullable<BaseTexture>);
  8529. private _colorGradingEnabled;
  8530. /**
  8531. * Gets wether the color grading effect is enabled.
  8532. */
  8533. get colorGradingEnabled(): boolean;
  8534. /**
  8535. * Sets wether the color grading effect is enabled.
  8536. */
  8537. set colorGradingEnabled(value: boolean);
  8538. private _colorGradingWithGreenDepth;
  8539. /**
  8540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8541. */
  8542. get colorGradingWithGreenDepth(): boolean;
  8543. /**
  8544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8545. */
  8546. set colorGradingWithGreenDepth(value: boolean);
  8547. private _colorGradingBGR;
  8548. /**
  8549. * Gets wether the color grading texture contains BGR values.
  8550. */
  8551. get colorGradingBGR(): boolean;
  8552. /**
  8553. * Sets wether the color grading texture contains BGR values.
  8554. */
  8555. set colorGradingBGR(value: boolean);
  8556. /** @hidden */
  8557. _exposure: number;
  8558. /**
  8559. * Gets the Exposure used in the effect.
  8560. */
  8561. get exposure(): number;
  8562. /**
  8563. * Sets the Exposure used in the effect.
  8564. */
  8565. set exposure(value: number);
  8566. private _toneMappingEnabled;
  8567. /**
  8568. * Gets wether the tone mapping effect is enabled.
  8569. */
  8570. get toneMappingEnabled(): boolean;
  8571. /**
  8572. * Sets wether the tone mapping effect is enabled.
  8573. */
  8574. set toneMappingEnabled(value: boolean);
  8575. private _toneMappingType;
  8576. /**
  8577. * Gets the type of tone mapping effect.
  8578. */
  8579. get toneMappingType(): number;
  8580. /**
  8581. * Sets the type of tone mapping effect used in BabylonJS.
  8582. */
  8583. set toneMappingType(value: number);
  8584. protected _contrast: number;
  8585. /**
  8586. * Gets the contrast used in the effect.
  8587. */
  8588. get contrast(): number;
  8589. /**
  8590. * Sets the contrast used in the effect.
  8591. */
  8592. set contrast(value: number);
  8593. /**
  8594. * Vignette stretch size.
  8595. */
  8596. vignetteStretch: number;
  8597. /**
  8598. * Vignette centre X Offset.
  8599. */
  8600. vignetteCentreX: number;
  8601. /**
  8602. * Vignette centre Y Offset.
  8603. */
  8604. vignetteCentreY: number;
  8605. /**
  8606. * Vignette weight or intensity of the vignette effect.
  8607. */
  8608. vignetteWeight: number;
  8609. /**
  8610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8611. * if vignetteEnabled is set to true.
  8612. */
  8613. vignetteColor: Color4;
  8614. /**
  8615. * Camera field of view used by the Vignette effect.
  8616. */
  8617. vignetteCameraFov: number;
  8618. private _vignetteBlendMode;
  8619. /**
  8620. * Gets the vignette blend mode allowing different kind of effect.
  8621. */
  8622. get vignetteBlendMode(): number;
  8623. /**
  8624. * Sets the vignette blend mode allowing different kind of effect.
  8625. */
  8626. set vignetteBlendMode(value: number);
  8627. private _vignetteEnabled;
  8628. /**
  8629. * Gets wether the vignette effect is enabled.
  8630. */
  8631. get vignetteEnabled(): boolean;
  8632. /**
  8633. * Sets wether the vignette effect is enabled.
  8634. */
  8635. set vignetteEnabled(value: boolean);
  8636. private _applyByPostProcess;
  8637. /**
  8638. * Gets wether the image processing is applied through a post process or not.
  8639. */
  8640. get applyByPostProcess(): boolean;
  8641. /**
  8642. * Sets wether the image processing is applied through a post process or not.
  8643. */
  8644. set applyByPostProcess(value: boolean);
  8645. private _isEnabled;
  8646. /**
  8647. * Gets wether the image processing is enabled or not.
  8648. */
  8649. get isEnabled(): boolean;
  8650. /**
  8651. * Sets wether the image processing is enabled or not.
  8652. */
  8653. set isEnabled(value: boolean);
  8654. /**
  8655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8656. */
  8657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8658. /**
  8659. * Method called each time the image processing information changes requires to recompile the effect.
  8660. */
  8661. protected _updateParameters(): void;
  8662. /**
  8663. * Gets the current class name.
  8664. * @return "ImageProcessingConfiguration"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Prepare the list of uniforms associated with the Image Processing effects.
  8669. * @param uniforms The list of uniforms used in the effect
  8670. * @param defines the list of defines currently in use
  8671. */
  8672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8673. /**
  8674. * Prepare the list of samplers associated with the Image Processing effects.
  8675. * @param samplersList The list of uniforms used in the effect
  8676. * @param defines the list of defines currently in use
  8677. */
  8678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8679. /**
  8680. * Prepare the list of defines associated to the shader.
  8681. * @param defines the list of defines to complete
  8682. * @param forPostProcess Define if we are currently in post process mode or not
  8683. */
  8684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8685. /**
  8686. * Returns true if all the image processing information are ready.
  8687. * @returns True if ready, otherwise, false
  8688. */
  8689. isReady(): boolean;
  8690. /**
  8691. * Binds the image processing to the shader.
  8692. * @param effect The effect to bind to
  8693. * @param overrideAspectRatio Override the aspect ratio of the effect
  8694. */
  8695. bind(effect: Effect, overrideAspectRatio?: number): void;
  8696. /**
  8697. * Clones the current image processing instance.
  8698. * @return The cloned image processing
  8699. */
  8700. clone(): ImageProcessingConfiguration;
  8701. /**
  8702. * Serializes the current image processing instance to a json representation.
  8703. * @return a JSON representation
  8704. */
  8705. serialize(): any;
  8706. /**
  8707. * Parses the image processing from a json representation.
  8708. * @param source the JSON source to parse
  8709. * @return The parsed image processing
  8710. */
  8711. static Parse(source: any): ImageProcessingConfiguration;
  8712. private static _VIGNETTEMODE_MULTIPLY;
  8713. private static _VIGNETTEMODE_OPAQUE;
  8714. /**
  8715. * Used to apply the vignette as a mix with the pixel color.
  8716. */
  8717. static get VIGNETTEMODE_MULTIPLY(): number;
  8718. /**
  8719. * Used to apply the vignette as a replacement of the pixel color.
  8720. */
  8721. static get VIGNETTEMODE_OPAQUE(): number;
  8722. }
  8723. }
  8724. declare module "babylonjs/Shaders/postprocess.vertex" {
  8725. /** @hidden */
  8726. export var postprocessVertexShader: {
  8727. name: string;
  8728. shader: string;
  8729. };
  8730. }
  8731. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8733. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8734. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8735. /**
  8736. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8737. */
  8738. export type RenderTargetTextureSize = number | {
  8739. width: number;
  8740. height: number;
  8741. layers?: number;
  8742. };
  8743. module "babylonjs/Engines/thinEngine" {
  8744. interface ThinEngine {
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8752. /**
  8753. * Creates a depth stencil texture.
  8754. * This is only available in WebGL 2 or with the depth texture extension available.
  8755. * @param size The size of face edge in the texture.
  8756. * @param options The options defining the texture.
  8757. * @returns The texture
  8758. */
  8759. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8760. /** @hidden */
  8761. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8762. }
  8763. }
  8764. }
  8765. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8766. /**
  8767. * Defines the kind of connection point for node based material
  8768. */
  8769. export enum NodeMaterialBlockConnectionPointTypes {
  8770. /** Float */
  8771. Float = 1,
  8772. /** Int */
  8773. Int = 2,
  8774. /** Vector2 */
  8775. Vector2 = 4,
  8776. /** Vector3 */
  8777. Vector3 = 8,
  8778. /** Vector4 */
  8779. Vector4 = 16,
  8780. /** Color3 */
  8781. Color3 = 32,
  8782. /** Color4 */
  8783. Color4 = 64,
  8784. /** Matrix */
  8785. Matrix = 128,
  8786. /** Custom object */
  8787. Object = 256,
  8788. /** Detect type based on connection */
  8789. AutoDetect = 1024,
  8790. /** Output type that will be defined by input type */
  8791. BasedOnInput = 2048
  8792. }
  8793. }
  8794. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8795. /**
  8796. * Enum used to define the target of a block
  8797. */
  8798. export enum NodeMaterialBlockTargets {
  8799. /** Vertex shader */
  8800. Vertex = 1,
  8801. /** Fragment shader */
  8802. Fragment = 2,
  8803. /** Neutral */
  8804. Neutral = 4,
  8805. /** Vertex and Fragment */
  8806. VertexAndFragment = 3
  8807. }
  8808. }
  8809. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8810. /**
  8811. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8812. */
  8813. export enum NodeMaterialBlockConnectionPointMode {
  8814. /** Value is an uniform */
  8815. Uniform = 0,
  8816. /** Value is a mesh attribute */
  8817. Attribute = 1,
  8818. /** Value is a varying between vertex and fragment shaders */
  8819. Varying = 2,
  8820. /** Mode is undefined */
  8821. Undefined = 3
  8822. }
  8823. }
  8824. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8825. /**
  8826. * Enum used to define system values e.g. values automatically provided by the system
  8827. */
  8828. export enum NodeMaterialSystemValues {
  8829. /** World */
  8830. World = 1,
  8831. /** View */
  8832. View = 2,
  8833. /** Projection */
  8834. Projection = 3,
  8835. /** ViewProjection */
  8836. ViewProjection = 4,
  8837. /** WorldView */
  8838. WorldView = 5,
  8839. /** WorldViewProjection */
  8840. WorldViewProjection = 6,
  8841. /** CameraPosition */
  8842. CameraPosition = 7,
  8843. /** Fog Color */
  8844. FogColor = 8,
  8845. /** Delta time */
  8846. DeltaTime = 9
  8847. }
  8848. }
  8849. declare module "babylonjs/Maths/math.axis" {
  8850. import { Vector3 } from "babylonjs/Maths/math.vector";
  8851. /** Defines supported spaces */
  8852. export enum Space {
  8853. /** Local (object) space */
  8854. LOCAL = 0,
  8855. /** World space */
  8856. WORLD = 1,
  8857. /** Bone space */
  8858. BONE = 2
  8859. }
  8860. /** Defines the 3 main axes */
  8861. export class Axis {
  8862. /** X axis */
  8863. static X: Vector3;
  8864. /** Y axis */
  8865. static Y: Vector3;
  8866. /** Z axis */
  8867. static Z: Vector3;
  8868. }
  8869. }
  8870. declare module "babylonjs/Maths/math.frustum" {
  8871. import { Matrix } from "babylonjs/Maths/math.vector";
  8872. import { DeepImmutable } from "babylonjs/types";
  8873. import { Plane } from "babylonjs/Maths/math.plane";
  8874. /**
  8875. * Represents a camera frustum
  8876. */
  8877. export class Frustum {
  8878. /**
  8879. * Gets the planes representing the frustum
  8880. * @param transform matrix to be applied to the returned planes
  8881. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8882. */
  8883. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8884. /**
  8885. * Gets the near frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the far frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the left frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Gets the right frustum plane transformed by the transform matrix
  8904. * @param transform transformation matrix to be applied to the resulting frustum plane
  8905. * @param frustumPlane the resuling frustum plane
  8906. */
  8907. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8908. /**
  8909. * Gets the top frustum plane transformed by the transform matrix
  8910. * @param transform transformation matrix to be applied to the resulting frustum plane
  8911. * @param frustumPlane the resuling frustum plane
  8912. */
  8913. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8914. /**
  8915. * Gets the bottom frustum plane transformed by the transform matrix
  8916. * @param transform transformation matrix to be applied to the resulting frustum plane
  8917. * @param frustumPlane the resuling frustum plane
  8918. */
  8919. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8920. /**
  8921. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8922. * @param transform transformation matrix to be applied to the resulting frustum planes
  8923. * @param frustumPlanes the resuling frustum planes
  8924. */
  8925. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8926. }
  8927. }
  8928. declare module "babylonjs/Maths/math.size" {
  8929. /**
  8930. * Interface for the size containing width and height
  8931. */
  8932. export interface ISize {
  8933. /**
  8934. * Width
  8935. */
  8936. width: number;
  8937. /**
  8938. * Heighht
  8939. */
  8940. height: number;
  8941. }
  8942. /**
  8943. * Size containing widht and height
  8944. */
  8945. export class Size implements ISize {
  8946. /**
  8947. * Width
  8948. */
  8949. width: number;
  8950. /**
  8951. * Height
  8952. */
  8953. height: number;
  8954. /**
  8955. * Creates a Size object from the given width and height (floats).
  8956. * @param width width of the new size
  8957. * @param height height of the new size
  8958. */
  8959. constructor(width: number, height: number);
  8960. /**
  8961. * Returns a string with the Size width and height
  8962. * @returns a string with the Size width and height
  8963. */
  8964. toString(): string;
  8965. /**
  8966. * "Size"
  8967. * @returns the string "Size"
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Returns the Size hash code.
  8972. * @returns a hash code for a unique width and height
  8973. */
  8974. getHashCode(): number;
  8975. /**
  8976. * Updates the current size from the given one.
  8977. * @param src the given size
  8978. */
  8979. copyFrom(src: Size): void;
  8980. /**
  8981. * Updates in place the current Size from the given floats.
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. * @returns the updated Size.
  8985. */
  8986. copyFromFloats(width: number, height: number): Size;
  8987. /**
  8988. * Updates in place the current Size from the given floats.
  8989. * @param width width to set
  8990. * @param height height to set
  8991. * @returns the updated Size.
  8992. */
  8993. set(width: number, height: number): Size;
  8994. /**
  8995. * Multiplies the width and height by numbers
  8996. * @param w factor to multiple the width by
  8997. * @param h factor to multiple the height by
  8998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8999. */
  9000. multiplyByFloats(w: number, h: number): Size;
  9001. /**
  9002. * Clones the size
  9003. * @returns a new Size copied from the given one.
  9004. */
  9005. clone(): Size;
  9006. /**
  9007. * True if the current Size and the given one width and height are strictly equal.
  9008. * @param other the other size to compare against
  9009. * @returns True if the current Size and the given one width and height are strictly equal.
  9010. */
  9011. equals(other: Size): boolean;
  9012. /**
  9013. * The surface of the Size : width * height (float).
  9014. */
  9015. get surface(): number;
  9016. /**
  9017. * Create a new size of zero
  9018. * @returns a new Size set to (0.0, 0.0)
  9019. */
  9020. static Zero(): Size;
  9021. /**
  9022. * Sums the width and height of two sizes
  9023. * @param otherSize size to add to this size
  9024. * @returns a new Size set as the addition result of the current Size and the given one.
  9025. */
  9026. add(otherSize: Size): Size;
  9027. /**
  9028. * Subtracts the width and height of two
  9029. * @param otherSize size to subtract to this size
  9030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9031. */
  9032. subtract(otherSize: Size): Size;
  9033. /**
  9034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9035. * @param start starting size to lerp between
  9036. * @param end end size to lerp between
  9037. * @param amount amount to lerp between the start and end values
  9038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9039. */
  9040. static Lerp(start: Size, end: Size, amount: number): Size;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math.vertexFormat" {
  9044. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9045. /**
  9046. * Contains position and normal vectors for a vertex
  9047. */
  9048. export class PositionNormalVertex {
  9049. /** the position of the vertex (defaut: 0,0,0) */
  9050. position: Vector3;
  9051. /** the normal of the vertex (defaut: 0,1,0) */
  9052. normal: Vector3;
  9053. /**
  9054. * Creates a PositionNormalVertex
  9055. * @param position the position of the vertex (defaut: 0,0,0)
  9056. * @param normal the normal of the vertex (defaut: 0,1,0)
  9057. */
  9058. constructor(
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position?: Vector3,
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal?: Vector3);
  9063. /**
  9064. * Clones the PositionNormalVertex
  9065. * @returns the cloned PositionNormalVertex
  9066. */
  9067. clone(): PositionNormalVertex;
  9068. }
  9069. /**
  9070. * Contains position, normal and uv vectors for a vertex
  9071. */
  9072. export class PositionNormalTextureVertex {
  9073. /** the position of the vertex (defaut: 0,0,0) */
  9074. position: Vector3;
  9075. /** the normal of the vertex (defaut: 0,1,0) */
  9076. normal: Vector3;
  9077. /** the uv of the vertex (default: 0,0) */
  9078. uv: Vector2;
  9079. /**
  9080. * Creates a PositionNormalTextureVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. * @param uv the uv of the vertex (default: 0,0)
  9084. */
  9085. constructor(
  9086. /** the position of the vertex (defaut: 0,0,0) */
  9087. position?: Vector3,
  9088. /** the normal of the vertex (defaut: 0,1,0) */
  9089. normal?: Vector3,
  9090. /** the uv of the vertex (default: 0,0) */
  9091. uv?: Vector2);
  9092. /**
  9093. * Clones the PositionNormalTextureVertex
  9094. * @returns the cloned PositionNormalTextureVertex
  9095. */
  9096. clone(): PositionNormalTextureVertex;
  9097. }
  9098. }
  9099. declare module "babylonjs/Maths/math" {
  9100. export * from "babylonjs/Maths/math.axis";
  9101. export * from "babylonjs/Maths/math.color";
  9102. export * from "babylonjs/Maths/math.constants";
  9103. export * from "babylonjs/Maths/math.frustum";
  9104. export * from "babylonjs/Maths/math.path";
  9105. export * from "babylonjs/Maths/math.plane";
  9106. export * from "babylonjs/Maths/math.size";
  9107. export * from "babylonjs/Maths/math.vector";
  9108. export * from "babylonjs/Maths/math.vertexFormat";
  9109. export * from "babylonjs/Maths/math.viewport";
  9110. }
  9111. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9112. /**
  9113. * Enum defining the type of animations supported by InputBlock
  9114. */
  9115. export enum AnimatedInputBlockTypes {
  9116. /** No animation */
  9117. None = 0,
  9118. /** Time based animation. Will only work for floats */
  9119. Time = 1
  9120. }
  9121. }
  9122. declare module "babylonjs/Lights/shadowLight" {
  9123. import { Camera } from "babylonjs/Cameras/camera";
  9124. import { Scene } from "babylonjs/scene";
  9125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9127. import { Light } from "babylonjs/Lights/light";
  9128. /**
  9129. * Interface describing all the common properties and methods a shadow light needs to implement.
  9130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9131. * as well as binding the different shadow properties to the effects.
  9132. */
  9133. export interface IShadowLight extends Light {
  9134. /**
  9135. * The light id in the scene (used in scene.findLighById for instance)
  9136. */
  9137. id: string;
  9138. /**
  9139. * The position the shdow will be casted from.
  9140. */
  9141. position: Vector3;
  9142. /**
  9143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9144. */
  9145. direction: Vector3;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. /**
  9155. * The friendly name of the light in the scene.
  9156. */
  9157. name: string;
  9158. /**
  9159. * Defines the shadow projection clipping minimum z value.
  9160. */
  9161. shadowMinZ: number;
  9162. /**
  9163. * Defines the shadow projection clipping maximum z value.
  9164. */
  9165. shadowMaxZ: number;
  9166. /**
  9167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9169. */
  9170. computeTransformedInformation(): boolean;
  9171. /**
  9172. * Gets the scene the light belongs to.
  9173. * @returns The scene
  9174. */
  9175. getScene(): Scene;
  9176. /**
  9177. * Callback defining a custom Projection Matrix Builder.
  9178. * This can be used to override the default projection matrix computation.
  9179. */
  9180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9181. /**
  9182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9183. * @param matrix The materix to updated with the projection information
  9184. * @param viewMatrix The transform matrix of the light
  9185. * @param renderList The list of mesh to render in the map
  9186. * @returns The current light
  9187. */
  9188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9189. /**
  9190. * Gets the current depth scale used in ESM.
  9191. * @returns The scale
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9196. * @returns true if a cube texture needs to be use
  9197. */
  9198. needCube(): boolean;
  9199. /**
  9200. * Detects if the projection matrix requires to be recomputed this frame.
  9201. * @returns true if it requires to be recomputed otherwise, false.
  9202. */
  9203. needProjectionMatrixCompute(): boolean;
  9204. /**
  9205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9206. */
  9207. forceProjectionMatrixCompute(): void;
  9208. /**
  9209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9212. */
  9213. getShadowDirection(faceIndex?: number): Vector3;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. }
  9227. /**
  9228. * Base implementation IShadowLight
  9229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9230. */
  9231. export abstract class ShadowLight extends Light implements IShadowLight {
  9232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9233. protected _position: Vector3;
  9234. protected _setPosition(value: Vector3): void;
  9235. /**
  9236. * Sets the position the shadow will be casted from. Also use as the light position for both
  9237. * point and spot lights.
  9238. */
  9239. get position(): Vector3;
  9240. /**
  9241. * Sets the position the shadow will be casted from. Also use as the light position for both
  9242. * point and spot lights.
  9243. */
  9244. set position(value: Vector3);
  9245. protected _direction: Vector3;
  9246. protected _setDirection(value: Vector3): void;
  9247. /**
  9248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9249. * Also use as the light direction on spot and directional lights.
  9250. */
  9251. get direction(): Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9254. * Also use as the light direction on spot and directional lights.
  9255. */
  9256. set direction(value: Vector3);
  9257. protected _shadowMinZ: number;
  9258. /**
  9259. * Gets the shadow projection clipping minimum z value.
  9260. */
  9261. get shadowMinZ(): number;
  9262. /**
  9263. * Sets the shadow projection clipping minimum z value.
  9264. */
  9265. set shadowMinZ(value: number);
  9266. protected _shadowMaxZ: number;
  9267. /**
  9268. * Sets the shadow projection clipping maximum z value.
  9269. */
  9270. get shadowMaxZ(): number;
  9271. /**
  9272. * Gets the shadow projection clipping maximum z value.
  9273. */
  9274. set shadowMaxZ(value: number);
  9275. /**
  9276. * Callback defining a custom Projection Matrix Builder.
  9277. * This can be used to override the default projection matrix computation.
  9278. */
  9279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9280. /**
  9281. * The transformed position. Position of the light in world space taking parenting in account.
  9282. */
  9283. transformedPosition: Vector3;
  9284. /**
  9285. * The transformed direction. Direction of the light in world space taking parenting in account.
  9286. */
  9287. transformedDirection: Vector3;
  9288. private _needProjectionMatrixCompute;
  9289. /**
  9290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9292. */
  9293. computeTransformedInformation(): boolean;
  9294. /**
  9295. * Return the depth scale used for the shadow map.
  9296. * @returns the depth scale.
  9297. */
  9298. getDepthScale(): number;
  9299. /**
  9300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9303. */
  9304. getShadowDirection(faceIndex?: number): Vector3;
  9305. /**
  9306. * Returns the ShadowLight absolute position in the World.
  9307. * @returns the position vector in world space
  9308. */
  9309. getAbsolutePosition(): Vector3;
  9310. /**
  9311. * Sets the ShadowLight direction toward the passed target.
  9312. * @param target The point to target in local space
  9313. * @returns the updated ShadowLight direction
  9314. */
  9315. setDirectionToTarget(target: Vector3): Vector3;
  9316. /**
  9317. * Returns the light rotation in euler definition.
  9318. * @returns the x y z rotation in local space.
  9319. */
  9320. getRotation(): Vector3;
  9321. /**
  9322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9323. * @returns true if a cube texture needs to be use
  9324. */
  9325. needCube(): boolean;
  9326. /**
  9327. * Detects if the projection matrix requires to be recomputed this frame.
  9328. * @returns true if it requires to be recomputed otherwise, false.
  9329. */
  9330. needProjectionMatrixCompute(): boolean;
  9331. /**
  9332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9333. */
  9334. forceProjectionMatrixCompute(): void;
  9335. /** @hidden */
  9336. _initCache(): void;
  9337. /** @hidden */
  9338. _isSynchronized(): boolean;
  9339. /**
  9340. * Computes the world matrix of the node
  9341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9342. * @returns the world matrix
  9343. */
  9344. computeWorldMatrix(force?: boolean): Matrix;
  9345. /**
  9346. * Gets the minZ used for shadow according to both the scene and the light.
  9347. * @param activeCamera The camera we are returning the min for
  9348. * @returns the depth min z
  9349. */
  9350. getDepthMinZ(activeCamera: Camera): number;
  9351. /**
  9352. * Gets the maxZ used for shadow according to both the scene and the light.
  9353. * @param activeCamera The camera we are returning the max for
  9354. * @returns the depth max z
  9355. */
  9356. getDepthMaxZ(activeCamera: Camera): number;
  9357. /**
  9358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9359. * @param matrix The materix to updated with the projection information
  9360. * @param viewMatrix The transform matrix of the light
  9361. * @param renderList The list of mesh to render in the map
  9362. * @returns The current light
  9363. */
  9364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9368. /** @hidden */
  9369. export var packingFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9375. /** @hidden */
  9376. export var bayerDitherFunctions: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9383. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9384. /** @hidden */
  9385. export var shadowMapFragmentDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9391. /** @hidden */
  9392. export var clipPlaneFragmentDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9398. /** @hidden */
  9399. export var clipPlaneFragment: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9405. /** @hidden */
  9406. export var shadowMapFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9412. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9415. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9416. /** @hidden */
  9417. export var shadowMapPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9423. /** @hidden */
  9424. export var bonesDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9430. /** @hidden */
  9431. export var morphTargetsVertexGlobalDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9437. /** @hidden */
  9438. export var morphTargetsVertexDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9444. /** @hidden */
  9445. export var instancesDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9451. /** @hidden */
  9452. export var helperFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9458. /** @hidden */
  9459. export var shadowMapVertexDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9465. /** @hidden */
  9466. export var clipPlaneVertexDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9493. /** @hidden */
  9494. export var shadowMapVertexNormalBias: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9500. /** @hidden */
  9501. export var shadowMapVertexMetric: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9507. /** @hidden */
  9508. export var clipPlaneVertex: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9514. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9519. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9527. /** @hidden */
  9528. export var shadowMapVertexShader: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9534. /** @hidden */
  9535. export var depthBoxBlurPixelShader: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9541. /** @hidden */
  9542. export var shadowMapFragmentSoftTransparentShadow: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Materials/effectFallbacks" {
  9548. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9549. import { Effect } from "babylonjs/Materials/effect";
  9550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9551. /**
  9552. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9553. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9554. */
  9555. export class EffectFallbacks implements IEffectFallbacks {
  9556. private _defines;
  9557. private _currentRank;
  9558. private _maxRank;
  9559. private _mesh;
  9560. /**
  9561. * Removes the fallback from the bound mesh.
  9562. */
  9563. unBindMesh(): void;
  9564. /**
  9565. * Adds a fallback on the specified property.
  9566. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9567. * @param define The name of the define in the shader
  9568. */
  9569. addFallback(rank: number, define: string): void;
  9570. /**
  9571. * Sets the mesh to use CPU skinning when needing to fallback.
  9572. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9573. * @param mesh The mesh to use the fallbacks.
  9574. */
  9575. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9576. /**
  9577. * Checks to see if more fallbacks are still availible.
  9578. */
  9579. get hasMoreFallbacks(): boolean;
  9580. /**
  9581. * Removes the defines that should be removed when falling back.
  9582. * @param currentDefines defines the current define statements for the shader.
  9583. * @param effect defines the current effect we try to compile
  9584. * @returns The resulting defines with defines of the current rank removed.
  9585. */
  9586. reduce(currentDefines: string, effect: Effect): string;
  9587. }
  9588. }
  9589. declare module "babylonjs/Actions/action" {
  9590. import { Observable } from "babylonjs/Misc/observable";
  9591. import { Condition } from "babylonjs/Actions/condition";
  9592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9593. import { Nullable } from "babylonjs/types";
  9594. import { Scene } from "babylonjs/scene";
  9595. import { ActionManager } from "babylonjs/Actions/actionManager";
  9596. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9597. import { Node } from "babylonjs/node";
  9598. /**
  9599. * Interface used to define Action
  9600. */
  9601. export interface IAction {
  9602. /**
  9603. * Trigger for the action
  9604. */
  9605. trigger: number;
  9606. /** Options of the trigger */
  9607. triggerOptions: any;
  9608. /**
  9609. * Gets the trigger parameters
  9610. * @returns the trigger parameters
  9611. */
  9612. getTriggerParameter(): any;
  9613. /**
  9614. * Internal only - executes current action event
  9615. * @hidden
  9616. */
  9617. _executeCurrent(evt?: ActionEvent): void;
  9618. /**
  9619. * Serialize placeholder for child classes
  9620. * @param parent of child
  9621. * @returns the serialized object
  9622. */
  9623. serialize(parent: any): any;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. _prepare(): void;
  9629. /**
  9630. * Internal only - manager for action
  9631. * @hidden
  9632. */
  9633. _actionManager: Nullable<AbstractActionManager>;
  9634. /**
  9635. * Adds action to chain of actions, may be a DoNothingAction
  9636. * @param action defines the next action to execute
  9637. * @returns The action passed in
  9638. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9639. */
  9640. then(action: IAction): IAction;
  9641. }
  9642. /**
  9643. * The action to be carried out following a trigger
  9644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9645. */
  9646. export class Action implements IAction {
  9647. /** the trigger, with or without parameters, for the action */
  9648. triggerOptions: any;
  9649. /**
  9650. * Trigger for the action
  9651. */
  9652. trigger: number;
  9653. /**
  9654. * Internal only - manager for action
  9655. * @hidden
  9656. */
  9657. _actionManager: ActionManager;
  9658. private _nextActiveAction;
  9659. private _child;
  9660. private _condition?;
  9661. private _triggerParameter;
  9662. /**
  9663. * An event triggered prior to action being executed.
  9664. */
  9665. onBeforeExecuteObservable: Observable<Action>;
  9666. /**
  9667. * Creates a new Action
  9668. * @param triggerOptions the trigger, with or without parameters, for the action
  9669. * @param condition an optional determinant of action
  9670. */
  9671. constructor(
  9672. /** the trigger, with or without parameters, for the action */
  9673. triggerOptions: any, condition?: Condition);
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _prepare(): void;
  9679. /**
  9680. * Gets the trigger parameters
  9681. * @returns the trigger parameters
  9682. */
  9683. getTriggerParameter(): any;
  9684. /**
  9685. * Internal only - executes current action event
  9686. * @hidden
  9687. */
  9688. _executeCurrent(evt?: ActionEvent): void;
  9689. /**
  9690. * Execute placeholder for child classes
  9691. * @param evt optional action event
  9692. */
  9693. execute(evt?: ActionEvent): void;
  9694. /**
  9695. * Skips to next active action
  9696. */
  9697. skipToNextActiveAction(): void;
  9698. /**
  9699. * Adds action to chain of actions, may be a DoNothingAction
  9700. * @param action defines the next action to execute
  9701. * @returns The action passed in
  9702. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9703. */
  9704. then(action: Action): Action;
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _getProperty(propertyPath: string): string;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. _getEffectiveTarget(target: any, propertyPath: string): any;
  9715. /**
  9716. * Serialize placeholder for child classes
  9717. * @param parent of child
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. /**
  9722. * Internal only called by serialize
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedAction: any, parent?: any): any;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. static _SerializeValueAsString: (value: any) => string;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. static _GetTargetProperty: (target: Scene | Node) => {
  9736. name: string;
  9737. targetType: string;
  9738. value: string;
  9739. };
  9740. }
  9741. }
  9742. declare module "babylonjs/Actions/condition" {
  9743. import { ActionManager } from "babylonjs/Actions/actionManager";
  9744. /**
  9745. * A Condition applied to an Action
  9746. */
  9747. export class Condition {
  9748. /**
  9749. * Internal only - manager for action
  9750. * @hidden
  9751. */
  9752. _actionManager: ActionManager;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. _evaluationId: number;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. _currentResult: boolean;
  9763. /**
  9764. * Creates a new Condition
  9765. * @param actionManager the manager of the action the condition is applied to
  9766. */
  9767. constructor(actionManager: ActionManager);
  9768. /**
  9769. * Check if the current condition is valid
  9770. * @returns a boolean
  9771. */
  9772. isValid(): boolean;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. _getProperty(propertyPath: string): string;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. _getEffectiveTarget(target: any, propertyPath: string): any;
  9783. /**
  9784. * Serialize placeholder for child classes
  9785. * @returns the serialized object
  9786. */
  9787. serialize(): any;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. protected _serialize(serializedCondition: any): any;
  9793. }
  9794. /**
  9795. * Defines specific conditional operators as extensions of Condition
  9796. */
  9797. export class ValueCondition extends Condition {
  9798. /** path to specify the property of the target the conditional operator uses */
  9799. propertyPath: string;
  9800. /** the value compared by the conditional operator against the current value of the property */
  9801. value: any;
  9802. /** the conditional operator, default ValueCondition.IsEqual */
  9803. operator: number;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private static _IsEqual;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private static _IsDifferent;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsGreater;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsLesser;
  9824. /**
  9825. * returns the number for IsEqual
  9826. */
  9827. static get IsEqual(): number;
  9828. /**
  9829. * Returns the number for IsDifferent
  9830. */
  9831. static get IsDifferent(): number;
  9832. /**
  9833. * Returns the number for IsGreater
  9834. */
  9835. static get IsGreater(): number;
  9836. /**
  9837. * Returns the number for IsLesser
  9838. */
  9839. static get IsLesser(): number;
  9840. /**
  9841. * Internal only The action manager for the condition
  9842. * @hidden
  9843. */
  9844. _actionManager: ActionManager;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private _target;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private _effectiveTarget;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _property;
  9860. /**
  9861. * Creates a new ValueCondition
  9862. * @param actionManager manager for the action the condition applies to
  9863. * @param target for the action
  9864. * @param propertyPath path to specify the property of the target the conditional operator uses
  9865. * @param value the value compared by the conditional operator against the current value of the property
  9866. * @param operator the conditional operator, default ValueCondition.IsEqual
  9867. */
  9868. constructor(actionManager: ActionManager, target: any,
  9869. /** path to specify the property of the target the conditional operator uses */
  9870. propertyPath: string,
  9871. /** the value compared by the conditional operator against the current value of the property */
  9872. value: any,
  9873. /** the conditional operator, default ValueCondition.IsEqual */
  9874. operator?: number);
  9875. /**
  9876. * Compares the given value with the property value for the specified conditional operator
  9877. * @returns the result of the comparison
  9878. */
  9879. isValid(): boolean;
  9880. /**
  9881. * Serialize the ValueCondition into a JSON compatible object
  9882. * @returns serialization object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Gets the name of the conditional operator for the ValueCondition
  9887. * @param operator the conditional operator
  9888. * @returns the name
  9889. */
  9890. static GetOperatorName(operator: number): string;
  9891. }
  9892. /**
  9893. * Defines a predicate condition as an extension of Condition
  9894. */
  9895. export class PredicateCondition extends Condition {
  9896. /** defines the predicate function used to validate the condition */
  9897. predicate: () => boolean;
  9898. /**
  9899. * Internal only - manager for action
  9900. * @hidden
  9901. */
  9902. _actionManager: ActionManager;
  9903. /**
  9904. * Creates a new PredicateCondition
  9905. * @param actionManager manager for the action the condition applies to
  9906. * @param predicate defines the predicate function used to validate the condition
  9907. */
  9908. constructor(actionManager: ActionManager,
  9909. /** defines the predicate function used to validate the condition */
  9910. predicate: () => boolean);
  9911. /**
  9912. * @returns the validity of the predicate condition
  9913. */
  9914. isValid(): boolean;
  9915. }
  9916. /**
  9917. * Defines a state condition as an extension of Condition
  9918. */
  9919. export class StateCondition extends Condition {
  9920. /** Value to compare with target state */
  9921. value: string;
  9922. /**
  9923. * Internal only - manager for action
  9924. * @hidden
  9925. */
  9926. _actionManager: ActionManager;
  9927. /**
  9928. * Internal only
  9929. * @hidden
  9930. */
  9931. private _target;
  9932. /**
  9933. * Creates a new StateCondition
  9934. * @param actionManager manager for the action the condition applies to
  9935. * @param target of the condition
  9936. * @param value to compare with target state
  9937. */
  9938. constructor(actionManager: ActionManager, target: any,
  9939. /** Value to compare with target state */
  9940. value: string);
  9941. /**
  9942. * Gets a boolean indicating if the current condition is met
  9943. * @returns the validity of the state
  9944. */
  9945. isValid(): boolean;
  9946. /**
  9947. * Serialize the StateCondition into a JSON compatible object
  9948. * @returns serialization object
  9949. */
  9950. serialize(): any;
  9951. }
  9952. }
  9953. declare module "babylonjs/Actions/directActions" {
  9954. import { Action } from "babylonjs/Actions/action";
  9955. import { Condition } from "babylonjs/Actions/condition";
  9956. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9957. /**
  9958. * This defines an action responsible to toggle a boolean once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class SwitchBooleanAction extends Action {
  9962. /**
  9963. * The path to the boolean property in the target object
  9964. */
  9965. propertyPath: string;
  9966. private _target;
  9967. private _effectiveTarget;
  9968. private _property;
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param target defines the object containing the boolean
  9973. * @param propertyPath defines the path to the boolean property in the target object
  9974. * @param condition defines the trigger related conditions
  9975. */
  9976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9977. /** @hidden */
  9978. _prepare(): void;
  9979. /**
  9980. * Execute the action toggle the boolean value.
  9981. */
  9982. execute(): void;
  9983. /**
  9984. * Serializes the actions and its related information.
  9985. * @param parent defines the object to serialize in
  9986. * @returns the serialized object
  9987. */
  9988. serialize(parent: any): any;
  9989. }
  9990. /**
  9991. * This defines an action responsible to set a the state field of the target
  9992. * to a desired value once triggered.
  9993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9994. */
  9995. export class SetStateAction extends Action {
  9996. /**
  9997. * The value to store in the state field.
  9998. */
  9999. value: string;
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the state property
  10005. * @param value defines the value to store in the state field
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10009. /**
  10010. * Execute the action and store the value on the target state property.
  10011. */
  10012. execute(): void;
  10013. /**
  10014. * Serializes the actions and its related information.
  10015. * @param parent defines the object to serialize in
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. }
  10020. /**
  10021. * This defines an action responsible to set a property of the target
  10022. * to a desired value once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class SetValueAction extends Action {
  10026. /**
  10027. * The path of the property to set in the target.
  10028. */
  10029. propertyPath: string;
  10030. /**
  10031. * The value to set in the property
  10032. */
  10033. value: any;
  10034. private _target;
  10035. private _effectiveTarget;
  10036. private _property;
  10037. /**
  10038. * Instantiate the action
  10039. * @param triggerOptions defines the trigger options
  10040. * @param target defines the object containing the property
  10041. * @param propertyPath defines the path of the property to set in the target
  10042. * @param value defines the value to set in the property
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and set the targetted property to the desired value.
  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 to increment the target value
  10061. * to a desired value once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class IncrementValueAction extends Action {
  10065. /**
  10066. * The path of the property to increment in the target.
  10067. */
  10068. propertyPath: string;
  10069. /**
  10070. * The value we should increment the property by.
  10071. */
  10072. value: any;
  10073. private _target;
  10074. private _effectiveTarget;
  10075. private _property;
  10076. /**
  10077. * Instantiate the action
  10078. * @param triggerOptions defines the trigger options
  10079. * @param target defines the object containing the property
  10080. * @param propertyPath defines the path of the property to increment in the target
  10081. * @param value defines the value value we should increment the property by
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and increment the target of the value amount.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible to start an animation once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class PlayAnimationAction extends Action {
  10103. /**
  10104. * Where the animation should start (animation frame)
  10105. */
  10106. from: number;
  10107. /**
  10108. * Where the animation should stop (animation frame)
  10109. */
  10110. to: number;
  10111. /**
  10112. * Define if the animation should loop or stop after the first play.
  10113. */
  10114. loop?: boolean;
  10115. private _target;
  10116. /**
  10117. * Instantiate the action
  10118. * @param triggerOptions defines the trigger options
  10119. * @param target defines the target animation or animation name
  10120. * @param from defines from where the animation should start (animation frame)
  10121. * @param end defines where the animation should stop (animation frame)
  10122. * @param loop defines if the animation should loop or stop after the first play
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and play the animation.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. /**
  10140. * This defines an action responsible to stop an animation once triggered.
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10142. */
  10143. export class StopAnimationAction extends Action {
  10144. private _target;
  10145. /**
  10146. * Instantiate the action
  10147. * @param triggerOptions defines the trigger options
  10148. * @param target defines the target animation or animation name
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and stop the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible that does nothing once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class DoNothingAction extends Action {
  10170. /**
  10171. * Instantiate the action
  10172. * @param triggerOptions defines the trigger options
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions?: any, condition?: Condition);
  10176. /**
  10177. * Execute the action and do nothing.
  10178. */
  10179. execute(): void;
  10180. /**
  10181. * Serializes the actions and its related information.
  10182. * @param parent defines the object to serialize in
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. }
  10187. /**
  10188. * This defines an action responsible to trigger several actions once triggered.
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10190. */
  10191. export class CombineAction extends Action {
  10192. /**
  10193. * The list of aggregated animations to run.
  10194. */
  10195. children: Action[];
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param children defines the list of aggregated animations to run
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action and executes all the aggregated actions.
  10207. */
  10208. execute(evt: ActionEvent): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to run code (external event) once triggered.
  10218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10219. */
  10220. export class ExecuteCodeAction extends Action {
  10221. /**
  10222. * The callback function to run.
  10223. */
  10224. func: (evt: ActionEvent) => void;
  10225. /**
  10226. * Instantiate the action
  10227. * @param triggerOptions defines the trigger options
  10228. * @param func defines the callback function to run
  10229. * @param condition defines the trigger related conditions
  10230. */
  10231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10232. /**
  10233. * Execute the action and run the attached code.
  10234. */
  10235. execute(evt: ActionEvent): void;
  10236. }
  10237. /**
  10238. * This defines an action responsible to set the parent property of the target once triggered.
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10240. */
  10241. export class SetParentAction extends Action {
  10242. private _parent;
  10243. private _target;
  10244. /**
  10245. * Instantiate the action
  10246. * @param triggerOptions defines the trigger options
  10247. * @param target defines the target containing the parent property
  10248. * @param parent defines from where the animation should start (animation frame)
  10249. * @param condition defines the trigger related conditions
  10250. */
  10251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10252. /** @hidden */
  10253. _prepare(): void;
  10254. /**
  10255. * Execute the action and set the parent property.
  10256. */
  10257. execute(): void;
  10258. /**
  10259. * Serializes the actions and its related information.
  10260. * @param parent defines the object to serialize in
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. }
  10265. }
  10266. declare module "babylonjs/Actions/actionManager" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10269. import { Scene } from "babylonjs/scene";
  10270. import { IAction } from "babylonjs/Actions/action";
  10271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10272. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10273. /**
  10274. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10275. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10277. */
  10278. export class ActionManager extends AbstractActionManager {
  10279. /**
  10280. * Nothing
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly NothingTrigger: number;
  10284. /**
  10285. * On pick
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickTrigger: number;
  10289. /**
  10290. * On left pick
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLeftPickTrigger: number;
  10294. /**
  10295. * On right pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnRightPickTrigger: number;
  10299. /**
  10300. * On center pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnCenterPickTrigger: number;
  10304. /**
  10305. * On pick down
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnPickDownTrigger: number;
  10309. /**
  10310. * On double pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnDoublePickTrigger: number;
  10314. /**
  10315. * On pick up
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickUpTrigger: number;
  10319. /**
  10320. * On pick out.
  10321. * This trigger will only be raised if you also declared a OnPickDown
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickOutTrigger: number;
  10325. /**
  10326. * On long press
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnLongPressTrigger: number;
  10330. /**
  10331. * On pointer over
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPointerOverTrigger: number;
  10335. /**
  10336. * On pointer out
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPointerOutTrigger: number;
  10340. /**
  10341. * On every frame
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnEveryFrameTrigger: number;
  10345. /**
  10346. * On intersection enter
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnIntersectionEnterTrigger: number;
  10350. /**
  10351. * On intersection exit
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnIntersectionExitTrigger: number;
  10355. /**
  10356. * On key down
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnKeyDownTrigger: number;
  10360. /**
  10361. * On key up
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnKeyUpTrigger: number;
  10365. private _scene;
  10366. /**
  10367. * Creates a new action manager
  10368. * @param scene defines the hosting scene
  10369. */
  10370. constructor(scene: Scene);
  10371. /**
  10372. * Releases all associated resources
  10373. */
  10374. dispose(): void;
  10375. /**
  10376. * Gets hosting scene
  10377. * @returns the hosting scene
  10378. */
  10379. getScene(): Scene;
  10380. /**
  10381. * Does this action manager handles actions of any of the given triggers
  10382. * @param triggers defines the triggers to be tested
  10383. * @return a boolean indicating whether one (or more) of the triggers is handled
  10384. */
  10385. hasSpecificTriggers(triggers: number[]): boolean;
  10386. /**
  10387. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10388. * speed.
  10389. * @param triggerA defines the trigger to be tested
  10390. * @param triggerB defines the trigger to be tested
  10391. * @return a boolean indicating whether one (or more) of the triggers is handled
  10392. */
  10393. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10394. /**
  10395. * Does this action manager handles actions of a given trigger
  10396. * @param trigger defines the trigger to be tested
  10397. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10398. * @return whether the trigger is handled
  10399. */
  10400. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10401. /**
  10402. * Does this action manager has pointer triggers
  10403. */
  10404. get hasPointerTriggers(): boolean;
  10405. /**
  10406. * Does this action manager has pick triggers
  10407. */
  10408. get hasPickTriggers(): boolean;
  10409. /**
  10410. * Registers an action to this action manager
  10411. * @param action defines the action to be registered
  10412. * @return the action amended (prepared) after registration
  10413. */
  10414. registerAction(action: IAction): Nullable<IAction>;
  10415. /**
  10416. * Unregisters an action to this action manager
  10417. * @param action defines the action to be unregistered
  10418. * @return a boolean indicating whether the action has been unregistered
  10419. */
  10420. unregisterAction(action: IAction): Boolean;
  10421. /**
  10422. * Process a specific trigger
  10423. * @param trigger defines the trigger to process
  10424. * @param evt defines the event details to be processed
  10425. */
  10426. processTrigger(trigger: number, evt?: IActionEvent): void;
  10427. /** @hidden */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /** @hidden */
  10430. _getProperty(propertyPath: string): string;
  10431. /**
  10432. * Serialize this manager to a JSON object
  10433. * @param name defines the property name to store this manager
  10434. * @returns a JSON representation of this manager
  10435. */
  10436. serialize(name: string): any;
  10437. /**
  10438. * Creates a new ActionManager from a JSON data
  10439. * @param parsedActions defines the JSON data to read from
  10440. * @param object defines the hosting mesh
  10441. * @param scene defines the hosting scene
  10442. */
  10443. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10444. /**
  10445. * Get a trigger name by index
  10446. * @param trigger defines the trigger index
  10447. * @returns a trigger name
  10448. */
  10449. static GetTriggerName(trigger: number): string;
  10450. }
  10451. }
  10452. declare module "babylonjs/Sprites/sprite" {
  10453. import { Vector3 } from "babylonjs/Maths/math.vector";
  10454. import { Nullable } from "babylonjs/types";
  10455. import { ActionManager } from "babylonjs/Actions/actionManager";
  10456. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10457. import { Color4 } from "babylonjs/Maths/math.color";
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10460. import { Animation } from "babylonjs/Animations/animation";
  10461. /**
  10462. * Class used to represent a sprite
  10463. * @see https://doc.babylonjs.com/babylon101/sprites
  10464. */
  10465. export class Sprite implements IAnimatable {
  10466. /** defines the name */
  10467. name: string;
  10468. /** Gets or sets the current world position */
  10469. position: Vector3;
  10470. /** Gets or sets the main color */
  10471. color: Color4;
  10472. /** Gets or sets the width */
  10473. width: number;
  10474. /** Gets or sets the height */
  10475. height: number;
  10476. /** Gets or sets rotation angle */
  10477. angle: number;
  10478. /** Gets or sets the cell index in the sprite sheet */
  10479. cellIndex: number;
  10480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10481. cellRef: string;
  10482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10483. invertU: boolean;
  10484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10485. invertV: boolean;
  10486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10487. disposeWhenFinishedAnimating: boolean;
  10488. /** Gets the list of attached animations */
  10489. animations: Nullable<Array<Animation>>;
  10490. /** Gets or sets a boolean indicating if the sprite can be picked */
  10491. isPickable: boolean;
  10492. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10493. useAlphaForPicking: boolean;
  10494. /** @hidden */
  10495. _xOffset: number;
  10496. /** @hidden */
  10497. _yOffset: number;
  10498. /** @hidden */
  10499. _xSize: number;
  10500. /** @hidden */
  10501. _ySize: number;
  10502. /**
  10503. * Gets or sets the associated action manager
  10504. */
  10505. actionManager: Nullable<ActionManager>;
  10506. /**
  10507. * An event triggered when the control has been disposed
  10508. */
  10509. onDisposeObservable: Observable<Sprite>;
  10510. private _animationStarted;
  10511. private _loopAnimation;
  10512. private _fromIndex;
  10513. private _toIndex;
  10514. private _delay;
  10515. private _direction;
  10516. private _manager;
  10517. private _time;
  10518. private _onAnimationEnd;
  10519. /**
  10520. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10521. */
  10522. isVisible: boolean;
  10523. /**
  10524. * Gets or sets the sprite size
  10525. */
  10526. get size(): number;
  10527. set size(value: number);
  10528. /**
  10529. * Returns a boolean indicating if the animation is started
  10530. */
  10531. get animationStarted(): boolean;
  10532. /**
  10533. * Gets or sets the unique id of the sprite
  10534. */
  10535. uniqueId: number;
  10536. /**
  10537. * Gets the manager of this sprite
  10538. */
  10539. get manager(): ISpriteManager;
  10540. /**
  10541. * Creates a new Sprite
  10542. * @param name defines the name
  10543. * @param manager defines the manager
  10544. */
  10545. constructor(
  10546. /** defines the name */
  10547. name: string, manager: ISpriteManager);
  10548. /**
  10549. * Returns the string "Sprite"
  10550. * @returns "Sprite"
  10551. */
  10552. getClassName(): string;
  10553. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10554. get fromIndex(): number;
  10555. set fromIndex(value: number);
  10556. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10557. get toIndex(): number;
  10558. set toIndex(value: number);
  10559. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10560. get loopAnimation(): boolean;
  10561. set loopAnimation(value: boolean);
  10562. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10563. get delay(): number;
  10564. set delay(value: number);
  10565. /**
  10566. * Starts an animation
  10567. * @param from defines the initial key
  10568. * @param to defines the end key
  10569. * @param loop defines if the animation must loop
  10570. * @param delay defines the start delay (in ms)
  10571. * @param onAnimationEnd defines a callback to call when animation ends
  10572. */
  10573. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10574. /** Stops current animation (if any) */
  10575. stopAnimation(): void;
  10576. /** @hidden */
  10577. _animate(deltaTime: number): void;
  10578. /** Release associated resources */
  10579. dispose(): void;
  10580. /**
  10581. * Serializes the sprite to a JSON object
  10582. * @returns the JSON object
  10583. */
  10584. serialize(): any;
  10585. /**
  10586. * Parses a JSON object to create a new sprite
  10587. * @param parsedSprite The JSON object to parse
  10588. * @param manager defines the hosting manager
  10589. * @returns the new sprite
  10590. */
  10591. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10592. }
  10593. }
  10594. declare module "babylonjs/Collisions/pickingInfo" {
  10595. import { Nullable } from "babylonjs/types";
  10596. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10598. import { Sprite } from "babylonjs/Sprites/sprite";
  10599. import { Ray } from "babylonjs/Culling/ray";
  10600. /**
  10601. * Information about the result of picking within a scene
  10602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10603. */
  10604. export class PickingInfo {
  10605. /** @hidden */
  10606. _pickingUnavailable: boolean;
  10607. /**
  10608. * If the pick collided with an object
  10609. */
  10610. hit: boolean;
  10611. /**
  10612. * Distance away where the pick collided
  10613. */
  10614. distance: number;
  10615. /**
  10616. * The location of pick collision
  10617. */
  10618. pickedPoint: Nullable<Vector3>;
  10619. /**
  10620. * The mesh corresponding the the pick collision
  10621. */
  10622. pickedMesh: Nullable<AbstractMesh>;
  10623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10624. bu: number;
  10625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10626. bv: number;
  10627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10628. faceId: number;
  10629. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10630. subMeshFaceId: number;
  10631. /** Id of the the submesh that was picked */
  10632. subMeshId: number;
  10633. /** If a sprite was picked, this will be the sprite the pick collided with */
  10634. pickedSprite: Nullable<Sprite>;
  10635. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10636. thinInstanceIndex: number;
  10637. /**
  10638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10639. */
  10640. originMesh: Nullable<AbstractMesh>;
  10641. /**
  10642. * The ray that was used to perform the picking.
  10643. */
  10644. ray: Nullable<Ray>;
  10645. /**
  10646. * Gets the normal correspodning to the face the pick collided with
  10647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10649. * @returns The normal correspodning to the face the pick collided with
  10650. */
  10651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10652. /**
  10653. * Gets the texture coordinates of where the pick occured
  10654. * @returns the vector containing the coordnates of the texture
  10655. */
  10656. getTextureCoordinates(): Nullable<Vector2>;
  10657. }
  10658. }
  10659. declare module "babylonjs/Culling/ray" {
  10660. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10664. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10665. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10667. import { Plane } from "babylonjs/Maths/math.plane";
  10668. /**
  10669. * Class representing a ray with position and direction
  10670. */
  10671. export class Ray {
  10672. /** origin point */
  10673. origin: Vector3;
  10674. /** direction */
  10675. direction: Vector3;
  10676. /** length of the ray */
  10677. length: number;
  10678. private static readonly _TmpVector3;
  10679. private _tmpRay;
  10680. /**
  10681. * Creates a new ray
  10682. * @param origin origin point
  10683. * @param direction direction
  10684. * @param length length of the ray
  10685. */
  10686. constructor(
  10687. /** origin point */
  10688. origin: Vector3,
  10689. /** direction */
  10690. direction: Vector3,
  10691. /** length of the ray */
  10692. length?: number);
  10693. /**
  10694. * Checks if the ray intersects a box
  10695. * This does not account for the ray lenght by design to improve perfs.
  10696. * @param minimum bound of the box
  10697. * @param maximum bound of the box
  10698. * @param intersectionTreshold extra extend to be added to the box in all direction
  10699. * @returns if the box was hit
  10700. */
  10701. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10702. /**
  10703. * Checks if the ray intersects a box
  10704. * This does not account for the ray lenght by design to improve perfs.
  10705. * @param box the bounding box to check
  10706. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10707. * @returns if the box was hit
  10708. */
  10709. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10710. /**
  10711. * If the ray hits a sphere
  10712. * @param sphere the bounding sphere to check
  10713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10714. * @returns true if it hits the sphere
  10715. */
  10716. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10717. /**
  10718. * If the ray hits a triange
  10719. * @param vertex0 triangle vertex
  10720. * @param vertex1 triangle vertex
  10721. * @param vertex2 triangle vertex
  10722. * @returns intersection information if hit
  10723. */
  10724. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10725. /**
  10726. * Checks if ray intersects a plane
  10727. * @param plane the plane to check
  10728. * @returns the distance away it was hit
  10729. */
  10730. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10731. /**
  10732. * Calculate the intercept of a ray on a given axis
  10733. * @param axis to check 'x' | 'y' | 'z'
  10734. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10735. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10736. */
  10737. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10738. /**
  10739. * Checks if ray intersects a mesh
  10740. * @param mesh the mesh to check
  10741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10742. * @returns picking info of the intersecton
  10743. */
  10744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10745. /**
  10746. * Checks if ray intersects a mesh
  10747. * @param meshes the meshes to check
  10748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10749. * @param results array to store result in
  10750. * @returns Array of picking infos
  10751. */
  10752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10753. private _comparePickingInfo;
  10754. private static smallnum;
  10755. private static rayl;
  10756. /**
  10757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10758. * @param sega the first point of the segment to test the intersection against
  10759. * @param segb the second point of the segment to test the intersection against
  10760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10762. */
  10763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10764. /**
  10765. * Update the ray from viewport position
  10766. * @param x position
  10767. * @param y y position
  10768. * @param viewportWidth viewport width
  10769. * @param viewportHeight viewport height
  10770. * @param world world matrix
  10771. * @param view view matrix
  10772. * @param projection projection matrix
  10773. * @returns this ray updated
  10774. */
  10775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10776. /**
  10777. * Creates a ray with origin and direction of 0,0,0
  10778. * @returns the new ray
  10779. */
  10780. static Zero(): Ray;
  10781. /**
  10782. * Creates a new ray from screen space and viewport
  10783. * @param x position
  10784. * @param y y position
  10785. * @param viewportWidth viewport width
  10786. * @param viewportHeight viewport height
  10787. * @param world world matrix
  10788. * @param view view matrix
  10789. * @param projection projection matrix
  10790. * @returns new ray
  10791. */
  10792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10793. /**
  10794. * 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
  10795. * transformed to the given world matrix.
  10796. * @param origin The origin point
  10797. * @param end The end point
  10798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10799. * @returns the new ray
  10800. */
  10801. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Transforms a ray by a matrix
  10804. * @param ray ray to transform
  10805. * @param matrix matrix to apply
  10806. * @returns the resulting new ray
  10807. */
  10808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Transforms a ray by a matrix
  10811. * @param ray ray to transform
  10812. * @param matrix matrix to apply
  10813. * @param result ray to store result in
  10814. */
  10815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10816. /**
  10817. * Unproject a ray from screen space to object space
  10818. * @param sourceX defines the screen space x coordinate to use
  10819. * @param sourceY defines the screen space y coordinate to use
  10820. * @param viewportWidth defines the current width of the viewport
  10821. * @param viewportHeight defines the current height of the viewport
  10822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10823. * @param view defines the view matrix to use
  10824. * @param projection defines the projection matrix to use
  10825. */
  10826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10827. }
  10828. /**
  10829. * Type used to define predicate used to select faces when a mesh intersection is detected
  10830. */
  10831. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10832. module "babylonjs/scene" {
  10833. interface Scene {
  10834. /** @hidden */
  10835. _tempPickingRay: Nullable<Ray>;
  10836. /** @hidden */
  10837. _cachedRayForTransform: Ray;
  10838. /** @hidden */
  10839. _pickWithRayInverseMatrix: Matrix;
  10840. /** @hidden */
  10841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10842. /** @hidden */
  10843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10844. /** @hidden */
  10845. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/sceneComponent" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10853. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10855. import { Nullable } from "babylonjs/types";
  10856. import { Camera } from "babylonjs/Cameras/camera";
  10857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10858. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10859. import { AbstractScene } from "babylonjs/abstractScene";
  10860. import { Mesh } from "babylonjs/Meshes/mesh";
  10861. /**
  10862. * Groups all the scene component constants in one place to ease maintenance.
  10863. * @hidden
  10864. */
  10865. export class SceneComponentConstants {
  10866. static readonly NAME_EFFECTLAYER: string;
  10867. static readonly NAME_LAYER: string;
  10868. static readonly NAME_LENSFLARESYSTEM: string;
  10869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10870. static readonly NAME_PARTICLESYSTEM: string;
  10871. static readonly NAME_GAMEPAD: string;
  10872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10874. static readonly NAME_PREPASSRENDERER: string;
  10875. static readonly NAME_DEPTHRENDERER: string;
  10876. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10877. static readonly NAME_SPRITE: string;
  10878. static readonly NAME_SUBSURFACE: string;
  10879. static readonly NAME_OUTLINERENDERER: string;
  10880. static readonly NAME_PROCEDURALTEXTURE: string;
  10881. static readonly NAME_SHADOWGENERATOR: string;
  10882. static readonly NAME_OCTREE: string;
  10883. static readonly NAME_PHYSICSENGINE: string;
  10884. static readonly NAME_AUDIO: string;
  10885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10893. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10894. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10895. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10900. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10901. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10902. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10905. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10906. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10907. static readonly STEP_AFTERRENDER_AUDIO: number;
  10908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10912. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10913. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10914. static readonly STEP_POINTERMOVE_SPRITE: number;
  10915. static readonly STEP_POINTERDOWN_SPRITE: number;
  10916. static readonly STEP_POINTERUP_SPRITE: number;
  10917. }
  10918. /**
  10919. * This represents a scene component.
  10920. *
  10921. * This is used to decouple the dependency the scene is having on the different workloads like
  10922. * layers, post processes...
  10923. */
  10924. export interface ISceneComponent {
  10925. /**
  10926. * The name of the component. Each component must have a unique name.
  10927. */
  10928. name: string;
  10929. /**
  10930. * The scene the component belongs to.
  10931. */
  10932. scene: Scene;
  10933. /**
  10934. * Register the component to one instance of a scene.
  10935. */
  10936. register(): void;
  10937. /**
  10938. * Rebuilds the elements related to this component in case of
  10939. * context lost for instance.
  10940. */
  10941. rebuild(): void;
  10942. /**
  10943. * Disposes the component and the associated ressources.
  10944. */
  10945. dispose(): void;
  10946. }
  10947. /**
  10948. * This represents a SERIALIZABLE scene component.
  10949. *
  10950. * This extends Scene Component to add Serialization methods on top.
  10951. */
  10952. export interface ISceneSerializableComponent extends ISceneComponent {
  10953. /**
  10954. * Adds all the elements from the container to the scene
  10955. * @param container the container holding the elements
  10956. */
  10957. addFromContainer(container: AbstractScene): void;
  10958. /**
  10959. * Removes all the elements in the container from the scene
  10960. * @param container contains the elements to remove
  10961. * @param dispose if the removed element should be disposed (default: false)
  10962. */
  10963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10964. /**
  10965. * Serializes the component data to the specified json object
  10966. * @param serializationObject The object to serialize to
  10967. */
  10968. serialize(serializationObject: any): void;
  10969. }
  10970. /**
  10971. * Strong typing of a Mesh related stage step action
  10972. */
  10973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10974. /**
  10975. * Strong typing of a Evaluate Sub Mesh related stage step action
  10976. */
  10977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10978. /**
  10979. * Strong typing of a Active Mesh related stage step action
  10980. */
  10981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10982. /**
  10983. * Strong typing of a Camera related stage step action
  10984. */
  10985. export type CameraStageAction = (camera: Camera) => void;
  10986. /**
  10987. * Strong typing of a Camera Frame buffer related stage step action
  10988. */
  10989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10990. /**
  10991. * Strong typing of a Render Target related stage step action
  10992. */
  10993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10994. /**
  10995. * Strong typing of a RenderingGroup related stage step action
  10996. */
  10997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10998. /**
  10999. * Strong typing of a Mesh Render related stage step action
  11000. */
  11001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11002. /**
  11003. * Strong typing of a simple stage step action
  11004. */
  11005. export type SimpleStageAction = () => void;
  11006. /**
  11007. * Strong typing of a render target action.
  11008. */
  11009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11010. /**
  11011. * Strong typing of a pointer move action.
  11012. */
  11013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11014. /**
  11015. * Strong typing of a pointer up/down action.
  11016. */
  11017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11018. /**
  11019. * Representation of a stage in the scene (Basically a list of ordered steps)
  11020. * @hidden
  11021. */
  11022. export class Stage<T extends Function> extends Array<{
  11023. index: number;
  11024. component: ISceneComponent;
  11025. action: T;
  11026. }> {
  11027. /**
  11028. * Hide ctor from the rest of the world.
  11029. * @param items The items to add.
  11030. */
  11031. private constructor();
  11032. /**
  11033. * Creates a new Stage.
  11034. * @returns A new instance of a Stage
  11035. */
  11036. static Create<T extends Function>(): Stage<T>;
  11037. /**
  11038. * Registers a step in an ordered way in the targeted stage.
  11039. * @param index Defines the position to register the step in
  11040. * @param component Defines the component attached to the step
  11041. * @param action Defines the action to launch during the step
  11042. */
  11043. registerStep(index: number, component: ISceneComponent, action: T): void;
  11044. /**
  11045. * Clears all the steps from the stage.
  11046. */
  11047. clear(): void;
  11048. }
  11049. }
  11050. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11051. import { Nullable } from "babylonjs/types";
  11052. import { Observable } from "babylonjs/Misc/observable";
  11053. import { Scene } from "babylonjs/scene";
  11054. import { Sprite } from "babylonjs/Sprites/sprite";
  11055. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11056. import { Ray } from "babylonjs/Culling/ray";
  11057. import { Camera } from "babylonjs/Cameras/camera";
  11058. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11059. import { ISceneComponent } from "babylonjs/sceneComponent";
  11060. module "babylonjs/scene" {
  11061. interface Scene {
  11062. /** @hidden */
  11063. _pointerOverSprite: Nullable<Sprite>;
  11064. /** @hidden */
  11065. _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */
  11067. _tempSpritePickingRay: Nullable<Ray>;
  11068. /**
  11069. * All of the sprite managers added to this scene
  11070. * @see https://doc.babylonjs.com/babylon101/sprites
  11071. */
  11072. spriteManagers: Array<ISpriteManager>;
  11073. /**
  11074. * An event triggered when sprites rendering is about to start
  11075. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11076. */
  11077. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11078. /**
  11079. * An event triggered when sprites rendering is done
  11080. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11081. */
  11082. onAfterSpritesRenderingObservable: Observable<Scene>;
  11083. /** @hidden */
  11084. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11085. /** Launch a ray to try to pick a sprite in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @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
  11089. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11090. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11091. * @returns a PickingInfo
  11092. */
  11093. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11094. /** Use the given ray to pick a sprite in the scene
  11095. * @param ray The ray (in world space) to use to pick meshes
  11096. * @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
  11097. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11099. * @returns a PickingInfo
  11100. */
  11101. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11102. /** @hidden */
  11103. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /** Launch a ray to try to pick sprites in the scene
  11105. * @param x position on screen
  11106. * @param y position on screen
  11107. * @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
  11108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo array
  11110. */
  11111. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11112. /** Use the given ray to pick sprites in the scene
  11113. * @param ray The ray (in world space) to use to pick meshes
  11114. * @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
  11115. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11116. * @returns a PickingInfo array
  11117. */
  11118. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11119. /**
  11120. * Force the sprite under the pointer
  11121. * @param sprite defines the sprite to use
  11122. */
  11123. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11124. /**
  11125. * Gets the sprite under the pointer
  11126. * @returns a Sprite or null if no sprite is under the pointer
  11127. */
  11128. getPointerOverSprite(): Nullable<Sprite>;
  11129. }
  11130. }
  11131. /**
  11132. * Defines the sprite scene component responsible to manage sprites
  11133. * in a given scene.
  11134. */
  11135. export class SpriteSceneComponent implements ISceneComponent {
  11136. /**
  11137. * The component name helpfull to identify the component in the list of scene components.
  11138. */
  11139. readonly name: string;
  11140. /**
  11141. * The scene the component belongs to.
  11142. */
  11143. scene: Scene;
  11144. /** @hidden */
  11145. private _spritePredicate;
  11146. /**
  11147. * Creates a new instance of the component for the given scene
  11148. * @param scene Defines the scene to register the component in
  11149. */
  11150. constructor(scene: Scene);
  11151. /**
  11152. * Registers the component in a given scene
  11153. */
  11154. register(): void;
  11155. /**
  11156. * Rebuilds the elements related to this component in case of
  11157. * context lost for instance.
  11158. */
  11159. rebuild(): void;
  11160. /**
  11161. * Disposes the component and the associated ressources.
  11162. */
  11163. dispose(): void;
  11164. private _pickSpriteButKeepRay;
  11165. private _pointerMove;
  11166. private _pointerDown;
  11167. private _pointerUp;
  11168. }
  11169. }
  11170. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11171. /** @hidden */
  11172. export var fogFragmentDeclaration: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11178. /** @hidden */
  11179. export var fogFragment: {
  11180. name: string;
  11181. shader: string;
  11182. };
  11183. }
  11184. declare module "babylonjs/Shaders/sprites.fragment" {
  11185. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11187. /** @hidden */
  11188. export var spritesPixelShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11194. /** @hidden */
  11195. export var fogVertexDeclaration: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/sprites.vertex" {
  11201. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11202. /** @hidden */
  11203. export var spritesVertexShader: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Sprites/spriteManager" {
  11209. import { IDisposable, Scene } from "babylonjs/scene";
  11210. import { Nullable } from "babylonjs/types";
  11211. import { Observable } from "babylonjs/Misc/observable";
  11212. import { Sprite } from "babylonjs/Sprites/sprite";
  11213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { Texture } from "babylonjs/Materials/Textures/texture";
  11216. import "babylonjs/Shaders/sprites.fragment";
  11217. import "babylonjs/Shaders/sprites.vertex";
  11218. import { Ray } from "babylonjs/Culling/ray";
  11219. /**
  11220. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11221. */
  11222. export interface ISpriteManager extends IDisposable {
  11223. /**
  11224. * Gets manager's name
  11225. */
  11226. name: string;
  11227. /**
  11228. * Restricts the camera to viewing objects with the same layerMask.
  11229. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11230. */
  11231. layerMask: number;
  11232. /**
  11233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11234. */
  11235. isPickable: boolean;
  11236. /**
  11237. * Gets the hosting scene
  11238. */
  11239. scene: Scene;
  11240. /**
  11241. * Specifies the rendering group id for this mesh (0 by default)
  11242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11243. */
  11244. renderingGroupId: number;
  11245. /**
  11246. * Defines the list of sprites managed by the manager.
  11247. */
  11248. sprites: Array<Sprite>;
  11249. /**
  11250. * Gets or sets the spritesheet texture
  11251. */
  11252. texture: Texture;
  11253. /** Defines the default width of a cell in the spritesheet */
  11254. cellWidth: number;
  11255. /** Defines the default height of a cell in the spritesheet */
  11256. cellHeight: number;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see https://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Define the Url to load snippets */
  11287. static SnippetUrl: string;
  11288. /** Snippet ID if the manager was created from the snippet server */
  11289. snippetId: string;
  11290. /** Gets the list of sprites */
  11291. sprites: Sprite[];
  11292. /** Gets or sets the rendering group id (0 by default) */
  11293. renderingGroupId: number;
  11294. /** Gets or sets camera layer mask */
  11295. layerMask: number;
  11296. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11297. fogEnabled: boolean;
  11298. /** Gets or sets a boolean indicating if the sprites are pickable */
  11299. isPickable: boolean;
  11300. /** Defines the default width of a cell in the spritesheet */
  11301. cellWidth: number;
  11302. /** Defines the default height of a cell in the spritesheet */
  11303. cellHeight: number;
  11304. /** Associative array from JSON sprite data file */
  11305. private _cellData;
  11306. /** Array of sprite names from JSON sprite data file */
  11307. private _spriteMap;
  11308. /** True when packed cell data from JSON file is ready*/
  11309. private _packedAndReady;
  11310. private _textureContent;
  11311. private _useInstancing;
  11312. /**
  11313. * An event triggered when the manager is disposed.
  11314. */
  11315. onDisposeObservable: Observable<SpriteManager>;
  11316. private _onDisposeObserver;
  11317. /**
  11318. * Callback called when the manager is disposed
  11319. */
  11320. set onDispose(callback: () => void);
  11321. private _capacity;
  11322. private _fromPacked;
  11323. private _spriteTexture;
  11324. private _epsilon;
  11325. private _scene;
  11326. private _vertexData;
  11327. private _buffer;
  11328. private _vertexBuffers;
  11329. private _spriteBuffer;
  11330. private _indexBuffer;
  11331. private _effectBase;
  11332. private _effectFog;
  11333. private _vertexBufferSize;
  11334. /**
  11335. * Gets or sets the unique id of the sprite
  11336. */
  11337. uniqueId: number;
  11338. /**
  11339. * Gets the array of sprites
  11340. */
  11341. get children(): Sprite[];
  11342. /**
  11343. * Gets the hosting scene
  11344. */
  11345. get scene(): Scene;
  11346. /**
  11347. * Gets the capacity of the manager
  11348. */
  11349. get capacity(): number;
  11350. /**
  11351. * Gets or sets the spritesheet texture
  11352. */
  11353. get texture(): Texture;
  11354. set texture(value: Texture);
  11355. private _blendMode;
  11356. /**
  11357. * Blend mode use to render the particle, it can be any of
  11358. * the static Constants.ALPHA_x properties provided in this class.
  11359. * Default value is Constants.ALPHA_COMBINE
  11360. */
  11361. get blendMode(): number;
  11362. set blendMode(blendMode: number);
  11363. /** Disables writing to the depth buffer when rendering the sprites.
  11364. * It can be handy to disable depth writing when using textures without alpha channel
  11365. * and setting some specific blend modes.
  11366. */
  11367. disableDepthWrite: boolean;
  11368. /**
  11369. * Creates a new sprite manager
  11370. * @param name defines the manager's name
  11371. * @param imgUrl defines the sprite sheet url
  11372. * @param capacity defines the maximum allowed number of sprites
  11373. * @param cellSize defines the size of a sprite cell
  11374. * @param scene defines the hosting scene
  11375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11376. * @param samplingMode defines the smapling mode to use with spritesheet
  11377. * @param fromPacked set to false; do not alter
  11378. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11379. */
  11380. constructor(
  11381. /** defines the manager's name */
  11382. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11383. /**
  11384. * Returns the string "SpriteManager"
  11385. * @returns "SpriteManager"
  11386. */
  11387. getClassName(): string;
  11388. private _makePacked;
  11389. private _appendSpriteVertex;
  11390. private _checkTextureAlpha;
  11391. /**
  11392. * Intersects the sprites with a ray
  11393. * @param ray defines the ray to intersect with
  11394. * @param camera defines the current active camera
  11395. * @param predicate defines a predicate used to select candidate sprites
  11396. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11397. * @returns null if no hit or a PickingInfo
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Render all child sprites
  11410. */
  11411. render(): void;
  11412. /**
  11413. * Release associated resources
  11414. */
  11415. dispose(): void;
  11416. /**
  11417. * Serializes the sprite manager to a JSON object
  11418. * @param serializeTexture defines if the texture must be serialized as well
  11419. * @returns the JSON object
  11420. */
  11421. serialize(serializeTexture?: boolean): any;
  11422. /**
  11423. * Parses a JSON object to create a new sprite manager.
  11424. * @param parsedManager The JSON object to parse
  11425. * @param scene The scene to create the sprite managerin
  11426. * @param rootUrl The root url to use to load external dependencies like texture
  11427. * @returns the new sprite manager
  11428. */
  11429. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11430. /**
  11431. * Creates a sprite manager from a snippet saved in a remote file
  11432. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11433. * @param url defines the url to load from
  11434. * @param scene defines the hosting scene
  11435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11436. * @returns a promise that will resolve to the new sprite manager
  11437. */
  11438. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11439. /**
  11440. * Creates a sprite manager from a snippet saved by the sprite editor
  11441. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11442. * @param scene defines the hosting scene
  11443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11444. * @returns a promise that will resolve to the new sprite manager
  11445. */
  11446. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11447. }
  11448. }
  11449. declare module "babylonjs/Misc/gradients" {
  11450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11451. /** Interface used by value gradients (color, factor, ...) */
  11452. export interface IValueGradient {
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number;
  11457. }
  11458. /** Class used to store color4 gradient */
  11459. export class ColorGradient implements IValueGradient {
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number;
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4;
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined;
  11472. /**
  11473. * Creates a new color4 gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param color1 gets or sets first associated color
  11476. * @param color2 gets or sets first second color
  11477. */
  11478. constructor(
  11479. /**
  11480. * Gets or sets the gradient value (between 0 and 1)
  11481. */
  11482. gradient: number,
  11483. /**
  11484. * Gets or sets first associated color
  11485. */
  11486. color1: Color4,
  11487. /**
  11488. * Gets or sets second associated color
  11489. */
  11490. color2?: Color4 | undefined);
  11491. /**
  11492. * Will get a color picked randomly between color1 and color2.
  11493. * If color2 is undefined then color1 will be used
  11494. * @param result defines the target Color4 to store the result in
  11495. */
  11496. getColorToRef(result: Color4): void;
  11497. }
  11498. /** Class used to store color 3 gradient */
  11499. export class Color3Gradient implements IValueGradient {
  11500. /**
  11501. * Gets or sets the gradient value (between 0 and 1)
  11502. */
  11503. gradient: number;
  11504. /**
  11505. * Gets or sets the associated color
  11506. */
  11507. color: Color3;
  11508. /**
  11509. * Creates a new color3 gradient
  11510. * @param gradient gets or sets the gradient value (between 0 and 1)
  11511. * @param color gets or sets associated color
  11512. */
  11513. constructor(
  11514. /**
  11515. * Gets or sets the gradient value (between 0 and 1)
  11516. */
  11517. gradient: number,
  11518. /**
  11519. * Gets or sets the associated color
  11520. */
  11521. color: Color3);
  11522. }
  11523. /** Class used to store factor gradient */
  11524. export class FactorGradient implements IValueGradient {
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number;
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number;
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined;
  11537. /**
  11538. * Creates a new factor gradient
  11539. * @param gradient gets or sets the gradient value (between 0 and 1)
  11540. * @param factor1 gets or sets first associated factor
  11541. * @param factor2 gets or sets second associated factor
  11542. */
  11543. constructor(
  11544. /**
  11545. * Gets or sets the gradient value (between 0 and 1)
  11546. */
  11547. gradient: number,
  11548. /**
  11549. * Gets or sets first associated factor
  11550. */
  11551. factor1: number,
  11552. /**
  11553. * Gets or sets second associated factor
  11554. */
  11555. factor2?: number | undefined);
  11556. /**
  11557. * Will get a number picked randomly between factor1 and factor2.
  11558. * If factor2 is undefined then factor1 will be used
  11559. * @returns the picked number
  11560. */
  11561. getFactor(): number;
  11562. }
  11563. /**
  11564. * Helper used to simplify some generic gradient tasks
  11565. */
  11566. export class GradientHelper {
  11567. /**
  11568. * Gets the current gradient from an array of IValueGradient
  11569. * @param ratio defines the current ratio to get
  11570. * @param gradients defines the array of IValueGradient
  11571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11572. */
  11573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11574. }
  11575. }
  11576. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11577. import { Nullable } from "babylonjs/types";
  11578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11579. import { Scene } from "babylonjs/scene";
  11580. module "babylonjs/Engines/thinEngine" {
  11581. interface ThinEngine {
  11582. /**
  11583. * Creates a raw texture
  11584. * @param data defines the data to store in the texture
  11585. * @param width defines the width of the texture
  11586. * @param height defines the height of the texture
  11587. * @param format defines the format of the data
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. * @returns the raw texture inside an InternalTexture
  11594. */
  11595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11596. /**
  11597. * Update a raw texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store in the texture
  11600. * @param format defines the format of the data
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11614. /**
  11615. * Creates a new raw cube texture
  11616. * @param data defines the array of data to use to create each face
  11617. * @param size defines the size of the textures
  11618. * @param format defines the format of the data
  11619. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11623. * @param compression defines the compression used (null by default)
  11624. * @returns the cube texture as an InternalTexture
  11625. */
  11626. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. */
  11635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11636. /**
  11637. * Update a raw cube texture
  11638. * @param texture defines the texture to udpdate
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param compression defines the compression used (null by default)
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. * @param level defines which level of the texture to update
  11655. */
  11656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11657. /**
  11658. * Creates a new raw cube texture from a specified url
  11659. * @param url defines the url where the data is located
  11660. * @param scene defines the current scene
  11661. * @param size defines the size of the textures
  11662. * @param format defines the format of the data
  11663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11664. * @param noMipmap defines if the engine should avoid generating the mip levels
  11665. * @param callback defines a callback used to extract texture data from loaded data
  11666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11667. * @param onLoad defines a callback called when texture is loaded
  11668. * @param onError defines a callback called if there is an error
  11669. * @returns the cube texture as an InternalTexture
  11670. */
  11671. 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;
  11672. /**
  11673. * Creates a new raw cube texture from a specified url
  11674. * @param url defines the url where the data is located
  11675. * @param scene defines the current scene
  11676. * @param size defines the size of the textures
  11677. * @param format defines the format of the data
  11678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11679. * @param noMipmap defines if the engine should avoid generating the mip levels
  11680. * @param callback defines a callback used to extract texture data from loaded data
  11681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11682. * @param onLoad defines a callback called when texture is loaded
  11683. * @param onError defines a callback called if there is an error
  11684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @returns the cube texture as an InternalTexture
  11687. */
  11688. 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;
  11689. /**
  11690. * Creates a new raw 3D texture
  11691. * @param data defines the data used to create the texture
  11692. * @param width defines the width of the texture
  11693. * @param height defines the height of the texture
  11694. * @param depth defines the depth of the texture
  11695. * @param format defines the format of the texture
  11696. * @param generateMipMaps defines if the engine must generate mip levels
  11697. * @param invertY defines if data must be stored with Y axis inverted
  11698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11699. * @param compression defines the compressed used (can be null)
  11700. * @param textureType defines the compressed used (can be null)
  11701. * @returns a new raw 3D texture (stored in an InternalTexture)
  11702. */
  11703. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11704. /**
  11705. * Update a raw 3D texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11712. /**
  11713. * Update a raw 3D texture
  11714. * @param texture defines the texture to update
  11715. * @param data defines the data to store
  11716. * @param format defines the data format
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param compression defines the used compression (can be null)
  11719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11722. /**
  11723. * Creates a new raw 2D array texture
  11724. * @param data defines the data used to create the texture
  11725. * @param width defines the width of the texture
  11726. * @param height defines the height of the texture
  11727. * @param depth defines the number of layers of the texture
  11728. * @param format defines the format of the texture
  11729. * @param generateMipMaps defines if the engine must generate mip levels
  11730. * @param invertY defines if data must be stored with Y axis inverted
  11731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11732. * @param compression defines the compressed used (can be null)
  11733. * @param textureType defines the compressed used (can be null)
  11734. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11735. */
  11736. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11737. /**
  11738. * Update a raw 2D array texture
  11739. * @param texture defines the texture to update
  11740. * @param data defines the data to store
  11741. * @param format defines the data format
  11742. * @param invertY defines if data must be stored with Y axis inverted
  11743. */
  11744. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11745. /**
  11746. * Update a raw 2D array texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @param compression defines the used compression (can be null)
  11752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11755. }
  11756. }
  11757. }
  11758. declare module "babylonjs/Materials/Textures/rawTexture" {
  11759. import { Texture } from "babylonjs/Materials/Textures/texture";
  11760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11763. import { Scene } from "babylonjs/scene";
  11764. /**
  11765. * Raw texture can help creating a texture directly from an array of data.
  11766. * This can be super useful if you either get the data from an uncompressed source or
  11767. * if you wish to create your texture pixel by pixel.
  11768. */
  11769. export class RawTexture extends Texture {
  11770. /**
  11771. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11772. */
  11773. format: number;
  11774. /**
  11775. * Instantiates a new RawTexture.
  11776. * Raw texture can help creating a texture directly from an array of data.
  11777. * This can be super useful if you either get the data from an uncompressed source or
  11778. * if you wish to create your texture pixel by pixel.
  11779. * @param data define the array of data to use to create the texture
  11780. * @param width define the width of the texture
  11781. * @param height define the height of the texture
  11782. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps define whether mip maps should be generated or not
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. */
  11789. constructor(data: ArrayBufferView, width: number, height: number,
  11790. /**
  11791. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11792. */
  11793. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11794. /**
  11795. * Updates the texture underlying data.
  11796. * @param data Define the new data of the texture
  11797. */
  11798. update(data: ArrayBufferView): void;
  11799. /**
  11800. * Creates a luminance texture from some data.
  11801. * @param data Define the texture data
  11802. * @param width Define the width of the texture
  11803. * @param height Define the height of the texture
  11804. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11808. * @returns the luminance texture
  11809. */
  11810. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11811. /**
  11812. * Creates a luminance alpha texture from some data.
  11813. * @param data Define the texture data
  11814. * @param width Define the width of the texture
  11815. * @param height Define the height of the texture
  11816. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11820. * @returns the luminance alpha texture
  11821. */
  11822. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11823. /**
  11824. * Creates an alpha texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the alpha texture
  11833. */
  11834. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a RGB texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11845. * @returns the RGB alpha texture
  11846. */
  11847. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11848. /**
  11849. * Creates a RGBA texture from some data.
  11850. * @param data Define the texture data
  11851. * @param width Define the width of the texture
  11852. * @param height Define the height of the texture
  11853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11858. * @returns the RGBA texture
  11859. */
  11860. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11861. /**
  11862. * Creates a R texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11871. * @returns the R texture
  11872. */
  11873. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11874. }
  11875. }
  11876. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11878. import { IndicesArray, DataArray } from "babylonjs/types";
  11879. module "babylonjs/Engines/thinEngine" {
  11880. interface ThinEngine {
  11881. /**
  11882. * Update a dynamic index buffer
  11883. * @param indexBuffer defines the target index buffer
  11884. * @param indices defines the data to update
  11885. * @param offset defines the offset in the target index buffer where update should start
  11886. */
  11887. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11888. /**
  11889. * Updates a dynamic vertex buffer.
  11890. * @param vertexBuffer the vertex buffer to update
  11891. * @param data the data used to update the vertex buffer
  11892. * @param byteOffset the byte offset of the data
  11893. * @param byteLength the byte length of the data
  11894. */
  11895. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11896. }
  11897. }
  11898. }
  11899. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11900. import { Scene } from "babylonjs/scene";
  11901. import { ISceneComponent } from "babylonjs/sceneComponent";
  11902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11903. module "babylonjs/abstractScene" {
  11904. interface AbstractScene {
  11905. /**
  11906. * The list of procedural textures added to the scene
  11907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11908. */
  11909. proceduralTextures: Array<ProceduralTexture>;
  11910. }
  11911. }
  11912. /**
  11913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11914. * in a given scene.
  11915. */
  11916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11917. /**
  11918. * The component name helpfull to identify the component in the list of scene components.
  11919. */
  11920. readonly name: string;
  11921. /**
  11922. * The scene the component belongs to.
  11923. */
  11924. scene: Scene;
  11925. /**
  11926. * Creates a new instance of the component for the given scene
  11927. * @param scene Defines the scene to register the component in
  11928. */
  11929. constructor(scene: Scene);
  11930. /**
  11931. * Registers the component in a given scene
  11932. */
  11933. register(): void;
  11934. /**
  11935. * Rebuilds the elements related to this component in case of
  11936. * context lost for instance.
  11937. */
  11938. rebuild(): void;
  11939. /**
  11940. * Disposes the component and the associated ressources.
  11941. */
  11942. dispose(): void;
  11943. private _beforeClear;
  11944. }
  11945. }
  11946. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11949. module "babylonjs/Engines/thinEngine" {
  11950. interface ThinEngine {
  11951. /**
  11952. * Creates a new render target cube texture
  11953. * @param size defines the size of the texture
  11954. * @param options defines the options used to create the texture
  11955. * @returns a new render target cube texture stored in an InternalTexture
  11956. */
  11957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11958. }
  11959. }
  11960. }
  11961. declare module "babylonjs/Shaders/procedural.vertex" {
  11962. /** @hidden */
  11963. export var proceduralVertexShader: {
  11964. name: string;
  11965. shader: string;
  11966. };
  11967. }
  11968. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11969. import { Observable } from "babylonjs/Misc/observable";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Scene } from "babylonjs/scene";
  11972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11973. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11974. import { Effect } from "babylonjs/Materials/effect";
  11975. import { Texture } from "babylonjs/Materials/Textures/texture";
  11976. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11977. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11978. import "babylonjs/Shaders/procedural.vertex";
  11979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11980. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11981. /**
  11982. * 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.
  11983. * This is the base class of any Procedural texture and contains most of the shareable code.
  11984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11985. */
  11986. export class ProceduralTexture extends Texture {
  11987. /**
  11988. * Define if the texture is enabled or not (disabled texture will not render)
  11989. */
  11990. isEnabled: boolean;
  11991. /**
  11992. * Define if the texture must be cleared before rendering (default is true)
  11993. */
  11994. autoClear: boolean;
  11995. /**
  11996. * Callback called when the texture is generated
  11997. */
  11998. onGenerated: () => void;
  11999. /**
  12000. * Event raised when the texture is generated
  12001. */
  12002. onGeneratedObservable: Observable<ProceduralTexture>;
  12003. /**
  12004. * Event raised before the texture is generated
  12005. */
  12006. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12007. /**
  12008. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12009. */
  12010. nodeMaterialSource: Nullable<NodeMaterial>;
  12011. /** @hidden */
  12012. _generateMipMaps: boolean;
  12013. /** @hidden **/
  12014. _effect: Effect;
  12015. /** @hidden */
  12016. _textures: {
  12017. [key: string]: Texture;
  12018. };
  12019. /** @hidden */
  12020. protected _fallbackTexture: Nullable<Texture>;
  12021. private _size;
  12022. private _currentRefreshId;
  12023. private _frameId;
  12024. private _refreshRate;
  12025. private _vertexBuffers;
  12026. private _indexBuffer;
  12027. private _uniforms;
  12028. private _samplers;
  12029. private _fragment;
  12030. private _floats;
  12031. private _ints;
  12032. private _floatsArrays;
  12033. private _colors3;
  12034. private _colors4;
  12035. private _vectors2;
  12036. private _vectors3;
  12037. private _matrices;
  12038. private _fallbackTextureUsed;
  12039. private _fullEngine;
  12040. private _cachedDefines;
  12041. private _contentUpdateId;
  12042. private _contentData;
  12043. /**
  12044. * Instantiates a new procedural texture.
  12045. * 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.
  12046. * This is the base class of any Procedural texture and contains most of the shareable code.
  12047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12048. * @param name Define the name of the texture
  12049. * @param size Define the size of the texture to create
  12050. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12051. * @param scene Define the scene the texture belongs to
  12052. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12053. * @param generateMipMaps Define if the texture should creates mip maps or not
  12054. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12055. */
  12056. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12057. /**
  12058. * The effect that is created when initializing the post process.
  12059. * @returns The created effect corresponding the the postprocess.
  12060. */
  12061. getEffect(): Effect;
  12062. /**
  12063. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12064. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12065. */
  12066. getContent(): Nullable<ArrayBufferView>;
  12067. private _createIndexBuffer;
  12068. /** @hidden */
  12069. _rebuild(): void;
  12070. /**
  12071. * Resets the texture in order to recreate its associated resources.
  12072. * This can be called in case of context loss
  12073. */
  12074. reset(): void;
  12075. protected _getDefines(): string;
  12076. /**
  12077. * Is the texture ready to be used ? (rendered at least once)
  12078. * @returns true if ready, otherwise, false.
  12079. */
  12080. isReady(): boolean;
  12081. /**
  12082. * Resets the refresh counter of the texture and start bak from scratch.
  12083. * Could be useful to regenerate the texture if it is setup to render only once.
  12084. */
  12085. resetRefreshCounter(): void;
  12086. /**
  12087. * Set the fragment shader to use in order to render the texture.
  12088. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12089. */
  12090. setFragment(fragment: any): void;
  12091. /**
  12092. * Define the refresh rate of the texture or the rendering frequency.
  12093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12094. */
  12095. get refreshRate(): number;
  12096. set refreshRate(value: number);
  12097. /** @hidden */
  12098. _shouldRender(): boolean;
  12099. /**
  12100. * Get the size the texture is rendering at.
  12101. * @returns the size (on cube texture it is always squared)
  12102. */
  12103. getRenderSize(): RenderTargetTextureSize;
  12104. /**
  12105. * Resize the texture to new value.
  12106. * @param size Define the new size the texture should have
  12107. * @param generateMipMaps Define whether the new texture should create mip maps
  12108. */
  12109. resize(size: number, generateMipMaps: boolean): void;
  12110. private _checkUniform;
  12111. /**
  12112. * Set a texture in the shader program used to render.
  12113. * @param name Define the name of the uniform samplers as defined in the shader
  12114. * @param texture Define the texture to bind to this sampler
  12115. * @return the texture itself allowing "fluent" like uniform updates
  12116. */
  12117. setTexture(name: string, texture: Texture): ProceduralTexture;
  12118. /**
  12119. * Set a float in the shader.
  12120. * @param name Define the name of the uniform as defined in the shader
  12121. * @param value Define the value to give to the uniform
  12122. * @return the texture itself allowing "fluent" like uniform updates
  12123. */
  12124. setFloat(name: string, value: number): ProceduralTexture;
  12125. /**
  12126. * Set a int in the shader.
  12127. * @param name Define the name of the uniform as defined in the shader
  12128. * @param value Define the value to give to the uniform
  12129. * @return the texture itself allowing "fluent" like uniform updates
  12130. */
  12131. setInt(name: string, value: number): ProceduralTexture;
  12132. /**
  12133. * Set an array of floats in the shader.
  12134. * @param name Define the name of the uniform as defined in the shader
  12135. * @param value Define the value to give to the uniform
  12136. * @return the texture itself allowing "fluent" like uniform updates
  12137. */
  12138. setFloats(name: string, value: number[]): ProceduralTexture;
  12139. /**
  12140. * Set a vec3 in the shader from a Color3.
  12141. * @param name Define the name of the uniform as defined in the shader
  12142. * @param value Define the value to give to the uniform
  12143. * @return the texture itself allowing "fluent" like uniform updates
  12144. */
  12145. setColor3(name: string, value: Color3): ProceduralTexture;
  12146. /**
  12147. * Set a vec4 in the shader from a Color4.
  12148. * @param name Define the name of the uniform as defined in the shader
  12149. * @param value Define the value to give to the uniform
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setColor4(name: string, value: Color4): ProceduralTexture;
  12153. /**
  12154. * Set a vec2 in the shader from a Vector2.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setVector2(name: string, value: Vector2): ProceduralTexture;
  12160. /**
  12161. * Set a vec3 in the shader from a Vector3.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setVector3(name: string, value: Vector3): ProceduralTexture;
  12167. /**
  12168. * Set a mat4 in the shader from a MAtrix.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12174. /**
  12175. * Render the texture to its associated render target.
  12176. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12177. */
  12178. render(useCameraPostProcess?: boolean): void;
  12179. /**
  12180. * Clone the texture.
  12181. * @returns the cloned texture
  12182. */
  12183. clone(): ProceduralTexture;
  12184. /**
  12185. * Dispose the texture and release its asoociated resources.
  12186. */
  12187. dispose(): void;
  12188. }
  12189. }
  12190. declare module "babylonjs/Particles/baseParticleSystem" {
  12191. import { Nullable } from "babylonjs/types";
  12192. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12194. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12195. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12196. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12198. import { Color4 } from "babylonjs/Maths/math.color";
  12199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12200. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12201. import { Animation } from "babylonjs/Animations/animation";
  12202. import { Scene } from "babylonjs/scene";
  12203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12205. /**
  12206. * This represents the base class for particle system in Babylon.
  12207. * 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.
  12208. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12209. * @example https://doc.babylonjs.com/babylon101/particles
  12210. */
  12211. export class BaseParticleSystem {
  12212. /**
  12213. * Source color is added to the destination color without alpha affecting the result
  12214. */
  12215. static BLENDMODE_ONEONE: number;
  12216. /**
  12217. * Blend current color and particle color using particle’s alpha
  12218. */
  12219. static BLENDMODE_STANDARD: number;
  12220. /**
  12221. * Add current color and particle color multiplied by particle’s alpha
  12222. */
  12223. static BLENDMODE_ADD: number;
  12224. /**
  12225. * Multiply current color with particle color
  12226. */
  12227. static BLENDMODE_MULTIPLY: number;
  12228. /**
  12229. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12230. */
  12231. static BLENDMODE_MULTIPLYADD: number;
  12232. /**
  12233. * List of animations used by the particle system.
  12234. */
  12235. animations: Animation[];
  12236. /**
  12237. * Gets or sets the unique id of the particle system
  12238. */
  12239. uniqueId: number;
  12240. /**
  12241. * The id of the Particle system.
  12242. */
  12243. id: string;
  12244. /**
  12245. * The friendly name of the Particle system.
  12246. */
  12247. name: string;
  12248. /**
  12249. * Snippet ID if the particle system was created from the snippet server
  12250. */
  12251. snippetId: string;
  12252. /**
  12253. * The rendering group used by the Particle system to chose when to render.
  12254. */
  12255. renderingGroupId: number;
  12256. /**
  12257. * The emitter represents the Mesh or position we are attaching the particle system to.
  12258. */
  12259. emitter: Nullable<AbstractMesh | Vector3>;
  12260. /**
  12261. * The maximum number of particles to emit per frame
  12262. */
  12263. emitRate: number;
  12264. /**
  12265. * If you want to launch only a few particles at once, that can be done, as well.
  12266. */
  12267. manualEmitCount: number;
  12268. /**
  12269. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12270. */
  12271. updateSpeed: number;
  12272. /**
  12273. * The amount of time the particle system is running (depends of the overall update speed).
  12274. */
  12275. targetStopDuration: number;
  12276. /**
  12277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12278. */
  12279. disposeOnStop: boolean;
  12280. /**
  12281. * Minimum power of emitting particles.
  12282. */
  12283. minEmitPower: number;
  12284. /**
  12285. * Maximum power of emitting particles.
  12286. */
  12287. maxEmitPower: number;
  12288. /**
  12289. * Minimum life time of emitting particles.
  12290. */
  12291. minLifeTime: number;
  12292. /**
  12293. * Maximum life time of emitting particles.
  12294. */
  12295. maxLifeTime: number;
  12296. /**
  12297. * Minimum Size of emitting particles.
  12298. */
  12299. minSize: number;
  12300. /**
  12301. * Maximum Size of emitting particles.
  12302. */
  12303. maxSize: number;
  12304. /**
  12305. * Minimum scale of emitting particles on X axis.
  12306. */
  12307. minScaleX: number;
  12308. /**
  12309. * Maximum scale of emitting particles on X axis.
  12310. */
  12311. maxScaleX: number;
  12312. /**
  12313. * Minimum scale of emitting particles on Y axis.
  12314. */
  12315. minScaleY: number;
  12316. /**
  12317. * Maximum scale of emitting particles on Y axis.
  12318. */
  12319. maxScaleY: number;
  12320. /**
  12321. * Gets or sets the minimal initial rotation in radians.
  12322. */
  12323. minInitialRotation: number;
  12324. /**
  12325. * Gets or sets the maximal initial rotation in radians.
  12326. */
  12327. maxInitialRotation: number;
  12328. /**
  12329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12330. */
  12331. minAngularSpeed: number;
  12332. /**
  12333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12334. */
  12335. maxAngularSpeed: number;
  12336. /**
  12337. * The texture used to render each particle. (this can be a spritesheet)
  12338. */
  12339. particleTexture: Nullable<BaseTexture>;
  12340. /**
  12341. * The layer mask we are rendering the particles through.
  12342. */
  12343. layerMask: number;
  12344. /**
  12345. * This can help using your own shader to render the particle system.
  12346. * The according effect will be created
  12347. */
  12348. customShader: any;
  12349. /**
  12350. * By default particle system starts as soon as they are created. This prevents the
  12351. * automatic start to happen and let you decide when to start emitting particles.
  12352. */
  12353. preventAutoStart: boolean;
  12354. private _noiseTexture;
  12355. /**
  12356. * Gets or sets a texture used to add random noise to particle positions
  12357. */
  12358. get noiseTexture(): Nullable<ProceduralTexture>;
  12359. set noiseTexture(value: Nullable<ProceduralTexture>);
  12360. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12361. noiseStrength: Vector3;
  12362. /**
  12363. * Callback triggered when the particle animation is ending.
  12364. */
  12365. onAnimationEnd: Nullable<() => void>;
  12366. /**
  12367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12368. */
  12369. blendMode: number;
  12370. /**
  12371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12372. * to override the particles.
  12373. */
  12374. forceDepthWrite: boolean;
  12375. /** 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 */
  12376. preWarmCycles: number;
  12377. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12378. preWarmStepOffset: number;
  12379. /**
  12380. * 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)
  12381. */
  12382. spriteCellChangeSpeed: number;
  12383. /**
  12384. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12385. */
  12386. startSpriteCellID: number;
  12387. /**
  12388. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12389. */
  12390. endSpriteCellID: number;
  12391. /**
  12392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12393. */
  12394. spriteCellWidth: number;
  12395. /**
  12396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12397. */
  12398. spriteCellHeight: number;
  12399. /**
  12400. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12401. */
  12402. spriteRandomStartCell: boolean;
  12403. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12404. translationPivot: Vector2;
  12405. /** @hidden */
  12406. protected _isAnimationSheetEnabled: boolean;
  12407. /**
  12408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12409. */
  12410. beginAnimationOnStart: boolean;
  12411. /**
  12412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12413. */
  12414. beginAnimationFrom: number;
  12415. /**
  12416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12417. */
  12418. beginAnimationTo: number;
  12419. /**
  12420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12421. */
  12422. beginAnimationLoop: boolean;
  12423. /**
  12424. * Gets or sets a world offset applied to all particles
  12425. */
  12426. worldOffset: Vector3;
  12427. /**
  12428. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12429. */
  12430. get isAnimationSheetEnabled(): boolean;
  12431. set isAnimationSheetEnabled(value: boolean);
  12432. /**
  12433. * Get hosting scene
  12434. * @returns the scene
  12435. */
  12436. getScene(): Nullable<Scene>;
  12437. /**
  12438. * You can use gravity if you want to give an orientation to your particles.
  12439. */
  12440. gravity: Vector3;
  12441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12454. /**
  12455. * Defines the delay in milliseconds before starting the system (0 by default)
  12456. */
  12457. startDelay: number;
  12458. /**
  12459. * Gets the current list of drag gradients.
  12460. * You must use addDragGradient and removeDragGradient to udpate this list
  12461. * @returns the list of drag gradients
  12462. */
  12463. getDragGradients(): Nullable<Array<FactorGradient>>;
  12464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12465. limitVelocityDamping: number;
  12466. /**
  12467. * Gets the current list of limit velocity gradients.
  12468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12469. * @returns the list of limit velocity gradients
  12470. */
  12471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12472. /**
  12473. * Gets the current list of color gradients.
  12474. * You must use addColorGradient and removeColorGradient to udpate this list
  12475. * @returns the list of color gradients
  12476. */
  12477. getColorGradients(): Nullable<Array<ColorGradient>>;
  12478. /**
  12479. * Gets the current list of size gradients.
  12480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12481. * @returns the list of size gradients
  12482. */
  12483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12484. /**
  12485. * Gets the current list of color remap gradients.
  12486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12487. * @returns the list of color remap gradients
  12488. */
  12489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12490. /**
  12491. * Gets the current list of alpha remap gradients.
  12492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12493. * @returns the list of alpha remap gradients
  12494. */
  12495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12496. /**
  12497. * Gets the current list of life time gradients.
  12498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12499. * @returns the list of life time gradients
  12500. */
  12501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12502. /**
  12503. * Gets the current list of angular speed gradients.
  12504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12505. * @returns the list of angular speed gradients
  12506. */
  12507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12508. /**
  12509. * Gets the current list of velocity gradients.
  12510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12511. * @returns the list of velocity gradients
  12512. */
  12513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of start size gradients.
  12516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12517. * @returns the list of start size gradients
  12518. */
  12519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12520. /**
  12521. * Gets the current list of emit rate gradients.
  12522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12523. * @returns the list of emit rate gradients
  12524. */
  12525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12529. */
  12530. get direction1(): Vector3;
  12531. set direction1(value: Vector3);
  12532. /**
  12533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12535. */
  12536. get direction2(): Vector3;
  12537. set direction2(value: Vector3);
  12538. /**
  12539. * 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.
  12540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12541. */
  12542. get minEmitBox(): Vector3;
  12543. set minEmitBox(value: Vector3);
  12544. /**
  12545. * 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.
  12546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12547. */
  12548. get maxEmitBox(): Vector3;
  12549. set maxEmitBox(value: Vector3);
  12550. /**
  12551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12552. */
  12553. color1: Color4;
  12554. /**
  12555. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12556. */
  12557. color2: Color4;
  12558. /**
  12559. * Color the particle will have at the end of its lifetime
  12560. */
  12561. colorDead: Color4;
  12562. /**
  12563. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12564. */
  12565. textureMask: Color4;
  12566. /**
  12567. * The particle emitter type defines the emitter used by the particle system.
  12568. * It can be for example box, sphere, or cone...
  12569. */
  12570. particleEmitterType: IParticleEmitterType;
  12571. /** @hidden */
  12572. _isSubEmitter: boolean;
  12573. /**
  12574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12576. */
  12577. billboardMode: number;
  12578. protected _isBillboardBased: boolean;
  12579. /**
  12580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12581. */
  12582. get isBillboardBased(): boolean;
  12583. set isBillboardBased(value: boolean);
  12584. /**
  12585. * The scene the particle system belongs to.
  12586. */
  12587. protected _scene: Nullable<Scene>;
  12588. /**
  12589. * The engine the particle system belongs to.
  12590. */
  12591. protected _engine: ThinEngine;
  12592. /**
  12593. * Local cache of defines for image processing.
  12594. */
  12595. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12596. /**
  12597. * Default configuration related to image processing available in the standard Material.
  12598. */
  12599. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12600. /**
  12601. * Gets the image processing configuration used either in this material.
  12602. */
  12603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12604. /**
  12605. * Sets the Default image processing configuration used either in the this material.
  12606. *
  12607. * If sets to null, the scene one is in use.
  12608. */
  12609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12610. /**
  12611. * Attaches a new image processing configuration to the Standard Material.
  12612. * @param configuration
  12613. */
  12614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12615. /** @hidden */
  12616. protected _reset(): void;
  12617. /** @hidden */
  12618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12619. /**
  12620. * Instantiates a particle system.
  12621. * 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.
  12622. * @param name The name of the particle system
  12623. */
  12624. constructor(name: string);
  12625. /**
  12626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @returns the emitter
  12630. */
  12631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12632. /**
  12633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12634. * @param radius The radius of the hemisphere to emit from
  12635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12636. * @returns the emitter
  12637. */
  12638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12639. /**
  12640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12641. * @param radius The radius of the sphere to emit from
  12642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12643. * @returns the emitter
  12644. */
  12645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12646. /**
  12647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12648. * @param radius The radius of the sphere to emit from
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @returns the emitter
  12652. */
  12653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12656. * @param radius The radius of the emission cylinder
  12657. * @param height The height of the emission cylinder
  12658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12660. * @returns the emitter
  12661. */
  12662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12663. /**
  12664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12665. * @param radius The radius of the cylinder to emit from
  12666. * @param height The height of the emission cylinder
  12667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @returns the emitter
  12671. */
  12672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12675. * @param radius The radius of the cone to emit from
  12676. * @param angle The base angle of the cone
  12677. * @returns the emitter
  12678. */
  12679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12680. /**
  12681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @returns the emitter
  12687. */
  12688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12689. }
  12690. }
  12691. declare module "babylonjs/Particles/subEmitter" {
  12692. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12693. import { Scene } from "babylonjs/scene";
  12694. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12695. /**
  12696. * Type of sub emitter
  12697. */
  12698. export enum SubEmitterType {
  12699. /**
  12700. * Attached to the particle over it's lifetime
  12701. */
  12702. ATTACHED = 0,
  12703. /**
  12704. * Created when the particle dies
  12705. */
  12706. END = 1
  12707. }
  12708. /**
  12709. * Sub emitter class used to emit particles from an existing particle
  12710. */
  12711. export class SubEmitter {
  12712. /**
  12713. * the particle system to be used by the sub emitter
  12714. */
  12715. particleSystem: ParticleSystem;
  12716. /**
  12717. * Type of the submitter (Default: END)
  12718. */
  12719. type: SubEmitterType;
  12720. /**
  12721. * 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)
  12722. * Note: This only is supported when using an emitter of type Mesh
  12723. */
  12724. inheritDirection: boolean;
  12725. /**
  12726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12727. */
  12728. inheritedVelocityAmount: number;
  12729. /**
  12730. * Creates a sub emitter
  12731. * @param particleSystem the particle system to be used by the sub emitter
  12732. */
  12733. constructor(
  12734. /**
  12735. * the particle system to be used by the sub emitter
  12736. */
  12737. particleSystem: ParticleSystem);
  12738. /**
  12739. * Clones the sub emitter
  12740. * @returns the cloned sub emitter
  12741. */
  12742. clone(): SubEmitter;
  12743. /**
  12744. * Serialize current object to a JSON object
  12745. * @returns the serialized object
  12746. */
  12747. serialize(): any;
  12748. /** @hidden */
  12749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12750. /**
  12751. * Creates a new SubEmitter from a serialized JSON version
  12752. * @param serializationObject defines the JSON object to read from
  12753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12754. * @param rootUrl defines the rootUrl for data loading
  12755. * @returns a new SubEmitter
  12756. */
  12757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12758. /** Release associated resources */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12763. /** @hidden */
  12764. export var imageProcessingDeclaration: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12770. /** @hidden */
  12771. export var imageProcessingFunctions: {
  12772. name: string;
  12773. shader: string;
  12774. };
  12775. }
  12776. declare module "babylonjs/Shaders/particles.fragment" {
  12777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12782. /** @hidden */
  12783. export var particlesPixelShader: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/particles.vertex" {
  12789. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12791. /** @hidden */
  12792. export var particlesVertexShader: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12798. import { Nullable } from "babylonjs/types";
  12799. import { Plane } from "babylonjs/Maths/math";
  12800. /**
  12801. * Interface used to define entities containing multiple clip planes
  12802. */
  12803. export interface IClipPlanesHolder {
  12804. /**
  12805. * Gets or sets the active clipplane 1
  12806. */
  12807. clipPlane: Nullable<Plane>;
  12808. /**
  12809. * Gets or sets the active clipplane 2
  12810. */
  12811. clipPlane2: Nullable<Plane>;
  12812. /**
  12813. * Gets or sets the active clipplane 3
  12814. */
  12815. clipPlane3: Nullable<Plane>;
  12816. /**
  12817. * Gets or sets the active clipplane 4
  12818. */
  12819. clipPlane4: Nullable<Plane>;
  12820. /**
  12821. * Gets or sets the active clipplane 5
  12822. */
  12823. clipPlane5: Nullable<Plane>;
  12824. /**
  12825. * Gets or sets the active clipplane 6
  12826. */
  12827. clipPlane6: Nullable<Plane>;
  12828. }
  12829. }
  12830. declare module "babylonjs/Materials/thinMaterialHelper" {
  12831. import { Effect } from "babylonjs/Materials/effect";
  12832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12833. /**
  12834. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12835. *
  12836. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12837. *
  12838. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12839. */
  12840. export class ThinMaterialHelper {
  12841. /**
  12842. * Binds the clip plane information from the holder to the effect.
  12843. * @param effect The effect we are binding the data to
  12844. * @param holder The entity containing the clip plane information
  12845. */
  12846. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12847. }
  12848. }
  12849. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12850. module "babylonjs/Engines/thinEngine" {
  12851. interface ThinEngine {
  12852. /**
  12853. * Sets alpha constants used by some alpha blending modes
  12854. * @param r defines the red component
  12855. * @param g defines the green component
  12856. * @param b defines the blue component
  12857. * @param a defines the alpha component
  12858. */
  12859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12860. /**
  12861. * Sets the current alpha mode
  12862. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12865. */
  12866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12867. /**
  12868. * Gets the current alpha mode
  12869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12870. * @returns the current alpha mode
  12871. */
  12872. getAlphaMode(): number;
  12873. /**
  12874. * Sets the current alpha equation
  12875. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12876. */
  12877. setAlphaEquation(equation: number): void;
  12878. /**
  12879. * Gets the current alpha equation.
  12880. * @returns the current alpha equation
  12881. */
  12882. getAlphaEquation(): number;
  12883. }
  12884. }
  12885. }
  12886. declare module "babylonjs/Particles/particleSystem" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12889. import { Observable } from "babylonjs/Misc/observable";
  12890. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12891. import { Effect } from "babylonjs/Materials/effect";
  12892. import { IDisposable } from "babylonjs/scene";
  12893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12895. import { Particle } from "babylonjs/Particles/particle";
  12896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12897. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12898. import "babylonjs/Shaders/particles.fragment";
  12899. import "babylonjs/Shaders/particles.vertex";
  12900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12902. import "babylonjs/Engines/Extensions/engine.alpha";
  12903. import { Scene } from "babylonjs/scene";
  12904. /**
  12905. * This represents a particle system in Babylon.
  12906. * 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.
  12907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12908. * @example https://doc.babylonjs.com/babylon101/particles
  12909. */
  12910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12911. /**
  12912. * Billboard mode will only apply to Y axis
  12913. */
  12914. static readonly BILLBOARDMODE_Y: number;
  12915. /**
  12916. * Billboard mode will apply to all axes
  12917. */
  12918. static readonly BILLBOARDMODE_ALL: number;
  12919. /**
  12920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12921. */
  12922. static readonly BILLBOARDMODE_STRETCHED: number;
  12923. /**
  12924. * This function can be defined to provide custom update for active particles.
  12925. * This function will be called instead of regular update (age, position, color, etc.).
  12926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12927. */
  12928. updateFunction: (particles: Particle[]) => void;
  12929. private _emitterWorldMatrix;
  12930. /**
  12931. * This function can be defined to specify initial direction for every new particle.
  12932. * It by default use the emitterType defined function
  12933. */
  12934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12935. /**
  12936. * This function can be defined to specify initial position for every new particle.
  12937. * It by default use the emitterType defined function
  12938. */
  12939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12940. /**
  12941. * @hidden
  12942. */
  12943. _inheritedVelocityOffset: Vector3;
  12944. /**
  12945. * An event triggered when the system is disposed
  12946. */
  12947. onDisposeObservable: Observable<IParticleSystem>;
  12948. private _onDisposeObserver;
  12949. /**
  12950. * Sets a callback that will be triggered when the system is disposed
  12951. */
  12952. set onDispose(callback: () => void);
  12953. private _particles;
  12954. private _epsilon;
  12955. private _capacity;
  12956. private _stockParticles;
  12957. private _newPartsExcess;
  12958. private _vertexData;
  12959. private _vertexBuffer;
  12960. private _vertexBuffers;
  12961. private _spriteBuffer;
  12962. private _indexBuffer;
  12963. private _effect;
  12964. private _customEffect;
  12965. private _cachedDefines;
  12966. private _scaledColorStep;
  12967. private _colorDiff;
  12968. private _scaledDirection;
  12969. private _scaledGravity;
  12970. private _currentRenderId;
  12971. private _alive;
  12972. private _useInstancing;
  12973. private _started;
  12974. private _stopped;
  12975. private _actualFrame;
  12976. private _scaledUpdateSpeed;
  12977. private _vertexBufferSize;
  12978. /** @hidden */
  12979. _currentEmitRateGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentEmitRate1: number;
  12982. /** @hidden */
  12983. _currentEmitRate2: number;
  12984. /** @hidden */
  12985. _currentStartSizeGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentStartSize1: number;
  12988. /** @hidden */
  12989. _currentStartSize2: number;
  12990. private readonly _rawTextureWidth;
  12991. private _rampGradientsTexture;
  12992. private _useRampGradients;
  12993. /** Gets or sets a matrix to use to compute projection */
  12994. defaultProjectionMatrix: Matrix;
  12995. /** Gets or sets a matrix to use to compute view */
  12996. defaultViewMatrix: Matrix;
  12997. /** Gets or sets a boolean indicating that ramp gradients must be used
  12998. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12999. */
  13000. get useRampGradients(): boolean;
  13001. set useRampGradients(value: boolean);
  13002. /**
  13003. * 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.
  13004. * 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: [])
  13005. */
  13006. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13007. private _subEmitters;
  13008. /**
  13009. * @hidden
  13010. * If the particle systems emitter should be disposed when the particle system is disposed
  13011. */
  13012. _disposeEmitterOnDispose: boolean;
  13013. /**
  13014. * The current active Sub-systems, this property is used by the root particle system only.
  13015. */
  13016. activeSubSystems: Array<ParticleSystem>;
  13017. /**
  13018. * Specifies if the particles are updated in emitter local space or world space
  13019. */
  13020. isLocal: boolean;
  13021. private _rootParticleSystem;
  13022. /**
  13023. * Gets the current list of active particles
  13024. */
  13025. get particles(): Particle[];
  13026. /**
  13027. * Gets the number of particles active at the same time.
  13028. * @returns The number of active particles.
  13029. */
  13030. getActiveCount(): number;
  13031. /**
  13032. * Returns the string "ParticleSystem"
  13033. * @returns a string containing the class name
  13034. */
  13035. getClassName(): string;
  13036. /**
  13037. * Gets a boolean indicating that the system is stopping
  13038. * @returns true if the system is currently stopping
  13039. */
  13040. isStopping(): boolean;
  13041. /**
  13042. * Gets the custom effect used to render the particles
  13043. * @param blendMode Blend mode for which the effect should be retrieved
  13044. * @returns The effect
  13045. */
  13046. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13047. /**
  13048. * Sets the custom effect used to render the particles
  13049. * @param effect The effect to set
  13050. * @param blendMode Blend mode for which the effect should be set
  13051. */
  13052. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13053. /** @hidden */
  13054. private _onBeforeDrawParticlesObservable;
  13055. /**
  13056. * Observable that will be called just before the particles are drawn
  13057. */
  13058. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13059. /**
  13060. * Gets the name of the particle vertex shader
  13061. */
  13062. get vertexShaderName(): string;
  13063. /**
  13064. * Instantiates a particle system.
  13065. * 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.
  13066. * @param name The name of the particle system
  13067. * @param capacity The max number of particles alive at the same time
  13068. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13069. * @param customEffect a custom effect used to change the way particles are rendered by default
  13070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13071. * @param epsilon Offset used to render the particles
  13072. */
  13073. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13074. private _addFactorGradient;
  13075. private _removeFactorGradient;
  13076. /**
  13077. * Adds a new life time gradient
  13078. * @param gradient defines the gradient to use (between 0 and 1)
  13079. * @param factor defines the life time factor to affect to the specified gradient
  13080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13081. * @returns the current particle system
  13082. */
  13083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13084. /**
  13085. * Remove a specific life time gradient
  13086. * @param gradient defines the gradient to remove
  13087. * @returns the current particle system
  13088. */
  13089. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13090. /**
  13091. * Adds a new size gradient
  13092. * @param gradient defines the gradient to use (between 0 and 1)
  13093. * @param factor defines the size factor to affect to the specified gradient
  13094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13095. * @returns the current particle system
  13096. */
  13097. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13098. /**
  13099. * Remove a specific size gradient
  13100. * @param gradient defines the gradient to remove
  13101. * @returns the current particle system
  13102. */
  13103. removeSizeGradient(gradient: number): IParticleSystem;
  13104. /**
  13105. * Adds a new color remap gradient
  13106. * @param gradient defines the gradient to use (between 0 and 1)
  13107. * @param min defines the color remap minimal range
  13108. * @param max defines the color remap maximal range
  13109. * @returns the current particle system
  13110. */
  13111. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13112. /**
  13113. * Remove a specific color remap gradient
  13114. * @param gradient defines the gradient to remove
  13115. * @returns the current particle system
  13116. */
  13117. removeColorRemapGradient(gradient: number): IParticleSystem;
  13118. /**
  13119. * Adds a new alpha remap gradient
  13120. * @param gradient defines the gradient to use (between 0 and 1)
  13121. * @param min defines the alpha remap minimal range
  13122. * @param max defines the alpha remap maximal range
  13123. * @returns the current particle system
  13124. */
  13125. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13126. /**
  13127. * Remove a specific alpha remap gradient
  13128. * @param gradient defines the gradient to remove
  13129. * @returns the current particle system
  13130. */
  13131. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13132. /**
  13133. * Adds a new angular speed gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the angular speed to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific angular speed gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new velocity gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the velocity to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific velocity gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeVelocityGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new limit velocity gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param factor defines the limit velocity value to affect to the specified gradient
  13164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13165. * @returns the current particle system
  13166. */
  13167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific limit velocity gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new drag gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param factor defines the drag value to affect to the specified gradient
  13178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13179. * @returns the current particle system
  13180. */
  13181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific drag gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeDragGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the emit rate value to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific emit rate gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeEmitRateGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the start size value to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific start size gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeStartSizeGradient(gradient: number): IParticleSystem;
  13216. private _createRampGradientTexture;
  13217. /**
  13218. * Gets the current list of ramp gradients.
  13219. * You must use addRampGradient and removeRampGradient to udpate this list
  13220. * @returns the list of ramp gradients
  13221. */
  13222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13223. /** Force the system to rebuild all gradients that need to be resync */
  13224. forceRefreshGradients(): void;
  13225. private _syncRampGradientTexture;
  13226. /**
  13227. * Adds a new ramp gradient used to remap particle colors
  13228. * @param gradient defines the gradient to use (between 0 and 1)
  13229. * @param color defines the color to affect to the specified gradient
  13230. * @returns the current particle system
  13231. */
  13232. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13233. /**
  13234. * Remove a specific ramp gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeRampGradient(gradient: number): ParticleSystem;
  13239. /**
  13240. * Adds a new color gradient
  13241. * @param gradient defines the gradient to use (between 0 and 1)
  13242. * @param color1 defines the color to affect to the specified gradient
  13243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13244. * @returns this particle system
  13245. */
  13246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13247. /**
  13248. * Remove a specific color gradient
  13249. * @param gradient defines the gradient to remove
  13250. * @returns this particle system
  13251. */
  13252. removeColorGradient(gradient: number): IParticleSystem;
  13253. private _fetchR;
  13254. protected _reset(): void;
  13255. private _resetEffect;
  13256. private _createVertexBuffers;
  13257. private _createIndexBuffer;
  13258. /**
  13259. * Gets the maximum number of particles active at the same time.
  13260. * @returns The max number of active particles.
  13261. */
  13262. getCapacity(): number;
  13263. /**
  13264. * Gets whether there are still active particles in the system.
  13265. * @returns True if it is alive, otherwise false.
  13266. */
  13267. isAlive(): boolean;
  13268. /**
  13269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13270. * @returns True if it has been started, otherwise false.
  13271. */
  13272. isStarted(): boolean;
  13273. private _prepareSubEmitterInternalArray;
  13274. /**
  13275. * Starts the particle system and begins to emit
  13276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13277. */
  13278. start(delay?: number): void;
  13279. /**
  13280. * Stops the particle system.
  13281. * @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.
  13282. */
  13283. stop(stopSubEmitters?: boolean): void;
  13284. /**
  13285. * Remove all active particles
  13286. */
  13287. reset(): void;
  13288. /**
  13289. * @hidden (for internal use only)
  13290. */
  13291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13292. /**
  13293. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13294. * Its lifetime will start back at 0.
  13295. */
  13296. recycleParticle: (particle: Particle) => void;
  13297. private _stopSubEmitters;
  13298. private _createParticle;
  13299. private _removeFromRoot;
  13300. private _emitFromParticle;
  13301. private _update;
  13302. /** @hidden */
  13303. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13304. /** @hidden */
  13305. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13306. /**
  13307. * Fill the defines array according to the current settings of the particle system
  13308. * @param defines Array to be updated
  13309. * @param blendMode blend mode to take into account when updating the array
  13310. */
  13311. fillDefines(defines: Array<string>, blendMode: number): void;
  13312. /**
  13313. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13314. * @param uniforms Uniforms array to fill
  13315. * @param attributes Attributes array to fill
  13316. * @param samplers Samplers array to fill
  13317. */
  13318. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13319. /** @hidden */
  13320. private _getEffect;
  13321. /**
  13322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13323. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13324. */
  13325. animate(preWarmOnly?: boolean): void;
  13326. private _appendParticleVertices;
  13327. /**
  13328. * Rebuilds the particle system.
  13329. */
  13330. rebuild(): void;
  13331. /**
  13332. * Is this system ready to be used/rendered
  13333. * @return true if the system is ready
  13334. */
  13335. isReady(): boolean;
  13336. private _render;
  13337. /**
  13338. * Renders the particle system in its current state.
  13339. * @returns the current number of particles
  13340. */
  13341. render(): number;
  13342. /**
  13343. * Disposes the particle system and free the associated resources
  13344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13345. */
  13346. dispose(disposeTexture?: boolean): void;
  13347. /**
  13348. * Clones the particle system.
  13349. * @param name The name of the cloned object
  13350. * @param newEmitter The new emitter to use
  13351. * @returns the cloned particle system
  13352. */
  13353. clone(name: string, newEmitter: any): ParticleSystem;
  13354. /**
  13355. * Serializes the particle system to a JSON object
  13356. * @param serializeTexture defines if the texture must be serialized as well
  13357. * @returns the JSON object
  13358. */
  13359. serialize(serializeTexture?: boolean): any;
  13360. /** @hidden */
  13361. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13362. /** @hidden */
  13363. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13364. /**
  13365. * Parses a JSON object to create a particle system.
  13366. * @param parsedParticleSystem The JSON object to parse
  13367. * @param sceneOrEngine The scene or the engine to create the particle system in
  13368. * @param rootUrl The root url to use to load external dependencies like texture
  13369. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13370. * @returns the Parsed particle system
  13371. */
  13372. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13373. }
  13374. }
  13375. declare module "babylonjs/Particles/particle" {
  13376. import { Nullable } from "babylonjs/types";
  13377. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13378. import { Color4 } from "babylonjs/Maths/math.color";
  13379. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13380. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13381. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13382. /**
  13383. * A particle represents one of the element emitted by a particle system.
  13384. * This is mainly define by its coordinates, direction, velocity and age.
  13385. */
  13386. export class Particle {
  13387. /**
  13388. * The particle system the particle belongs to.
  13389. */
  13390. particleSystem: ParticleSystem;
  13391. private static _Count;
  13392. /**
  13393. * Unique ID of the particle
  13394. */
  13395. id: number;
  13396. /**
  13397. * The world position of the particle in the scene.
  13398. */
  13399. position: Vector3;
  13400. /**
  13401. * The world direction of the particle in the scene.
  13402. */
  13403. direction: Vector3;
  13404. /**
  13405. * The color of the particle.
  13406. */
  13407. color: Color4;
  13408. /**
  13409. * The color change of the particle per step.
  13410. */
  13411. colorStep: Color4;
  13412. /**
  13413. * Defines how long will the life of the particle be.
  13414. */
  13415. lifeTime: number;
  13416. /**
  13417. * The current age of the particle.
  13418. */
  13419. age: number;
  13420. /**
  13421. * The current size of the particle.
  13422. */
  13423. size: number;
  13424. /**
  13425. * The current scale of the particle.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * The current angle of the particle.
  13430. */
  13431. angle: number;
  13432. /**
  13433. * Defines how fast is the angle changing.
  13434. */
  13435. angularSpeed: number;
  13436. /**
  13437. * Defines the cell index used by the particle to be rendered from a sprite.
  13438. */
  13439. cellIndex: number;
  13440. /**
  13441. * The information required to support color remapping
  13442. */
  13443. remapData: Vector4;
  13444. /** @hidden */
  13445. _randomCellOffset?: number;
  13446. /** @hidden */
  13447. _initialDirection: Nullable<Vector3>;
  13448. /** @hidden */
  13449. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13450. /** @hidden */
  13451. _initialStartSpriteCellID: number;
  13452. /** @hidden */
  13453. _initialEndSpriteCellID: number;
  13454. /** @hidden */
  13455. _currentColorGradient: Nullable<ColorGradient>;
  13456. /** @hidden */
  13457. _currentColor1: Color4;
  13458. /** @hidden */
  13459. _currentColor2: Color4;
  13460. /** @hidden */
  13461. _currentSizeGradient: Nullable<FactorGradient>;
  13462. /** @hidden */
  13463. _currentSize1: number;
  13464. /** @hidden */
  13465. _currentSize2: number;
  13466. /** @hidden */
  13467. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13468. /** @hidden */
  13469. _currentAngularSpeed1: number;
  13470. /** @hidden */
  13471. _currentAngularSpeed2: number;
  13472. /** @hidden */
  13473. _currentVelocityGradient: Nullable<FactorGradient>;
  13474. /** @hidden */
  13475. _currentVelocity1: number;
  13476. /** @hidden */
  13477. _currentVelocity2: number;
  13478. /** @hidden */
  13479. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13480. /** @hidden */
  13481. _currentLimitVelocity1: number;
  13482. /** @hidden */
  13483. _currentLimitVelocity2: number;
  13484. /** @hidden */
  13485. _currentDragGradient: Nullable<FactorGradient>;
  13486. /** @hidden */
  13487. _currentDrag1: number;
  13488. /** @hidden */
  13489. _currentDrag2: number;
  13490. /** @hidden */
  13491. _randomNoiseCoordinates1: Vector3;
  13492. /** @hidden */
  13493. _randomNoiseCoordinates2: Vector3;
  13494. /** @hidden */
  13495. _localPosition?: Vector3;
  13496. /**
  13497. * Creates a new instance Particle
  13498. * @param particleSystem the particle system the particle belongs to
  13499. */
  13500. constructor(
  13501. /**
  13502. * The particle system the particle belongs to.
  13503. */
  13504. particleSystem: ParticleSystem);
  13505. private updateCellInfoFromSystem;
  13506. /**
  13507. * Defines how the sprite cell index is updated for the particle
  13508. */
  13509. updateCellIndex(): void;
  13510. /** @hidden */
  13511. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13512. /** @hidden */
  13513. _inheritParticleInfoToSubEmitters(): void;
  13514. /** @hidden */
  13515. _reset(): void;
  13516. /**
  13517. * Copy the properties of particle to another one.
  13518. * @param other the particle to copy the information to.
  13519. */
  13520. copyTo(other: Particle): void;
  13521. }
  13522. }
  13523. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13525. import { Effect } from "babylonjs/Materials/effect";
  13526. import { Particle } from "babylonjs/Particles/particle";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { Scene } from "babylonjs/scene";
  13529. /**
  13530. * Particle emitter represents a volume emitting particles.
  13531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13532. */
  13533. export interface IParticleEmitterType {
  13534. /**
  13535. * Called by the particle System when the direction is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param directionToUpdate is the direction vector to update with the result
  13538. * @param particle is the particle we are computed the direction for
  13539. * @param isLocal defines if the direction should be set in local space
  13540. */
  13541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Called by the particle System when the position is computed for the created particle.
  13544. * @param worldMatrix is the world matrix of the particle system
  13545. * @param positionToUpdate is the position vector to update with the result
  13546. * @param particle is the particle we are computed the position for
  13547. * @param isLocal defines if the position should be set in local space
  13548. */
  13549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13550. /**
  13551. * Clones the current emitter and returns a copy of it
  13552. * @returns the new emitter
  13553. */
  13554. clone(): IParticleEmitterType;
  13555. /**
  13556. * Called by the GPUParticleSystem to setup the update shader
  13557. * @param effect defines the update shader
  13558. */
  13559. applyToShader(effect: Effect): void;
  13560. /**
  13561. * Returns a string to use to update the GPU particles update shader
  13562. * @returns the effect defines string
  13563. */
  13564. getEffectDefines(): string;
  13565. /**
  13566. * Returns a string representing the class name
  13567. * @returns a string containing the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Serializes the particle system to a JSON object.
  13572. * @returns the JSON object
  13573. */
  13574. serialize(): any;
  13575. /**
  13576. * Parse properties from a JSON object
  13577. * @param serializationObject defines the JSON object
  13578. * @param scene defines the hosting scene
  13579. */
  13580. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13585. import { Effect } from "babylonjs/Materials/effect";
  13586. import { Particle } from "babylonjs/Particles/particle";
  13587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a box.
  13590. * It emits the particles randomly between 2 given directions.
  13591. */
  13592. export class BoxParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13595. */
  13596. direction1: Vector3;
  13597. /**
  13598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13599. */
  13600. direction2: Vector3;
  13601. /**
  13602. * 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.
  13603. */
  13604. minEmitBox: Vector3;
  13605. /**
  13606. * 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.
  13607. */
  13608. maxEmitBox: Vector3;
  13609. /**
  13610. * Creates a new instance BoxParticleEmitter
  13611. */
  13612. constructor();
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. * @param isLocal defines if the direction should be set in local space
  13619. */
  13620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Called by the particle System when the position is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param positionToUpdate is the position vector to update with the result
  13625. * @param particle is the particle we are computed the position for
  13626. * @param isLocal defines if the position should be set in local space
  13627. */
  13628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): BoxParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "BoxParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13663. import { Effect } from "babylonjs/Materials/effect";
  13664. import { Particle } from "babylonjs/Particles/particle";
  13665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13666. /**
  13667. * Particle emitter emitting particles from the inside of a cone.
  13668. * It emits the particles alongside the cone volume from the base to the particle.
  13669. * The emission direction might be randomized.
  13670. */
  13671. export class ConeParticleEmitter implements IParticleEmitterType {
  13672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13673. directionRandomizer: number;
  13674. private _radius;
  13675. private _angle;
  13676. private _height;
  13677. /**
  13678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13679. */
  13680. radiusRange: number;
  13681. /**
  13682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13683. */
  13684. heightRange: number;
  13685. /**
  13686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13687. */
  13688. emitFromSpawnPointOnly: boolean;
  13689. /**
  13690. * Gets or sets the radius of the emission cone
  13691. */
  13692. get radius(): number;
  13693. set radius(value: number);
  13694. /**
  13695. * Gets or sets the angle of the emission cone
  13696. */
  13697. get angle(): number;
  13698. set angle(value: number);
  13699. private _buildHeight;
  13700. /**
  13701. * Creates a new instance ConeParticleEmitter
  13702. * @param radius the radius of the emission cone (1 by default)
  13703. * @param angle the cone base angle (PI by default)
  13704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13705. */
  13706. constructor(radius?: number, angle?: number,
  13707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13708. directionRandomizer?: number);
  13709. /**
  13710. * Called by the particle System when the direction is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param directionToUpdate is the direction vector to update with the result
  13713. * @param particle is the particle we are computed the direction for
  13714. * @param isLocal defines if the direction should be set in local space
  13715. */
  13716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Called by the particle System when the position is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param positionToUpdate is the position vector to update with the result
  13721. * @param particle is the particle we are computed the position for
  13722. * @param isLocal defines if the position should be set in local space
  13723. */
  13724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Clones the current emitter and returns a copy of it
  13727. * @returns the new emitter
  13728. */
  13729. clone(): ConeParticleEmitter;
  13730. /**
  13731. * Called by the GPUParticleSystem to setup the update shader
  13732. * @param effect defines the update shader
  13733. */
  13734. applyToShader(effect: Effect): void;
  13735. /**
  13736. * Returns a string to use to update the GPU particles update shader
  13737. * @returns a string containng the defines string
  13738. */
  13739. getEffectDefines(): string;
  13740. /**
  13741. * Returns the string "ConeParticleEmitter"
  13742. * @returns a string containing the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Serializes the particle system to a JSON object.
  13747. * @returns the JSON object
  13748. */
  13749. serialize(): any;
  13750. /**
  13751. * Parse properties from a JSON object
  13752. * @param serializationObject defines the JSON object
  13753. */
  13754. parse(serializationObject: any): void;
  13755. }
  13756. }
  13757. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13759. import { Effect } from "babylonjs/Materials/effect";
  13760. import { Particle } from "babylonjs/Particles/particle";
  13761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a cylinder.
  13764. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13765. */
  13766. export class CylinderParticleEmitter implements IParticleEmitterType {
  13767. /**
  13768. * The radius of the emission cylinder.
  13769. */
  13770. radius: number;
  13771. /**
  13772. * The height of the emission cylinder.
  13773. */
  13774. height: number;
  13775. /**
  13776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13777. */
  13778. radiusRange: number;
  13779. /**
  13780. * How much to randomize the particle direction [0-1].
  13781. */
  13782. directionRandomizer: number;
  13783. /**
  13784. * Creates a new instance CylinderParticleEmitter
  13785. * @param radius the radius of the emission cylinder (1 by default)
  13786. * @param height the height of the emission cylinder (1 by default)
  13787. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission cylinder.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The height of the emission cylinder.
  13797. */
  13798. height?: number,
  13799. /**
  13800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13801. */
  13802. radiusRange?: number,
  13803. /**
  13804. * How much to randomize the particle direction [0-1].
  13805. */
  13806. directionRandomizer?: number);
  13807. /**
  13808. * Called by the particle System when the direction is computed for the created particle.
  13809. * @param worldMatrix is the world matrix of the particle system
  13810. * @param directionToUpdate is the direction vector to update with the result
  13811. * @param particle is the particle we are computed the direction for
  13812. * @param isLocal defines if the direction should be set in local space
  13813. */
  13814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13815. /**
  13816. * Called by the particle System when the position is computed for the created particle.
  13817. * @param worldMatrix is the world matrix of the particle system
  13818. * @param positionToUpdate is the position vector to update with the result
  13819. * @param particle is the particle we are computed the position for
  13820. * @param isLocal defines if the position should be set in local space
  13821. */
  13822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13823. /**
  13824. * Clones the current emitter and returns a copy of it
  13825. * @returns the new emitter
  13826. */
  13827. clone(): CylinderParticleEmitter;
  13828. /**
  13829. * Called by the GPUParticleSystem to setup the update shader
  13830. * @param effect defines the update shader
  13831. */
  13832. applyToShader(effect: Effect): void;
  13833. /**
  13834. * Returns a string to use to update the GPU particles update shader
  13835. * @returns a string containng the defines string
  13836. */
  13837. getEffectDefines(): string;
  13838. /**
  13839. * Returns the string "CylinderParticleEmitter"
  13840. * @returns a string containing the class name
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Serializes the particle system to a JSON object.
  13845. * @returns the JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Parse properties from a JSON object
  13850. * @param serializationObject defines the JSON object
  13851. */
  13852. parse(serializationObject: any): void;
  13853. }
  13854. /**
  13855. * Particle emitter emitting particles from the inside of a cylinder.
  13856. * It emits the particles randomly between two vectors.
  13857. */
  13858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13859. /**
  13860. * The min limit of the emission direction.
  13861. */
  13862. direction1: Vector3;
  13863. /**
  13864. * The max limit of the emission direction.
  13865. */
  13866. direction2: Vector3;
  13867. /**
  13868. * Creates a new instance CylinderDirectedParticleEmitter
  13869. * @param radius the radius of the emission cylinder (1 by default)
  13870. * @param height the height of the emission cylinder (1 by default)
  13871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13872. * @param direction1 the min limit of the emission direction (up vector by default)
  13873. * @param direction2 the max limit of the emission direction (up vector by default)
  13874. */
  13875. constructor(radius?: number, height?: number, radiusRange?: number,
  13876. /**
  13877. * The min limit of the emission direction.
  13878. */
  13879. direction1?: Vector3,
  13880. /**
  13881. * The max limit of the emission direction.
  13882. */
  13883. direction2?: Vector3);
  13884. /**
  13885. * Called by the particle System when the direction is computed for the created particle.
  13886. * @param worldMatrix is the world matrix of the particle system
  13887. * @param directionToUpdate is the direction vector to update with the result
  13888. * @param particle is the particle we are computed the direction for
  13889. */
  13890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13891. /**
  13892. * Clones the current emitter and returns a copy of it
  13893. * @returns the new emitter
  13894. */
  13895. clone(): CylinderDirectedParticleEmitter;
  13896. /**
  13897. * Called by the GPUParticleSystem to setup the update shader
  13898. * @param effect defines the update shader
  13899. */
  13900. applyToShader(effect: Effect): void;
  13901. /**
  13902. * Returns a string to use to update the GPU particles update shader
  13903. * @returns a string containng the defines string
  13904. */
  13905. getEffectDefines(): string;
  13906. /**
  13907. * Returns the string "CylinderDirectedParticleEmitter"
  13908. * @returns a string containing the class name
  13909. */
  13910. getClassName(): string;
  13911. /**
  13912. * Serializes the particle system to a JSON object.
  13913. * @returns the JSON object
  13914. */
  13915. serialize(): any;
  13916. /**
  13917. * Parse properties from a JSON object
  13918. * @param serializationObject defines the JSON object
  13919. */
  13920. parse(serializationObject: any): void;
  13921. }
  13922. }
  13923. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13924. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13925. import { Effect } from "babylonjs/Materials/effect";
  13926. import { Particle } from "babylonjs/Particles/particle";
  13927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13928. /**
  13929. * Particle emitter emitting particles from the inside of a hemisphere.
  13930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13931. */
  13932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius: number;
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange: number;
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer: number;
  13945. /**
  13946. * Creates a new instance HemisphericParticleEmitter
  13947. * @param radius the radius of the emission hemisphere (1 by default)
  13948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13950. */
  13951. constructor(
  13952. /**
  13953. * The radius of the emission hemisphere.
  13954. */
  13955. radius?: number,
  13956. /**
  13957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13958. */
  13959. radiusRange?: number,
  13960. /**
  13961. * How much to randomize the particle direction [0-1].
  13962. */
  13963. directionRandomizer?: number);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): HemisphericParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "HemisphericParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. */
  14009. parse(serializationObject: any): void;
  14010. }
  14011. }
  14012. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14013. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14014. import { Effect } from "babylonjs/Materials/effect";
  14015. import { Particle } from "babylonjs/Particles/particle";
  14016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14017. /**
  14018. * Particle emitter emitting particles from a point.
  14019. * It emits the particles randomly between 2 given directions.
  14020. */
  14021. export class PointParticleEmitter implements IParticleEmitterType {
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Creates a new instance PointParticleEmitter
  14032. */
  14033. constructor();
  14034. /**
  14035. * Called by the particle System when the direction is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param directionToUpdate is the direction vector to update with the result
  14038. * @param particle is the particle we are computed the direction for
  14039. * @param isLocal defines if the direction should be set in local space
  14040. */
  14041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Called by the particle System when the position is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param positionToUpdate is the position vector to update with the result
  14046. * @param particle is the particle we are computed the position for
  14047. * @param isLocal defines if the position should be set in local space
  14048. */
  14049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Clones the current emitter and returns a copy of it
  14052. * @returns the new emitter
  14053. */
  14054. clone(): PointParticleEmitter;
  14055. /**
  14056. * Called by the GPUParticleSystem to setup the update shader
  14057. * @param effect defines the update shader
  14058. */
  14059. applyToShader(effect: Effect): void;
  14060. /**
  14061. * Returns a string to use to update the GPU particles update shader
  14062. * @returns a string containng the defines string
  14063. */
  14064. getEffectDefines(): string;
  14065. /**
  14066. * Returns the string "PointParticleEmitter"
  14067. * @returns a string containing the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Serializes the particle system to a JSON object.
  14072. * @returns the JSON object
  14073. */
  14074. serialize(): any;
  14075. /**
  14076. * Parse properties from a JSON object
  14077. * @param serializationObject defines the JSON object
  14078. */
  14079. parse(serializationObject: any): void;
  14080. }
  14081. }
  14082. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14084. import { Effect } from "babylonjs/Materials/effect";
  14085. import { Particle } from "babylonjs/Particles/particle";
  14086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14087. /**
  14088. * Particle emitter emitting particles from the inside of a sphere.
  14089. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14090. */
  14091. export class SphereParticleEmitter implements IParticleEmitterType {
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius: number;
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange: number;
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer: number;
  14104. /**
  14105. * Creates a new instance SphereParticleEmitter
  14106. * @param radius the radius of the emission sphere (1 by default)
  14107. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14109. */
  14110. constructor(
  14111. /**
  14112. * The radius of the emission sphere.
  14113. */
  14114. radius?: number,
  14115. /**
  14116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14117. */
  14118. radiusRange?: number,
  14119. /**
  14120. * How much to randomize the particle direction [0-1].
  14121. */
  14122. directionRandomizer?: number);
  14123. /**
  14124. * Called by the particle System when the direction is computed for the created particle.
  14125. * @param worldMatrix is the world matrix of the particle system
  14126. * @param directionToUpdate is the direction vector to update with the result
  14127. * @param particle is the particle we are computed the direction for
  14128. * @param isLocal defines if the direction should be set in local space
  14129. */
  14130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14131. /**
  14132. * Called by the particle System when the position is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param positionToUpdate is the position vector to update with the result
  14135. * @param particle is the particle we are computed the position for
  14136. * @param isLocal defines if the position should be set in local space
  14137. */
  14138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14139. /**
  14140. * Clones the current emitter and returns a copy of it
  14141. * @returns the new emitter
  14142. */
  14143. clone(): SphereParticleEmitter;
  14144. /**
  14145. * Called by the GPUParticleSystem to setup the update shader
  14146. * @param effect defines the update shader
  14147. */
  14148. applyToShader(effect: Effect): void;
  14149. /**
  14150. * Returns a string to use to update the GPU particles update shader
  14151. * @returns a string containng the defines string
  14152. */
  14153. getEffectDefines(): string;
  14154. /**
  14155. * Returns the string "SphereParticleEmitter"
  14156. * @returns a string containing the class name
  14157. */
  14158. getClassName(): string;
  14159. /**
  14160. * Serializes the particle system to a JSON object.
  14161. * @returns the JSON object
  14162. */
  14163. serialize(): any;
  14164. /**
  14165. * Parse properties from a JSON object
  14166. * @param serializationObject defines the JSON object
  14167. */
  14168. parse(serializationObject: any): void;
  14169. }
  14170. /**
  14171. * Particle emitter emitting particles from the inside of a sphere.
  14172. * It emits the particles randomly between two vectors.
  14173. */
  14174. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14175. /**
  14176. * The min limit of the emission direction.
  14177. */
  14178. direction1: Vector3;
  14179. /**
  14180. * The max limit of the emission direction.
  14181. */
  14182. direction2: Vector3;
  14183. /**
  14184. * Creates a new instance SphereDirectedParticleEmitter
  14185. * @param radius the radius of the emission sphere (1 by default)
  14186. * @param direction1 the min limit of the emission direction (up vector by default)
  14187. * @param direction2 the max limit of the emission direction (up vector by default)
  14188. */
  14189. constructor(radius?: number,
  14190. /**
  14191. * The min limit of the emission direction.
  14192. */
  14193. direction1?: Vector3,
  14194. /**
  14195. * The max limit of the emission direction.
  14196. */
  14197. direction2?: Vector3);
  14198. /**
  14199. * Called by the particle System when the direction is computed for the created particle.
  14200. * @param worldMatrix is the world matrix of the particle system
  14201. * @param directionToUpdate is the direction vector to update with the result
  14202. * @param particle is the particle we are computed the direction for
  14203. */
  14204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14205. /**
  14206. * Clones the current emitter and returns a copy of it
  14207. * @returns the new emitter
  14208. */
  14209. clone(): SphereDirectedParticleEmitter;
  14210. /**
  14211. * Called by the GPUParticleSystem to setup the update shader
  14212. * @param effect defines the update shader
  14213. */
  14214. applyToShader(effect: Effect): void;
  14215. /**
  14216. * Returns a string to use to update the GPU particles update shader
  14217. * @returns a string containng the defines string
  14218. */
  14219. getEffectDefines(): string;
  14220. /**
  14221. * Returns the string "SphereDirectedParticleEmitter"
  14222. * @returns a string containing the class name
  14223. */
  14224. getClassName(): string;
  14225. /**
  14226. * Serializes the particle system to a JSON object.
  14227. * @returns the JSON object
  14228. */
  14229. serialize(): any;
  14230. /**
  14231. * Parse properties from a JSON object
  14232. * @param serializationObject defines the JSON object
  14233. */
  14234. parse(serializationObject: any): void;
  14235. }
  14236. }
  14237. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14239. import { Effect } from "babylonjs/Materials/effect";
  14240. import { Particle } from "babylonjs/Particles/particle";
  14241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14242. import { Nullable } from "babylonjs/types";
  14243. /**
  14244. * Particle emitter emitting particles from a custom list of positions.
  14245. */
  14246. export class CustomParticleEmitter implements IParticleEmitterType {
  14247. /**
  14248. * Gets or sets the position generator that will create the inital position of each particle.
  14249. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14250. */
  14251. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14252. /**
  14253. * Gets or sets the destination generator that will create the final destination of each particle.
  14254. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14255. */
  14256. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14257. /**
  14258. * Creates a new instance CustomParticleEmitter
  14259. */
  14260. constructor();
  14261. /**
  14262. * Called by the particle System when the direction is computed for the created particle.
  14263. * @param worldMatrix is the world matrix of the particle system
  14264. * @param directionToUpdate is the direction vector to update with the result
  14265. * @param particle is the particle we are computed the direction for
  14266. * @param isLocal defines if the direction should be set in local space
  14267. */
  14268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14269. /**
  14270. * Called by the particle System when the position is computed for the created particle.
  14271. * @param worldMatrix is the world matrix of the particle system
  14272. * @param positionToUpdate is the position vector to update with the result
  14273. * @param particle is the particle we are computed the position for
  14274. * @param isLocal defines if the position should be set in local space
  14275. */
  14276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14277. /**
  14278. * Clones the current emitter and returns a copy of it
  14279. * @returns the new emitter
  14280. */
  14281. clone(): CustomParticleEmitter;
  14282. /**
  14283. * Called by the GPUParticleSystem to setup the update shader
  14284. * @param effect defines the update shader
  14285. */
  14286. applyToShader(effect: Effect): void;
  14287. /**
  14288. * Returns a string to use to update the GPU particles update shader
  14289. * @returns a string containng the defines string
  14290. */
  14291. getEffectDefines(): string;
  14292. /**
  14293. * Returns the string "PointParticleEmitter"
  14294. * @returns a string containing the class name
  14295. */
  14296. getClassName(): string;
  14297. /**
  14298. * Serializes the particle system to a JSON object.
  14299. * @returns the JSON object
  14300. */
  14301. serialize(): any;
  14302. /**
  14303. * Parse properties from a JSON object
  14304. * @param serializationObject defines the JSON object
  14305. */
  14306. parse(serializationObject: any): void;
  14307. }
  14308. }
  14309. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14311. import { Effect } from "babylonjs/Materials/effect";
  14312. import { Particle } from "babylonjs/Particles/particle";
  14313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14314. import { Nullable } from "babylonjs/types";
  14315. import { Scene } from "babylonjs/scene";
  14316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14317. /**
  14318. * Particle emitter emitting particles from the inside of a box.
  14319. * It emits the particles randomly between 2 given directions.
  14320. */
  14321. export class MeshParticleEmitter implements IParticleEmitterType {
  14322. private _indices;
  14323. private _positions;
  14324. private _normals;
  14325. private _storedNormal;
  14326. private _mesh;
  14327. /**
  14328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14329. */
  14330. direction1: Vector3;
  14331. /**
  14332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14333. */
  14334. direction2: Vector3;
  14335. /**
  14336. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14337. */
  14338. useMeshNormalsForDirection: boolean;
  14339. /** Defines the mesh to use as source */
  14340. get mesh(): Nullable<AbstractMesh>;
  14341. set mesh(value: Nullable<AbstractMesh>);
  14342. /**
  14343. * Creates a new instance MeshParticleEmitter
  14344. * @param mesh defines the mesh to use as source
  14345. */
  14346. constructor(mesh?: Nullable<AbstractMesh>);
  14347. /**
  14348. * Called by the particle System when the direction is computed for the created particle.
  14349. * @param worldMatrix is the world matrix of the particle system
  14350. * @param directionToUpdate is the direction vector to update with the result
  14351. * @param particle is the particle we are computed the direction for
  14352. * @param isLocal defines if the direction should be set in local space
  14353. */
  14354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14355. /**
  14356. * Called by the particle System when the position is computed for the created particle.
  14357. * @param worldMatrix is the world matrix of the particle system
  14358. * @param positionToUpdate is the position vector to update with the result
  14359. * @param particle is the particle we are computed the position for
  14360. * @param isLocal defines if the position should be set in local space
  14361. */
  14362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14363. /**
  14364. * Clones the current emitter and returns a copy of it
  14365. * @returns the new emitter
  14366. */
  14367. clone(): MeshParticleEmitter;
  14368. /**
  14369. * Called by the GPUParticleSystem to setup the update shader
  14370. * @param effect defines the update shader
  14371. */
  14372. applyToShader(effect: Effect): void;
  14373. /**
  14374. * Returns a string to use to update the GPU particles update shader
  14375. * @returns a string containng the defines string
  14376. */
  14377. getEffectDefines(): string;
  14378. /**
  14379. * Returns the string "BoxParticleEmitter"
  14380. * @returns a string containing the class name
  14381. */
  14382. getClassName(): string;
  14383. /**
  14384. * Serializes the particle system to a JSON object.
  14385. * @returns the JSON object
  14386. */
  14387. serialize(): any;
  14388. /**
  14389. * Parse properties from a JSON object
  14390. * @param serializationObject defines the JSON object
  14391. * @param scene defines the hosting scene
  14392. */
  14393. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14394. }
  14395. }
  14396. declare module "babylonjs/Particles/EmitterTypes/index" {
  14397. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14398. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14402. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14403. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14406. }
  14407. declare module "babylonjs/Particles/IParticleSystem" {
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14415. import { Effect } from "babylonjs/Materials/effect";
  14416. import { Observable } from "babylonjs/Misc/observable";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14419. /**
  14420. * Interface representing a particle system in Babylon.js.
  14421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14423. */
  14424. export interface IParticleSystem {
  14425. /**
  14426. * List of animations used by the particle system.
  14427. */
  14428. animations: Animation[];
  14429. /**
  14430. * The id of the Particle system.
  14431. */
  14432. id: string;
  14433. /**
  14434. * The name of the Particle system.
  14435. */
  14436. name: string;
  14437. /**
  14438. * The emitter represents the Mesh or position we are attaching the particle system to.
  14439. */
  14440. emitter: Nullable<AbstractMesh | Vector3>;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The layer mask we are rendering the particles through.
  14451. */
  14452. layerMask: number;
  14453. /**
  14454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14455. */
  14456. updateSpeed: number;
  14457. /**
  14458. * The amount of time the particle system is running (depends of the overall update speed).
  14459. */
  14460. targetStopDuration: number;
  14461. /**
  14462. * The texture used to render each particle. (this can be a spritesheet)
  14463. */
  14464. particleTexture: Nullable<BaseTexture>;
  14465. /**
  14466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14467. */
  14468. blendMode: number;
  14469. /**
  14470. * Minimum life time of emitting particles.
  14471. */
  14472. minLifeTime: number;
  14473. /**
  14474. * Maximum life time of emitting particles.
  14475. */
  14476. maxLifeTime: number;
  14477. /**
  14478. * Minimum Size of emitting particles.
  14479. */
  14480. minSize: number;
  14481. /**
  14482. * Maximum Size of emitting particles.
  14483. */
  14484. maxSize: number;
  14485. /**
  14486. * Minimum scale of emitting particles on X axis.
  14487. */
  14488. minScaleX: number;
  14489. /**
  14490. * Maximum scale of emitting particles on X axis.
  14491. */
  14492. maxScaleX: number;
  14493. /**
  14494. * Minimum scale of emitting particles on Y axis.
  14495. */
  14496. minScaleY: number;
  14497. /**
  14498. * Maximum scale of emitting particles on Y axis.
  14499. */
  14500. maxScaleY: number;
  14501. /**
  14502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14503. */
  14504. color1: Color4;
  14505. /**
  14506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14507. */
  14508. color2: Color4;
  14509. /**
  14510. * Color the particle will have at the end of its lifetime.
  14511. */
  14512. colorDead: Color4;
  14513. /**
  14514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14515. */
  14516. emitRate: number;
  14517. /**
  14518. * You can use gravity if you want to give an orientation to your particles.
  14519. */
  14520. gravity: Vector3;
  14521. /**
  14522. * Minimum power of emitting particles.
  14523. */
  14524. minEmitPower: number;
  14525. /**
  14526. * Maximum power of emitting particles.
  14527. */
  14528. maxEmitPower: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * Gets or sets the minimal initial rotation in radians.
  14539. */
  14540. minInitialRotation: number;
  14541. /**
  14542. * Gets or sets the maximal initial rotation in radians.
  14543. */
  14544. maxInitialRotation: number;
  14545. /**
  14546. * The particle emitter type defines the emitter used by the particle system.
  14547. * It can be for example box, sphere, or cone...
  14548. */
  14549. particleEmitterType: Nullable<IParticleEmitterType>;
  14550. /**
  14551. * Defines the delay in milliseconds before starting the system (0 by default)
  14552. */
  14553. startDelay: number;
  14554. /**
  14555. * 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
  14556. */
  14557. preWarmCycles: number;
  14558. /**
  14559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14560. */
  14561. preWarmStepOffset: number;
  14562. /**
  14563. * 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)
  14564. */
  14565. spriteCellChangeSpeed: number;
  14566. /**
  14567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14568. */
  14569. startSpriteCellID: number;
  14570. /**
  14571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14572. */
  14573. endSpriteCellID: number;
  14574. /**
  14575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14576. */
  14577. spriteCellWidth: number;
  14578. /**
  14579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14580. */
  14581. spriteCellHeight: number;
  14582. /**
  14583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14584. */
  14585. spriteRandomStartCell: boolean;
  14586. /**
  14587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14588. */
  14589. isAnimationSheetEnabled: boolean;
  14590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14591. translationPivot: Vector2;
  14592. /**
  14593. * Gets or sets a texture used to add random noise to particle positions
  14594. */
  14595. noiseTexture: Nullable<BaseTexture>;
  14596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14597. noiseStrength: Vector3;
  14598. /**
  14599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14601. */
  14602. billboardMode: number;
  14603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14604. limitVelocityDamping: number;
  14605. /**
  14606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14607. */
  14608. beginAnimationOnStart: boolean;
  14609. /**
  14610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14611. */
  14612. beginAnimationFrom: number;
  14613. /**
  14614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14615. */
  14616. beginAnimationTo: number;
  14617. /**
  14618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationLoop: boolean;
  14621. /**
  14622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14623. */
  14624. disposeOnStop: boolean;
  14625. /**
  14626. * Specifies if the particles are updated in emitter local space or world space
  14627. */
  14628. isLocal: boolean;
  14629. /** Snippet ID if the particle system was created from the snippet server */
  14630. snippetId: string;
  14631. /** Gets or sets a matrix to use to compute projection */
  14632. defaultProjectionMatrix: Matrix;
  14633. /**
  14634. * Gets the maximum number of particles active at the same time.
  14635. * @returns The max number of active particles.
  14636. */
  14637. getCapacity(): number;
  14638. /**
  14639. * Gets the number of particles active at the same time.
  14640. * @returns The number of active particles.
  14641. */
  14642. getActiveCount(): number;
  14643. /**
  14644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14645. * @returns True if it has been started, otherwise false.
  14646. */
  14647. isStarted(): boolean;
  14648. /**
  14649. * Animates the particle system for this frame.
  14650. */
  14651. animate(): void;
  14652. /**
  14653. * Renders the particle system in its current state.
  14654. * @returns the current number of particles
  14655. */
  14656. render(): number;
  14657. /**
  14658. * Dispose the particle system and frees its associated resources.
  14659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14660. */
  14661. dispose(disposeTexture?: boolean): void;
  14662. /**
  14663. * An event triggered when the system is disposed
  14664. */
  14665. onDisposeObservable: Observable<IParticleSystem>;
  14666. /**
  14667. * Clones the particle system.
  14668. * @param name The name of the cloned object
  14669. * @param newEmitter The new emitter to use
  14670. * @returns the cloned particle system
  14671. */
  14672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14673. /**
  14674. * Serializes the particle system to a JSON object
  14675. * @param serializeTexture defines if the texture must be serialized as well
  14676. * @returns the JSON object
  14677. */
  14678. serialize(serializeTexture: boolean): any;
  14679. /**
  14680. * Rebuild the particle system
  14681. */
  14682. rebuild(): void;
  14683. /** Force the system to rebuild all gradients that need to be resync */
  14684. forceRefreshGradients(): void;
  14685. /**
  14686. * Starts the particle system and begins to emit
  14687. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14688. */
  14689. start(delay?: number): void;
  14690. /**
  14691. * Stops the particle system.
  14692. */
  14693. stop(): void;
  14694. /**
  14695. * Remove all active particles
  14696. */
  14697. reset(): void;
  14698. /**
  14699. * Gets a boolean indicating that the system is stopping
  14700. * @returns true if the system is currently stopping
  14701. */
  14702. isStopping(): boolean;
  14703. /**
  14704. * Is this system ready to be used/rendered
  14705. * @return true if the system is ready
  14706. */
  14707. isReady(): boolean;
  14708. /**
  14709. * Returns the string "ParticleSystem"
  14710. * @returns a string containing the class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets the custom effect used to render the particles
  14715. * @param blendMode Blend mode for which the effect should be retrieved
  14716. * @returns The effect
  14717. */
  14718. getCustomEffect(blendMode: number): Nullable<Effect>;
  14719. /**
  14720. * Sets the custom effect used to render the particles
  14721. * @param effect The effect to set
  14722. * @param blendMode Blend mode for which the effect should be set
  14723. */
  14724. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14725. /**
  14726. * Fill the defines array according to the current settings of the particle system
  14727. * @param defines Array to be updated
  14728. * @param blendMode blend mode to take into account when updating the array
  14729. */
  14730. fillDefines(defines: Array<string>, blendMode: number): void;
  14731. /**
  14732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14733. * @param uniforms Uniforms array to fill
  14734. * @param attributes Attributes array to fill
  14735. * @param samplers Samplers array to fill
  14736. */
  14737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14738. /**
  14739. * Observable that will be called just before the particles are drawn
  14740. */
  14741. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14742. /**
  14743. * Gets the name of the particle vertex shader
  14744. */
  14745. vertexShaderName: string;
  14746. /**
  14747. * Adds a new color gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color1 defines the color to affect to the specified gradient
  14750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14751. * @returns the current particle system
  14752. */
  14753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14754. /**
  14755. * Remove a specific color gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeColorGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new size gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the size factor to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific size gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeSizeGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Gets the current list of color gradients.
  14776. * You must use addColorGradient and removeColorGradient to udpate this list
  14777. * @returns the list of color gradients
  14778. */
  14779. getColorGradients(): Nullable<Array<ColorGradient>>;
  14780. /**
  14781. * Gets the current list of size gradients.
  14782. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14783. * @returns the list of size gradients
  14784. */
  14785. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14786. /**
  14787. * Gets the current list of angular speed gradients.
  14788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14789. * @returns the list of angular speed gradients
  14790. */
  14791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Gets the current list of velocity gradients.
  14808. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14809. * @returns the list of velocity gradients
  14810. */
  14811. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Adds a new velocity gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the velocity to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific velocity gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeVelocityGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of limit velocity gradients.
  14828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14829. * @returns the list of limit velocity gradients
  14830. */
  14831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new limit velocity gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the limit velocity to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific limit velocity gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new drag gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the drag to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific drag gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeDragGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Gets the current list of drag gradients.
  14862. * You must use addDragGradient and removeDragGradient to udpate this list
  14863. * @returns the list of drag gradients
  14864. */
  14865. getDragGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param factor defines the emit rate to affect to the specified gradient
  14870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14871. * @returns the current particle system
  14872. */
  14873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific emit rate gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeEmitRateGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Gets the current list of emit rate gradients.
  14882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14883. * @returns the list of emit rate gradients
  14884. */
  14885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14886. /**
  14887. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param factor defines the start size to affect to the specified gradient
  14890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14891. * @returns the current particle system
  14892. */
  14893. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific start size gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeStartSizeGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Gets the current list of start size gradients.
  14902. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14903. * @returns the list of start size gradients
  14904. */
  14905. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14906. /**
  14907. * Adds a new life time gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the life time factor to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific life time gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of life time gradients.
  14922. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14923. * @returns the list of life time gradients
  14924. */
  14925. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Gets the current list of color gradients.
  14928. * You must use addColorGradient and removeColorGradient to udpate this list
  14929. * @returns the list of color gradients
  14930. */
  14931. getColorGradients(): Nullable<Array<ColorGradient>>;
  14932. /**
  14933. * Adds a new ramp gradient used to remap particle colors
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param color defines the color to affect to the specified gradient
  14936. * @returns the current particle system
  14937. */
  14938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14939. /**
  14940. * Gets the current list of ramp gradients.
  14941. * You must use addRampGradient and removeRampGradient to udpate this list
  14942. * @returns the list of ramp gradients
  14943. */
  14944. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14945. /** Gets or sets a boolean indicating that ramp gradients must be used
  14946. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14947. */
  14948. useRampGradients: boolean;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of color remap gradients.
  14959. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14960. * @returns the list of color remap gradients
  14961. */
  14962. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @returns the emitter
  14982. */
  14983. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14984. /**
  14985. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14986. * @param radius The radius of the hemisphere to emit from
  14987. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14988. * @returns the emitter
  14989. */
  14990. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14991. /**
  14992. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14993. * @param radius The radius of the sphere to emit from
  14994. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14995. * @returns the emitter
  14996. */
  14997. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14998. /**
  14999. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15000. * @param radius The radius of the sphere to emit from
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @returns the emitter
  15004. */
  15005. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15008. * @param radius The radius of the emission cylinder
  15009. * @param height The height of the emission cylinder
  15010. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15011. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15012. * @returns the emitter
  15013. */
  15014. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15015. /**
  15016. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15017. * @param radius The radius of the cylinder to emit from
  15018. * @param height The height of the emission cylinder
  15019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @returns the emitter
  15023. */
  15024. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15025. /**
  15026. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15027. * @param radius The radius of the cone to emit from
  15028. * @param angle The base angle of the cone
  15029. * @returns the emitter
  15030. */
  15031. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15032. /**
  15033. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15037. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @returns the emitter
  15039. */
  15040. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15041. /**
  15042. * Get hosting scene
  15043. * @returns the scene
  15044. */
  15045. getScene(): Nullable<Scene>;
  15046. }
  15047. }
  15048. declare module "babylonjs/Meshes/transformNode" {
  15049. import { DeepImmutable } from "babylonjs/types";
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Nullable } from "babylonjs/types";
  15052. import { Camera } from "babylonjs/Cameras/camera";
  15053. import { Scene } from "babylonjs/scene";
  15054. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15055. import { Node } from "babylonjs/node";
  15056. import { Bone } from "babylonjs/Bones/bone";
  15057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15058. import { Space } from "babylonjs/Maths/math.axis";
  15059. /**
  15060. * 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.
  15061. * @see https://doc.babylonjs.com/how_to/transformnode
  15062. */
  15063. export class TransformNode extends Node {
  15064. /**
  15065. * Object will not rotate to face the camera
  15066. */
  15067. static BILLBOARDMODE_NONE: number;
  15068. /**
  15069. * Object will rotate to face the camera but only on the x axis
  15070. */
  15071. static BILLBOARDMODE_X: number;
  15072. /**
  15073. * Object will rotate to face the camera but only on the y axis
  15074. */
  15075. static BILLBOARDMODE_Y: number;
  15076. /**
  15077. * Object will rotate to face the camera but only on the z axis
  15078. */
  15079. static BILLBOARDMODE_Z: number;
  15080. /**
  15081. * Object will rotate to face the camera
  15082. */
  15083. static BILLBOARDMODE_ALL: number;
  15084. /**
  15085. * Object will rotate to face the camera's position instead of orientation
  15086. */
  15087. static BILLBOARDMODE_USE_POSITION: number;
  15088. private static _TmpRotation;
  15089. private static _TmpScaling;
  15090. private static _TmpTranslation;
  15091. private _forward;
  15092. private _forwardInverted;
  15093. private _up;
  15094. private _right;
  15095. private _rightInverted;
  15096. private _position;
  15097. private _rotation;
  15098. private _rotationQuaternion;
  15099. protected _scaling: Vector3;
  15100. protected _isDirty: boolean;
  15101. private _transformToBoneReferal;
  15102. private _isAbsoluteSynced;
  15103. private _billboardMode;
  15104. /**
  15105. * Gets or sets the billboard mode. Default is 0.
  15106. *
  15107. * | Value | Type | Description |
  15108. * | --- | --- | --- |
  15109. * | 0 | BILLBOARDMODE_NONE | |
  15110. * | 1 | BILLBOARDMODE_X | |
  15111. * | 2 | BILLBOARDMODE_Y | |
  15112. * | 4 | BILLBOARDMODE_Z | |
  15113. * | 7 | BILLBOARDMODE_ALL | |
  15114. *
  15115. */
  15116. get billboardMode(): number;
  15117. set billboardMode(value: number);
  15118. private _preserveParentRotationForBillboard;
  15119. /**
  15120. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15121. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15122. */
  15123. get preserveParentRotationForBillboard(): boolean;
  15124. set preserveParentRotationForBillboard(value: boolean);
  15125. /**
  15126. * 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
  15127. */
  15128. scalingDeterminant: number;
  15129. private _infiniteDistance;
  15130. /**
  15131. * Gets or sets the distance of the object to max, often used by skybox
  15132. */
  15133. get infiniteDistance(): boolean;
  15134. set infiniteDistance(value: boolean);
  15135. /**
  15136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15137. * By default the system will update normals to compensate
  15138. */
  15139. ignoreNonUniformScaling: boolean;
  15140. /**
  15141. * 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
  15142. */
  15143. reIntegrateRotationIntoRotationQuaternion: boolean;
  15144. /** @hidden */
  15145. _poseMatrix: Nullable<Matrix>;
  15146. /** @hidden */
  15147. _localMatrix: Matrix;
  15148. private _usePivotMatrix;
  15149. private _absolutePosition;
  15150. private _absoluteScaling;
  15151. private _absoluteRotationQuaternion;
  15152. private _pivotMatrix;
  15153. private _pivotMatrixInverse;
  15154. /** @hidden */
  15155. _postMultiplyPivotMatrix: boolean;
  15156. protected _isWorldMatrixFrozen: boolean;
  15157. /** @hidden */
  15158. _indexInSceneTransformNodesArray: number;
  15159. /**
  15160. * An event triggered after the world matrix is updated
  15161. */
  15162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15164. /**
  15165. * Gets a string identifying the name of the class
  15166. * @returns "TransformNode" string
  15167. */
  15168. getClassName(): string;
  15169. /**
  15170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15171. */
  15172. get position(): Vector3;
  15173. set position(newPosition: Vector3);
  15174. /**
  15175. * 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)).
  15176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15177. */
  15178. get rotation(): Vector3;
  15179. set rotation(newRotation: Vector3);
  15180. /**
  15181. * 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)).
  15182. */
  15183. get scaling(): Vector3;
  15184. set scaling(newScaling: Vector3);
  15185. /**
  15186. * 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).
  15187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15188. */
  15189. get rotationQuaternion(): Nullable<Quaternion>;
  15190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15191. /**
  15192. * The forward direction of that transform in world space.
  15193. */
  15194. get forward(): Vector3;
  15195. /**
  15196. * The up direction of that transform in world space.
  15197. */
  15198. get up(): Vector3;
  15199. /**
  15200. * The right direction of that transform in world space.
  15201. */
  15202. get right(): Vector3;
  15203. /**
  15204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15205. * @param matrix the matrix to copy the pose from
  15206. * @returns this TransformNode.
  15207. */
  15208. updatePoseMatrix(matrix: Matrix): TransformNode;
  15209. /**
  15210. * Returns the mesh Pose matrix.
  15211. * @returns the pose matrix
  15212. */
  15213. getPoseMatrix(): Matrix;
  15214. /** @hidden */
  15215. _isSynchronized(): boolean;
  15216. /** @hidden */
  15217. _initCache(): void;
  15218. /**
  15219. * Flag the transform node as dirty (Forcing it to update everything)
  15220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15221. * @returns this transform node
  15222. */
  15223. markAsDirty(property: string): TransformNode;
  15224. /**
  15225. * Returns the current mesh absolute position.
  15226. * Returns a Vector3.
  15227. */
  15228. get absolutePosition(): Vector3;
  15229. /**
  15230. * Returns the current mesh absolute scaling.
  15231. * Returns a Vector3.
  15232. */
  15233. get absoluteScaling(): Vector3;
  15234. /**
  15235. * Returns the current mesh absolute rotation.
  15236. * Returns a Quaternion.
  15237. */
  15238. get absoluteRotationQuaternion(): Quaternion;
  15239. /**
  15240. * Sets a new matrix to apply before all other transformation
  15241. * @param matrix defines the transform matrix
  15242. * @returns the current TransformNode
  15243. */
  15244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15245. /**
  15246. * Sets a new pivot matrix to the current node
  15247. * @param matrix defines the new pivot matrix to use
  15248. * @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
  15249. * @returns the current TransformNode
  15250. */
  15251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15252. /**
  15253. * Returns the mesh pivot matrix.
  15254. * Default : Identity.
  15255. * @returns the matrix
  15256. */
  15257. getPivotMatrix(): Matrix;
  15258. /**
  15259. * Instantiate (when possible) or clone that node with its hierarchy
  15260. * @param newParent defines the new parent to use for the instance (or clone)
  15261. * @param options defines options to configure how copy is done
  15262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15263. * @returns an instance (or a clone) of the current node with its hiearchy
  15264. */
  15265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15266. doNotInstantiate: boolean;
  15267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15268. /**
  15269. * Prevents the World matrix to be computed any longer
  15270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15271. * @returns the TransformNode.
  15272. */
  15273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15274. /**
  15275. * Allows back the World matrix computation.
  15276. * @returns the TransformNode.
  15277. */
  15278. unfreezeWorldMatrix(): this;
  15279. /**
  15280. * True if the World matrix has been frozen.
  15281. */
  15282. get isWorldMatrixFrozen(): boolean;
  15283. /**
  15284. * Retuns the mesh absolute position in the World.
  15285. * @returns a Vector3.
  15286. */
  15287. getAbsolutePosition(): Vector3;
  15288. /**
  15289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15290. * @param absolutePosition the absolute position to set
  15291. * @returns the TransformNode.
  15292. */
  15293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15294. /**
  15295. * Sets the mesh position in its local space.
  15296. * @param vector3 the position to set in localspace
  15297. * @returns the TransformNode.
  15298. */
  15299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15300. /**
  15301. * Returns the mesh position in the local space from the current World matrix values.
  15302. * @returns a new Vector3.
  15303. */
  15304. getPositionExpressedInLocalSpace(): Vector3;
  15305. /**
  15306. * Translates the mesh along the passed Vector3 in its local space.
  15307. * @param vector3 the distance to translate in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. locallyTranslate(vector3: Vector3): TransformNode;
  15311. private static _lookAtVectorCache;
  15312. /**
  15313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15314. * @param targetPoint the position (must be in same space as current mesh) to look at
  15315. * @param yawCor optional yaw (y-axis) correction in radians
  15316. * @param pitchCor optional pitch (x-axis) correction in radians
  15317. * @param rollCor optional roll (z-axis) correction in radians
  15318. * @param space the choosen space of the target
  15319. * @returns the TransformNode.
  15320. */
  15321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15322. /**
  15323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15324. * This Vector3 is expressed in the World space.
  15325. * @param localAxis axis to rotate
  15326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15327. */
  15328. getDirection(localAxis: Vector3): Vector3;
  15329. /**
  15330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15331. * localAxis is expressed in the mesh local space.
  15332. * result is computed in the Wordl space from the mesh World matrix.
  15333. * @param localAxis axis to rotate
  15334. * @param result the resulting transformnode
  15335. * @returns this TransformNode.
  15336. */
  15337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15338. /**
  15339. * Sets this transform node rotation to the given local axis.
  15340. * @param localAxis the axis in local space
  15341. * @param yawCor optional yaw (y-axis) correction in radians
  15342. * @param pitchCor optional pitch (x-axis) correction in radians
  15343. * @param rollCor optional roll (z-axis) correction in radians
  15344. * @returns this TransformNode
  15345. */
  15346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15347. /**
  15348. * Sets a new pivot point to the current node
  15349. * @param point defines the new pivot point to use
  15350. * @param space defines if the point is in world or local space (local by default)
  15351. * @returns the current TransformNode
  15352. */
  15353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15354. /**
  15355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15356. * @returns the pivot point
  15357. */
  15358. getPivotPoint(): Vector3;
  15359. /**
  15360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15361. * @param result the vector3 to store the result
  15362. * @returns this TransformNode.
  15363. */
  15364. getPivotPointToRef(result: Vector3): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. */
  15369. getAbsolutePivotPoint(): Vector3;
  15370. /**
  15371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15372. * @param result vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Defines the passed node as the parent of the current node.
  15378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15379. * @see https://doc.babylonjs.com/how_to/parenting
  15380. * @param node the node ot set as the parent
  15381. * @returns this TransformNode.
  15382. */
  15383. setParent(node: Nullable<Node>): TransformNode;
  15384. private _nonUniformScaling;
  15385. /**
  15386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15387. */
  15388. get nonUniformScaling(): boolean;
  15389. /** @hidden */
  15390. _updateNonUniformScalingState(value: boolean): boolean;
  15391. /**
  15392. * Attach the current TransformNode to another TransformNode associated with a bone
  15393. * @param bone Bone affecting the TransformNode
  15394. * @param affectedTransformNode TransformNode associated with the bone
  15395. * @returns this object
  15396. */
  15397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15398. /**
  15399. * Detach the transform node if its associated with a bone
  15400. * @returns this object
  15401. */
  15402. detachFromBone(): TransformNode;
  15403. private static _rotationAxisCache;
  15404. /**
  15405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15408. * The passed axis is also normalized.
  15409. * @param axis the axis to rotate around
  15410. * @param amount the amount to rotate in radians
  15411. * @param space Space to rotate in (Default: local)
  15412. * @returns the TransformNode.
  15413. */
  15414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized. .
  15419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15420. * @param point the point to rotate around
  15421. * @param axis the axis to rotate around
  15422. * @param amount the amount to rotate in radians
  15423. * @returns the TransformNode
  15424. */
  15425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15426. /**
  15427. * Translates the mesh along the axis vector for the passed distance in the given space.
  15428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15429. * @param axis the axis to translate in
  15430. * @param distance the distance to translate
  15431. * @param space Space to rotate in (Default: local)
  15432. * @returns the TransformNode.
  15433. */
  15434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15435. /**
  15436. * Adds a rotation step to the mesh current rotation.
  15437. * x, y, z are Euler angles expressed in radians.
  15438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15439. * This means this rotation is made in the mesh local space only.
  15440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15442. * ```javascript
  15443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15444. * ```
  15445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15446. * 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.
  15447. * @param x Rotation to add
  15448. * @param y Rotation to add
  15449. * @param z Rotation to add
  15450. * @returns the TransformNode.
  15451. */
  15452. addRotation(x: number, y: number, z: number): TransformNode;
  15453. /**
  15454. * @hidden
  15455. */
  15456. protected _getEffectiveParent(): Nullable<Node>;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15465. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15466. */
  15467. resetLocalMatrix(independentOfChildren?: boolean): void;
  15468. protected _afterComputeWorldMatrix(): void;
  15469. /**
  15470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15471. * @param func callback function to add
  15472. *
  15473. * @returns the TransformNode.
  15474. */
  15475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15476. /**
  15477. * Removes a registered callback function.
  15478. * @param func callback function to remove
  15479. * @returns the TransformNode.
  15480. */
  15481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15482. /**
  15483. * Gets the position of the current mesh in camera space
  15484. * @param camera defines the camera to use
  15485. * @returns a position
  15486. */
  15487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15488. /**
  15489. * Returns the distance from the mesh to the active camera
  15490. * @param camera defines the camera to use
  15491. * @returns the distance
  15492. */
  15493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15494. /**
  15495. * Clone the current transform node
  15496. * @param name Name of the new clone
  15497. * @param newParent New parent for the clone
  15498. * @param doNotCloneChildren Do not clone children hierarchy
  15499. * @returns the new transform node
  15500. */
  15501. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15502. /**
  15503. * Serializes the objects information.
  15504. * @param currentSerializationObject defines the object to serialize in
  15505. * @returns the serialized object
  15506. */
  15507. serialize(currentSerializationObject?: any): any;
  15508. /**
  15509. * Returns a new TransformNode object parsed from the source provided.
  15510. * @param parsedTransformNode is the source.
  15511. * @param scene the scne the object belongs to
  15512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15513. * @returns a new TransformNode object parsed from the source provided.
  15514. */
  15515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15516. /**
  15517. * Get all child-transformNodes of this node
  15518. * @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
  15519. * @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
  15520. * @returns an array of TransformNode
  15521. */
  15522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15523. /**
  15524. * Releases resources associated with this transform node.
  15525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15527. */
  15528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15529. /**
  15530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15534. * @returns the current mesh
  15535. */
  15536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15537. private _syncAbsoluteScalingAndRotation;
  15538. }
  15539. }
  15540. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15541. /**
  15542. * Class used to override all child animations of a given target
  15543. */
  15544. export class AnimationPropertiesOverride {
  15545. /**
  15546. * Gets or sets a value indicating if animation blending must be used
  15547. */
  15548. enableBlending: boolean;
  15549. /**
  15550. * Gets or sets the blending speed to use when enableBlending is true
  15551. */
  15552. blendingSpeed: number;
  15553. /**
  15554. * Gets or sets the default loop mode to use
  15555. */
  15556. loopMode: number;
  15557. }
  15558. }
  15559. declare module "babylonjs/Bones/bone" {
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15562. import { Nullable } from "babylonjs/types";
  15563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15565. import { Node } from "babylonjs/node";
  15566. import { Space } from "babylonjs/Maths/math.axis";
  15567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15568. /**
  15569. * Class used to store bone information
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15571. */
  15572. export class Bone extends Node {
  15573. /**
  15574. * defines the bone name
  15575. */
  15576. name: string;
  15577. private static _tmpVecs;
  15578. private static _tmpQuat;
  15579. private static _tmpMats;
  15580. /**
  15581. * Gets the list of child bones
  15582. */
  15583. children: Bone[];
  15584. /** Gets the animations associated with this bone */
  15585. animations: import("babylonjs/Animations/animation").Animation[];
  15586. /**
  15587. * Gets or sets bone length
  15588. */
  15589. length: number;
  15590. /**
  15591. * @hidden Internal only
  15592. * Set this value to map this bone to a different index in the transform matrices
  15593. * Set this value to -1 to exclude the bone from the transform matrices
  15594. */
  15595. _index: Nullable<number>;
  15596. private _skeleton;
  15597. private _localMatrix;
  15598. private _restPose;
  15599. private _bindPose;
  15600. private _baseMatrix;
  15601. private _absoluteTransform;
  15602. private _invertedAbsoluteTransform;
  15603. private _parent;
  15604. private _scalingDeterminant;
  15605. private _worldTransform;
  15606. private _localScaling;
  15607. private _localRotation;
  15608. private _localPosition;
  15609. private _needToDecompose;
  15610. private _needToCompose;
  15611. /** @hidden */
  15612. _linkedTransformNode: Nullable<TransformNode>;
  15613. /** @hidden */
  15614. _waitingTransformNodeId: Nullable<string>;
  15615. /** @hidden */
  15616. get _matrix(): Matrix;
  15617. /** @hidden */
  15618. set _matrix(value: Matrix);
  15619. /**
  15620. * Create a new bone
  15621. * @param name defines the bone name
  15622. * @param skeleton defines the parent skeleton
  15623. * @param parentBone defines the parent (can be null if the bone is the root)
  15624. * @param localMatrix defines the local matrix
  15625. * @param restPose defines the rest pose matrix
  15626. * @param baseMatrix defines the base matrix
  15627. * @param index defines index of the bone in the hiearchy
  15628. */
  15629. constructor(
  15630. /**
  15631. * defines the bone name
  15632. */
  15633. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15634. /**
  15635. * Gets the current object class name.
  15636. * @return the class name
  15637. */
  15638. getClassName(): string;
  15639. /**
  15640. * Gets the parent skeleton
  15641. * @returns a skeleton
  15642. */
  15643. getSkeleton(): Skeleton;
  15644. /**
  15645. * Gets parent bone
  15646. * @returns a bone or null if the bone is the root of the bone hierarchy
  15647. */
  15648. getParent(): Nullable<Bone>;
  15649. /**
  15650. * Returns an array containing the root bones
  15651. * @returns an array containing the root bones
  15652. */
  15653. getChildren(): Array<Bone>;
  15654. /**
  15655. * Gets the node index in matrix array generated for rendering
  15656. * @returns the node index
  15657. */
  15658. getIndex(): number;
  15659. /**
  15660. * Sets the parent bone
  15661. * @param parent defines the parent (can be null if the bone is the root)
  15662. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15663. */
  15664. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15665. /**
  15666. * Gets the local matrix
  15667. * @returns a matrix
  15668. */
  15669. getLocalMatrix(): Matrix;
  15670. /**
  15671. * Gets the base matrix (initial matrix which remains unchanged)
  15672. * @returns a matrix
  15673. */
  15674. getBaseMatrix(): Matrix;
  15675. /**
  15676. * Gets the rest pose matrix
  15677. * @returns a matrix
  15678. */
  15679. getRestPose(): Matrix;
  15680. /**
  15681. * Sets the rest pose matrix
  15682. * @param matrix the local-space rest pose to set for this bone
  15683. */
  15684. setRestPose(matrix: Matrix): void;
  15685. /**
  15686. * Gets the bind pose matrix
  15687. * @returns the bind pose matrix
  15688. */
  15689. getBindPose(): Matrix;
  15690. /**
  15691. * Sets the bind pose matrix
  15692. * @param matrix the local-space bind pose to set for this bone
  15693. */
  15694. setBindPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15697. */
  15698. getWorldMatrix(): Matrix;
  15699. /**
  15700. * Sets the local matrix to rest pose matrix
  15701. */
  15702. returnToRest(): void;
  15703. /**
  15704. * Gets the inverse of the absolute transform matrix.
  15705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15706. * @returns a matrix
  15707. */
  15708. getInvertedAbsoluteTransform(): Matrix;
  15709. /**
  15710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15711. * @returns a matrix
  15712. */
  15713. getAbsoluteTransform(): Matrix;
  15714. /**
  15715. * Links with the given transform node.
  15716. * The local matrix of this bone is copied from the transform node every frame.
  15717. * @param transformNode defines the transform node to link to
  15718. */
  15719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15720. /**
  15721. * Gets the node used to drive the bone's transformation
  15722. * @returns a transform node or null
  15723. */
  15724. getTransformNode(): Nullable<TransformNode>;
  15725. /** Gets or sets current position (in local space) */
  15726. get position(): Vector3;
  15727. set position(newPosition: Vector3);
  15728. /** Gets or sets current rotation (in local space) */
  15729. get rotation(): Vector3;
  15730. set rotation(newRotation: Vector3);
  15731. /** Gets or sets current rotation quaternion (in local space) */
  15732. get rotationQuaternion(): Quaternion;
  15733. set rotationQuaternion(newRotation: Quaternion);
  15734. /** Gets or sets current scaling (in local space) */
  15735. get scaling(): Vector3;
  15736. set scaling(newScaling: Vector3);
  15737. /**
  15738. * Gets the animation properties override
  15739. */
  15740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15741. private _decompose;
  15742. private _compose;
  15743. /**
  15744. * Update the base and local matrices
  15745. * @param matrix defines the new base or local matrix
  15746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15747. * @param updateLocalMatrix defines if the local matrix should be updated
  15748. */
  15749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15750. /** @hidden */
  15751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15752. /**
  15753. * Flag the bone as dirty (Forcing it to update everything)
  15754. */
  15755. markAsDirty(): void;
  15756. /** @hidden */
  15757. _markAsDirtyAndCompose(): void;
  15758. private _markAsDirtyAndDecompose;
  15759. /**
  15760. * Translate the bone in local or world space
  15761. * @param vec The amount to translate the bone
  15762. * @param space The space that the translation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the postion of the bone in local or world space
  15768. * @param position The position to set the bone
  15769. * @param space The space that the position is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the absolute position of the bone (world space)
  15775. * @param position The position to set the bone
  15776. * @param mesh The mesh that this bone is attached to
  15777. */
  15778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15779. /**
  15780. * Scale the bone on the x, y and z axes (in local space)
  15781. * @param x The amount to scale the bone on the x axis
  15782. * @param y The amount to scale the bone on the y axis
  15783. * @param z The amount to scale the bone on the z axis
  15784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15785. */
  15786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15787. /**
  15788. * Set the bone scaling in local space
  15789. * @param scale defines the scaling vector
  15790. */
  15791. setScale(scale: Vector3): void;
  15792. /**
  15793. * Gets the current scaling in local space
  15794. * @returns the current scaling vector
  15795. */
  15796. getScale(): Vector3;
  15797. /**
  15798. * Gets the current scaling in local space and stores it in a target vector
  15799. * @param result defines the target vector
  15800. */
  15801. getScaleToRef(result: Vector3): void;
  15802. /**
  15803. * Set the yaw, pitch, and roll of the bone in local or world space
  15804. * @param yaw The rotation of the bone on the y axis
  15805. * @param pitch The rotation of the bone on the x axis
  15806. * @param roll The rotation of the bone on the z axis
  15807. * @param space The space that the axes of rotation are in
  15808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15809. */
  15810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15811. /**
  15812. * Add a rotation to the bone on an axis in local or world space
  15813. * @param axis The axis to rotate the bone on
  15814. * @param amount The amount to rotate the bone
  15815. * @param space The space that the axis is in
  15816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15817. */
  15818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15819. /**
  15820. * Set the rotation of the bone to a particular axis angle in local or world space
  15821. * @param axis The axis to rotate the bone on
  15822. * @param angle The angle that the bone should be rotated to
  15823. * @param space The space that the axis is in
  15824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15825. */
  15826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15827. /**
  15828. * Set the euler rotation of the bone in local or world space
  15829. * @param rotation The euler rotation that the bone should be set to
  15830. * @param space The space that the rotation is in
  15831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15832. */
  15833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15834. /**
  15835. * Set the quaternion rotation of the bone in local or world space
  15836. * @param quat The quaternion rotation that the bone should be set to
  15837. * @param space The space that the rotation is in
  15838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15839. */
  15840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Set the rotation matrix of the bone in local or world space
  15843. * @param rotMat The rotation matrix that the bone should be set to
  15844. * @param space The space that the rotation is in
  15845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15846. */
  15847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15848. private _rotateWithMatrix;
  15849. private _getNegativeRotationToRef;
  15850. /**
  15851. * Get the position of the bone in local or world space
  15852. * @param space The space that the returned position is in
  15853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15854. * @returns The position of the bone
  15855. */
  15856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15857. /**
  15858. * Copy the position of the bone to a vector3 in local or world space
  15859. * @param space The space that the returned position is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. * @param result The vector3 to copy the position to
  15862. */
  15863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15864. /**
  15865. * Get the absolute position of the bone (world space)
  15866. * @param mesh The mesh that this bone is attached to
  15867. * @returns The absolute position of the bone
  15868. */
  15869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15870. /**
  15871. * Copy the absolute position of the bone (world space) to the result param
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @param result The vector3 to copy the absolute position to
  15874. */
  15875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15876. /**
  15877. * Compute the absolute transforms of this bone and its children
  15878. */
  15879. computeAbsoluteTransforms(): void;
  15880. /**
  15881. * Get the world direction from an axis that is in the local space of the bone
  15882. * @param localAxis The local direction that is used to compute the world direction
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @returns The world direction
  15885. */
  15886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15887. /**
  15888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15889. * @param localAxis The local direction that is used to compute the world direction
  15890. * @param mesh The mesh that this bone is attached to
  15891. * @param result The vector3 that the world direction will be copied to
  15892. */
  15893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15894. /**
  15895. * Get the euler rotation of the bone in local or world space
  15896. * @param space The space that the rotation should be in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The euler rotation
  15899. */
  15900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15903. * @param space The space that the rotation should be in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 that the rotation should be copied to
  15906. */
  15907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15908. /**
  15909. * Get the quaternion rotation of the bone in either local or world space
  15910. * @param space The space that the rotation should be in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @returns The quaternion rotation
  15913. */
  15914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15915. /**
  15916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15917. * @param space The space that the rotation should be in
  15918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15919. * @param result The quaternion that the rotation should be copied to
  15920. */
  15921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15922. /**
  15923. * Get the rotation matrix of the bone in local or world space
  15924. * @param space The space that the rotation should be in
  15925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15926. * @returns The rotation matrix
  15927. */
  15928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15929. /**
  15930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15931. * @param space The space that the rotation should be in
  15932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15933. * @param result The quaternion that the rotation should be copied to
  15934. */
  15935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15936. /**
  15937. * Get the world position of a point that is in the local space of the bone
  15938. * @param position The local position
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @returns The world position
  15941. */
  15942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15943. /**
  15944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15945. * @param position The local position
  15946. * @param mesh The mesh that this bone is attached to
  15947. * @param result The vector3 that the world position should be copied to
  15948. */
  15949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15950. /**
  15951. * Get the local position of a point that is in world space
  15952. * @param position The world position
  15953. * @param mesh The mesh that this bone is attached to
  15954. * @returns The local position
  15955. */
  15956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15957. /**
  15958. * Get the local position of a point that is in world space and copy it to the result param
  15959. * @param position The world position
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @param result The vector3 that the local position should be copied to
  15962. */
  15963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15964. /**
  15965. * Set the current local matrix as the restPose for this bone.
  15966. */
  15967. setCurrentPoseAsRest(): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Animations/runtimeAnimation" {
  15971. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15972. import { Animatable } from "babylonjs/Animations/animatable";
  15973. import { Scene } from "babylonjs/scene";
  15974. /**
  15975. * Defines a runtime animation
  15976. */
  15977. export class RuntimeAnimation {
  15978. private _events;
  15979. /**
  15980. * The current frame of the runtime animation
  15981. */
  15982. private _currentFrame;
  15983. /**
  15984. * The animation used by the runtime animation
  15985. */
  15986. private _animation;
  15987. /**
  15988. * The target of the runtime animation
  15989. */
  15990. private _target;
  15991. /**
  15992. * The initiating animatable
  15993. */
  15994. private _host;
  15995. /**
  15996. * The original value of the runtime animation
  15997. */
  15998. private _originalValue;
  15999. /**
  16000. * The original blend value of the runtime animation
  16001. */
  16002. private _originalBlendValue;
  16003. /**
  16004. * The offsets cache of the runtime animation
  16005. */
  16006. private _offsetsCache;
  16007. /**
  16008. * The high limits cache of the runtime animation
  16009. */
  16010. private _highLimitsCache;
  16011. /**
  16012. * Specifies if the runtime animation has been stopped
  16013. */
  16014. private _stopped;
  16015. /**
  16016. * The blending factor of the runtime animation
  16017. */
  16018. private _blendingFactor;
  16019. /**
  16020. * The BabylonJS scene
  16021. */
  16022. private _scene;
  16023. /**
  16024. * The current value of the runtime animation
  16025. */
  16026. private _currentValue;
  16027. /** @hidden */
  16028. _animationState: _IAnimationState;
  16029. /**
  16030. * The active target of the runtime animation
  16031. */
  16032. private _activeTargets;
  16033. private _currentActiveTarget;
  16034. private _directTarget;
  16035. /**
  16036. * The target path of the runtime animation
  16037. */
  16038. private _targetPath;
  16039. /**
  16040. * The weight of the runtime animation
  16041. */
  16042. private _weight;
  16043. /**
  16044. * The ratio offset of the runtime animation
  16045. */
  16046. private _ratioOffset;
  16047. /**
  16048. * The previous delay of the runtime animation
  16049. */
  16050. private _previousDelay;
  16051. /**
  16052. * The previous ratio of the runtime animation
  16053. */
  16054. private _previousRatio;
  16055. private _enableBlending;
  16056. private _keys;
  16057. private _minFrame;
  16058. private _maxFrame;
  16059. private _minValue;
  16060. private _maxValue;
  16061. private _targetIsArray;
  16062. /**
  16063. * Gets the current frame of the runtime animation
  16064. */
  16065. get currentFrame(): number;
  16066. /**
  16067. * Gets the weight of the runtime animation
  16068. */
  16069. get weight(): number;
  16070. /**
  16071. * Gets the current value of the runtime animation
  16072. */
  16073. get currentValue(): any;
  16074. /**
  16075. * Gets the target path of the runtime animation
  16076. */
  16077. get targetPath(): string;
  16078. /**
  16079. * Gets the actual target of the runtime animation
  16080. */
  16081. get target(): any;
  16082. /**
  16083. * Gets the additive state of the runtime animation
  16084. */
  16085. get isAdditive(): boolean;
  16086. /** @hidden */
  16087. _onLoop: () => void;
  16088. /**
  16089. * Create a new RuntimeAnimation object
  16090. * @param target defines the target of the animation
  16091. * @param animation defines the source animation object
  16092. * @param scene defines the hosting scene
  16093. * @param host defines the initiating Animatable
  16094. */
  16095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16096. private _preparePath;
  16097. /**
  16098. * Gets the animation from the runtime animation
  16099. */
  16100. get animation(): Animation;
  16101. /**
  16102. * Resets the runtime animation to the beginning
  16103. * @param restoreOriginal defines whether to restore the target property to the original value
  16104. */
  16105. reset(restoreOriginal?: boolean): void;
  16106. /**
  16107. * Specifies if the runtime animation is stopped
  16108. * @returns Boolean specifying if the runtime animation is stopped
  16109. */
  16110. isStopped(): boolean;
  16111. /**
  16112. * Disposes of the runtime animation
  16113. */
  16114. dispose(): void;
  16115. /**
  16116. * Apply the interpolated value to the target
  16117. * @param currentValue defines the value computed by the animation
  16118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16119. */
  16120. setValue(currentValue: any, weight: number): void;
  16121. private _getOriginalValues;
  16122. private _setValue;
  16123. /**
  16124. * Gets the loop pmode of the runtime animation
  16125. * @returns Loop Mode
  16126. */
  16127. private _getCorrectLoopMode;
  16128. /**
  16129. * Move the current animation to a given frame
  16130. * @param frame defines the frame to move to
  16131. */
  16132. goToFrame(frame: number): void;
  16133. /**
  16134. * @hidden Internal use only
  16135. */
  16136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16137. /**
  16138. * Execute the current animation
  16139. * @param delay defines the delay to add to the current frame
  16140. * @param from defines the lower bound of the animation range
  16141. * @param to defines the upper bound of the animation range
  16142. * @param loop defines if the current animation must loop
  16143. * @param speedRatio defines the current speed ratio
  16144. * @param weight defines the weight of the animation (default is -1 so no weight)
  16145. * @param onLoop optional callback called when animation loops
  16146. * @returns a boolean indicating if the animation is running
  16147. */
  16148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16149. }
  16150. }
  16151. declare module "babylonjs/Animations/animatable" {
  16152. import { Animation } from "babylonjs/Animations/animation";
  16153. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16154. import { Nullable } from "babylonjs/types";
  16155. import { Observable } from "babylonjs/Misc/observable";
  16156. import { Scene } from "babylonjs/scene";
  16157. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16158. import { Node } from "babylonjs/node";
  16159. /**
  16160. * Class used to store an actual running animation
  16161. */
  16162. export class Animatable {
  16163. /** defines the target object */
  16164. target: any;
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame: number;
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame: number;
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation: boolean;
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined;
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined;
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive: boolean;
  16177. private _localDelayOffset;
  16178. private _pausedDelay;
  16179. private _runtimeAnimations;
  16180. private _paused;
  16181. private _scene;
  16182. private _speedRatio;
  16183. private _weight;
  16184. private _syncRoot;
  16185. /**
  16186. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16187. * This will only apply for non looping animation (default is true)
  16188. */
  16189. disposeOnEnd: boolean;
  16190. /**
  16191. * Gets a boolean indicating if the animation has started
  16192. */
  16193. animationStarted: boolean;
  16194. /**
  16195. * Observer raised when the animation ends
  16196. */
  16197. onAnimationEndObservable: Observable<Animatable>;
  16198. /**
  16199. * Observer raised when the animation loops
  16200. */
  16201. onAnimationLoopObservable: Observable<Animatable>;
  16202. /**
  16203. * Gets the root Animatable used to synchronize and normalize animations
  16204. */
  16205. get syncRoot(): Nullable<Animatable>;
  16206. /**
  16207. * Gets the current frame of the first RuntimeAnimation
  16208. * Used to synchronize Animatables
  16209. */
  16210. get masterFrame(): number;
  16211. /**
  16212. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16213. */
  16214. get weight(): number;
  16215. set weight(value: number);
  16216. /**
  16217. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16218. */
  16219. get speedRatio(): number;
  16220. set speedRatio(value: number);
  16221. /**
  16222. * Creates a new Animatable
  16223. * @param scene defines the hosting scene
  16224. * @param target defines the target object
  16225. * @param fromFrame defines the starting frame number (default is 0)
  16226. * @param toFrame defines the ending frame number (default is 100)
  16227. * @param loopAnimation defines if the animation must loop (default is false)
  16228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16230. * @param animations defines a group of animation to add to the new Animatable
  16231. * @param onAnimationLoop defines a callback to call when animation loops
  16232. * @param isAdditive defines whether the animation should be evaluated additively
  16233. */
  16234. constructor(scene: Scene,
  16235. /** defines the target object */
  16236. target: any,
  16237. /** defines the starting frame number (default is 0) */
  16238. fromFrame?: number,
  16239. /** defines the ending frame number (default is 100) */
  16240. toFrame?: number,
  16241. /** defines if the animation must loop (default is false) */
  16242. loopAnimation?: boolean, speedRatio?: number,
  16243. /** defines a callback to call when animation ends if it is not looping */
  16244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16245. /** defines a callback to call when animation loops */
  16246. onAnimationLoop?: (() => void) | null | undefined,
  16247. /** defines whether the animation should be evaluated additively */
  16248. isAdditive?: boolean);
  16249. /**
  16250. * Synchronize and normalize current Animatable with a source Animatable
  16251. * This is useful when using animation weights and when animations are not of the same length
  16252. * @param root defines the root Animatable to synchronize with
  16253. * @returns the current Animatable
  16254. */
  16255. syncWith(root: Animatable): Animatable;
  16256. /**
  16257. * Gets the list of runtime animations
  16258. * @returns an array of RuntimeAnimation
  16259. */
  16260. getAnimations(): RuntimeAnimation[];
  16261. /**
  16262. * Adds more animations to the current animatable
  16263. * @param target defines the target of the animations
  16264. * @param animations defines the new animations to add
  16265. */
  16266. appendAnimations(target: any, animations: Animation[]): void;
  16267. /**
  16268. * Gets the source animation for a specific property
  16269. * @param property defines the propertyu to look for
  16270. * @returns null or the source animation for the given property
  16271. */
  16272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16273. /**
  16274. * Gets the runtime animation for a specific property
  16275. * @param property defines the propertyu to look for
  16276. * @returns null or the runtime animation for the given property
  16277. */
  16278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16279. /**
  16280. * Resets the animatable to its original state
  16281. */
  16282. reset(): void;
  16283. /**
  16284. * Allows the animatable to blend with current running animations
  16285. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16286. * @param blendingSpeed defines the blending speed to use
  16287. */
  16288. enableBlending(blendingSpeed: number): void;
  16289. /**
  16290. * Disable animation blending
  16291. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16292. */
  16293. disableBlending(): void;
  16294. /**
  16295. * Jump directly to a given frame
  16296. * @param frame defines the frame to jump to
  16297. */
  16298. goToFrame(frame: number): void;
  16299. /**
  16300. * Pause the animation
  16301. */
  16302. pause(): void;
  16303. /**
  16304. * Restart the animation
  16305. */
  16306. restart(): void;
  16307. private _raiseOnAnimationEnd;
  16308. /**
  16309. * Stop and delete the current animation
  16310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16311. * @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)
  16312. */
  16313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16314. /**
  16315. * Wait asynchronously for the animation to end
  16316. * @returns a promise which will be fullfilled when the animation ends
  16317. */
  16318. waitAsync(): Promise<Animatable>;
  16319. /** @hidden */
  16320. _animate(delay: number): boolean;
  16321. }
  16322. module "babylonjs/scene" {
  16323. interface Scene {
  16324. /** @hidden */
  16325. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16326. /** @hidden */
  16327. _processLateAnimationBindingsForMatrices(holder: {
  16328. totalWeight: number;
  16329. totalAdditiveWeight: number;
  16330. animations: RuntimeAnimation[];
  16331. additiveAnimations: RuntimeAnimation[];
  16332. originalValue: Matrix;
  16333. }): any;
  16334. /** @hidden */
  16335. _processLateAnimationBindingsForQuaternions(holder: {
  16336. totalWeight: number;
  16337. totalAdditiveWeight: number;
  16338. animations: RuntimeAnimation[];
  16339. additiveAnimations: RuntimeAnimation[];
  16340. originalValue: Quaternion;
  16341. }, refQuaternion: Quaternion): Quaternion;
  16342. /** @hidden */
  16343. _processLateAnimationBindings(): void;
  16344. /**
  16345. * Will start the animation sequence of a given target
  16346. * @param target defines the target
  16347. * @param from defines from which frame should animation start
  16348. * @param to defines until which frame should animation run.
  16349. * @param weight defines the weight to apply to the animation (1.0 by default)
  16350. * @param loop defines if the animation loops
  16351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16352. * @param onAnimationEnd defines the function to be executed when the animation ends
  16353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16354. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16355. * @param onAnimationLoop defines the callback to call when an animation loops
  16356. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16357. * @returns the animatable object created for this animation
  16358. */
  16359. 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;
  16360. /**
  16361. * Will start the animation sequence of a given target
  16362. * @param target defines the target
  16363. * @param from defines from which frame should animation start
  16364. * @param to defines until which frame should animation run.
  16365. * @param loop defines if the animation loops
  16366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16367. * @param onAnimationEnd defines the function to be executed when the animation ends
  16368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16370. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16371. * @param onAnimationLoop defines the callback to call when an animation loops
  16372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16373. * @returns the animatable object created for this animation
  16374. */
  16375. 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;
  16376. /**
  16377. * Will start the animation sequence of a given target and its hierarchy
  16378. * @param target defines the target
  16379. * @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.
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param loop defines if the animation loops
  16383. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16384. * @param onAnimationEnd defines the function to be executed when the animation ends
  16385. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16386. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the list of created animatables
  16391. */
  16392. 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[];
  16393. /**
  16394. * Begin a new animation on a given node
  16395. * @param target defines the target where the animation will take place
  16396. * @param animations defines the list of animations to start
  16397. * @param from defines the initial value
  16398. * @param to defines the final value
  16399. * @param loop defines if you want animation to loop (off by default)
  16400. * @param speedRatio defines the speed ratio to apply to all animations
  16401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16402. * @param onAnimationLoop defines the callback to call when an animation loops
  16403. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16404. * @returns the list of created animatables
  16405. */
  16406. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16407. /**
  16408. * Begin a new animation on a given node and its hierarchy
  16409. * @param target defines the root node where the animation will take place
  16410. * @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.
  16411. * @param animations defines the list of animations to start
  16412. * @param from defines the initial value
  16413. * @param to defines the final value
  16414. * @param loop defines if you want animation to loop (off by default)
  16415. * @param speedRatio defines the speed ratio to apply to all animations
  16416. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the list of animatables created for all nodes
  16420. */
  16421. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16422. /**
  16423. * Gets the animatable associated with a specific target
  16424. * @param target defines the target of the animatable
  16425. * @returns the required animatable if found
  16426. */
  16427. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16428. /**
  16429. * Gets all animatables associated with a given target
  16430. * @param target defines the target to look animatables for
  16431. * @returns an array of Animatables
  16432. */
  16433. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16434. /**
  16435. * Stops and removes all animations that have been applied to the scene
  16436. */
  16437. stopAllAnimations(): void;
  16438. /**
  16439. * Gets the current delta time used by animation engine
  16440. */
  16441. deltaTime: number;
  16442. }
  16443. }
  16444. module "babylonjs/Bones/bone" {
  16445. interface Bone {
  16446. /**
  16447. * Copy an animation range from another bone
  16448. * @param source defines the source bone
  16449. * @param rangeName defines the range name to copy
  16450. * @param frameOffset defines the frame offset
  16451. * @param rescaleAsRequired defines if rescaling must be applied if required
  16452. * @param skelDimensionsRatio defines the scaling ratio
  16453. * @returns true if operation was successful
  16454. */
  16455. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16456. }
  16457. }
  16458. }
  16459. declare module "babylonjs/Bones/skeleton" {
  16460. import { Bone } from "babylonjs/Bones/bone";
  16461. import { Observable } from "babylonjs/Misc/observable";
  16462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16463. import { Scene } from "babylonjs/scene";
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16467. import { Animatable } from "babylonjs/Animations/animatable";
  16468. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16469. import { Animation } from "babylonjs/Animations/animation";
  16470. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16471. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16472. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16473. /**
  16474. * Class used to handle skinning animations
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16476. */
  16477. export class Skeleton implements IAnimatable {
  16478. /** defines the skeleton name */
  16479. name: string;
  16480. /** defines the skeleton Id */
  16481. id: string;
  16482. /**
  16483. * Defines the list of child bones
  16484. */
  16485. bones: Bone[];
  16486. /**
  16487. * Defines an estimate of the dimension of the skeleton at rest
  16488. */
  16489. dimensionsAtRest: Vector3;
  16490. /**
  16491. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16492. */
  16493. needInitialSkinMatrix: boolean;
  16494. /**
  16495. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16496. */
  16497. overrideMesh: Nullable<AbstractMesh>;
  16498. /**
  16499. * Gets the list of animations attached to this skeleton
  16500. */
  16501. animations: Array<Animation>;
  16502. private _scene;
  16503. private _isDirty;
  16504. private _transformMatrices;
  16505. private _transformMatrixTexture;
  16506. private _meshesWithPoseMatrix;
  16507. private _animatables;
  16508. private _identity;
  16509. private _synchronizedWithMesh;
  16510. private _ranges;
  16511. private _lastAbsoluteTransformsUpdateId;
  16512. private _canUseTextureForBones;
  16513. private _uniqueId;
  16514. /** @hidden */
  16515. _numBonesWithLinkedTransformNode: number;
  16516. /** @hidden */
  16517. _hasWaitingData: Nullable<boolean>;
  16518. /** @hidden */
  16519. _waitingOverrideMeshId: Nullable<string>;
  16520. /**
  16521. * Specifies if the skeleton should be serialized
  16522. */
  16523. doNotSerialize: boolean;
  16524. private _useTextureToStoreBoneMatrices;
  16525. /**
  16526. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16527. * Please note that this option is not available if the hardware does not support it
  16528. */
  16529. get useTextureToStoreBoneMatrices(): boolean;
  16530. set useTextureToStoreBoneMatrices(value: boolean);
  16531. private _animationPropertiesOverride;
  16532. /**
  16533. * Gets or sets the animation properties override
  16534. */
  16535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16537. /**
  16538. * List of inspectable custom properties (used by the Inspector)
  16539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16540. */
  16541. inspectableCustomProperties: IInspectable[];
  16542. /**
  16543. * An observable triggered before computing the skeleton's matrices
  16544. */
  16545. onBeforeComputeObservable: Observable<Skeleton>;
  16546. /**
  16547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16548. */
  16549. get isUsingTextureForMatrices(): boolean;
  16550. /**
  16551. * Gets the unique ID of this skeleton
  16552. */
  16553. get uniqueId(): number;
  16554. /**
  16555. * Creates a new skeleton
  16556. * @param name defines the skeleton name
  16557. * @param id defines the skeleton Id
  16558. * @param scene defines the hosting scene
  16559. */
  16560. constructor(
  16561. /** defines the skeleton name */
  16562. name: string,
  16563. /** defines the skeleton Id */
  16564. id: string, scene: Scene);
  16565. /**
  16566. * Gets the current object class name.
  16567. * @return the class name
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * Returns an array containing the root bones
  16572. * @returns an array containing the root bones
  16573. */
  16574. getChildren(): Array<Bone>;
  16575. /**
  16576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16578. * @returns a Float32Array containing matrices data
  16579. */
  16580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16581. /**
  16582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16584. * @returns a raw texture containing the data
  16585. */
  16586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16587. /**
  16588. * Gets the current hosting scene
  16589. * @returns a scene object
  16590. */
  16591. getScene(): Scene;
  16592. /**
  16593. * Gets a string representing the current skeleton data
  16594. * @param fullDetails defines a boolean indicating if we want a verbose version
  16595. * @returns a string representing the current skeleton data
  16596. */
  16597. toString(fullDetails?: boolean): string;
  16598. /**
  16599. * Get bone's index searching by name
  16600. * @param name defines bone's name to search for
  16601. * @return the indice of the bone. Returns -1 if not found
  16602. */
  16603. getBoneIndexByName(name: string): number;
  16604. /**
  16605. * Creater a new animation range
  16606. * @param name defines the name of the range
  16607. * @param from defines the start key
  16608. * @param to defines the end key
  16609. */
  16610. createAnimationRange(name: string, from: number, to: number): void;
  16611. /**
  16612. * Delete a specific animation range
  16613. * @param name defines the name of the range
  16614. * @param deleteFrames defines if frames must be removed as well
  16615. */
  16616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16617. /**
  16618. * Gets a specific animation range
  16619. * @param name defines the name of the range to look for
  16620. * @returns the requested animation range or null if not found
  16621. */
  16622. getAnimationRange(name: string): Nullable<AnimationRange>;
  16623. /**
  16624. * Gets the list of all animation ranges defined on this skeleton
  16625. * @returns an array
  16626. */
  16627. getAnimationRanges(): Nullable<AnimationRange>[];
  16628. /**
  16629. * Copy animation range from a source skeleton.
  16630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16631. * @param source defines the source skeleton
  16632. * @param name defines the name of the range to copy
  16633. * @param rescaleAsRequired defines if rescaling must be applied if required
  16634. * @returns true if operation was successful
  16635. */
  16636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16637. /**
  16638. * Forces the skeleton to go to rest pose
  16639. */
  16640. returnToRest(): void;
  16641. private _getHighestAnimationFrame;
  16642. /**
  16643. * Begin a specific animation range
  16644. * @param name defines the name of the range to start
  16645. * @param loop defines if looping must be turned on (false by default)
  16646. * @param speedRatio defines the speed ratio to apply (1 by default)
  16647. * @param onAnimationEnd defines a callback which will be called when animation will end
  16648. * @returns a new animatable
  16649. */
  16650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16651. /**
  16652. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16653. * @param skeleton defines the Skeleton containing the animation range to convert
  16654. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16655. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16656. * @returns the original skeleton
  16657. */
  16658. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16659. /** @hidden */
  16660. _markAsDirty(): void;
  16661. /** @hidden */
  16662. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16663. /** @hidden */
  16664. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16665. private _computeTransformMatrices;
  16666. /**
  16667. * Build all resources required to render a skeleton
  16668. */
  16669. prepare(): void;
  16670. /**
  16671. * Gets the list of animatables currently running for this skeleton
  16672. * @returns an array of animatables
  16673. */
  16674. getAnimatables(): IAnimatable[];
  16675. /**
  16676. * Clone the current skeleton
  16677. * @param name defines the name of the new skeleton
  16678. * @param id defines the id of the new skeleton
  16679. * @returns the new skeleton
  16680. */
  16681. clone(name: string, id?: string): Skeleton;
  16682. /**
  16683. * Enable animation blending for this skeleton
  16684. * @param blendingSpeed defines the blending speed to apply
  16685. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16686. */
  16687. enableBlending(blendingSpeed?: number): void;
  16688. /**
  16689. * Releases all resources associated with the current skeleton
  16690. */
  16691. dispose(): void;
  16692. /**
  16693. * Serialize the skeleton in a JSON object
  16694. * @returns a JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Creates a new skeleton from serialized data
  16699. * @param parsedSkeleton defines the serialized data
  16700. * @param scene defines the hosting scene
  16701. * @returns a new skeleton
  16702. */
  16703. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16704. /**
  16705. * Compute all node absolute transforms
  16706. * @param forceUpdate defines if computation must be done even if cache is up to date
  16707. */
  16708. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16709. /**
  16710. * Gets the root pose matrix
  16711. * @returns a matrix
  16712. */
  16713. getPoseMatrix(): Nullable<Matrix>;
  16714. /**
  16715. * Sorts bones per internal index
  16716. */
  16717. sortBones(): void;
  16718. private _sortBones;
  16719. /**
  16720. * Set the current local matrix as the restPose for all bones in the skeleton.
  16721. */
  16722. setCurrentPoseAsRest(): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Meshes/instancedMesh" {
  16726. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16728. import { Camera } from "babylonjs/Cameras/camera";
  16729. import { Node } from "babylonjs/node";
  16730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16731. import { Mesh } from "babylonjs/Meshes/mesh";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. import { Skeleton } from "babylonjs/Bones/skeleton";
  16734. import { Light } from "babylonjs/Lights/light";
  16735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16736. /**
  16737. * Creates an instance based on a source mesh.
  16738. */
  16739. export class InstancedMesh extends AbstractMesh {
  16740. private _sourceMesh;
  16741. private _currentLOD;
  16742. /** @hidden */
  16743. _indexInSourceMeshInstanceArray: number;
  16744. constructor(name: string, source: Mesh);
  16745. /**
  16746. * Returns the string "InstancedMesh".
  16747. */
  16748. getClassName(): string;
  16749. /** Gets the list of lights affecting that mesh */
  16750. get lightSources(): Light[];
  16751. _resyncLightSources(): void;
  16752. _resyncLightSource(light: Light): void;
  16753. _removeLightSource(light: Light, dispose: boolean): void;
  16754. /**
  16755. * If the source mesh receives shadows
  16756. */
  16757. get receiveShadows(): boolean;
  16758. /**
  16759. * The material of the source mesh
  16760. */
  16761. get material(): Nullable<Material>;
  16762. /**
  16763. * Visibility of the source mesh
  16764. */
  16765. get visibility(): number;
  16766. /**
  16767. * Skeleton of the source mesh
  16768. */
  16769. get skeleton(): Nullable<Skeleton>;
  16770. /**
  16771. * Rendering ground id of the source mesh
  16772. */
  16773. get renderingGroupId(): number;
  16774. set renderingGroupId(value: number);
  16775. /**
  16776. * Returns the total number of vertices (integer).
  16777. */
  16778. getTotalVertices(): number;
  16779. /**
  16780. * Returns a positive integer : the total number of indices in this mesh geometry.
  16781. * @returns the numner of indices or zero if the mesh has no geometry.
  16782. */
  16783. getTotalIndices(): number;
  16784. /**
  16785. * The source mesh of the instance
  16786. */
  16787. get sourceMesh(): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16791. * @param name defines the name of the new instance
  16792. * @returns a new InstancedMesh
  16793. */
  16794. createInstance(name: string): InstancedMesh;
  16795. /**
  16796. * Is this node ready to be used/rendered
  16797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16798. * @return {boolean} is it ready
  16799. */
  16800. isReady(completeCheck?: boolean): boolean;
  16801. /**
  16802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16803. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16804. * @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.
  16805. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16806. */
  16807. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16808. /**
  16809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16811. * The `data` are either a numeric array either a Float32Array.
  16812. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16813. * 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).
  16814. * Note that a new underlying VertexBuffer object is created each call.
  16815. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16816. *
  16817. * Possible `kind` values :
  16818. * - VertexBuffer.PositionKind
  16819. * - VertexBuffer.UVKind
  16820. * - VertexBuffer.UV2Kind
  16821. * - VertexBuffer.UV3Kind
  16822. * - VertexBuffer.UV4Kind
  16823. * - VertexBuffer.UV5Kind
  16824. * - VertexBuffer.UV6Kind
  16825. * - VertexBuffer.ColorKind
  16826. * - VertexBuffer.MatricesIndicesKind
  16827. * - VertexBuffer.MatricesIndicesExtraKind
  16828. * - VertexBuffer.MatricesWeightsKind
  16829. * - VertexBuffer.MatricesWeightsExtraKind
  16830. *
  16831. * Returns the Mesh.
  16832. */
  16833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16834. /**
  16835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16836. * If the mesh has no geometry, it is simply returned as it is.
  16837. * The `data` are either a numeric array either a Float32Array.
  16838. * No new underlying VertexBuffer object is created.
  16839. * 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.
  16840. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16841. *
  16842. * Possible `kind` values :
  16843. * - VertexBuffer.PositionKind
  16844. * - VertexBuffer.UVKind
  16845. * - VertexBuffer.UV2Kind
  16846. * - VertexBuffer.UV3Kind
  16847. * - VertexBuffer.UV4Kind
  16848. * - VertexBuffer.UV5Kind
  16849. * - VertexBuffer.UV6Kind
  16850. * - VertexBuffer.ColorKind
  16851. * - VertexBuffer.MatricesIndicesKind
  16852. * - VertexBuffer.MatricesIndicesExtraKind
  16853. * - VertexBuffer.MatricesWeightsKind
  16854. * - VertexBuffer.MatricesWeightsExtraKind
  16855. *
  16856. * Returns the Mesh.
  16857. */
  16858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16859. /**
  16860. * Sets the mesh indices.
  16861. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16862. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16863. * This method creates a new index buffer each call.
  16864. * Returns the Mesh.
  16865. */
  16866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16867. /**
  16868. * Boolean : True if the mesh owns the requested kind of data.
  16869. */
  16870. isVerticesDataPresent(kind: string): boolean;
  16871. /**
  16872. * Returns an array of indices (IndicesArray).
  16873. */
  16874. getIndices(): Nullable<IndicesArray>;
  16875. get _positions(): Nullable<Vector3[]>;
  16876. /**
  16877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16878. * This means the mesh underlying bounding box and sphere are recomputed.
  16879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16880. * @returns the current mesh
  16881. */
  16882. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16883. /** @hidden */
  16884. _preActivate(): InstancedMesh;
  16885. /** @hidden */
  16886. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16887. /** @hidden */
  16888. _postActivate(): void;
  16889. getWorldMatrix(): Matrix;
  16890. get isAnInstance(): boolean;
  16891. /**
  16892. * Returns the current associated LOD AbstractMesh.
  16893. */
  16894. getLOD(camera: Camera): AbstractMesh;
  16895. /** @hidden */
  16896. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16897. /** @hidden */
  16898. _syncSubMeshes(): InstancedMesh;
  16899. /** @hidden */
  16900. _generatePointsArray(): boolean;
  16901. /** @hidden */
  16902. _updateBoundingInfo(): AbstractMesh;
  16903. /**
  16904. * Creates a new InstancedMesh from the current mesh.
  16905. * - name (string) : the cloned mesh name
  16906. * - newParent (optional Node) : the optional Node to parent the clone to.
  16907. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16908. *
  16909. * Returns the clone.
  16910. */
  16911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16912. /**
  16913. * Disposes the InstancedMesh.
  16914. * Returns nothing.
  16915. */
  16916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16917. }
  16918. module "babylonjs/Meshes/mesh" {
  16919. interface Mesh {
  16920. /**
  16921. * Register a custom buffer that will be instanced
  16922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16923. * @param kind defines the buffer kind
  16924. * @param stride defines the stride in floats
  16925. */
  16926. registerInstancedBuffer(kind: string, stride: number): void;
  16927. /**
  16928. * true to use the edge renderer for all instances of this mesh
  16929. */
  16930. edgesShareWithInstances: boolean;
  16931. /** @hidden */
  16932. _userInstancedBuffersStorage: {
  16933. data: {
  16934. [key: string]: Float32Array;
  16935. };
  16936. sizes: {
  16937. [key: string]: number;
  16938. };
  16939. vertexBuffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. strides: {
  16943. [key: string]: number;
  16944. };
  16945. };
  16946. }
  16947. }
  16948. module "babylonjs/Meshes/abstractMesh" {
  16949. interface AbstractMesh {
  16950. /**
  16951. * Object used to store instanced buffers defined by user
  16952. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16953. */
  16954. instancedBuffers: {
  16955. [key: string]: any;
  16956. };
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Materials/shaderMaterial" {
  16961. import { Nullable } from "babylonjs/types";
  16962. import { Scene } from "babylonjs/scene";
  16963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16965. import { Mesh } from "babylonjs/Meshes/mesh";
  16966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16968. import { Effect } from "babylonjs/Materials/effect";
  16969. import { Material } from "babylonjs/Materials/material";
  16970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16971. /**
  16972. * Defines the options associated with the creation of a shader material.
  16973. */
  16974. export interface IShaderMaterialOptions {
  16975. /**
  16976. * Does the material work in alpha blend mode
  16977. */
  16978. needAlphaBlending: boolean;
  16979. /**
  16980. * Does the material work in alpha test mode
  16981. */
  16982. needAlphaTesting: boolean;
  16983. /**
  16984. * The list of attribute names used in the shader
  16985. */
  16986. attributes: string[];
  16987. /**
  16988. * The list of unifrom names used in the shader
  16989. */
  16990. uniforms: string[];
  16991. /**
  16992. * The list of UBO names used in the shader
  16993. */
  16994. uniformBuffers: string[];
  16995. /**
  16996. * The list of sampler names used in the shader
  16997. */
  16998. samplers: string[];
  16999. /**
  17000. * The list of defines used in the shader
  17001. */
  17002. defines: string[];
  17003. }
  17004. /**
  17005. * 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.
  17006. *
  17007. * This returned material effects how the mesh will look based on the code in the shaders.
  17008. *
  17009. * @see https://doc.babylonjs.com/how_to/shader_material
  17010. */
  17011. export class ShaderMaterial extends Material {
  17012. private _shaderPath;
  17013. private _options;
  17014. private _textures;
  17015. private _textureArrays;
  17016. private _floats;
  17017. private _ints;
  17018. private _floatsArrays;
  17019. private _colors3;
  17020. private _colors3Arrays;
  17021. private _colors4;
  17022. private _colors4Arrays;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _vectors4;
  17026. private _matrices;
  17027. private _matrixArrays;
  17028. private _matrices3x3;
  17029. private _matrices2x2;
  17030. private _vectors2Arrays;
  17031. private _vectors3Arrays;
  17032. private _vectors4Arrays;
  17033. private _cachedWorldViewMatrix;
  17034. private _cachedWorldViewProjectionMatrix;
  17035. private _renderId;
  17036. private _multiview;
  17037. private _cachedDefines;
  17038. /** Define the Url to load snippets */
  17039. static SnippetUrl: string;
  17040. /** Snippet ID if the material was created from the snippet server */
  17041. snippetId: string;
  17042. /**
  17043. * Instantiate a new shader material.
  17044. * 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.
  17045. * This returned material effects how the mesh will look based on the code in the shaders.
  17046. * @see https://doc.babylonjs.com/how_to/shader_material
  17047. * @param name Define the name of the material in the scene
  17048. * @param scene Define the scene the material belongs to
  17049. * @param shaderPath Defines the route to the shader code in one of three ways:
  17050. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17051. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17052. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17053. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17054. * @param options Define the options used to create the shader
  17055. */
  17056. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17057. /**
  17058. * Gets the shader path used to define the shader code
  17059. * It can be modified to trigger a new compilation
  17060. */
  17061. get shaderPath(): any;
  17062. /**
  17063. * Sets the shader path used to define the shader code
  17064. * It can be modified to trigger a new compilation
  17065. */
  17066. set shaderPath(shaderPath: any);
  17067. /**
  17068. * Gets the options used to compile the shader.
  17069. * They can be modified to trigger a new compilation
  17070. */
  17071. get options(): IShaderMaterialOptions;
  17072. /**
  17073. * Gets the current class name of the material e.g. "ShaderMaterial"
  17074. * Mainly use in serialization.
  17075. * @returns the class name
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * Specifies if the material will require alpha blending
  17080. * @returns a boolean specifying if alpha blending is needed
  17081. */
  17082. needAlphaBlending(): boolean;
  17083. /**
  17084. * Specifies if this material should be rendered in alpha test mode
  17085. * @returns a boolean specifying if an alpha test is needed.
  17086. */
  17087. needAlphaTesting(): boolean;
  17088. private _checkUniform;
  17089. /**
  17090. * Set a texture in the shader.
  17091. * @param name Define the name of the uniform samplers as defined in the shader
  17092. * @param texture Define the texture to bind to this sampler
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17096. /**
  17097. * Set a texture array in the shader.
  17098. * @param name Define the name of the uniform sampler array as defined in the shader
  17099. * @param textures Define the list of textures to bind to this sampler
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17103. /**
  17104. * Set a float in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloat(name: string, value: number): ShaderMaterial;
  17110. /**
  17111. * Set a int in the shader.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setInt(name: string, value: number): ShaderMaterial;
  17117. /**
  17118. * Set an array of floats in the shader.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setFloats(name: string, value: number[]): ShaderMaterial;
  17124. /**
  17125. * Set a vec3 in the shader from a Color3.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the material itself allowing "fluent" like uniform updates
  17129. */
  17130. setColor3(name: string, value: Color3): ShaderMaterial;
  17131. /**
  17132. * Set a vec3 array in the shader from a Color3 array.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the material itself allowing "fluent" like uniform updates
  17136. */
  17137. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17138. /**
  17139. * Set a vec4 in the shader from a Color4.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setColor4(name: string, value: Color4): ShaderMaterial;
  17145. /**
  17146. * Set a vec4 array in the shader from a Color4 array.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17152. /**
  17153. * Set a vec2 in the shader from a Vector2.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setVector2(name: string, value: Vector2): ShaderMaterial;
  17159. /**
  17160. * Set a vec3 in the shader from a Vector3.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setVector3(name: string, value: Vector3): ShaderMaterial;
  17166. /**
  17167. * Set a vec4 in the shader from a Vector4.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setVector4(name: string, value: Vector4): ShaderMaterial;
  17173. /**
  17174. * Set a mat4 in the shader from a Matrix.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17180. /**
  17181. * Set a float32Array in the shader from a matrix array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17187. /**
  17188. * Set a mat3 in the shader from a Float32Array.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17194. /**
  17195. * Set a mat2 in the shader from a Float32Array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 array in the shader from a number array.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setArray2(name: string, value: number[]): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a number array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setArray3(name: string, value: number[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 array in the shader from a number array.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setArray4(name: string, value: number[]): ShaderMaterial;
  17222. private _checkCache;
  17223. /**
  17224. * Specifies that the submesh is ready to be used
  17225. * @param mesh defines the mesh to check
  17226. * @param subMesh defines which submesh to check
  17227. * @param useInstances specifies that instances should be used
  17228. * @returns a boolean indicating that the submesh is ready or not
  17229. */
  17230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17231. /**
  17232. * Checks if the material is ready to render the requested mesh
  17233. * @param mesh Define the mesh to render
  17234. * @param useInstances Define whether or not the material is used with instances
  17235. * @returns true if ready, otherwise false
  17236. */
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. /**
  17239. * Binds the world matrix to the material
  17240. * @param world defines the world transformation matrix
  17241. * @param effectOverride - If provided, use this effect instead of internal effect
  17242. */
  17243. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17244. /**
  17245. * Binds the submesh to this material by preparing the effect and shader to draw
  17246. * @param world defines the world transformation matrix
  17247. * @param mesh defines the mesh containing the submesh
  17248. * @param subMesh defines the submesh to bind the material to
  17249. */
  17250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17251. /**
  17252. * Binds the material to the mesh
  17253. * @param world defines the world transformation matrix
  17254. * @param mesh defines the mesh to bind the material to
  17255. * @param effectOverride - If provided, use this effect instead of internal effect
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17258. protected _afterBind(mesh?: Mesh): void;
  17259. /**
  17260. * Gets the active textures from the material
  17261. * @returns an array of textures
  17262. */
  17263. getActiveTextures(): BaseTexture[];
  17264. /**
  17265. * Specifies if the material uses a texture
  17266. * @param texture defines the texture to check against the material
  17267. * @returns a boolean specifying if the material uses the texture
  17268. */
  17269. hasTexture(texture: BaseTexture): boolean;
  17270. /**
  17271. * Makes a duplicate of the material, and gives it a new name
  17272. * @param name defines the new name for the duplicated material
  17273. * @returns the cloned material
  17274. */
  17275. clone(name: string): ShaderMaterial;
  17276. /**
  17277. * Disposes the material
  17278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17281. */
  17282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17283. /**
  17284. * Serializes this material in a JSON representation
  17285. * @returns the serialized material object
  17286. */
  17287. serialize(): any;
  17288. /**
  17289. * Creates a shader material from parsed shader material data
  17290. * @param source defines the JSON represnetation of the material
  17291. * @param scene defines the hosting scene
  17292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17293. * @returns a new material
  17294. */
  17295. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17296. /**
  17297. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17298. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17299. * @param url defines the url to load from
  17300. * @param scene defines the hosting scene
  17301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17302. * @returns a promise that will resolve to the new ShaderMaterial
  17303. */
  17304. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17305. /**
  17306. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17307. * @param snippetId defines the snippet to load
  17308. * @param scene defines the hosting scene
  17309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17310. * @returns a promise that will resolve to the new ShaderMaterial
  17311. */
  17312. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17313. }
  17314. }
  17315. declare module "babylonjs/Shaders/color.fragment" {
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17318. /** @hidden */
  17319. export var colorPixelShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module "babylonjs/Shaders/color.vertex" {
  17325. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17331. /** @hidden */
  17332. export var colorVertexShader: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Meshes/linesMesh" {
  17338. import { Nullable } from "babylonjs/types";
  17339. import { Scene } from "babylonjs/scene";
  17340. import { Color3 } from "babylonjs/Maths/math.color";
  17341. import { Node } from "babylonjs/node";
  17342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17343. import { Mesh } from "babylonjs/Meshes/mesh";
  17344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { Material } from "babylonjs/Materials/material";
  17347. import "babylonjs/Shaders/color.fragment";
  17348. import "babylonjs/Shaders/color.vertex";
  17349. /**
  17350. * Line mesh
  17351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17352. */
  17353. export class LinesMesh extends Mesh {
  17354. /**
  17355. * If vertex color should be applied to the mesh
  17356. */
  17357. readonly useVertexColor?: boolean | undefined;
  17358. /**
  17359. * If vertex alpha should be applied to the mesh
  17360. */
  17361. readonly useVertexAlpha?: boolean | undefined;
  17362. /**
  17363. * Color of the line (Default: White)
  17364. */
  17365. color: Color3;
  17366. /**
  17367. * Alpha of the line (Default: 1)
  17368. */
  17369. alpha: number;
  17370. /**
  17371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17372. * This margin is expressed in world space coordinates, so its value may vary.
  17373. * Default value is 0.1
  17374. */
  17375. intersectionThreshold: number;
  17376. private _colorShader;
  17377. private color4;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. get material(): Material;
  17410. /**
  17411. * @hidden
  17412. */
  17413. set material(value: Material);
  17414. /**
  17415. * @hidden
  17416. */
  17417. get checkCollisions(): boolean;
  17418. /** @hidden */
  17419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17420. /** @hidden */
  17421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17422. /**
  17423. * Disposes of the line mesh
  17424. * @param doNotRecurse If children should be disposed
  17425. */
  17426. dispose(doNotRecurse?: boolean): void;
  17427. /**
  17428. * Returns a new LineMesh object cloned from the current one.
  17429. */
  17430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17431. /**
  17432. * Creates a new InstancedLinesMesh object from the mesh model.
  17433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17434. * @param name defines the name of the new instance
  17435. * @returns a new InstancedLinesMesh
  17436. */
  17437. createInstance(name: string): InstancedLinesMesh;
  17438. }
  17439. /**
  17440. * Creates an instance based on a source LinesMesh
  17441. */
  17442. export class InstancedLinesMesh extends InstancedMesh {
  17443. /**
  17444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17445. * This margin is expressed in world space coordinates, so its value may vary.
  17446. * Initilized with the intersectionThreshold value of the source LinesMesh
  17447. */
  17448. intersectionThreshold: number;
  17449. constructor(name: string, source: LinesMesh);
  17450. /**
  17451. * Returns the string "InstancedLinesMesh".
  17452. */
  17453. getClassName(): string;
  17454. }
  17455. }
  17456. declare module "babylonjs/Shaders/line.fragment" {
  17457. /** @hidden */
  17458. export var linePixelShader: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/line.vertex" {
  17464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17482. import { SmartArray } from "babylonjs/Misc/smartArray";
  17483. module "babylonjs/scene" {
  17484. interface Scene {
  17485. /** @hidden */
  17486. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/abstractMesh" {
  17490. interface AbstractMesh {
  17491. /**
  17492. * Gets the edgesRenderer associated with the mesh
  17493. */
  17494. edgesRenderer: Nullable<EdgesRenderer>;
  17495. }
  17496. }
  17497. module "babylonjs/Meshes/linesMesh" {
  17498. interface LinesMesh {
  17499. /**
  17500. * Enables the edge rendering mode on the mesh.
  17501. * This mode makes the mesh edges visible
  17502. * @param epsilon defines the maximal distance between two angles to detect a face
  17503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17504. * @returns the currentAbstractMesh
  17505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17506. */
  17507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17508. }
  17509. }
  17510. module "babylonjs/Meshes/linesMesh" {
  17511. interface InstancedLinesMesh {
  17512. /**
  17513. * Enables the edge rendering mode on the mesh.
  17514. * This mode makes the mesh edges visible
  17515. * @param epsilon defines the maximal distance between two angles to detect a face
  17516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17517. * @returns the current InstancedLinesMesh
  17518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17519. */
  17520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17521. }
  17522. }
  17523. /**
  17524. * Defines the minimum contract an Edges renderer should follow.
  17525. */
  17526. export interface IEdgesRenderer extends IDisposable {
  17527. /**
  17528. * Gets or sets a boolean indicating if the edgesRenderer is active
  17529. */
  17530. isEnabled: boolean;
  17531. /**
  17532. * Renders the edges of the attached mesh,
  17533. */
  17534. render(): void;
  17535. /**
  17536. * Checks wether or not the edges renderer is ready to render.
  17537. * @return true if ready, otherwise false.
  17538. */
  17539. isReady(): boolean;
  17540. /**
  17541. * List of instances to render in case the source mesh has instances
  17542. */
  17543. customInstances: SmartArray<Matrix>;
  17544. }
  17545. /**
  17546. * Defines the additional options of the edges renderer
  17547. */
  17548. export interface IEdgesRendererOptions {
  17549. /**
  17550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17551. * If not defined, the default value is true
  17552. */
  17553. useAlternateEdgeFinder?: boolean;
  17554. /**
  17555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17556. * If not defined, the default value is true.
  17557. * 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)
  17558. * This option is used only if useAlternateEdgeFinder = true
  17559. */
  17560. useFastVertexMerger?: boolean;
  17561. /**
  17562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17563. * The default value is 1e-6
  17564. * This option is used only if useAlternateEdgeFinder = true
  17565. */
  17566. epsilonVertexMerge?: number;
  17567. /**
  17568. * 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
  17569. * 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.
  17570. * This option is used only if useAlternateEdgeFinder = true
  17571. */
  17572. applyTessellation?: boolean;
  17573. /**
  17574. * 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
  17575. * The default value is 1e-6
  17576. * This option is used only if useAlternateEdgeFinder = true
  17577. */
  17578. epsilonVertexAligned?: number;
  17579. }
  17580. /**
  17581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17582. */
  17583. export class EdgesRenderer implements IEdgesRenderer {
  17584. /**
  17585. * Define the size of the edges with an orthographic camera
  17586. */
  17587. edgesWidthScalerForOrthographic: number;
  17588. /**
  17589. * Define the size of the edges with a perspective camera
  17590. */
  17591. edgesWidthScalerForPerspective: number;
  17592. protected _source: AbstractMesh;
  17593. protected _linesPositions: number[];
  17594. protected _linesNormals: number[];
  17595. protected _linesIndices: number[];
  17596. protected _epsilon: number;
  17597. protected _indicesCount: number;
  17598. protected _lineShader: ShaderMaterial;
  17599. protected _ib: DataBuffer;
  17600. protected _buffers: {
  17601. [key: string]: Nullable<VertexBuffer>;
  17602. };
  17603. protected _buffersForInstances: {
  17604. [key: string]: Nullable<VertexBuffer>;
  17605. };
  17606. protected _checkVerticesInsteadOfIndices: boolean;
  17607. protected _options: Nullable<IEdgesRendererOptions>;
  17608. private _meshRebuildObserver;
  17609. private _meshDisposeObserver;
  17610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17611. isEnabled: boolean;
  17612. /**
  17613. * List of instances to render in case the source mesh has instances
  17614. */
  17615. customInstances: SmartArray<Matrix>;
  17616. private static GetShader;
  17617. /**
  17618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17620. * @param source Mesh used to create edges
  17621. * @param epsilon sum of angles in adjacency to check for edge
  17622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17624. * @param options The options to apply when generating the edges
  17625. */
  17626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17627. protected _prepareRessources(): void;
  17628. /** @hidden */
  17629. _rebuild(): void;
  17630. /**
  17631. * Releases the required resources for the edges renderer
  17632. */
  17633. dispose(): void;
  17634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17636. /**
  17637. * Checks if the pair of p0 and p1 is en edge
  17638. * @param faceIndex
  17639. * @param edge
  17640. * @param faceNormals
  17641. * @param p0
  17642. * @param p1
  17643. * @private
  17644. */
  17645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17646. /**
  17647. * push line into the position, normal and index buffer
  17648. * @protected
  17649. */
  17650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17651. /**
  17652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17653. */
  17654. private _tessellateTriangle;
  17655. private _generateEdgesLinesAlternate;
  17656. /**
  17657. * Generates lines edges from adjacencjes
  17658. * @private
  17659. */
  17660. _generateEdgesLines(): void;
  17661. /**
  17662. * Checks wether or not the edges renderer is ready to render.
  17663. * @return true if ready, otherwise false.
  17664. */
  17665. isReady(): boolean;
  17666. /**
  17667. * Renders the edges of the attached mesh,
  17668. */
  17669. render(): void;
  17670. }
  17671. /**
  17672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17673. */
  17674. export class LineEdgesRenderer extends EdgesRenderer {
  17675. /**
  17676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17677. * @param source LineMesh used to generate edges
  17678. * @param epsilon not important (specified angle for edge detection)
  17679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17680. */
  17681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17682. /**
  17683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17684. */
  17685. _generateEdgesLines(): void;
  17686. }
  17687. }
  17688. declare module "babylonjs/Rendering/renderingGroup" {
  17689. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17692. import { Nullable } from "babylonjs/types";
  17693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17694. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17695. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17696. import { Material } from "babylonjs/Materials/material";
  17697. import { Scene } from "babylonjs/scene";
  17698. /**
  17699. * This represents the object necessary to create a rendering group.
  17700. * This is exclusively used and created by the rendering manager.
  17701. * To modify the behavior, you use the available helpers in your scene or meshes.
  17702. * @hidden
  17703. */
  17704. export class RenderingGroup {
  17705. index: number;
  17706. private static _zeroVector;
  17707. private _scene;
  17708. private _opaqueSubMeshes;
  17709. private _transparentSubMeshes;
  17710. private _alphaTestSubMeshes;
  17711. private _depthOnlySubMeshes;
  17712. private _particleSystems;
  17713. private _spriteManagers;
  17714. private _opaqueSortCompareFn;
  17715. private _alphaTestSortCompareFn;
  17716. private _transparentSortCompareFn;
  17717. private _renderOpaque;
  17718. private _renderAlphaTest;
  17719. private _renderTransparent;
  17720. /** @hidden */
  17721. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17722. onBeforeTransparentRendering: () => void;
  17723. /**
  17724. * Set the opaque sort comparison function.
  17725. * If null the sub meshes will be render in the order they were created
  17726. */
  17727. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17728. /**
  17729. * Set the alpha test sort comparison function.
  17730. * If null the sub meshes will be render in the order they were created
  17731. */
  17732. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17733. /**
  17734. * Set the transparent sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Creates a new rendering group.
  17740. * @param index The rendering group index
  17741. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17742. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17743. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17744. */
  17745. 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>);
  17746. /**
  17747. * Render all the sub meshes contained in the group.
  17748. * @param customRenderFunction Used to override the default render behaviour of the group.
  17749. * @returns true if rendered some submeshes.
  17750. */
  17751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17752. /**
  17753. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17754. * @param subMeshes The submeshes to render
  17755. */
  17756. private renderOpaqueSorted;
  17757. /**
  17758. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17759. * @param subMeshes The submeshes to render
  17760. */
  17761. private renderAlphaTestSorted;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderTransparentSorted;
  17767. /**
  17768. * Renders the submeshes in a specified order.
  17769. * @param subMeshes The submeshes to sort before render
  17770. * @param sortCompareFn The comparison function use to sort
  17771. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17772. * @param transparent Specifies to activate blending if true
  17773. */
  17774. private static renderSorted;
  17775. /**
  17776. * Renders the submeshes in the order they were dispatched (no sort applied).
  17777. * @param subMeshes The submeshes to render
  17778. */
  17779. private static renderUnsorted;
  17780. /**
  17781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17782. * are rendered back to front if in the same alpha index.
  17783. *
  17784. * @param a The first submesh
  17785. * @param b The second submesh
  17786. * @returns The result of the comparison
  17787. */
  17788. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17789. /**
  17790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17791. * are rendered back to front.
  17792. *
  17793. * @param a The first submesh
  17794. * @param b The second submesh
  17795. * @returns The result of the comparison
  17796. */
  17797. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17798. /**
  17799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17800. * are rendered front to back (prevent overdraw).
  17801. *
  17802. * @param a The first submesh
  17803. * @param b The second submesh
  17804. * @returns The result of the comparison
  17805. */
  17806. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17807. /**
  17808. * Resets the different lists of submeshes to prepare a new frame.
  17809. */
  17810. prepare(): void;
  17811. dispose(): void;
  17812. /**
  17813. * Inserts the submesh in its correct queue depending on its material.
  17814. * @param subMesh The submesh to dispatch
  17815. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17816. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17817. */
  17818. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17819. dispatchSprites(spriteManager: ISpriteManager): void;
  17820. dispatchParticles(particleSystem: IParticleSystem): void;
  17821. private _renderParticles;
  17822. private _renderSprites;
  17823. }
  17824. }
  17825. declare module "babylonjs/Rendering/renderingManager" {
  17826. import { Nullable } from "babylonjs/types";
  17827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17829. import { SmartArray } from "babylonjs/Misc/smartArray";
  17830. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17832. import { Material } from "babylonjs/Materials/material";
  17833. import { Scene } from "babylonjs/scene";
  17834. import { Camera } from "babylonjs/Cameras/camera";
  17835. /**
  17836. * Interface describing the different options available in the rendering manager
  17837. * regarding Auto Clear between groups.
  17838. */
  17839. export interface IRenderingManagerAutoClearSetup {
  17840. /**
  17841. * Defines whether or not autoclear is enable.
  17842. */
  17843. autoClear: boolean;
  17844. /**
  17845. * Defines whether or not to autoclear the depth buffer.
  17846. */
  17847. depth: boolean;
  17848. /**
  17849. * Defines whether or not to autoclear the stencil buffer.
  17850. */
  17851. stencil: boolean;
  17852. }
  17853. /**
  17854. * This class is used by the onRenderingGroupObservable
  17855. */
  17856. export class RenderingGroupInfo {
  17857. /**
  17858. * The Scene that being rendered
  17859. */
  17860. scene: Scene;
  17861. /**
  17862. * The camera currently used for the rendering pass
  17863. */
  17864. camera: Nullable<Camera>;
  17865. /**
  17866. * The ID of the renderingGroup being processed
  17867. */
  17868. renderingGroupId: number;
  17869. }
  17870. /**
  17871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17872. * It is enable to manage the different groups as well as the different necessary sort functions.
  17873. * This should not be used directly aside of the few static configurations
  17874. */
  17875. export class RenderingManager {
  17876. /**
  17877. * The max id used for rendering groups (not included)
  17878. */
  17879. static MAX_RENDERINGGROUPS: number;
  17880. /**
  17881. * The min id used for rendering groups (included)
  17882. */
  17883. static MIN_RENDERINGGROUPS: number;
  17884. /**
  17885. * Used to globally prevent autoclearing scenes.
  17886. */
  17887. static AUTOCLEAR: boolean;
  17888. /**
  17889. * @hidden
  17890. */
  17891. _useSceneAutoClearSetup: boolean;
  17892. private _scene;
  17893. private _renderingGroups;
  17894. private _depthStencilBufferAlreadyCleaned;
  17895. private _autoClearDepthStencil;
  17896. private _customOpaqueSortCompareFn;
  17897. private _customAlphaTestSortCompareFn;
  17898. private _customTransparentSortCompareFn;
  17899. private _renderingGroupInfo;
  17900. /**
  17901. * Instantiates a new rendering group for a particular scene
  17902. * @param scene Defines the scene the groups belongs to
  17903. */
  17904. constructor(scene: Scene);
  17905. private _clearDepthStencilBuffer;
  17906. /**
  17907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17908. * @hidden
  17909. */
  17910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17911. /**
  17912. * Resets the different information of the group to prepare a new frame
  17913. * @hidden
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Dispose and release the group and its associated resources.
  17918. * @hidden
  17919. */
  17920. dispose(): void;
  17921. /**
  17922. * Clear the info related to rendering groups preventing retention points during dispose.
  17923. */
  17924. freeRenderingGroups(): void;
  17925. private _prepareRenderingGroup;
  17926. /**
  17927. * Add a sprite manager to the rendering manager in order to render it this frame.
  17928. * @param spriteManager Define the sprite manager to render
  17929. */
  17930. dispatchSprites(spriteManager: ISpriteManager): void;
  17931. /**
  17932. * Add a particle system to the rendering manager in order to render it this frame.
  17933. * @param particleSystem Define the particle system to render
  17934. */
  17935. dispatchParticles(particleSystem: IParticleSystem): void;
  17936. /**
  17937. * Add a submesh to the manager in order to render it this frame
  17938. * @param subMesh The submesh to dispatch
  17939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17941. */
  17942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17943. /**
  17944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17945. * This allowed control for front to back rendering or reversly depending of the special needs.
  17946. *
  17947. * @param renderingGroupId The rendering group id corresponding to its index
  17948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17951. */
  17952. 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;
  17953. /**
  17954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17955. *
  17956. * @param renderingGroupId The rendering group id corresponding to its index
  17957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17960. */
  17961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17962. /**
  17963. * Gets the current auto clear configuration for one rendering group of the rendering
  17964. * manager.
  17965. * @param index the rendering group index to get the information for
  17966. * @returns The auto clear setup for the requested rendering group
  17967. */
  17968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17969. }
  17970. }
  17971. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17972. import { SmartArray } from "babylonjs/Misc/smartArray";
  17973. import { Nullable } from "babylonjs/types";
  17974. import { Scene } from "babylonjs/scene";
  17975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17978. import { Mesh } from "babylonjs/Meshes/mesh";
  17979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17980. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17981. import { Effect } from "babylonjs/Materials/effect";
  17982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17984. import "babylonjs/Shaders/shadowMap.fragment";
  17985. import "babylonjs/Shaders/shadowMap.vertex";
  17986. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17987. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. /**
  17990. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17991. */
  17992. export interface ICustomShaderOptions {
  17993. /**
  17994. * Gets or sets the custom shader name to use
  17995. */
  17996. shaderName: string;
  17997. /**
  17998. * The list of attribute names used in the shader
  17999. */
  18000. attributes?: string[];
  18001. /**
  18002. * The list of unifrom names used in the shader
  18003. */
  18004. uniforms?: string[];
  18005. /**
  18006. * The list of sampler names used in the shader
  18007. */
  18008. samplers?: string[];
  18009. /**
  18010. * The list of defines used in the shader
  18011. */
  18012. defines?: string[];
  18013. }
  18014. /**
  18015. * Interface to implement to create a shadow generator compatible with BJS.
  18016. */
  18017. export interface IShadowGenerator {
  18018. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18019. id: string;
  18020. /**
  18021. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18022. * @returns The render target texture if present otherwise, null
  18023. */
  18024. getShadowMap(): Nullable<RenderTargetTexture>;
  18025. /**
  18026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18027. * @param subMesh The submesh we want to render in the shadow map
  18028. * @param useInstances Defines wether will draw in the map using instances
  18029. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18030. * @returns true if ready otherwise, false
  18031. */
  18032. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18033. /**
  18034. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18035. * @param defines Defines of the material we want to update
  18036. * @param lightIndex Index of the light in the enabled light list of the material
  18037. */
  18038. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18039. /**
  18040. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18041. * defined in the generator but impacting the effect).
  18042. * It implies the unifroms available on the materials are the standard BJS ones.
  18043. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18044. * @param effect The effect we are binfing the information for
  18045. */
  18046. bindShadowLight(lightIndex: string, effect: Effect): void;
  18047. /**
  18048. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18049. * (eq to shadow prjection matrix * light transform matrix)
  18050. * @returns The transform matrix used to create the shadow map
  18051. */
  18052. getTransformMatrix(): Matrix;
  18053. /**
  18054. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18055. * Cube and 2D textures for instance.
  18056. */
  18057. recreateShadowMap(): void;
  18058. /**
  18059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18060. * @param onCompiled Callback triggered at the and of the effects compilation
  18061. * @param options Sets of optional options forcing the compilation with different modes
  18062. */
  18063. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18064. useInstances: boolean;
  18065. }>): void;
  18066. /**
  18067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18068. * @param options Sets of optional options forcing the compilation with different modes
  18069. * @returns A promise that resolves when the compilation completes
  18070. */
  18071. forceCompilationAsync(options?: Partial<{
  18072. useInstances: boolean;
  18073. }>): Promise<void>;
  18074. /**
  18075. * Serializes the shadow generator setup to a json object.
  18076. * @returns The serialized JSON object
  18077. */
  18078. serialize(): any;
  18079. /**
  18080. * Disposes the Shadow map and related Textures and effects.
  18081. */
  18082. dispose(): void;
  18083. }
  18084. /**
  18085. * Default implementation IShadowGenerator.
  18086. * This is the main object responsible of generating shadows in the framework.
  18087. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18088. */
  18089. export class ShadowGenerator implements IShadowGenerator {
  18090. /**
  18091. * Name of the shadow generator class
  18092. */
  18093. static CLASSNAME: string;
  18094. /**
  18095. * Shadow generator mode None: no filtering applied.
  18096. */
  18097. static readonly FILTER_NONE: number;
  18098. /**
  18099. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18100. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18101. */
  18102. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18103. /**
  18104. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18105. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18106. */
  18107. static readonly FILTER_POISSONSAMPLING: number;
  18108. /**
  18109. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18115. * edge artifacts on steep falloff.
  18116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18117. */
  18118. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18121. * edge artifacts on steep falloff.
  18122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18123. */
  18124. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18125. /**
  18126. * Shadow generator mode PCF: Percentage Closer Filtering
  18127. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18128. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18129. */
  18130. static readonly FILTER_PCF: number;
  18131. /**
  18132. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18134. * Contact Hardening
  18135. */
  18136. static readonly FILTER_PCSS: number;
  18137. /**
  18138. * Reserved for PCF and PCSS
  18139. * Highest Quality.
  18140. *
  18141. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18142. *
  18143. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18144. */
  18145. static readonly QUALITY_HIGH: number;
  18146. /**
  18147. * Reserved for PCF and PCSS
  18148. * Good tradeoff for quality/perf cross devices
  18149. *
  18150. * Execute PCF on a 3*3 kernel.
  18151. *
  18152. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18153. */
  18154. static readonly QUALITY_MEDIUM: number;
  18155. /**
  18156. * Reserved for PCF and PCSS
  18157. * The lowest quality but the fastest.
  18158. *
  18159. * Execute PCF on a 1*1 kernel.
  18160. *
  18161. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18162. */
  18163. static readonly QUALITY_LOW: number;
  18164. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18165. id: string;
  18166. /** Gets or sets the custom shader name to use */
  18167. customShaderOptions: ICustomShaderOptions;
  18168. /**
  18169. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18170. */
  18171. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18172. /**
  18173. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18174. */
  18175. onAfterShadowMapRenderObservable: Observable<Effect>;
  18176. /**
  18177. * Observable triggered before a mesh is rendered in the shadow map.
  18178. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18179. */
  18180. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18181. /**
  18182. * Observable triggered after a mesh is rendered in the shadow map.
  18183. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18184. */
  18185. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18186. protected _bias: number;
  18187. /**
  18188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18189. */
  18190. get bias(): number;
  18191. /**
  18192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18193. */
  18194. set bias(bias: number);
  18195. protected _normalBias: number;
  18196. /**
  18197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18198. */
  18199. get normalBias(): number;
  18200. /**
  18201. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18202. */
  18203. set normalBias(normalBias: number);
  18204. protected _blurBoxOffset: number;
  18205. /**
  18206. * Gets the blur box offset: offset applied during the blur pass.
  18207. * Only useful if useKernelBlur = false
  18208. */
  18209. get blurBoxOffset(): number;
  18210. /**
  18211. * Sets the blur box offset: offset applied during the blur pass.
  18212. * Only useful if useKernelBlur = false
  18213. */
  18214. set blurBoxOffset(value: number);
  18215. protected _blurScale: number;
  18216. /**
  18217. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18218. * 2 means half of the size.
  18219. */
  18220. get blurScale(): number;
  18221. /**
  18222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18223. * 2 means half of the size.
  18224. */
  18225. set blurScale(value: number);
  18226. protected _blurKernel: number;
  18227. /**
  18228. * Gets the blur kernel: kernel size of the blur pass.
  18229. * Only useful if useKernelBlur = true
  18230. */
  18231. get blurKernel(): number;
  18232. /**
  18233. * Sets the blur kernel: kernel size of the blur pass.
  18234. * Only useful if useKernelBlur = true
  18235. */
  18236. set blurKernel(value: number);
  18237. protected _useKernelBlur: boolean;
  18238. /**
  18239. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18241. */
  18242. get useKernelBlur(): boolean;
  18243. /**
  18244. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18245. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18246. */
  18247. set useKernelBlur(value: boolean);
  18248. protected _depthScale: number;
  18249. /**
  18250. * Gets the depth scale used in ESM mode.
  18251. */
  18252. get depthScale(): number;
  18253. /**
  18254. * Sets the depth scale used in ESM mode.
  18255. * This can override the scale stored on the light.
  18256. */
  18257. set depthScale(value: number);
  18258. protected _validateFilter(filter: number): number;
  18259. protected _filter: number;
  18260. /**
  18261. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18263. */
  18264. get filter(): number;
  18265. /**
  18266. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18267. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18268. */
  18269. set filter(value: number);
  18270. /**
  18271. * Gets if the current filter is set to Poisson Sampling.
  18272. */
  18273. get usePoissonSampling(): boolean;
  18274. /**
  18275. * Sets the current filter to Poisson Sampling.
  18276. */
  18277. set usePoissonSampling(value: boolean);
  18278. /**
  18279. * Gets if the current filter is set to ESM.
  18280. */
  18281. get useExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter is to ESM.
  18284. */
  18285. set useExponentialShadowMap(value: boolean);
  18286. /**
  18287. * Gets if the current filter is set to filtered ESM.
  18288. */
  18289. get useBlurExponentialShadowMap(): boolean;
  18290. /**
  18291. * Gets if the current filter is set to filtered ESM.
  18292. */
  18293. set useBlurExponentialShadowMap(value: boolean);
  18294. /**
  18295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18296. * exponential to prevent steep falloff artifacts).
  18297. */
  18298. get useCloseExponentialShadowMap(): boolean;
  18299. /**
  18300. * Sets the current filter to "close ESM" (using the inverse of the
  18301. * exponential to prevent steep falloff artifacts).
  18302. */
  18303. set useCloseExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useBlurCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useBlurCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18316. */
  18317. get usePercentageCloserFiltering(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCF" (percentage closer filtering).
  18320. */
  18321. set usePercentageCloserFiltering(value: boolean);
  18322. protected _filteringQuality: number;
  18323. /**
  18324. * Gets the PCF or PCSS Quality.
  18325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18326. */
  18327. get filteringQuality(): number;
  18328. /**
  18329. * Sets the PCF or PCSS Quality.
  18330. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18331. */
  18332. set filteringQuality(filteringQuality: number);
  18333. /**
  18334. * Gets if the current filter is set to "PCSS" (contact hardening).
  18335. */
  18336. get useContactHardeningShadow(): boolean;
  18337. /**
  18338. * Sets the current filter to "PCSS" (contact hardening).
  18339. */
  18340. set useContactHardeningShadow(value: boolean);
  18341. protected _contactHardeningLightSizeUVRatio: number;
  18342. /**
  18343. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18344. * Using a ratio helps keeping shape stability independently of the map size.
  18345. *
  18346. * It does not account for the light projection as it was having too much
  18347. * instability during the light setup or during light position changes.
  18348. *
  18349. * Only valid if useContactHardeningShadow is true.
  18350. */
  18351. get contactHardeningLightSizeUVRatio(): number;
  18352. /**
  18353. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18362. protected _darkness: number;
  18363. /** Gets or sets the actual darkness of a shadow */
  18364. get darkness(): number;
  18365. set darkness(value: number);
  18366. /**
  18367. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18368. * 0 means strongest and 1 would means no shadow.
  18369. * @returns the darkness.
  18370. */
  18371. getDarkness(): number;
  18372. /**
  18373. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18374. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18375. * @returns the shadow generator allowing fluent coding.
  18376. */
  18377. setDarkness(darkness: number): ShadowGenerator;
  18378. protected _transparencyShadow: boolean;
  18379. /** Gets or sets the ability to have transparent shadow */
  18380. get transparencyShadow(): boolean;
  18381. set transparencyShadow(value: boolean);
  18382. /**
  18383. * Sets the ability to have transparent shadow (boolean).
  18384. * @param transparent True if transparent else False
  18385. * @returns the shadow generator allowing fluent coding
  18386. */
  18387. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18388. /**
  18389. * Enables or disables shadows with varying strength based on the transparency
  18390. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18391. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18392. * mesh.visibility * alphaTexture.a
  18393. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18394. */
  18395. enableSoftTransparentShadow: boolean;
  18396. protected _shadowMap: Nullable<RenderTargetTexture>;
  18397. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18398. /**
  18399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18400. * @returns The render target texture if present otherwise, null
  18401. */
  18402. getShadowMap(): Nullable<RenderTargetTexture>;
  18403. /**
  18404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18405. * @returns The render target texture if the shadow map is present otherwise, null
  18406. */
  18407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the class name of that object
  18410. * @returns "ShadowGenerator"
  18411. */
  18412. getClassName(): string;
  18413. /**
  18414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18415. * @param mesh Mesh to add
  18416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18417. * @returns the Shadow Generator itself
  18418. */
  18419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18420. /**
  18421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18422. * @param mesh Mesh to remove
  18423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18424. * @returns the Shadow Generator itself
  18425. */
  18426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18427. /**
  18428. * Controls the extent to which the shadows fade out at the edge of the frustum
  18429. */
  18430. frustumEdgeFalloff: number;
  18431. protected _light: IShadowLight;
  18432. /**
  18433. * Returns the associated light object.
  18434. * @returns the light generating the shadow
  18435. */
  18436. getLight(): IShadowLight;
  18437. /**
  18438. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18439. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18440. * It might on the other hand introduce peter panning.
  18441. */
  18442. forceBackFacesOnly: boolean;
  18443. protected _scene: Scene;
  18444. protected _lightDirection: Vector3;
  18445. protected _effect: Effect;
  18446. protected _viewMatrix: Matrix;
  18447. protected _projectionMatrix: Matrix;
  18448. protected _transformMatrix: Matrix;
  18449. protected _cachedPosition: Vector3;
  18450. protected _cachedDirection: Vector3;
  18451. protected _cachedDefines: string;
  18452. protected _currentRenderID: number;
  18453. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18454. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18456. protected _blurPostProcesses: PostProcess[];
  18457. protected _mapSize: number;
  18458. protected _currentFaceIndex: number;
  18459. protected _currentFaceIndexCache: number;
  18460. protected _textureType: number;
  18461. protected _defaultTextureMatrix: Matrix;
  18462. protected _storedUniqueId: Nullable<number>;
  18463. /** @hidden */
  18464. static _SceneComponentInitialization: (scene: Scene) => void;
  18465. /**
  18466. * Creates a ShadowGenerator object.
  18467. * A ShadowGenerator is the required tool to use the shadows.
  18468. * Each light casting shadows needs to use its own ShadowGenerator.
  18469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18471. * @param light The light object generating the shadows.
  18472. * @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.
  18473. */
  18474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18475. protected _initializeGenerator(): void;
  18476. protected _createTargetRenderTexture(): void;
  18477. protected _initializeShadowMap(): void;
  18478. protected _initializeBlurRTTAndPostProcesses(): void;
  18479. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18480. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18481. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18482. protected _applyFilterValues(): void;
  18483. /**
  18484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18485. * @param onCompiled Callback triggered at the and of the effects compilation
  18486. * @param options Sets of optional options forcing the compilation with different modes
  18487. */
  18488. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18489. useInstances: boolean;
  18490. }>): void;
  18491. /**
  18492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18493. * @param options Sets of optional options forcing the compilation with different modes
  18494. * @returns A promise that resolves when the compilation completes
  18495. */
  18496. forceCompilationAsync(options?: Partial<{
  18497. useInstances: boolean;
  18498. }>): Promise<void>;
  18499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18500. private _prepareShadowDefines;
  18501. /**
  18502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18503. * @param subMesh The submesh we want to render in the shadow map
  18504. * @param useInstances Defines wether will draw in the map using instances
  18505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18506. * @returns true if ready otherwise, false
  18507. */
  18508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18509. /**
  18510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18511. * @param defines Defines of the material we want to update
  18512. * @param lightIndex Index of the light in the enabled light list of the material
  18513. */
  18514. prepareDefines(defines: any, lightIndex: number): void;
  18515. /**
  18516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18517. * defined in the generator but impacting the effect).
  18518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18519. * @param effect The effect we are binfing the information for
  18520. */
  18521. bindShadowLight(lightIndex: string, effect: Effect): void;
  18522. /**
  18523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18524. * (eq to shadow prjection matrix * light transform matrix)
  18525. * @returns The transform matrix used to create the shadow map
  18526. */
  18527. getTransformMatrix(): Matrix;
  18528. /**
  18529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18530. * Cube and 2D textures for instance.
  18531. */
  18532. recreateShadowMap(): void;
  18533. protected _disposeBlurPostProcesses(): void;
  18534. protected _disposeRTTandPostProcesses(): void;
  18535. /**
  18536. * Disposes the ShadowGenerator.
  18537. * Returns nothing.
  18538. */
  18539. dispose(): void;
  18540. /**
  18541. * Serializes the shadow generator setup to a json object.
  18542. * @returns The serialized JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18547. * @param parsedShadowGenerator The JSON object to parse
  18548. * @param scene The scene to create the shadow map for
  18549. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18550. * @returns The parsed shadow generator
  18551. */
  18552. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18553. }
  18554. }
  18555. declare module "babylonjs/Lights/light" {
  18556. import { Nullable } from "babylonjs/types";
  18557. import { Scene } from "babylonjs/scene";
  18558. import { Vector3 } from "babylonjs/Maths/math.vector";
  18559. import { Color3 } from "babylonjs/Maths/math.color";
  18560. import { Node } from "babylonjs/node";
  18561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18564. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18565. /**
  18566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18568. * 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.
  18569. */
  18570. export abstract class Light extends Node {
  18571. /**
  18572. * Falloff Default: light is falling off following the material specification:
  18573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18574. */
  18575. static readonly FALLOFF_DEFAULT: number;
  18576. /**
  18577. * Falloff Physical: light is falling off following the inverse squared distance law.
  18578. */
  18579. static readonly FALLOFF_PHYSICAL: number;
  18580. /**
  18581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18582. * to enhance interoperability with other engines.
  18583. */
  18584. static readonly FALLOFF_GLTF: number;
  18585. /**
  18586. * Falloff Standard: light is falling off like in the standard material
  18587. * to enhance interoperability with other materials.
  18588. */
  18589. static readonly FALLOFF_STANDARD: number;
  18590. /**
  18591. * If every light affecting the material is in this lightmapMode,
  18592. * material.lightmapTexture adds or multiplies
  18593. * (depends on material.useLightmapAsShadowmap)
  18594. * after every other light calculations.
  18595. */
  18596. static readonly LIGHTMAP_DEFAULT: number;
  18597. /**
  18598. * material.lightmapTexture as only diffuse lighting from this light
  18599. * adds only specular lighting from this light
  18600. * adds dynamic shadows
  18601. */
  18602. static readonly LIGHTMAP_SPECULAR: number;
  18603. /**
  18604. * material.lightmapTexture as only lighting
  18605. * no light calculation from this light
  18606. * only adds dynamic shadows from this light
  18607. */
  18608. static readonly LIGHTMAP_SHADOWSONLY: number;
  18609. /**
  18610. * Each light type uses the default quantity according to its type:
  18611. * point/spot lights use luminous intensity
  18612. * directional lights use illuminance
  18613. */
  18614. static readonly INTENSITYMODE_AUTOMATIC: number;
  18615. /**
  18616. * lumen (lm)
  18617. */
  18618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18619. /**
  18620. * candela (lm/sr)
  18621. */
  18622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18623. /**
  18624. * lux (lm/m^2)
  18625. */
  18626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18627. /**
  18628. * nit (cd/m^2)
  18629. */
  18630. static readonly INTENSITYMODE_LUMINANCE: number;
  18631. /**
  18632. * Light type const id of the point light.
  18633. */
  18634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18635. /**
  18636. * Light type const id of the directional light.
  18637. */
  18638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18639. /**
  18640. * Light type const id of the spot light.
  18641. */
  18642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18643. /**
  18644. * Light type const id of the hemispheric light.
  18645. */
  18646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18647. /**
  18648. * Diffuse gives the basic color to an object.
  18649. */
  18650. diffuse: Color3;
  18651. /**
  18652. * Specular produces a highlight color on an object.
  18653. * Note: This is note affecting PBR materials.
  18654. */
  18655. specular: Color3;
  18656. /**
  18657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18658. * falling off base on range or angle.
  18659. * This can be set to any values in Light.FALLOFF_x.
  18660. *
  18661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18662. * other types of materials.
  18663. */
  18664. falloffType: number;
  18665. /**
  18666. * Strength of the light.
  18667. * Note: By default it is define in the framework own unit.
  18668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18669. */
  18670. intensity: number;
  18671. private _range;
  18672. protected _inverseSquaredRange: number;
  18673. /**
  18674. * Defines how far from the source the light is impacting in scene units.
  18675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18676. */
  18677. get range(): number;
  18678. /**
  18679. * Defines how far from the source the light is impacting in scene units.
  18680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18681. */
  18682. set range(value: number);
  18683. /**
  18684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18685. * of light.
  18686. */
  18687. private _photometricScale;
  18688. private _intensityMode;
  18689. /**
  18690. * Gets the photometric scale used to interpret the intensity.
  18691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18692. */
  18693. get intensityMode(): number;
  18694. /**
  18695. * Sets the photometric scale used to interpret the intensity.
  18696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18697. */
  18698. set intensityMode(value: number);
  18699. private _radius;
  18700. /**
  18701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18702. */
  18703. get radius(): number;
  18704. /**
  18705. * sets the light radius used by PBR Materials to simulate soft area lights.
  18706. */
  18707. set radius(value: number);
  18708. private _renderPriority;
  18709. /**
  18710. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18711. * exceeding the number allowed of the materials.
  18712. */
  18713. renderPriority: number;
  18714. private _shadowEnabled;
  18715. /**
  18716. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18717. * the current shadow generator.
  18718. */
  18719. get shadowEnabled(): boolean;
  18720. /**
  18721. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18722. * the current shadow generator.
  18723. */
  18724. set shadowEnabled(value: boolean);
  18725. private _includedOnlyMeshes;
  18726. /**
  18727. * Gets the only meshes impacted by this light.
  18728. */
  18729. get includedOnlyMeshes(): AbstractMesh[];
  18730. /**
  18731. * Sets the only meshes impacted by this light.
  18732. */
  18733. set includedOnlyMeshes(value: AbstractMesh[]);
  18734. private _excludedMeshes;
  18735. /**
  18736. * Gets the meshes not impacted by this light.
  18737. */
  18738. get excludedMeshes(): AbstractMesh[];
  18739. /**
  18740. * Sets the meshes not impacted by this light.
  18741. */
  18742. set excludedMeshes(value: AbstractMesh[]);
  18743. private _excludeWithLayerMask;
  18744. /**
  18745. * Gets the layer id use to find what meshes are not impacted by the light.
  18746. * Inactive if 0
  18747. */
  18748. get excludeWithLayerMask(): number;
  18749. /**
  18750. * Sets the layer id use to find what meshes are not impacted by the light.
  18751. * Inactive if 0
  18752. */
  18753. set excludeWithLayerMask(value: number);
  18754. private _includeOnlyWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get includeOnlyWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set includeOnlyWithLayerMask(value: number);
  18765. private _lightmapMode;
  18766. /**
  18767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18768. */
  18769. get lightmapMode(): number;
  18770. /**
  18771. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18772. */
  18773. set lightmapMode(value: number);
  18774. /**
  18775. * Shadow generator associted to the light.
  18776. * @hidden Internal use only.
  18777. */
  18778. _shadowGenerator: Nullable<IShadowGenerator>;
  18779. /**
  18780. * @hidden Internal use only.
  18781. */
  18782. _excludedMeshesIds: string[];
  18783. /**
  18784. * @hidden Internal use only.
  18785. */
  18786. _includedOnlyMeshesIds: string[];
  18787. /**
  18788. * The current light unifom buffer.
  18789. * @hidden Internal use only.
  18790. */
  18791. _uniformBuffer: UniformBuffer;
  18792. /** @hidden */
  18793. _renderId: number;
  18794. /**
  18795. * Creates a Light object in the scene.
  18796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18797. * @param name The firendly name of the light
  18798. * @param scene The scene the light belongs too
  18799. */
  18800. constructor(name: string, scene: Scene);
  18801. protected abstract _buildUniformLayout(): void;
  18802. /**
  18803. * Sets the passed Effect "effect" with the Light information.
  18804. * @param effect The effect to update
  18805. * @param lightIndex The index of the light in the effect to update
  18806. * @returns The light
  18807. */
  18808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18809. /**
  18810. * Sets the passed Effect "effect" with the Light textures.
  18811. * @param effect The effect to update
  18812. * @param lightIndex The index of the light in the effect to update
  18813. * @returns The light
  18814. */
  18815. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18816. /**
  18817. * Binds the lights information from the scene to the effect for the given mesh.
  18818. * @param lightIndex Light index
  18819. * @param scene The scene where the light belongs to
  18820. * @param effect The effect we are binding the data to
  18821. * @param useSpecular Defines if specular is supported
  18822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18823. */
  18824. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18825. /**
  18826. * Sets the passed Effect "effect" with the Light information.
  18827. * @param effect The effect to update
  18828. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18829. * @returns The light
  18830. */
  18831. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18832. /**
  18833. * Returns the string "Light".
  18834. * @returns the class name
  18835. */
  18836. getClassName(): string;
  18837. /** @hidden */
  18838. readonly _isLight: boolean;
  18839. /**
  18840. * Converts the light information to a readable string for debug purpose.
  18841. * @param fullDetails Supports for multiple levels of logging within scene loading
  18842. * @returns the human readable light info
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /** @hidden */
  18846. protected _syncParentEnabledState(): void;
  18847. /**
  18848. * Set the enabled state of this node.
  18849. * @param value - the new enabled state
  18850. */
  18851. setEnabled(value: boolean): void;
  18852. /**
  18853. * Returns the Light associated shadow generator if any.
  18854. * @return the associated shadow generator.
  18855. */
  18856. getShadowGenerator(): Nullable<IShadowGenerator>;
  18857. /**
  18858. * Returns a Vector3, the absolute light position in the World.
  18859. * @returns the world space position of the light
  18860. */
  18861. getAbsolutePosition(): Vector3;
  18862. /**
  18863. * Specifies if the light will affect the passed mesh.
  18864. * @param mesh The mesh to test against the light
  18865. * @return true the mesh is affected otherwise, false.
  18866. */
  18867. canAffectMesh(mesh: AbstractMesh): boolean;
  18868. /**
  18869. * Sort function to order lights for rendering.
  18870. * @param a First Light object to compare to second.
  18871. * @param b Second Light object to compare first.
  18872. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18873. */
  18874. static CompareLightsPriority(a: Light, b: Light): number;
  18875. /**
  18876. * Releases resources associated with this node.
  18877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18879. */
  18880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18881. /**
  18882. * Returns the light type ID (integer).
  18883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18884. */
  18885. getTypeID(): number;
  18886. /**
  18887. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18888. * @returns the scaled intensity in intensity mode unit
  18889. */
  18890. getScaledIntensity(): number;
  18891. /**
  18892. * Returns a new Light object, named "name", from the current one.
  18893. * @param name The name of the cloned light
  18894. * @param newParent The parent of this light, if it has one
  18895. * @returns the new created light
  18896. */
  18897. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18898. /**
  18899. * Serializes the current light into a Serialization object.
  18900. * @returns the serialized object.
  18901. */
  18902. serialize(): any;
  18903. /**
  18904. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18905. * This new light is named "name" and added to the passed scene.
  18906. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18907. * @param name The friendly name of the light
  18908. * @param scene The scene the new light will belong to
  18909. * @returns the constructor function
  18910. */
  18911. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18912. /**
  18913. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18914. * @param parsedLight The JSON representation of the light
  18915. * @param scene The scene to create the parsed light in
  18916. * @returns the created light after parsing
  18917. */
  18918. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18919. private _hookArrayForExcluded;
  18920. private _hookArrayForIncludedOnly;
  18921. private _resyncMeshes;
  18922. /**
  18923. * Forces the meshes to update their light related information in their rendering used effects
  18924. * @hidden Internal Use Only
  18925. */
  18926. _markMeshesAsLightDirty(): void;
  18927. /**
  18928. * Recomputes the cached photometric scale if needed.
  18929. */
  18930. private _computePhotometricScale;
  18931. /**
  18932. * Returns the Photometric Scale according to the light type and intensity mode.
  18933. */
  18934. private _getPhotometricScale;
  18935. /**
  18936. * Reorder the light in the scene according to their defined priority.
  18937. * @hidden Internal Use Only
  18938. */
  18939. _reorderLightsInScene(): void;
  18940. /**
  18941. * Prepares the list of defines specific to the light type.
  18942. * @param defines the list of defines
  18943. * @param lightIndex defines the index of the light for the effect
  18944. */
  18945. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18946. }
  18947. }
  18948. declare module "babylonjs/Cameras/targetCamera" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Camera } from "babylonjs/Cameras/camera";
  18951. import { Scene } from "babylonjs/scene";
  18952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18953. /**
  18954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. */
  18958. export class TargetCamera extends Camera {
  18959. private static _RigCamTransformMatrix;
  18960. private static _TargetTransformMatrix;
  18961. private static _TargetFocalPoint;
  18962. private _tmpUpVector;
  18963. private _tmpTargetVector;
  18964. /**
  18965. * Define the current direction the camera is moving to
  18966. */
  18967. cameraDirection: Vector3;
  18968. /**
  18969. * Define the current rotation the camera is rotating to
  18970. */
  18971. cameraRotation: Vector2;
  18972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18973. ignoreParentScaling: boolean;
  18974. /**
  18975. * When set, the up vector of the camera will be updated by the rotation of the camera
  18976. */
  18977. updateUpVectorFromRotation: boolean;
  18978. private _tmpQuaternion;
  18979. /**
  18980. * Define the current rotation of the camera
  18981. */
  18982. rotation: Vector3;
  18983. /**
  18984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18985. */
  18986. rotationQuaternion: Quaternion;
  18987. /**
  18988. * Define the current speed of the camera
  18989. */
  18990. speed: number;
  18991. /**
  18992. * Add constraint to the camera to prevent it to move freely in all directions and
  18993. * around all axis.
  18994. */
  18995. noRotationConstraint: boolean;
  18996. /**
  18997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18998. * panning
  18999. */
  19000. invertRotation: boolean;
  19001. /**
  19002. * Speed multiplier for inverse camera panning
  19003. */
  19004. inverseRotationSpeed: number;
  19005. /**
  19006. * Define the current target of the camera as an object or a position.
  19007. */
  19008. lockedTarget: any;
  19009. /** @hidden */
  19010. _currentTarget: Vector3;
  19011. /** @hidden */
  19012. _initialFocalDistance: number;
  19013. /** @hidden */
  19014. _viewMatrix: Matrix;
  19015. /** @hidden */
  19016. _camMatrix: Matrix;
  19017. /** @hidden */
  19018. _cameraTransformMatrix: Matrix;
  19019. /** @hidden */
  19020. _cameraRotationMatrix: Matrix;
  19021. /** @hidden */
  19022. _referencePoint: Vector3;
  19023. /** @hidden */
  19024. _transformedReferencePoint: Vector3;
  19025. /** @hidden */
  19026. _reset: () => void;
  19027. private _defaultUp;
  19028. /**
  19029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19030. * This is the base of the follow, arc rotate cameras and Free camera
  19031. * @see https://doc.babylonjs.com/features/cameras
  19032. * @param name Defines the name of the camera in the scene
  19033. * @param position Defines the start position of the camera in the scene
  19034. * @param scene Defines the scene the camera belongs to
  19035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19036. */
  19037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19038. /**
  19039. * Gets the position in front of the camera at a given distance.
  19040. * @param distance The distance from the camera we want the position to be
  19041. * @returns the position
  19042. */
  19043. getFrontPosition(distance: number): Vector3;
  19044. /** @hidden */
  19045. _getLockedTargetPosition(): Nullable<Vector3>;
  19046. private _storedPosition;
  19047. private _storedRotation;
  19048. private _storedRotationQuaternion;
  19049. /**
  19050. * Store current camera state of the camera (fov, position, rotation, etc..)
  19051. * @returns the camera
  19052. */
  19053. storeState(): Camera;
  19054. /**
  19055. * Restored camera state. You must call storeState() first
  19056. * @returns whether it was successful or not
  19057. * @hidden
  19058. */
  19059. _restoreStateValues(): boolean;
  19060. /** @hidden */
  19061. _initCache(): void;
  19062. /** @hidden */
  19063. _updateCache(ignoreParentClass?: boolean): void;
  19064. /** @hidden */
  19065. _isSynchronizedViewMatrix(): boolean;
  19066. /** @hidden */
  19067. _computeLocalCameraSpeed(): number;
  19068. /**
  19069. * Defines the target the camera should look at.
  19070. * @param target Defines the new target as a Vector or a mesh
  19071. */
  19072. setTarget(target: Vector3): void;
  19073. /**
  19074. * Defines the target point of the camera.
  19075. * The camera looks towards it form the radius distance.
  19076. */
  19077. get target(): Vector3;
  19078. set target(value: Vector3);
  19079. /**
  19080. * Return the current target position of the camera. This value is expressed in local space.
  19081. * @returns the target position
  19082. */
  19083. getTarget(): Vector3;
  19084. /** @hidden */
  19085. _decideIfNeedsToMove(): boolean;
  19086. /** @hidden */
  19087. _updatePosition(): void;
  19088. /** @hidden */
  19089. _checkInputs(): void;
  19090. protected _updateCameraRotationMatrix(): void;
  19091. /**
  19092. * 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)
  19093. * @returns the current camera
  19094. */
  19095. private _rotateUpVectorWithCameraRotationMatrix;
  19096. private _cachedRotationZ;
  19097. private _cachedQuaternionRotationZ;
  19098. /** @hidden */
  19099. _getViewMatrix(): Matrix;
  19100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19101. /**
  19102. * @hidden
  19103. */
  19104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19105. /**
  19106. * @hidden
  19107. */
  19108. _updateRigCameras(): void;
  19109. private _getRigCamPositionAndTarget;
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. }
  19116. }
  19117. declare module "babylonjs/Events/keyboardEvents" {
  19118. /**
  19119. * Gather the list of keyboard event types as constants.
  19120. */
  19121. export class KeyboardEventTypes {
  19122. /**
  19123. * The keydown event is fired when a key becomes active (pressed).
  19124. */
  19125. static readonly KEYDOWN: number;
  19126. /**
  19127. * The keyup event is fired when a key has been released.
  19128. */
  19129. static readonly KEYUP: number;
  19130. }
  19131. /**
  19132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19133. */
  19134. export class KeyboardInfo {
  19135. /**
  19136. * Defines the type of event (KeyboardEventTypes)
  19137. */
  19138. type: number;
  19139. /**
  19140. * Defines the related dom event
  19141. */
  19142. event: KeyboardEvent;
  19143. /**
  19144. * Instantiates a new keyboard info.
  19145. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19146. * @param type Defines the type of event (KeyboardEventTypes)
  19147. * @param event Defines the related dom event
  19148. */
  19149. constructor(
  19150. /**
  19151. * Defines the type of event (KeyboardEventTypes)
  19152. */
  19153. type: number,
  19154. /**
  19155. * Defines the related dom event
  19156. */
  19157. event: KeyboardEvent);
  19158. }
  19159. /**
  19160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19162. */
  19163. export class KeyboardInfoPre extends KeyboardInfo {
  19164. /**
  19165. * Defines the type of event (KeyboardEventTypes)
  19166. */
  19167. type: number;
  19168. /**
  19169. * Defines the related dom event
  19170. */
  19171. event: KeyboardEvent;
  19172. /**
  19173. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19174. */
  19175. skipOnPointerObservable: boolean;
  19176. /**
  19177. * Instantiates a new keyboard pre info.
  19178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19179. * @param type Defines the type of event (KeyboardEventTypes)
  19180. * @param event Defines the related dom event
  19181. */
  19182. constructor(
  19183. /**
  19184. * Defines the type of event (KeyboardEventTypes)
  19185. */
  19186. type: number,
  19187. /**
  19188. * Defines the related dom event
  19189. */
  19190. event: KeyboardEvent);
  19191. }
  19192. }
  19193. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19194. import { Nullable } from "babylonjs/types";
  19195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19197. /**
  19198. * Manage the keyboard inputs to control the movement of a free camera.
  19199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19200. */
  19201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19202. /**
  19203. * Defines the camera the input is attached to.
  19204. */
  19205. camera: FreeCamera;
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19208. */
  19209. keysUp: number[];
  19210. /**
  19211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19212. */
  19213. keysUpward: number[];
  19214. /**
  19215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19216. */
  19217. keysDown: number[];
  19218. /**
  19219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19220. */
  19221. keysDownward: number[];
  19222. /**
  19223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19224. */
  19225. keysLeft: number[];
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19228. */
  19229. keysRight: number[];
  19230. private _keys;
  19231. private _onCanvasBlurObserver;
  19232. private _onKeyboardObserver;
  19233. private _engine;
  19234. private _scene;
  19235. /**
  19236. * Attach the input controls to a specific dom element to get the input from.
  19237. * @param element Defines the element the controls should be listened from
  19238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19239. */
  19240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19241. /**
  19242. * Detach the current controls from the specified dom element.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: Nullable<HTMLElement>): void;
  19246. /**
  19247. * Update the current camera state depending on the inputs that have been used this frame.
  19248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19249. */
  19250. checkInputs(): void;
  19251. /**
  19252. * Gets the class name of the current intput.
  19253. * @returns the class name
  19254. */
  19255. getClassName(): string;
  19256. /** @hidden */
  19257. _onLostFocus(): void;
  19258. /**
  19259. * Get the friendly name associated with the input class.
  19260. * @returns the input friendly name
  19261. */
  19262. getSimpleName(): string;
  19263. }
  19264. }
  19265. declare module "babylonjs/Events/pointerEvents" {
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Vector2 } from "babylonjs/Maths/math.vector";
  19268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19269. import { Ray } from "babylonjs/Culling/ray";
  19270. /**
  19271. * Gather the list of pointer event types as constants.
  19272. */
  19273. export class PointerEventTypes {
  19274. /**
  19275. * 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.
  19276. */
  19277. static readonly POINTERDOWN: number;
  19278. /**
  19279. * The pointerup event is fired when a pointer is no longer active.
  19280. */
  19281. static readonly POINTERUP: number;
  19282. /**
  19283. * The pointermove event is fired when a pointer changes coordinates.
  19284. */
  19285. static readonly POINTERMOVE: number;
  19286. /**
  19287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19288. */
  19289. static readonly POINTERWHEEL: number;
  19290. /**
  19291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19292. */
  19293. static readonly POINTERPICK: number;
  19294. /**
  19295. * The pointertap event is fired when a the object has been touched and released without drag.
  19296. */
  19297. static readonly POINTERTAP: number;
  19298. /**
  19299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19300. */
  19301. static readonly POINTERDOUBLETAP: number;
  19302. }
  19303. /**
  19304. * Base class of pointer info types.
  19305. */
  19306. export class PointerInfoBase {
  19307. /**
  19308. * Defines the type of event (PointerEventTypes)
  19309. */
  19310. type: number;
  19311. /**
  19312. * Defines the related dom event
  19313. */
  19314. event: PointerEvent | MouseWheelEvent;
  19315. /**
  19316. * Instantiates the base class of pointers info.
  19317. * @param type Defines the type of event (PointerEventTypes)
  19318. * @param event Defines the related dom event
  19319. */
  19320. constructor(
  19321. /**
  19322. * Defines the type of event (PointerEventTypes)
  19323. */
  19324. type: number,
  19325. /**
  19326. * Defines the related dom event
  19327. */
  19328. event: PointerEvent | MouseWheelEvent);
  19329. }
  19330. /**
  19331. * This class is used to store pointer related info for the onPrePointerObservable event.
  19332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19333. */
  19334. export class PointerInfoPre extends PointerInfoBase {
  19335. /**
  19336. * Ray from a pointer if availible (eg. 6dof controller)
  19337. */
  19338. ray: Nullable<Ray>;
  19339. /**
  19340. * Defines the local position of the pointer on the canvas.
  19341. */
  19342. localPosition: Vector2;
  19343. /**
  19344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19345. */
  19346. skipOnPointerObservable: boolean;
  19347. /**
  19348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19349. * @param type Defines the type of event (PointerEventTypes)
  19350. * @param event Defines the related dom event
  19351. * @param localX Defines the local x coordinates of the pointer when the event occured
  19352. * @param localY Defines the local y coordinates of the pointer when the event occured
  19353. */
  19354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19355. }
  19356. /**
  19357. * This type contains all the data related to a pointer event in Babylon.js.
  19358. * 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.
  19359. */
  19360. export class PointerInfo extends PointerInfoBase {
  19361. /**
  19362. * Defines the picking info associated to the info (if any)\
  19363. */
  19364. pickInfo: Nullable<PickingInfo>;
  19365. /**
  19366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19367. * @param type Defines the type of event (PointerEventTypes)
  19368. * @param event Defines the related dom event
  19369. * @param pickInfo Defines the picking info associated to the info (if any)\
  19370. */
  19371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19372. /**
  19373. * Defines the picking info associated to the info (if any)\
  19374. */
  19375. pickInfo: Nullable<PickingInfo>);
  19376. }
  19377. /**
  19378. * Data relating to a touch event on the screen.
  19379. */
  19380. export interface PointerTouch {
  19381. /**
  19382. * X coordinate of touch.
  19383. */
  19384. x: number;
  19385. /**
  19386. * Y coordinate of touch.
  19387. */
  19388. y: number;
  19389. /**
  19390. * Id of touch. Unique for each finger.
  19391. */
  19392. pointerId: number;
  19393. /**
  19394. * Event type passed from DOM.
  19395. */
  19396. type: any;
  19397. }
  19398. }
  19399. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19400. import { Observable } from "babylonjs/Misc/observable";
  19401. import { Nullable } from "babylonjs/types";
  19402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19404. /**
  19405. * Manage the mouse inputs to control the movement of a free camera.
  19406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19407. */
  19408. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19409. /**
  19410. * Define if touch is enabled in the mouse input
  19411. */
  19412. touchEnabled: boolean;
  19413. /**
  19414. * Defines the camera the input is attached to.
  19415. */
  19416. camera: FreeCamera;
  19417. /**
  19418. * Defines the buttons associated with the input to handle camera move.
  19419. */
  19420. buttons: number[];
  19421. /**
  19422. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19423. */
  19424. angularSensibility: number;
  19425. private _pointerInput;
  19426. private _onMouseMove;
  19427. private _observer;
  19428. private previousPosition;
  19429. /**
  19430. * Observable for when a pointer move event occurs containing the move offset
  19431. */
  19432. onPointerMovedObservable: Observable<{
  19433. offsetX: number;
  19434. offsetY: number;
  19435. }>;
  19436. /**
  19437. * @hidden
  19438. * If the camera should be rotated automatically based on pointer movement
  19439. */
  19440. _allowCameraRotation: boolean;
  19441. /**
  19442. * Manage the mouse inputs to control the movement of a free camera.
  19443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19444. * @param touchEnabled Defines if touch is enabled or not
  19445. */
  19446. constructor(
  19447. /**
  19448. * Define if touch is enabled in the mouse input
  19449. */
  19450. touchEnabled?: boolean);
  19451. /**
  19452. * Attach the input controls to a specific dom element to get the input from.
  19453. * @param element Defines the element the controls should be listened from
  19454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19455. */
  19456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19457. /**
  19458. * Called on JS contextmenu event.
  19459. * Override this method to provide functionality.
  19460. */
  19461. protected onContextMenu(evt: PointerEvent): void;
  19462. /**
  19463. * Detach the current controls from the specified dom element.
  19464. * @param element Defines the element to stop listening the inputs from
  19465. */
  19466. detachControl(element: Nullable<HTMLElement>): void;
  19467. /**
  19468. * Gets the class name of the current intput.
  19469. * @returns the class name
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Get the friendly name associated with the input class.
  19474. * @returns the input friendly name
  19475. */
  19476. getSimpleName(): string;
  19477. }
  19478. }
  19479. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19480. import { Nullable } from "babylonjs/types";
  19481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19483. /**
  19484. * Manage the touch inputs to control the movement of a free camera.
  19485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19486. */
  19487. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19488. /**
  19489. * Define if mouse events can be treated as touch events
  19490. */
  19491. allowMouse: boolean;
  19492. /**
  19493. * Defines the camera the input is attached to.
  19494. */
  19495. camera: FreeCamera;
  19496. /**
  19497. * Defines the touch sensibility for rotation.
  19498. * The higher the faster.
  19499. */
  19500. touchAngularSensibility: number;
  19501. /**
  19502. * Defines the touch sensibility for move.
  19503. * The higher the faster.
  19504. */
  19505. touchMoveSensibility: number;
  19506. private _offsetX;
  19507. private _offsetY;
  19508. private _pointerPressed;
  19509. private _pointerInput;
  19510. private _observer;
  19511. private _onLostFocus;
  19512. /**
  19513. * Manage the touch inputs to control the movement of a free camera.
  19514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19515. * @param allowMouse Defines if mouse events can be treated as touch events
  19516. */
  19517. constructor(
  19518. /**
  19519. * Define if mouse events can be treated as touch events
  19520. */
  19521. allowMouse?: boolean);
  19522. /**
  19523. * Attach the input controls to a specific dom element to get the input from.
  19524. * @param element Defines the element the controls should be listened from
  19525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19526. */
  19527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19528. /**
  19529. * Detach the current controls from the specified dom element.
  19530. * @param element Defines the element to stop listening the inputs from
  19531. */
  19532. detachControl(element: Nullable<HTMLElement>): void;
  19533. /**
  19534. * Update the current camera state depending on the inputs that have been used this frame.
  19535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19536. */
  19537. checkInputs(): void;
  19538. /**
  19539. * Gets the class name of the current intput.
  19540. * @returns the class name
  19541. */
  19542. getClassName(): string;
  19543. /**
  19544. * Get the friendly name associated with the input class.
  19545. * @returns the input friendly name
  19546. */
  19547. getSimpleName(): string;
  19548. }
  19549. }
  19550. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19553. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19554. import { Nullable } from "babylonjs/types";
  19555. /**
  19556. * Default Inputs manager for the FreeCamera.
  19557. * It groups all the default supported inputs for ease of use.
  19558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19559. */
  19560. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19561. /**
  19562. * @hidden
  19563. */
  19564. _mouseInput: Nullable<FreeCameraMouseInput>;
  19565. /**
  19566. * Instantiates a new FreeCameraInputsManager.
  19567. * @param camera Defines the camera the inputs belong to
  19568. */
  19569. constructor(camera: FreeCamera);
  19570. /**
  19571. * Add keyboard input support to the input manager.
  19572. * @returns the current input manager
  19573. */
  19574. addKeyboard(): FreeCameraInputsManager;
  19575. /**
  19576. * Add mouse input support to the input manager.
  19577. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19578. * @returns the current input manager
  19579. */
  19580. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19581. /**
  19582. * Removes the mouse input support from the manager
  19583. * @returns the current input manager
  19584. */
  19585. removeMouse(): FreeCameraInputsManager;
  19586. /**
  19587. * Add touch input support to the input manager.
  19588. * @returns the current input manager
  19589. */
  19590. addTouch(): FreeCameraInputsManager;
  19591. /**
  19592. * Remove all attached input methods from a camera
  19593. */
  19594. clear(): void;
  19595. }
  19596. }
  19597. declare module "babylonjs/Cameras/freeCamera" {
  19598. import { Vector3 } from "babylonjs/Maths/math.vector";
  19599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19600. import { Scene } from "babylonjs/scene";
  19601. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19602. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19603. /**
  19604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19606. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19607. */
  19608. export class FreeCamera extends TargetCamera {
  19609. /**
  19610. * Define the collision ellipsoid of the camera.
  19611. * This is helpful to simulate a camera body like the player body around the camera
  19612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19613. */
  19614. ellipsoid: Vector3;
  19615. /**
  19616. * Define an offset for the position of the ellipsoid around the camera.
  19617. * This can be helpful to determine the center of the body near the gravity center of the body
  19618. * instead of its head.
  19619. */
  19620. ellipsoidOffset: Vector3;
  19621. /**
  19622. * Enable or disable collisions of the camera with the rest of the scene objects.
  19623. */
  19624. checkCollisions: boolean;
  19625. /**
  19626. * Enable or disable gravity on the camera.
  19627. */
  19628. applyGravity: boolean;
  19629. /**
  19630. * Define the input manager associated to the camera.
  19631. */
  19632. inputs: FreeCameraInputsManager;
  19633. /**
  19634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19635. * Higher values reduce sensitivity.
  19636. */
  19637. get angularSensibility(): number;
  19638. /**
  19639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19640. * Higher values reduce sensitivity.
  19641. */
  19642. set angularSensibility(value: number);
  19643. /**
  19644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19645. */
  19646. get keysUp(): number[];
  19647. set keysUp(value: number[]);
  19648. /**
  19649. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19650. */
  19651. get keysUpward(): number[];
  19652. set keysUpward(value: number[]);
  19653. /**
  19654. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19655. */
  19656. get keysDown(): number[];
  19657. set keysDown(value: number[]);
  19658. /**
  19659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19660. */
  19661. get keysDownward(): number[];
  19662. set keysDownward(value: number[]);
  19663. /**
  19664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19665. */
  19666. get keysLeft(): number[];
  19667. set keysLeft(value: number[]);
  19668. /**
  19669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19670. */
  19671. get keysRight(): number[];
  19672. set keysRight(value: number[]);
  19673. /**
  19674. * Event raised when the camera collide with a mesh in the scene.
  19675. */
  19676. onCollide: (collidedMesh: AbstractMesh) => void;
  19677. private _collider;
  19678. private _needMoveForGravity;
  19679. private _oldPosition;
  19680. private _diffPosition;
  19681. private _newPosition;
  19682. /** @hidden */
  19683. _localDirection: Vector3;
  19684. /** @hidden */
  19685. _transformedDirection: Vector3;
  19686. /**
  19687. * Instantiates a Free Camera.
  19688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19691. * @param name Define the name of the camera in the scene
  19692. * @param position Define the start position of the camera in the scene
  19693. * @param scene Define the scene the camera belongs to
  19694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19697. /**
  19698. * Attached controls to the current camera.
  19699. * @param element Defines the element the controls should be listened from
  19700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19701. */
  19702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19703. /**
  19704. * Detach the current controls from the camera.
  19705. * The camera will stop reacting to inputs.
  19706. * @param element Defines the element to stop listening the inputs from
  19707. */
  19708. detachControl(element: HTMLElement): void;
  19709. private _collisionMask;
  19710. /**
  19711. * Define a collision mask to limit the list of object the camera can collide with
  19712. */
  19713. get collisionMask(): number;
  19714. set collisionMask(mask: number);
  19715. /** @hidden */
  19716. _collideWithWorld(displacement: Vector3): void;
  19717. private _onCollisionPositionChange;
  19718. /** @hidden */
  19719. _checkInputs(): void;
  19720. /** @hidden */
  19721. _decideIfNeedsToMove(): boolean;
  19722. /** @hidden */
  19723. _updatePosition(): void;
  19724. /**
  19725. * Destroy the camera and release the current resources hold by it.
  19726. */
  19727. dispose(): void;
  19728. /**
  19729. * Gets the current object class name.
  19730. * @return the class name
  19731. */
  19732. getClassName(): string;
  19733. }
  19734. }
  19735. declare module "babylonjs/Gamepads/gamepad" {
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. /**
  19738. * Represents a gamepad control stick position
  19739. */
  19740. export class StickValues {
  19741. /**
  19742. * The x component of the control stick
  19743. */
  19744. x: number;
  19745. /**
  19746. * The y component of the control stick
  19747. */
  19748. y: number;
  19749. /**
  19750. * Initializes the gamepad x and y control stick values
  19751. * @param x The x component of the gamepad control stick value
  19752. * @param y The y component of the gamepad control stick value
  19753. */
  19754. constructor(
  19755. /**
  19756. * The x component of the control stick
  19757. */
  19758. x: number,
  19759. /**
  19760. * The y component of the control stick
  19761. */
  19762. y: number);
  19763. }
  19764. /**
  19765. * An interface which manages callbacks for gamepad button changes
  19766. */
  19767. export interface GamepadButtonChanges {
  19768. /**
  19769. * Called when a gamepad has been changed
  19770. */
  19771. changed: boolean;
  19772. /**
  19773. * Called when a gamepad press event has been triggered
  19774. */
  19775. pressChanged: boolean;
  19776. /**
  19777. * Called when a touch event has been triggered
  19778. */
  19779. touchChanged: boolean;
  19780. /**
  19781. * Called when a value has changed
  19782. */
  19783. valueChanged: boolean;
  19784. }
  19785. /**
  19786. * Represents a gamepad
  19787. */
  19788. export class Gamepad {
  19789. /**
  19790. * The id of the gamepad
  19791. */
  19792. id: string;
  19793. /**
  19794. * The index of the gamepad
  19795. */
  19796. index: number;
  19797. /**
  19798. * The browser gamepad
  19799. */
  19800. browserGamepad: any;
  19801. /**
  19802. * Specifies what type of gamepad this represents
  19803. */
  19804. type: number;
  19805. private _leftStick;
  19806. private _rightStick;
  19807. /** @hidden */
  19808. _isConnected: boolean;
  19809. private _leftStickAxisX;
  19810. private _leftStickAxisY;
  19811. private _rightStickAxisX;
  19812. private _rightStickAxisY;
  19813. /**
  19814. * Triggered when the left control stick has been changed
  19815. */
  19816. private _onleftstickchanged;
  19817. /**
  19818. * Triggered when the right control stick has been changed
  19819. */
  19820. private _onrightstickchanged;
  19821. /**
  19822. * Represents a gamepad controller
  19823. */
  19824. static GAMEPAD: number;
  19825. /**
  19826. * Represents a generic controller
  19827. */
  19828. static GENERIC: number;
  19829. /**
  19830. * Represents an XBox controller
  19831. */
  19832. static XBOX: number;
  19833. /**
  19834. * Represents a pose-enabled controller
  19835. */
  19836. static POSE_ENABLED: number;
  19837. /**
  19838. * Represents an Dual Shock controller
  19839. */
  19840. static DUALSHOCK: number;
  19841. /**
  19842. * Specifies whether the left control stick should be Y-inverted
  19843. */
  19844. protected _invertLeftStickY: boolean;
  19845. /**
  19846. * Specifies if the gamepad has been connected
  19847. */
  19848. get isConnected(): boolean;
  19849. /**
  19850. * Initializes the gamepad
  19851. * @param id The id of the gamepad
  19852. * @param index The index of the gamepad
  19853. * @param browserGamepad The browser gamepad
  19854. * @param leftStickX The x component of the left joystick
  19855. * @param leftStickY The y component of the left joystick
  19856. * @param rightStickX The x component of the right joystick
  19857. * @param rightStickY The y component of the right joystick
  19858. */
  19859. constructor(
  19860. /**
  19861. * The id of the gamepad
  19862. */
  19863. id: string,
  19864. /**
  19865. * The index of the gamepad
  19866. */
  19867. index: number,
  19868. /**
  19869. * The browser gamepad
  19870. */
  19871. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19872. /**
  19873. * Callback triggered when the left joystick has changed
  19874. * @param callback
  19875. */
  19876. onleftstickchanged(callback: (values: StickValues) => void): void;
  19877. /**
  19878. * Callback triggered when the right joystick has changed
  19879. * @param callback
  19880. */
  19881. onrightstickchanged(callback: (values: StickValues) => void): void;
  19882. /**
  19883. * Gets the left joystick
  19884. */
  19885. get leftStick(): StickValues;
  19886. /**
  19887. * Sets the left joystick values
  19888. */
  19889. set leftStick(newValues: StickValues);
  19890. /**
  19891. * Gets the right joystick
  19892. */
  19893. get rightStick(): StickValues;
  19894. /**
  19895. * Sets the right joystick value
  19896. */
  19897. set rightStick(newValues: StickValues);
  19898. /**
  19899. * Updates the gamepad joystick positions
  19900. */
  19901. update(): void;
  19902. /**
  19903. * Disposes the gamepad
  19904. */
  19905. dispose(): void;
  19906. }
  19907. /**
  19908. * Represents a generic gamepad
  19909. */
  19910. export class GenericPad extends Gamepad {
  19911. private _buttons;
  19912. private _onbuttondown;
  19913. private _onbuttonup;
  19914. /**
  19915. * Observable triggered when a button has been pressed
  19916. */
  19917. onButtonDownObservable: Observable<number>;
  19918. /**
  19919. * Observable triggered when a button has been released
  19920. */
  19921. onButtonUpObservable: Observable<number>;
  19922. /**
  19923. * Callback triggered when a button has been pressed
  19924. * @param callback Called when a button has been pressed
  19925. */
  19926. onbuttondown(callback: (buttonPressed: number) => void): void;
  19927. /**
  19928. * Callback triggered when a button has been released
  19929. * @param callback Called when a button has been released
  19930. */
  19931. onbuttonup(callback: (buttonReleased: number) => void): void;
  19932. /**
  19933. * Initializes the generic gamepad
  19934. * @param id The id of the generic gamepad
  19935. * @param index The index of the generic gamepad
  19936. * @param browserGamepad The browser gamepad
  19937. */
  19938. constructor(id: string, index: number, browserGamepad: any);
  19939. private _setButtonValue;
  19940. /**
  19941. * Updates the generic gamepad
  19942. */
  19943. update(): void;
  19944. /**
  19945. * Disposes the generic gamepad
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19951. import { Observable } from "babylonjs/Misc/observable";
  19952. import { Nullable } from "babylonjs/types";
  19953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19956. import { Ray } from "babylonjs/Culling/ray";
  19957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19958. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19959. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19960. /**
  19961. * Defines the types of pose enabled controllers that are supported
  19962. */
  19963. export enum PoseEnabledControllerType {
  19964. /**
  19965. * HTC Vive
  19966. */
  19967. VIVE = 0,
  19968. /**
  19969. * Oculus Rift
  19970. */
  19971. OCULUS = 1,
  19972. /**
  19973. * Windows mixed reality
  19974. */
  19975. WINDOWS = 2,
  19976. /**
  19977. * Samsung gear VR
  19978. */
  19979. GEAR_VR = 3,
  19980. /**
  19981. * Google Daydream
  19982. */
  19983. DAYDREAM = 4,
  19984. /**
  19985. * Generic
  19986. */
  19987. GENERIC = 5
  19988. }
  19989. /**
  19990. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19991. */
  19992. export interface MutableGamepadButton {
  19993. /**
  19994. * Value of the button/trigger
  19995. */
  19996. value: number;
  19997. /**
  19998. * If the button/trigger is currently touched
  19999. */
  20000. touched: boolean;
  20001. /**
  20002. * If the button/trigger is currently pressed
  20003. */
  20004. pressed: boolean;
  20005. }
  20006. /**
  20007. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20008. * @hidden
  20009. */
  20010. export interface ExtendedGamepadButton extends GamepadButton {
  20011. /**
  20012. * If the button/trigger is currently pressed
  20013. */
  20014. readonly pressed: boolean;
  20015. /**
  20016. * If the button/trigger is currently touched
  20017. */
  20018. readonly touched: boolean;
  20019. /**
  20020. * Value of the button/trigger
  20021. */
  20022. readonly value: number;
  20023. }
  20024. /** @hidden */
  20025. export interface _GamePadFactory {
  20026. /**
  20027. * Returns whether or not the current gamepad can be created for this type of controller.
  20028. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20029. * @returns true if it can be created, otherwise false
  20030. */
  20031. canCreate(gamepadInfo: any): boolean;
  20032. /**
  20033. * Creates a new instance of the Gamepad.
  20034. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20035. * @returns the new gamepad instance
  20036. */
  20037. create(gamepadInfo: any): Gamepad;
  20038. }
  20039. /**
  20040. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20041. */
  20042. export class PoseEnabledControllerHelper {
  20043. /** @hidden */
  20044. static _ControllerFactories: _GamePadFactory[];
  20045. /** @hidden */
  20046. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20047. /**
  20048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20049. * @param vrGamepad the gamepad to initialized
  20050. * @returns a vr controller of the type the gamepad identified as
  20051. */
  20052. static InitiateController(vrGamepad: any): Gamepad;
  20053. }
  20054. /**
  20055. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20056. */
  20057. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20058. /**
  20059. * If the controller is used in a webXR session
  20060. */
  20061. isXR: boolean;
  20062. private _deviceRoomPosition;
  20063. private _deviceRoomRotationQuaternion;
  20064. /**
  20065. * The device position in babylon space
  20066. */
  20067. devicePosition: Vector3;
  20068. /**
  20069. * The device rotation in babylon space
  20070. */
  20071. deviceRotationQuaternion: Quaternion;
  20072. /**
  20073. * The scale factor of the device in babylon space
  20074. */
  20075. deviceScaleFactor: number;
  20076. /**
  20077. * (Likely devicePosition should be used instead) The device position in its room space
  20078. */
  20079. position: Vector3;
  20080. /**
  20081. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20082. */
  20083. rotationQuaternion: Quaternion;
  20084. /**
  20085. * The type of controller (Eg. Windows mixed reality)
  20086. */
  20087. controllerType: PoseEnabledControllerType;
  20088. protected _calculatedPosition: Vector3;
  20089. private _calculatedRotation;
  20090. /**
  20091. * The raw pose from the device
  20092. */
  20093. rawPose: DevicePose;
  20094. private _trackPosition;
  20095. private _maxRotationDistFromHeadset;
  20096. private _draggedRoomRotation;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _disableTrackPosition(fixedPosition: Vector3): void;
  20101. /**
  20102. * Internal, the mesh attached to the controller
  20103. * @hidden
  20104. */
  20105. _mesh: Nullable<AbstractMesh>;
  20106. private _poseControlledCamera;
  20107. private _leftHandSystemQuaternion;
  20108. /**
  20109. * Internal, matrix used to convert room space to babylon space
  20110. * @hidden
  20111. */
  20112. _deviceToWorld: Matrix;
  20113. /**
  20114. * Node to be used when casting a ray from the controller
  20115. * @hidden
  20116. */
  20117. _pointingPoseNode: Nullable<TransformNode>;
  20118. /**
  20119. * Name of the child mesh that can be used to cast a ray from the controller
  20120. */
  20121. static readonly POINTING_POSE: string;
  20122. /**
  20123. * Creates a new PoseEnabledController from a gamepad
  20124. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20125. */
  20126. constructor(browserGamepad: any);
  20127. private _workingMatrix;
  20128. /**
  20129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20130. */
  20131. update(): void;
  20132. /**
  20133. * Updates only the pose device and mesh without doing any button event checking
  20134. */
  20135. protected _updatePoseAndMesh(): void;
  20136. /**
  20137. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20138. * @param poseData raw pose fromthe device
  20139. */
  20140. updateFromDevice(poseData: DevicePose): void;
  20141. /**
  20142. * @hidden
  20143. */
  20144. _meshAttachedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Attaches a mesh to the controller
  20147. * @param mesh the mesh to be attached
  20148. */
  20149. attachToMesh(mesh: AbstractMesh): void;
  20150. /**
  20151. * Attaches the controllers mesh to a camera
  20152. * @param camera the camera the mesh should be attached to
  20153. */
  20154. attachToPoseControlledCamera(camera: TargetCamera): void;
  20155. /**
  20156. * Disposes of the controller
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * The mesh that is attached to the controller
  20161. */
  20162. get mesh(): Nullable<AbstractMesh>;
  20163. /**
  20164. * Gets the ray of the controller in the direction the controller is pointing
  20165. * @param length the length the resulting ray should be
  20166. * @returns a ray in the direction the controller is pointing
  20167. */
  20168. getForwardRay(length?: number): Ray;
  20169. }
  20170. }
  20171. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20172. import { Observable } from "babylonjs/Misc/observable";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20177. import { Nullable } from "babylonjs/types";
  20178. /**
  20179. * Defines the WebVRController object that represents controllers tracked in 3D space
  20180. */
  20181. export abstract class WebVRController extends PoseEnabledController {
  20182. /**
  20183. * Internal, the default controller model for the controller
  20184. */
  20185. protected _defaultModel: Nullable<AbstractMesh>;
  20186. /**
  20187. * Fired when the trigger state has changed
  20188. */
  20189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20190. /**
  20191. * Fired when the main button state has changed
  20192. */
  20193. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20194. /**
  20195. * Fired when the secondary button state has changed
  20196. */
  20197. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20198. /**
  20199. * Fired when the pad state has changed
  20200. */
  20201. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20202. /**
  20203. * Fired when controllers stick values have changed
  20204. */
  20205. onPadValuesChangedObservable: Observable<StickValues>;
  20206. /**
  20207. * Array of button availible on the controller
  20208. */
  20209. protected _buttons: Array<MutableGamepadButton>;
  20210. private _onButtonStateChange;
  20211. /**
  20212. * Fired when a controller button's state has changed
  20213. * @param callback the callback containing the button that was modified
  20214. */
  20215. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20216. /**
  20217. * X and Y axis corresponding to the controllers joystick
  20218. */
  20219. pad: StickValues;
  20220. /**
  20221. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20222. */
  20223. hand: string;
  20224. /**
  20225. * The default controller model for the controller
  20226. */
  20227. get defaultModel(): Nullable<AbstractMesh>;
  20228. /**
  20229. * Creates a new WebVRController from a gamepad
  20230. * @param vrGamepad the gamepad that the WebVRController should be created from
  20231. */
  20232. constructor(vrGamepad: any);
  20233. /**
  20234. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Function to be called when a button is modified
  20239. */
  20240. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20241. /**
  20242. * Loads a mesh and attaches it to the controller
  20243. * @param scene the scene the mesh should be added to
  20244. * @param meshLoaded callback for when the mesh has been loaded
  20245. */
  20246. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20247. private _setButtonValue;
  20248. private _changes;
  20249. private _checkChanges;
  20250. /**
  20251. * Disposes of th webVRCOntroller
  20252. */
  20253. dispose(): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Lights/hemisphericLight" {
  20257. import { Nullable } from "babylonjs/types";
  20258. import { Scene } from "babylonjs/scene";
  20259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20260. import { Color3 } from "babylonjs/Maths/math.color";
  20261. import { Effect } from "babylonjs/Materials/effect";
  20262. import { Light } from "babylonjs/Lights/light";
  20263. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20264. /**
  20265. * The HemisphericLight simulates the ambient environment light,
  20266. * so the passed direction is the light reflection direction, not the incoming direction.
  20267. */
  20268. export class HemisphericLight extends Light {
  20269. /**
  20270. * The groundColor is the light in the opposite direction to the one specified during creation.
  20271. * 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.
  20272. */
  20273. groundColor: Color3;
  20274. /**
  20275. * The light reflection direction, not the incoming direction.
  20276. */
  20277. direction: Vector3;
  20278. /**
  20279. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20280. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20281. * The HemisphericLight can't cast shadows.
  20282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20283. * @param name The friendly name of the light
  20284. * @param direction The direction of the light reflection
  20285. * @param scene The scene the light belongs to
  20286. */
  20287. constructor(name: string, direction: Vector3, scene: Scene);
  20288. protected _buildUniformLayout(): void;
  20289. /**
  20290. * Returns the string "HemisphericLight".
  20291. * @return The class name
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20296. * Returns the updated direction.
  20297. * @param target The target the direction should point to
  20298. * @return The computed direction
  20299. */
  20300. setDirectionToTarget(target: Vector3): Vector3;
  20301. /**
  20302. * Returns the shadow generator associated to the light.
  20303. * @returns Always null for hemispheric lights because it does not support shadows.
  20304. */
  20305. getShadowGenerator(): Nullable<IShadowGenerator>;
  20306. /**
  20307. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20308. * @param effect The effect to update
  20309. * @param lightIndex The index of the light in the effect to update
  20310. * @returns The hemispheric light
  20311. */
  20312. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20314. /**
  20315. * Computes the world matrix of the node
  20316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20317. * @param useWasUpdatedFlag defines a reserved property
  20318. * @returns the world matrix
  20319. */
  20320. computeWorldMatrix(): Matrix;
  20321. /**
  20322. * Returns the integer 3.
  20323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20324. */
  20325. getTypeID(): number;
  20326. /**
  20327. * Prepares the list of defines specific to the light type.
  20328. * @param defines the list of defines
  20329. * @param lightIndex defines the index of the light for the effect
  20330. */
  20331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20332. }
  20333. }
  20334. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20335. /** @hidden */
  20336. export var vrMultiviewToSingleviewPixelShader: {
  20337. name: string;
  20338. shader: string;
  20339. };
  20340. }
  20341. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20343. import { Scene } from "babylonjs/scene";
  20344. /**
  20345. * Renders to multiple views with a single draw call
  20346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20347. */
  20348. export class MultiviewRenderTarget extends RenderTargetTexture {
  20349. /**
  20350. * Creates a multiview render target
  20351. * @param scene scene used with the render target
  20352. * @param size the size of the render target (used for each view)
  20353. */
  20354. constructor(scene: Scene, size?: number | {
  20355. width: number;
  20356. height: number;
  20357. } | {
  20358. ratio: number;
  20359. });
  20360. /**
  20361. * @hidden
  20362. * @param faceIndex the face index, if its a cube texture
  20363. */
  20364. _bindFrameBuffer(faceIndex?: number): void;
  20365. /**
  20366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20367. * @returns the view count
  20368. */
  20369. getViewCount(): number;
  20370. }
  20371. }
  20372. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20377. import { Matrix } from "babylonjs/Maths/math.vector";
  20378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20379. module "babylonjs/Engines/engine" {
  20380. interface Engine {
  20381. /**
  20382. * Creates a new multiview render target
  20383. * @param width defines the width of the texture
  20384. * @param height defines the height of the texture
  20385. * @returns the created multiview texture
  20386. */
  20387. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20388. /**
  20389. * Binds a multiview framebuffer to be drawn to
  20390. * @param multiviewTexture texture to bind
  20391. */
  20392. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20393. }
  20394. }
  20395. module "babylonjs/Cameras/camera" {
  20396. interface Camera {
  20397. /**
  20398. * @hidden
  20399. * 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)
  20400. */
  20401. _useMultiviewToSingleView: boolean;
  20402. /**
  20403. * @hidden
  20404. * 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)
  20405. */
  20406. _multiviewTexture: Nullable<RenderTargetTexture>;
  20407. /**
  20408. * @hidden
  20409. * ensures the multiview texture of the camera exists and has the specified width/height
  20410. * @param width height to set on the multiview texture
  20411. * @param height width to set on the multiview texture
  20412. */
  20413. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20414. }
  20415. }
  20416. module "babylonjs/scene" {
  20417. interface Scene {
  20418. /** @hidden */
  20419. _transformMatrixR: Matrix;
  20420. /** @hidden */
  20421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20422. /** @hidden */
  20423. _createMultiviewUbo(): void;
  20424. /** @hidden */
  20425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20426. /** @hidden */
  20427. _renderMultiviewToSingleView(camera: Camera): void;
  20428. }
  20429. }
  20430. }
  20431. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20434. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20435. import "babylonjs/Engines/Extensions/engine.multiview";
  20436. /**
  20437. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20438. * This will not be used for webXR as it supports displaying texture arrays directly
  20439. */
  20440. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20441. /**
  20442. * Gets a string identifying the name of the class
  20443. * @returns "VRMultiviewToSingleviewPostProcess" string
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Initializes a VRMultiviewToSingleview
  20448. * @param name name of the post process
  20449. * @param camera camera to be applied to
  20450. * @param scaleFactor scaling factor to the size of the output texture
  20451. */
  20452. constructor(name: string, camera: Camera, scaleFactor: number);
  20453. }
  20454. }
  20455. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20456. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20457. import { Nullable } from "babylonjs/types";
  20458. import { Size } from "babylonjs/Maths/math.size";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20461. /**
  20462. * Interface used to define additional presentation attributes
  20463. */
  20464. export interface IVRPresentationAttributes {
  20465. /**
  20466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20467. */
  20468. highRefreshRate: boolean;
  20469. /**
  20470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20471. */
  20472. foveationLevel: number;
  20473. }
  20474. module "babylonjs/Engines/engine" {
  20475. interface Engine {
  20476. /** @hidden */
  20477. _vrDisplay: any;
  20478. /** @hidden */
  20479. _vrSupported: boolean;
  20480. /** @hidden */
  20481. _oldSize: Size;
  20482. /** @hidden */
  20483. _oldHardwareScaleFactor: number;
  20484. /** @hidden */
  20485. _vrExclusivePointerMode: boolean;
  20486. /** @hidden */
  20487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20488. /** @hidden */
  20489. _onVRDisplayPointerRestricted: () => void;
  20490. /** @hidden */
  20491. _onVRDisplayPointerUnrestricted: () => void;
  20492. /** @hidden */
  20493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20494. /** @hidden */
  20495. _onVrDisplayDisconnect: Nullable<() => void>;
  20496. /** @hidden */
  20497. _onVrDisplayPresentChange: Nullable<() => void>;
  20498. /**
  20499. * Observable signaled when VR display mode changes
  20500. */
  20501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20502. /**
  20503. * Observable signaled when VR request present is complete
  20504. */
  20505. onVRRequestPresentComplete: Observable<boolean>;
  20506. /**
  20507. * Observable signaled when VR request present starts
  20508. */
  20509. onVRRequestPresentStart: Observable<Engine>;
  20510. /**
  20511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20513. */
  20514. isInVRExclusivePointerMode: boolean;
  20515. /**
  20516. * Gets a boolean indicating if a webVR device was detected
  20517. * @returns true if a webVR device was detected
  20518. */
  20519. isVRDevicePresent(): boolean;
  20520. /**
  20521. * Gets the current webVR device
  20522. * @returns the current webVR device (or null)
  20523. */
  20524. getVRDevice(): any;
  20525. /**
  20526. * Initializes a webVR display and starts listening to display change events
  20527. * The onVRDisplayChangedObservable will be notified upon these changes
  20528. * @returns A promise containing a VRDisplay and if vr is supported
  20529. */
  20530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20531. /** @hidden */
  20532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20533. /**
  20534. * Gets or sets the presentation attributes used to configure VR rendering
  20535. */
  20536. vrPresentationAttributes?: IVRPresentationAttributes;
  20537. /**
  20538. * Call this function to switch to webVR mode
  20539. * Will do nothing if webVR is not supported or if there is no webVR device
  20540. * @param options the webvr options provided to the camera. mainly used for multiview
  20541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20542. */
  20543. enableVR(options: WebVROptions): void;
  20544. /** @hidden */
  20545. _onVRFullScreenTriggered(): void;
  20546. }
  20547. }
  20548. }
  20549. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20550. import { Nullable } from "babylonjs/types";
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20553. import { Scene } from "babylonjs/scene";
  20554. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20556. import { Node } from "babylonjs/node";
  20557. import { Ray } from "babylonjs/Culling/ray";
  20558. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20559. import "babylonjs/Engines/Extensions/engine.webVR";
  20560. /**
  20561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20562. * IMPORTANT!! The data is right-hand data.
  20563. * @export
  20564. * @interface DevicePose
  20565. */
  20566. export interface DevicePose {
  20567. /**
  20568. * The position of the device, values in array are [x,y,z].
  20569. */
  20570. readonly position: Nullable<Float32Array>;
  20571. /**
  20572. * The linearVelocity of the device, values in array are [x,y,z].
  20573. */
  20574. readonly linearVelocity: Nullable<Float32Array>;
  20575. /**
  20576. * The linearAcceleration of the device, values in array are [x,y,z].
  20577. */
  20578. readonly linearAcceleration: Nullable<Float32Array>;
  20579. /**
  20580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20581. */
  20582. readonly orientation: Nullable<Float32Array>;
  20583. /**
  20584. * The angularVelocity of the device, values in array are [x,y,z].
  20585. */
  20586. readonly angularVelocity: Nullable<Float32Array>;
  20587. /**
  20588. * The angularAcceleration of the device, values in array are [x,y,z].
  20589. */
  20590. readonly angularAcceleration: Nullable<Float32Array>;
  20591. }
  20592. /**
  20593. * Interface representing a pose controlled object in Babylon.
  20594. * A pose controlled object has both regular pose values as well as pose values
  20595. * from an external device such as a VR head mounted display
  20596. */
  20597. export interface PoseControlled {
  20598. /**
  20599. * The position of the object in babylon space.
  20600. */
  20601. position: Vector3;
  20602. /**
  20603. * The rotation quaternion of the object in babylon space.
  20604. */
  20605. rotationQuaternion: Quaternion;
  20606. /**
  20607. * The position of the device in babylon space.
  20608. */
  20609. devicePosition?: Vector3;
  20610. /**
  20611. * The rotation quaternion of the device in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The raw pose coming from the device.
  20616. */
  20617. rawPose: Nullable<DevicePose>;
  20618. /**
  20619. * The scale of the device to be used when translating from device space to babylon space.
  20620. */
  20621. deviceScaleFactor: number;
  20622. /**
  20623. * Updates the poseControlled values based on the input device pose.
  20624. * @param poseData the pose data to update the object with
  20625. */
  20626. updateFromDevice(poseData: DevicePose): void;
  20627. }
  20628. /**
  20629. * Set of options to customize the webVRCamera
  20630. */
  20631. export interface WebVROptions {
  20632. /**
  20633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20634. */
  20635. trackPosition?: boolean;
  20636. /**
  20637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20638. */
  20639. positionScale?: number;
  20640. /**
  20641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20642. */
  20643. displayName?: string;
  20644. /**
  20645. * Should the native controller meshes be initialized. (default: true)
  20646. */
  20647. controllerMeshes?: boolean;
  20648. /**
  20649. * Creating a default HemiLight only on controllers. (default: true)
  20650. */
  20651. defaultLightingOnControllers?: boolean;
  20652. /**
  20653. * If you don't want to use the default VR button of the helper. (default: false)
  20654. */
  20655. useCustomVRButton?: boolean;
  20656. /**
  20657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20658. */
  20659. customVRButton?: HTMLButtonElement;
  20660. /**
  20661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20662. */
  20663. rayLength?: number;
  20664. /**
  20665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20666. */
  20667. defaultHeight?: number;
  20668. /**
  20669. * If multiview should be used if availible (default: false)
  20670. */
  20671. useMultiview?: boolean;
  20672. }
  20673. /**
  20674. * This represents a WebVR camera.
  20675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20676. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20677. */
  20678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20679. private webVROptions;
  20680. /**
  20681. * @hidden
  20682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20683. */
  20684. _vrDevice: any;
  20685. /**
  20686. * The rawPose of the vrDevice.
  20687. */
  20688. rawPose: Nullable<DevicePose>;
  20689. private _onVREnabled;
  20690. private _specsVersion;
  20691. private _attached;
  20692. private _frameData;
  20693. protected _descendants: Array<Node>;
  20694. private _deviceRoomPosition;
  20695. /** @hidden */
  20696. _deviceRoomRotationQuaternion: Quaternion;
  20697. private _standingMatrix;
  20698. /**
  20699. * Represents device position in babylon space.
  20700. */
  20701. devicePosition: Vector3;
  20702. /**
  20703. * Represents device rotation in babylon space.
  20704. */
  20705. deviceRotationQuaternion: Quaternion;
  20706. /**
  20707. * The scale of the device to be used when translating from device space to babylon space.
  20708. */
  20709. deviceScaleFactor: number;
  20710. private _deviceToWorld;
  20711. private _worldToDevice;
  20712. /**
  20713. * References to the webVR controllers for the vrDevice.
  20714. */
  20715. controllers: Array<WebVRController>;
  20716. /**
  20717. * Emits an event when a controller is attached.
  20718. */
  20719. onControllersAttachedObservable: Observable<WebVRController[]>;
  20720. /**
  20721. * Emits an event when a controller's mesh has been loaded;
  20722. */
  20723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20724. /**
  20725. * Emits an event when the HMD's pose has been updated.
  20726. */
  20727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20728. private _poseSet;
  20729. /**
  20730. * If the rig cameras be used as parent instead of this camera.
  20731. */
  20732. rigParenting: boolean;
  20733. private _lightOnControllers;
  20734. private _defaultHeight?;
  20735. /**
  20736. * Instantiates a WebVRFreeCamera.
  20737. * @param name The name of the WebVRFreeCamera
  20738. * @param position The starting anchor position for the camera
  20739. * @param scene The scene the camera belongs to
  20740. * @param webVROptions a set of customizable options for the webVRCamera
  20741. */
  20742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20743. /**
  20744. * Gets the device distance from the ground in meters.
  20745. * @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.
  20746. */
  20747. deviceDistanceToRoomGround(): number;
  20748. /**
  20749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20751. */
  20752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20753. /**
  20754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20755. * @returns A promise with a boolean set to if the standing matrix is supported.
  20756. */
  20757. useStandingMatrixAsync(): Promise<boolean>;
  20758. /**
  20759. * Disposes the camera
  20760. */
  20761. dispose(): void;
  20762. /**
  20763. * Gets a vrController by name.
  20764. * @param name The name of the controller to retreive
  20765. * @returns the controller matching the name specified or null if not found
  20766. */
  20767. getControllerByName(name: string): Nullable<WebVRController>;
  20768. private _leftController;
  20769. /**
  20770. * The controller corresponding to the users left hand.
  20771. */
  20772. get leftController(): Nullable<WebVRController>;
  20773. private _rightController;
  20774. /**
  20775. * The controller corresponding to the users right hand.
  20776. */
  20777. get rightController(): Nullable<WebVRController>;
  20778. /**
  20779. * Casts a ray forward from the vrCamera's gaze.
  20780. * @param length Length of the ray (default: 100)
  20781. * @returns the ray corresponding to the gaze
  20782. */
  20783. getForwardRay(length?: number): Ray;
  20784. /**
  20785. * @hidden
  20786. * Updates the camera based on device's frame data
  20787. */
  20788. _checkInputs(): void;
  20789. /**
  20790. * Updates the poseControlled values based on the input device pose.
  20791. * @param poseData Pose coming from the device
  20792. */
  20793. updateFromDevice(poseData: DevicePose): void;
  20794. private _htmlElementAttached;
  20795. private _detachIfAttached;
  20796. /**
  20797. * WebVR's attach control will start broadcasting frames to the device.
  20798. * Note that in certain browsers (chrome for example) this function must be called
  20799. * within a user-interaction callback. Example:
  20800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20801. *
  20802. * @param element html element to attach the vrDevice to
  20803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20804. */
  20805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20806. /**
  20807. * Detaches the camera from the html element and disables VR
  20808. *
  20809. * @param element html element to detach from
  20810. */
  20811. detachControl(element: HTMLElement): void;
  20812. /**
  20813. * @returns the name of this class
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Calls resetPose on the vrDisplay
  20818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20819. */
  20820. resetToCurrentRotation(): void;
  20821. /**
  20822. * @hidden
  20823. * Updates the rig cameras (left and right eye)
  20824. */
  20825. _updateRigCameras(): void;
  20826. private _workingVector;
  20827. private _oneVector;
  20828. private _workingMatrix;
  20829. private updateCacheCalled;
  20830. private _correctPositionIfNotTrackPosition;
  20831. /**
  20832. * @hidden
  20833. * Updates the cached values of the camera
  20834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20835. */
  20836. _updateCache(ignoreParentClass?: boolean): void;
  20837. /**
  20838. * @hidden
  20839. * Get current device position in babylon world
  20840. */
  20841. _computeDevicePosition(): void;
  20842. /**
  20843. * Updates the current device position and rotation in the babylon world
  20844. */
  20845. update(): void;
  20846. /**
  20847. * @hidden
  20848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20849. * @returns an identity matrix
  20850. */
  20851. _getViewMatrix(): Matrix;
  20852. private _tmpMatrix;
  20853. /**
  20854. * This function is called by the two RIG cameras.
  20855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20856. * @hidden
  20857. */
  20858. _getWebVRViewMatrix(): Matrix;
  20859. /** @hidden */
  20860. _getWebVRProjectionMatrix(): Matrix;
  20861. private _onGamepadConnectedObserver;
  20862. private _onGamepadDisconnectedObserver;
  20863. private _updateCacheWhenTrackingDisabledObserver;
  20864. /**
  20865. * Initializes the controllers and their meshes
  20866. */
  20867. initControllers(): void;
  20868. }
  20869. }
  20870. declare module "babylonjs/Materials/materialHelper" {
  20871. import { Nullable } from "babylonjs/types";
  20872. import { Scene } from "babylonjs/scene";
  20873. import { Engine } from "babylonjs/Engines/engine";
  20874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20875. import { Light } from "babylonjs/Lights/light";
  20876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20877. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20879. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20881. /**
  20882. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20883. *
  20884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20885. *
  20886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20887. */
  20888. export class MaterialHelper {
  20889. /**
  20890. * Bind the current view position to an effect.
  20891. * @param effect The effect to be bound
  20892. * @param scene The scene the eyes position is used from
  20893. * @param variableName name of the shader variable that will hold the eye position
  20894. */
  20895. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20896. /**
  20897. * Helps preparing the defines values about the UVs in used in the effect.
  20898. * UVs are shared as much as we can accross channels in the shaders.
  20899. * @param texture The texture we are preparing the UVs for
  20900. * @param defines The defines to update
  20901. * @param key The channel key "diffuse", "specular"... used in the shader
  20902. */
  20903. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20904. /**
  20905. * Binds a texture matrix value to its corrsponding uniform
  20906. * @param texture The texture to bind the matrix for
  20907. * @param uniformBuffer The uniform buffer receivin the data
  20908. * @param key The channel key "diffuse", "specular"... used in the shader
  20909. */
  20910. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20911. /**
  20912. * Gets the current status of the fog (should it be enabled?)
  20913. * @param mesh defines the mesh to evaluate for fog support
  20914. * @param scene defines the hosting scene
  20915. * @returns true if fog must be enabled
  20916. */
  20917. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20918. /**
  20919. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20920. * @param mesh defines the current mesh
  20921. * @param scene defines the current scene
  20922. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20923. * @param pointsCloud defines if point cloud rendering has to be turned on
  20924. * @param fogEnabled defines if fog has to be turned on
  20925. * @param alphaTest defines if alpha testing has to be turned on
  20926. * @param defines defines the current list of defines
  20927. */
  20928. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20929. /**
  20930. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20931. * @param scene defines the current scene
  20932. * @param engine defines the current engine
  20933. * @param defines specifies the list of active defines
  20934. * @param useInstances defines if instances have to be turned on
  20935. * @param useClipPlane defines if clip plane have to be turned on
  20936. * @param useInstances defines if instances have to be turned on
  20937. * @param useThinInstances defines if thin instances have to be turned on
  20938. */
  20939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20940. /**
  20941. * Prepares the defines for bones
  20942. * @param mesh The mesh containing the geometry data we will draw
  20943. * @param defines The defines to update
  20944. */
  20945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20946. /**
  20947. * Prepares the defines for morph targets
  20948. * @param mesh The mesh containing the geometry data we will draw
  20949. * @param defines The defines to update
  20950. */
  20951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20952. /**
  20953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20954. * @param mesh The mesh containing the geometry data we will draw
  20955. * @param defines The defines to update
  20956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20957. * @param useBones Precise whether bones should be used or not (override mesh info)
  20958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20960. * @returns false if defines are considered not dirty and have not been checked
  20961. */
  20962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20963. /**
  20964. * Prepares the defines related to multiview
  20965. * @param scene The scene we are intending to draw
  20966. * @param defines The defines to update
  20967. */
  20968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20969. /**
  20970. * Prepares the defines related to the prepass
  20971. * @param scene The scene we are intending to draw
  20972. * @param defines The defines to update
  20973. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20974. */
  20975. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20976. /**
  20977. * Prepares the defines related to the light information passed in parameter
  20978. * @param scene The scene we are intending to draw
  20979. * @param mesh The mesh the effect is compiling for
  20980. * @param light The light the effect is compiling for
  20981. * @param lightIndex The index of the light
  20982. * @param defines The defines to update
  20983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20984. * @param state Defines the current state regarding what is needed (normals, etc...)
  20985. */
  20986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20987. needNormals: boolean;
  20988. needRebuild: boolean;
  20989. shadowEnabled: boolean;
  20990. specularEnabled: boolean;
  20991. lightmapMode: boolean;
  20992. }): void;
  20993. /**
  20994. * Prepares the defines related to the light information passed in parameter
  20995. * @param scene The scene we are intending to draw
  20996. * @param mesh The mesh the effect is compiling for
  20997. * @param defines The defines to update
  20998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21001. * @returns true if normals will be required for the rest of the effect
  21002. */
  21003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21004. /**
  21005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21006. * @param lightIndex defines the light index
  21007. * @param uniformsList The uniform list
  21008. * @param samplersList The sampler list
  21009. * @param projectedLightTexture defines if projected texture must be used
  21010. * @param uniformBuffersList defines an optional list of uniform buffers
  21011. */
  21012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21013. /**
  21014. * Prepares the uniforms and samplers list to be used in the effect
  21015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21016. * @param samplersList The sampler list
  21017. * @param defines The defines helping in the list generation
  21018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21019. */
  21020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21021. /**
  21022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21023. * @param defines The defines to update while falling back
  21024. * @param fallbacks The authorized effect fallbacks
  21025. * @param maxSimultaneousLights The maximum number of lights allowed
  21026. * @param rank the current rank of the Effect
  21027. * @returns The newly affected rank
  21028. */
  21029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21030. private static _TmpMorphInfluencers;
  21031. /**
  21032. * Prepares the list of attributes required for morph targets according to the effect defines.
  21033. * @param attribs The current list of supported attribs
  21034. * @param mesh The mesh to prepare the morph targets attributes for
  21035. * @param influencers The number of influencers
  21036. */
  21037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21038. /**
  21039. * Prepares the list of attributes required for morph targets according to the effect defines.
  21040. * @param attribs The current list of supported attribs
  21041. * @param mesh The mesh to prepare the morph targets attributes for
  21042. * @param defines The current Defines of the effect
  21043. */
  21044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the list of attributes required for bones according to the effect defines.
  21047. * @param attribs The current list of supported attribs
  21048. * @param mesh The mesh to prepare the bones attributes for
  21049. * @param defines The current Defines of the effect
  21050. * @param fallbacks The current efffect fallback strategy
  21051. */
  21052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21053. /**
  21054. * Check and prepare the list of attributes required for instances according to the effect defines.
  21055. * @param attribs The current list of supported attribs
  21056. * @param defines The current MaterialDefines of the effect
  21057. */
  21058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21059. /**
  21060. * Add the list of attributes required for instances to the attribs array.
  21061. * @param attribs The current list of supported attribs
  21062. */
  21063. static PushAttributesForInstances(attribs: string[]): void;
  21064. /**
  21065. * Binds the light information to the effect.
  21066. * @param light The light containing the generator
  21067. * @param effect The effect we are binding the data to
  21068. * @param lightIndex The light index in the effect used to render
  21069. */
  21070. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21071. /**
  21072. * Binds the lights information from the scene to the effect for the given mesh.
  21073. * @param light Light to bind
  21074. * @param lightIndex Light index
  21075. * @param scene The scene where the light belongs to
  21076. * @param effect The effect we are binding the data to
  21077. * @param useSpecular Defines if specular is supported
  21078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21079. */
  21080. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21081. /**
  21082. * Binds the lights information from the scene to the effect for the given mesh.
  21083. * @param scene The scene the lights belongs to
  21084. * @param mesh The mesh we are binding the information to render
  21085. * @param effect The effect we are binding the data to
  21086. * @param defines The generated defines for the effect
  21087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21089. */
  21090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21091. private static _tempFogColor;
  21092. /**
  21093. * Binds the fog information from the scene to the effect for the given mesh.
  21094. * @param scene The scene the lights belongs to
  21095. * @param mesh The mesh we are binding the information to render
  21096. * @param effect The effect we are binding the data to
  21097. * @param linearSpace Defines if the fog effect is applied in linear space
  21098. */
  21099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21100. /**
  21101. * Binds the bones information from the mesh to the effect.
  21102. * @param mesh The mesh we are binding the information to render
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21106. /**
  21107. * Binds the morph targets information from the mesh to the effect.
  21108. * @param abstractMesh The mesh we are binding the information to render
  21109. * @param effect The effect we are binding the data to
  21110. */
  21111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21112. /**
  21113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21114. * @param defines The generated defines used in the effect
  21115. * @param effect The effect we are binding the data to
  21116. * @param scene The scene we are willing to render with logarithmic scale for
  21117. */
  21118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21119. /**
  21120. * Binds the clip plane information from the scene to the effect.
  21121. * @param scene The scene the clip plane information are extracted from
  21122. * @param effect The effect we are binding the data to
  21123. */
  21124. static BindClipPlane(effect: Effect, scene: Scene): void;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21130. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Effect } from "babylonjs/Materials/effect";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { Scene } from "babylonjs/scene";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21137. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21138. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21139. import { Observable } from "babylonjs/Misc/observable";
  21140. /**
  21141. * Block used to expose an input value
  21142. */
  21143. export class InputBlock extends NodeMaterialBlock {
  21144. private _mode;
  21145. private _associatedVariableName;
  21146. private _storedValue;
  21147. private _valueCallback;
  21148. private _type;
  21149. private _animationType;
  21150. /** Gets or set a value used to limit the range of float values */
  21151. min: number;
  21152. /** Gets or set a value used to limit the range of float values */
  21153. max: number;
  21154. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21155. isBoolean: boolean;
  21156. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21157. matrixMode: number;
  21158. /** @hidden */
  21159. _systemValue: Nullable<NodeMaterialSystemValues>;
  21160. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21161. isConstant: boolean;
  21162. /** Gets or sets the group to use to display this block in the Inspector */
  21163. groupInInspector: string;
  21164. /** Gets an observable raised when the value is changed */
  21165. onValueChangedObservable: Observable<InputBlock>;
  21166. /**
  21167. * Gets or sets the connection point type (default is float)
  21168. */
  21169. get type(): NodeMaterialBlockConnectionPointTypes;
  21170. /**
  21171. * Creates a new InputBlock
  21172. * @param name defines the block name
  21173. * @param target defines the target of that block (Vertex by default)
  21174. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21175. */
  21176. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21177. /**
  21178. * Validates if a name is a reserve word.
  21179. * @param newName the new name to be given to the node.
  21180. * @returns false if the name is a reserve word, else true.
  21181. */
  21182. validateBlockName(newName: string): boolean;
  21183. /**
  21184. * Gets the output component
  21185. */
  21186. get output(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Set the source of this connection point to a vertex attribute
  21189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21190. * @returns the current connection point
  21191. */
  21192. setAsAttribute(attributeName?: string): InputBlock;
  21193. /**
  21194. * Set the source of this connection point to a system value
  21195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21196. * @returns the current connection point
  21197. */
  21198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21199. /**
  21200. * Gets or sets the value of that point.
  21201. * Please note that this value will be ignored if valueCallback is defined
  21202. */
  21203. get value(): any;
  21204. set value(value: any);
  21205. /**
  21206. * Gets or sets a callback used to get the value of that point.
  21207. * Please note that setting this value will force the connection point to ignore the value property
  21208. */
  21209. get valueCallback(): () => any;
  21210. set valueCallback(value: () => any);
  21211. /**
  21212. * Gets or sets the associated variable name in the shader
  21213. */
  21214. get associatedVariableName(): string;
  21215. set associatedVariableName(value: string);
  21216. /** Gets or sets the type of animation applied to the input */
  21217. get animationType(): AnimatedInputBlockTypes;
  21218. set animationType(value: AnimatedInputBlockTypes);
  21219. /**
  21220. * Gets a boolean indicating that this connection point not defined yet
  21221. */
  21222. get isUndefined(): boolean;
  21223. /**
  21224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21225. * In this case the connection point name must be the name of the uniform to use.
  21226. * Can only be set on inputs
  21227. */
  21228. get isUniform(): boolean;
  21229. set isUniform(value: boolean);
  21230. /**
  21231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21232. * In this case the connection point name must be the name of the attribute to use
  21233. * Can only be set on inputs
  21234. */
  21235. get isAttribute(): boolean;
  21236. set isAttribute(value: boolean);
  21237. /**
  21238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21239. * Can only be set on exit points
  21240. */
  21241. get isVarying(): boolean;
  21242. set isVarying(value: boolean);
  21243. /**
  21244. * Gets a boolean indicating that the current connection point is a system value
  21245. */
  21246. get isSystemValue(): boolean;
  21247. /**
  21248. * Gets or sets the current well known value or null if not defined as a system value
  21249. */
  21250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Animate the input if animationType !== None
  21259. * @param scene defines the rendering scene
  21260. */
  21261. animate(scene: Scene): void;
  21262. private _emitDefine;
  21263. initialize(state: NodeMaterialBuildState): void;
  21264. /**
  21265. * Set the input block to its default value (based on its type)
  21266. */
  21267. setDefaultValue(): void;
  21268. private _emitConstant;
  21269. /** @hidden */
  21270. get _noContextSwitch(): boolean;
  21271. private _emit;
  21272. /** @hidden */
  21273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21274. /** @hidden */
  21275. _transmit(effect: Effect, scene: Scene): void;
  21276. protected _buildBlock(state: NodeMaterialBuildState): void;
  21277. protected _dumpPropertiesCode(): string;
  21278. dispose(): void;
  21279. serialize(): any;
  21280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21281. }
  21282. }
  21283. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21284. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21286. import { Nullable } from "babylonjs/types";
  21287. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21290. /**
  21291. * Enum used to define the compatibility state between two connection points
  21292. */
  21293. export enum NodeMaterialConnectionPointCompatibilityStates {
  21294. /** Points are compatibles */
  21295. Compatible = 0,
  21296. /** Points are incompatible because of their types */
  21297. TypeIncompatible = 1,
  21298. /** Points are incompatible because of their targets (vertex vs fragment) */
  21299. TargetIncompatible = 2
  21300. }
  21301. /**
  21302. * Defines the direction of a connection point
  21303. */
  21304. export enum NodeMaterialConnectionPointDirection {
  21305. /** Input */
  21306. Input = 0,
  21307. /** Output */
  21308. Output = 1
  21309. }
  21310. /**
  21311. * Defines a connection point for a block
  21312. */
  21313. export class NodeMaterialConnectionPoint {
  21314. /** @hidden */
  21315. _ownerBlock: NodeMaterialBlock;
  21316. /** @hidden */
  21317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21318. private _endpoints;
  21319. private _associatedVariableName;
  21320. private _direction;
  21321. /** @hidden */
  21322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21323. /** @hidden */
  21324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21325. private _type;
  21326. /** @hidden */
  21327. _enforceAssociatedVariableName: boolean;
  21328. /** Gets the direction of the point */
  21329. get direction(): NodeMaterialConnectionPointDirection;
  21330. /** Indicates that this connection point needs dual validation before being connected to another point */
  21331. needDualDirectionValidation: boolean;
  21332. /**
  21333. * Gets or sets the additional types supported by this connection point
  21334. */
  21335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21336. /**
  21337. * Gets or sets the additional types excluded by this connection point
  21338. */
  21339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21340. /**
  21341. * Observable triggered when this point is connected
  21342. */
  21343. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21344. /**
  21345. * Gets or sets the associated variable name in the shader
  21346. */
  21347. get associatedVariableName(): string;
  21348. set associatedVariableName(value: string);
  21349. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21350. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21351. /**
  21352. * Gets or sets the connection point type (default is float)
  21353. */
  21354. get type(): NodeMaterialBlockConnectionPointTypes;
  21355. set type(value: NodeMaterialBlockConnectionPointTypes);
  21356. /**
  21357. * Gets or sets the connection point name
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the connection point name
  21362. */
  21363. displayName: string;
  21364. /**
  21365. * Gets or sets a boolean indicating that this connection point can be omitted
  21366. */
  21367. isOptional: boolean;
  21368. /**
  21369. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21370. */
  21371. isExposedOnFrame: boolean;
  21372. /**
  21373. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21374. */
  21375. define: string;
  21376. /** @hidden */
  21377. _prioritizeVertex: boolean;
  21378. private _target;
  21379. /** Gets or sets the target of that connection point */
  21380. get target(): NodeMaterialBlockTargets;
  21381. set target(value: NodeMaterialBlockTargets);
  21382. /**
  21383. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21384. */
  21385. get isConnected(): boolean;
  21386. /**
  21387. * Gets a boolean indicating that the current point is connected to an input block
  21388. */
  21389. get isConnectedToInputBlock(): boolean;
  21390. /**
  21391. * Gets a the connected input block (if any)
  21392. */
  21393. get connectInputBlock(): Nullable<InputBlock>;
  21394. /** Get the other side of the connection (if any) */
  21395. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21396. /** Get the block that owns this connection point */
  21397. get ownerBlock(): NodeMaterialBlock;
  21398. /** Get the block connected on the other side of this connection (if any) */
  21399. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21400. /** Get the block connected on the endpoints of this connection (if any) */
  21401. get connectedBlocks(): Array<NodeMaterialBlock>;
  21402. /** Gets the list of connected endpoints */
  21403. get endpoints(): NodeMaterialConnectionPoint[];
  21404. /** Gets a boolean indicating if that output point is connected to at least one input */
  21405. get hasEndpoints(): boolean;
  21406. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21407. get isConnectedInVertexShader(): boolean;
  21408. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21409. get isConnectedInFragmentShader(): boolean;
  21410. /**
  21411. * Creates a block suitable to be used as an input for this input point.
  21412. * If null is returned, a block based on the point type will be created.
  21413. * @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
  21414. */
  21415. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  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);
  21423. /**
  21424. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21425. * @returns the class name
  21426. */
  21427. getClassName(): string;
  21428. /**
  21429. * Gets a boolean indicating if the current point can be connected to another point
  21430. * @param connectionPoint defines the other connection point
  21431. * @returns a boolean
  21432. */
  21433. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21434. /**
  21435. * Gets a number indicating if the current point can be connected to another point
  21436. * @param connectionPoint defines the other connection point
  21437. * @returns a number defining the compatibility state
  21438. */
  21439. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21440. /**
  21441. * Connect this point to another connection point
  21442. * @param connectionPoint defines the other connection point
  21443. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21444. * @returns the current connection point
  21445. */
  21446. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21447. /**
  21448. * Disconnect this point from one of his endpoint
  21449. * @param endpoint defines the other connection point
  21450. * @returns the current connection point
  21451. */
  21452. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21453. /**
  21454. * Serializes this point in a JSON representation
  21455. * @param isInput defines if the connection point is an input (default is true)
  21456. * @returns the serialized point object
  21457. */
  21458. serialize(isInput?: boolean): any;
  21459. /**
  21460. * Release resources
  21461. */
  21462. dispose(): void;
  21463. }
  21464. }
  21465. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21466. /**
  21467. * Enum used to define the material modes
  21468. */
  21469. export enum NodeMaterialModes {
  21470. /** Regular material */
  21471. Material = 0,
  21472. /** For post process */
  21473. PostProcess = 1,
  21474. /** For particle system */
  21475. Particle = 2,
  21476. /** For procedural texture */
  21477. ProceduralTexture = 3
  21478. }
  21479. }
  21480. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21483. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21486. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21487. import { Effect } from "babylonjs/Materials/effect";
  21488. import { Mesh } from "babylonjs/Meshes/mesh";
  21489. import { Nullable } from "babylonjs/types";
  21490. import { Texture } from "babylonjs/Materials/Textures/texture";
  21491. import { Scene } from "babylonjs/scene";
  21492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21493. /**
  21494. * Block used to read a texture from a sampler
  21495. */
  21496. export class TextureBlock extends NodeMaterialBlock {
  21497. private _defineName;
  21498. private _linearDefineName;
  21499. private _gammaDefineName;
  21500. private _tempTextureRead;
  21501. private _samplerName;
  21502. private _transformedUVName;
  21503. private _textureTransformName;
  21504. private _textureInfoName;
  21505. private _mainUVName;
  21506. private _mainUVDefineName;
  21507. private _fragmentOnly;
  21508. /**
  21509. * Gets or sets the texture associated with the node
  21510. */
  21511. texture: Nullable<Texture>;
  21512. /**
  21513. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21514. */
  21515. convertToGammaSpace: boolean;
  21516. /**
  21517. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21518. */
  21519. convertToLinearSpace: boolean;
  21520. /**
  21521. * Create a new TextureBlock
  21522. * @param name defines the block name
  21523. */
  21524. constructor(name: string, fragmentOnly?: boolean);
  21525. /**
  21526. * Gets the current class name
  21527. * @returns the class name
  21528. */
  21529. getClassName(): string;
  21530. /**
  21531. * Gets the uv input component
  21532. */
  21533. get uv(): NodeMaterialConnectionPoint;
  21534. /**
  21535. * Gets the rgba output component
  21536. */
  21537. get rgba(): NodeMaterialConnectionPoint;
  21538. /**
  21539. * Gets the rgb output component
  21540. */
  21541. get rgb(): NodeMaterialConnectionPoint;
  21542. /**
  21543. * Gets the r output component
  21544. */
  21545. get r(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the g output component
  21548. */
  21549. get g(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the b output component
  21552. */
  21553. get b(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the a output component
  21556. */
  21557. get a(): NodeMaterialConnectionPoint;
  21558. get target(): NodeMaterialBlockTargets;
  21559. autoConfigure(material: NodeMaterial): void;
  21560. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21562. isReady(): boolean;
  21563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21564. private get _isMixed();
  21565. private _injectVertexCode;
  21566. private _writeTextureRead;
  21567. private _writeOutput;
  21568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21569. protected _dumpPropertiesCode(): string;
  21570. serialize(): any;
  21571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21572. }
  21573. }
  21574. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21575. /** @hidden */
  21576. export var reflectionFunction: {
  21577. name: string;
  21578. shader: string;
  21579. };
  21580. }
  21581. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21587. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21588. import { Effect } from "babylonjs/Materials/effect";
  21589. import { Mesh } from "babylonjs/Meshes/mesh";
  21590. import { Nullable } from "babylonjs/types";
  21591. import { Scene } from "babylonjs/scene";
  21592. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21593. /**
  21594. * Base block used to read a reflection texture from a sampler
  21595. */
  21596. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21597. /** @hidden */
  21598. _define3DName: string;
  21599. /** @hidden */
  21600. _defineCubicName: string;
  21601. /** @hidden */
  21602. _defineExplicitName: string;
  21603. /** @hidden */
  21604. _defineProjectionName: string;
  21605. /** @hidden */
  21606. _defineLocalCubicName: string;
  21607. /** @hidden */
  21608. _defineSphericalName: string;
  21609. /** @hidden */
  21610. _definePlanarName: string;
  21611. /** @hidden */
  21612. _defineEquirectangularName: string;
  21613. /** @hidden */
  21614. _defineMirroredEquirectangularFixedName: string;
  21615. /** @hidden */
  21616. _defineEquirectangularFixedName: string;
  21617. /** @hidden */
  21618. _defineSkyboxName: string;
  21619. /** @hidden */
  21620. _defineOppositeZ: string;
  21621. /** @hidden */
  21622. _cubeSamplerName: string;
  21623. /** @hidden */
  21624. _2DSamplerName: string;
  21625. protected _positionUVWName: string;
  21626. protected _directionWName: string;
  21627. protected _reflectionVectorName: string;
  21628. /** @hidden */
  21629. _reflectionCoordsName: string;
  21630. /** @hidden */
  21631. _reflectionMatrixName: string;
  21632. protected _reflectionColorName: string;
  21633. /**
  21634. * Gets or sets the texture associated with the node
  21635. */
  21636. texture: Nullable<BaseTexture>;
  21637. /**
  21638. * Create a new ReflectionTextureBaseBlock
  21639. * @param name defines the block name
  21640. */
  21641. constructor(name: string);
  21642. /**
  21643. * Gets the current class name
  21644. * @returns the class name
  21645. */
  21646. getClassName(): string;
  21647. /**
  21648. * Gets the world position input component
  21649. */
  21650. abstract get position(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the world position input component
  21653. */
  21654. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the world normal input component
  21657. */
  21658. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the world input component
  21661. */
  21662. abstract get world(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the camera (or eye) position component
  21665. */
  21666. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the view input component
  21669. */
  21670. abstract get view(): NodeMaterialConnectionPoint;
  21671. protected _getTexture(): Nullable<BaseTexture>;
  21672. autoConfigure(material: NodeMaterial): void;
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21674. isReady(): boolean;
  21675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21676. /**
  21677. * Gets the code to inject in the vertex shader
  21678. * @param state current state of the node material building
  21679. * @returns the shader code
  21680. */
  21681. handleVertexSide(state: NodeMaterialBuildState): string;
  21682. /**
  21683. * Handles the inits for the fragment code path
  21684. * @param state node material build state
  21685. */
  21686. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21687. /**
  21688. * Generates the reflection coords code for the fragment code path
  21689. * @param worldNormalVarName name of the world normal variable
  21690. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21691. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21692. * @returns the shader code
  21693. */
  21694. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21695. /**
  21696. * Generates the reflection color code for the fragment code path
  21697. * @param lodVarName name of the lod variable
  21698. * @param swizzleLookupTexture swizzle to use for the final color variable
  21699. * @returns the shader code
  21700. */
  21701. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21702. /**
  21703. * Generates the code corresponding to the connected output points
  21704. * @param state node material build state
  21705. * @param varName name of the variable to output
  21706. * @returns the shader code
  21707. */
  21708. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21709. protected _buildBlock(state: NodeMaterialBuildState): this;
  21710. protected _dumpPropertiesCode(): string;
  21711. serialize(): any;
  21712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21713. }
  21714. }
  21715. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21717. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21718. import { Nullable } from "babylonjs/types";
  21719. /**
  21720. * Defines a connection point to be used for points with a custom object type
  21721. */
  21722. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21723. private _blockType;
  21724. private _blockName;
  21725. private _nameForCheking?;
  21726. /**
  21727. * Creates a new connection point
  21728. * @param name defines the connection point name
  21729. * @param ownerBlock defines the block hosting this connection point
  21730. * @param direction defines the direction of the connection point
  21731. */
  21732. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21733. /**
  21734. * Gets a number indicating if the current point can be connected to another point
  21735. * @param connectionPoint defines the other connection point
  21736. * @returns a number defining the compatibility state
  21737. */
  21738. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21739. /**
  21740. * Creates a block suitable to be used as an input for this input point.
  21741. * If null is returned, a block based on the point type will be created.
  21742. * @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
  21743. */
  21744. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21745. }
  21746. }
  21747. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21748. /**
  21749. * Enum defining the type of properties that can be edited in the property pages in the NME
  21750. */
  21751. export enum PropertyTypeForEdition {
  21752. /** property is a boolean */
  21753. Boolean = 0,
  21754. /** property is a float */
  21755. Float = 1,
  21756. /** property is a Vector2 */
  21757. Vector2 = 2,
  21758. /** property is a list of values */
  21759. List = 3
  21760. }
  21761. /**
  21762. * Interface that defines an option in a variable of type list
  21763. */
  21764. export interface IEditablePropertyListOption {
  21765. /** label of the option */
  21766. "label": string;
  21767. /** value of the option */
  21768. "value": number;
  21769. }
  21770. /**
  21771. * Interface that defines the options available for an editable property
  21772. */
  21773. export interface IEditablePropertyOption {
  21774. /** min value */
  21775. "min"?: number;
  21776. /** max value */
  21777. "max"?: number;
  21778. /** notifiers: indicates which actions to take when the property is changed */
  21779. "notifiers"?: {
  21780. /** the material should be rebuilt */
  21781. "rebuild"?: boolean;
  21782. /** the preview should be updated */
  21783. "update"?: boolean;
  21784. };
  21785. /** list of the options for a variable of type list */
  21786. "options"?: IEditablePropertyListOption[];
  21787. }
  21788. /**
  21789. * Interface that describes an editable property
  21790. */
  21791. export interface IPropertyDescriptionForEdition {
  21792. /** name of the property */
  21793. "propertyName": string;
  21794. /** display name of the property */
  21795. "displayName": string;
  21796. /** type of the property */
  21797. "type": PropertyTypeForEdition;
  21798. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21799. "groupName": string;
  21800. /** options for the property */
  21801. "options": IEditablePropertyOption;
  21802. }
  21803. /**
  21804. * Decorator that flags a property in a node material block as being editable
  21805. */
  21806. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21807. }
  21808. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21811. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21813. import { Nullable } from "babylonjs/types";
  21814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21817. import { Effect } from "babylonjs/Materials/effect";
  21818. import { Scene } from "babylonjs/scene";
  21819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21820. /**
  21821. * Block used to implement the refraction part of the sub surface module of the PBR material
  21822. */
  21823. export class RefractionBlock extends NodeMaterialBlock {
  21824. /** @hidden */
  21825. _define3DName: string;
  21826. /** @hidden */
  21827. _refractionMatrixName: string;
  21828. /** @hidden */
  21829. _defineLODRefractionAlpha: string;
  21830. /** @hidden */
  21831. _defineLinearSpecularRefraction: string;
  21832. /** @hidden */
  21833. _defineOppositeZ: string;
  21834. /** @hidden */
  21835. _cubeSamplerName: string;
  21836. /** @hidden */
  21837. _2DSamplerName: string;
  21838. /** @hidden */
  21839. _vRefractionMicrosurfaceInfosName: string;
  21840. /** @hidden */
  21841. _vRefractionInfosName: string;
  21842. private _scene;
  21843. /**
  21844. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21845. * Materials half opaque for instance using refraction could benefit from this control.
  21846. */
  21847. linkRefractionWithTransparency: boolean;
  21848. /**
  21849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21850. */
  21851. invertRefractionY: boolean;
  21852. /**
  21853. * Gets or sets the texture associated with the node
  21854. */
  21855. texture: Nullable<BaseTexture>;
  21856. /**
  21857. * Create a new RefractionBlock
  21858. * @param name defines the block name
  21859. */
  21860. constructor(name: string);
  21861. /**
  21862. * Gets the current class name
  21863. * @returns the class name
  21864. */
  21865. getClassName(): string;
  21866. /**
  21867. * Gets the intensity input component
  21868. */
  21869. get intensity(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the index of refraction input component
  21872. */
  21873. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the tint at distance input component
  21876. */
  21877. get tintAtDistance(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the view input component
  21880. */
  21881. get view(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the refraction object output component
  21884. */
  21885. get refraction(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Returns true if the block has a texture
  21888. */
  21889. get hasTexture(): boolean;
  21890. protected _getTexture(): Nullable<BaseTexture>;
  21891. autoConfigure(material: NodeMaterial): void;
  21892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21893. isReady(): boolean;
  21894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21895. /**
  21896. * Gets the main code of the block (fragment side)
  21897. * @param state current state of the node material building
  21898. * @returns the shader code
  21899. */
  21900. getCode(state: NodeMaterialBuildState): string;
  21901. protected _buildBlock(state: NodeMaterialBuildState): this;
  21902. protected _dumpPropertiesCode(): string;
  21903. serialize(): any;
  21904. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21905. }
  21906. }
  21907. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21910. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21913. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21915. import { Nullable } from "babylonjs/types";
  21916. import { Scene } from "babylonjs/scene";
  21917. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21918. /**
  21919. * Base block used as input for post process
  21920. */
  21921. export class CurrentScreenBlock extends NodeMaterialBlock {
  21922. private _samplerName;
  21923. private _linearDefineName;
  21924. private _gammaDefineName;
  21925. private _mainUVName;
  21926. private _tempTextureRead;
  21927. /**
  21928. * Gets or sets the texture associated with the node
  21929. */
  21930. texture: Nullable<BaseTexture>;
  21931. /**
  21932. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21933. */
  21934. convertToGammaSpace: boolean;
  21935. /**
  21936. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21937. */
  21938. convertToLinearSpace: boolean;
  21939. /**
  21940. * Create a new CurrentScreenBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the uv input component
  21951. */
  21952. get uv(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the rgba output component
  21955. */
  21956. get rgba(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the rgb output component
  21959. */
  21960. get rgb(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the r output component
  21963. */
  21964. get r(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the g output component
  21967. */
  21968. get g(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the b output component
  21971. */
  21972. get b(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the a output component
  21975. */
  21976. get a(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Initialize the block and prepare the context for build
  21979. * @param state defines the state that will be used for the build
  21980. */
  21981. initialize(state: NodeMaterialBuildState): void;
  21982. get target(): NodeMaterialBlockTargets;
  21983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21984. isReady(): boolean;
  21985. private _injectVertexCode;
  21986. private _writeTextureRead;
  21987. private _writeOutput;
  21988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21989. serialize(): any;
  21990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21991. }
  21992. }
  21993. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21998. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22000. import { Nullable } from "babylonjs/types";
  22001. import { Scene } from "babylonjs/scene";
  22002. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22003. /**
  22004. * Base block used for the particle texture
  22005. */
  22006. export class ParticleTextureBlock extends NodeMaterialBlock {
  22007. private _samplerName;
  22008. private _linearDefineName;
  22009. private _gammaDefineName;
  22010. private _tempTextureRead;
  22011. /**
  22012. * Gets or sets the texture associated with the node
  22013. */
  22014. texture: Nullable<BaseTexture>;
  22015. /**
  22016. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22017. */
  22018. convertToGammaSpace: boolean;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22021. */
  22022. convertToLinearSpace: boolean;
  22023. /**
  22024. * Create a new ParticleTextureBlock
  22025. * @param name defines the block name
  22026. */
  22027. constructor(name: string);
  22028. /**
  22029. * Gets the current class name
  22030. * @returns the class name
  22031. */
  22032. getClassName(): string;
  22033. /**
  22034. * Gets the uv input component
  22035. */
  22036. get uv(): NodeMaterialConnectionPoint;
  22037. /**
  22038. * Gets the rgba output component
  22039. */
  22040. get rgba(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgb output component
  22043. */
  22044. get rgb(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the r output component
  22047. */
  22048. get r(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the g output component
  22051. */
  22052. get g(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the b output component
  22055. */
  22056. get b(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the a output component
  22059. */
  22060. get a(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Initialize the block and prepare the context for build
  22063. * @param state defines the state that will be used for the build
  22064. */
  22065. initialize(state: NodeMaterialBuildState): void;
  22066. autoConfigure(material: NodeMaterial): void;
  22067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22068. isReady(): boolean;
  22069. private _writeOutput;
  22070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22071. serialize(): any;
  22072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22073. }
  22074. }
  22075. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22078. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22079. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22080. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22081. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22082. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22083. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22084. import { Scene } from "babylonjs/scene";
  22085. /**
  22086. * Class used to store shared data between 2 NodeMaterialBuildState
  22087. */
  22088. export class NodeMaterialBuildStateSharedData {
  22089. /**
  22090. * Gets the list of emitted varyings
  22091. */
  22092. temps: string[];
  22093. /**
  22094. * Gets the list of emitted varyings
  22095. */
  22096. varyings: string[];
  22097. /**
  22098. * Gets the varying declaration string
  22099. */
  22100. varyingDeclaration: string;
  22101. /**
  22102. * Input blocks
  22103. */
  22104. inputBlocks: InputBlock[];
  22105. /**
  22106. * Input blocks
  22107. */
  22108. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22109. /**
  22110. * Bindable blocks (Blocks that need to set data to the effect)
  22111. */
  22112. bindableBlocks: NodeMaterialBlock[];
  22113. /**
  22114. * List of blocks that can provide a compilation fallback
  22115. */
  22116. blocksWithFallbacks: NodeMaterialBlock[];
  22117. /**
  22118. * List of blocks that can provide a define update
  22119. */
  22120. blocksWithDefines: NodeMaterialBlock[];
  22121. /**
  22122. * List of blocks that can provide a repeatable content
  22123. */
  22124. repeatableContentBlocks: NodeMaterialBlock[];
  22125. /**
  22126. * List of blocks that can provide a dynamic list of uniforms
  22127. */
  22128. dynamicUniformBlocks: NodeMaterialBlock[];
  22129. /**
  22130. * List of blocks that can block the isReady function for the material
  22131. */
  22132. blockingBlocks: NodeMaterialBlock[];
  22133. /**
  22134. * Gets the list of animated inputs
  22135. */
  22136. animatedInputs: InputBlock[];
  22137. /**
  22138. * Build Id used to avoid multiple recompilations
  22139. */
  22140. buildId: number;
  22141. /** List of emitted variables */
  22142. variableNames: {
  22143. [key: string]: number;
  22144. };
  22145. /** List of emitted defines */
  22146. defineNames: {
  22147. [key: string]: number;
  22148. };
  22149. /** Should emit comments? */
  22150. emitComments: boolean;
  22151. /** Emit build activity */
  22152. verbose: boolean;
  22153. /** Gets or sets the hosting scene */
  22154. scene: Scene;
  22155. /**
  22156. * Gets the compilation hints emitted at compilation time
  22157. */
  22158. hints: {
  22159. needWorldViewMatrix: boolean;
  22160. needWorldViewProjectionMatrix: boolean;
  22161. needAlphaBlending: boolean;
  22162. needAlphaTesting: boolean;
  22163. };
  22164. /**
  22165. * List of compilation checks
  22166. */
  22167. checks: {
  22168. emitVertex: boolean;
  22169. emitFragment: boolean;
  22170. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22171. };
  22172. /**
  22173. * Is vertex program allowed to be empty?
  22174. */
  22175. allowEmptyVertexProgram: boolean;
  22176. /** Creates a new shared data */
  22177. constructor();
  22178. /**
  22179. * Emits console errors and exceptions if there is a failing check
  22180. */
  22181. emitErrors(): void;
  22182. }
  22183. }
  22184. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22185. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22187. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22188. /**
  22189. * Class used to store node based material build state
  22190. */
  22191. export class NodeMaterialBuildState {
  22192. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22193. supportUniformBuffers: boolean;
  22194. /**
  22195. * Gets the list of emitted attributes
  22196. */
  22197. attributes: string[];
  22198. /**
  22199. * Gets the list of emitted uniforms
  22200. */
  22201. uniforms: string[];
  22202. /**
  22203. * Gets the list of emitted constants
  22204. */
  22205. constants: string[];
  22206. /**
  22207. * Gets the list of emitted samplers
  22208. */
  22209. samplers: string[];
  22210. /**
  22211. * Gets the list of emitted functions
  22212. */
  22213. functions: {
  22214. [key: string]: string;
  22215. };
  22216. /**
  22217. * Gets the list of emitted extensions
  22218. */
  22219. extensions: {
  22220. [key: string]: string;
  22221. };
  22222. /**
  22223. * Gets the target of the compilation state
  22224. */
  22225. target: NodeMaterialBlockTargets;
  22226. /**
  22227. * Gets the list of emitted counters
  22228. */
  22229. counters: {
  22230. [key: string]: number;
  22231. };
  22232. /**
  22233. * Shared data between multiple NodeMaterialBuildState instances
  22234. */
  22235. sharedData: NodeMaterialBuildStateSharedData;
  22236. /** @hidden */
  22237. _vertexState: NodeMaterialBuildState;
  22238. /** @hidden */
  22239. _attributeDeclaration: string;
  22240. /** @hidden */
  22241. _uniformDeclaration: string;
  22242. /** @hidden */
  22243. _constantDeclaration: string;
  22244. /** @hidden */
  22245. _samplerDeclaration: string;
  22246. /** @hidden */
  22247. _varyingTransfer: string;
  22248. /** @hidden */
  22249. _injectAtEnd: string;
  22250. private _repeatableContentAnchorIndex;
  22251. /** @hidden */
  22252. _builtCompilationString: string;
  22253. /**
  22254. * Gets the emitted compilation strings
  22255. */
  22256. compilationString: string;
  22257. /**
  22258. * Finalize the compilation strings
  22259. * @param state defines the current compilation state
  22260. */
  22261. finalize(state: NodeMaterialBuildState): void;
  22262. /** @hidden */
  22263. get _repeatableContentAnchor(): string;
  22264. /** @hidden */
  22265. _getFreeVariableName(prefix: string): string;
  22266. /** @hidden */
  22267. _getFreeDefineName(prefix: string): string;
  22268. /** @hidden */
  22269. _excludeVariableName(name: string): void;
  22270. /** @hidden */
  22271. _emit2DSampler(name: string): void;
  22272. /** @hidden */
  22273. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22274. /** @hidden */
  22275. _emitExtension(name: string, extension: string, define?: string): void;
  22276. /** @hidden */
  22277. _emitFunction(name: string, code: string, comments: string): void;
  22278. /** @hidden */
  22279. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22280. replaceStrings?: {
  22281. search: RegExp;
  22282. replace: string;
  22283. }[];
  22284. repeatKey?: string;
  22285. }): string;
  22286. /** @hidden */
  22287. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22288. repeatKey?: string;
  22289. removeAttributes?: boolean;
  22290. removeUniforms?: boolean;
  22291. removeVaryings?: boolean;
  22292. removeIfDef?: boolean;
  22293. replaceStrings?: {
  22294. search: RegExp;
  22295. replace: string;
  22296. }[];
  22297. }, storeKey?: string): void;
  22298. /** @hidden */
  22299. _registerTempVariable(name: string): boolean;
  22300. /** @hidden */
  22301. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22302. /** @hidden */
  22303. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22304. /** @hidden */
  22305. _emitFloat(value: number): string;
  22306. }
  22307. }
  22308. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22309. /**
  22310. * Helper class used to generate session unique ID
  22311. */
  22312. export class UniqueIdGenerator {
  22313. private static _UniqueIdCounter;
  22314. /**
  22315. * Gets an unique (relatively to the current scene) Id
  22316. */
  22317. static get UniqueId(): number;
  22318. }
  22319. }
  22320. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22321. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22323. import { Nullable } from "babylonjs/types";
  22324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22325. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22326. import { Effect } from "babylonjs/Materials/effect";
  22327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22328. import { Mesh } from "babylonjs/Meshes/mesh";
  22329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22330. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22331. import { Scene } from "babylonjs/scene";
  22332. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22333. /**
  22334. * Defines a block that can be used inside a node based material
  22335. */
  22336. export class NodeMaterialBlock {
  22337. private _buildId;
  22338. private _buildTarget;
  22339. private _target;
  22340. private _isFinalMerger;
  22341. private _isInput;
  22342. private _name;
  22343. protected _isUnique: boolean;
  22344. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22345. inputsAreExclusive: boolean;
  22346. /** @hidden */
  22347. _codeVariableName: string;
  22348. /** @hidden */
  22349. _inputs: NodeMaterialConnectionPoint[];
  22350. /** @hidden */
  22351. _outputs: NodeMaterialConnectionPoint[];
  22352. /** @hidden */
  22353. _preparationId: number;
  22354. /**
  22355. * Gets the name of the block
  22356. */
  22357. get name(): string;
  22358. /**
  22359. * Sets the name of the block. Will check if the name is valid.
  22360. */
  22361. set name(newName: string);
  22362. /**
  22363. * Gets or sets the unique id of the node
  22364. */
  22365. uniqueId: number;
  22366. /**
  22367. * Gets or sets the comments associated with this block
  22368. */
  22369. comments: string;
  22370. /**
  22371. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22372. */
  22373. get isUnique(): boolean;
  22374. /**
  22375. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22376. */
  22377. get isFinalMerger(): boolean;
  22378. /**
  22379. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22380. */
  22381. get isInput(): boolean;
  22382. /**
  22383. * Gets or sets the build Id
  22384. */
  22385. get buildId(): number;
  22386. set buildId(value: number);
  22387. /**
  22388. * Gets or sets the target of the block
  22389. */
  22390. get target(): NodeMaterialBlockTargets;
  22391. set target(value: NodeMaterialBlockTargets);
  22392. /**
  22393. * Gets the list of input points
  22394. */
  22395. get inputs(): NodeMaterialConnectionPoint[];
  22396. /** Gets the list of output points */
  22397. get outputs(): NodeMaterialConnectionPoint[];
  22398. /**
  22399. * Find an input by its name
  22400. * @param name defines the name of the input to look for
  22401. * @returns the input or null if not found
  22402. */
  22403. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22404. /**
  22405. * Find an output by its name
  22406. * @param name defines the name of the outputto look for
  22407. * @returns the output or null if not found
  22408. */
  22409. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22410. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22411. visibleInInspector: boolean;
  22412. /**
  22413. * Creates a new NodeMaterialBlock
  22414. * @param name defines the block name
  22415. * @param target defines the target of that block (Vertex by default)
  22416. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22417. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22418. */
  22419. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22420. /**
  22421. * Initialize the block and prepare the context for build
  22422. * @param state defines the state that will be used for the build
  22423. */
  22424. initialize(state: NodeMaterialBuildState): void;
  22425. /**
  22426. * Bind data to effect. Will only be called for blocks with isBindable === true
  22427. * @param effect defines the effect to bind data to
  22428. * @param nodeMaterial defines the hosting NodeMaterial
  22429. * @param mesh defines the mesh that will be rendered
  22430. * @param subMesh defines the submesh that will be rendered
  22431. */
  22432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22433. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22434. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22435. protected _writeFloat(value: number): string;
  22436. /**
  22437. * Gets the current class name e.g. "NodeMaterialBlock"
  22438. * @returns the class name
  22439. */
  22440. getClassName(): string;
  22441. /**
  22442. * Register a new input. Must be called inside a block constructor
  22443. * @param name defines the connection point name
  22444. * @param type defines the connection point type
  22445. * @param isOptional defines a boolean indicating that this input can be omitted
  22446. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22447. * @param point an already created connection point. If not provided, create a new one
  22448. * @returns the current block
  22449. */
  22450. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22451. /**
  22452. * Register a new output. Must be called inside a block constructor
  22453. * @param name defines the connection point name
  22454. * @param type defines the connection point type
  22455. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22456. * @param point an already created connection point. If not provided, create a new one
  22457. * @returns the current block
  22458. */
  22459. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22460. /**
  22461. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22462. * @param forOutput defines an optional connection point to check compatibility with
  22463. * @returns the first available input or null
  22464. */
  22465. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22466. /**
  22467. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22468. * @param forBlock defines an optional block to check compatibility with
  22469. * @returns the first available input or null
  22470. */
  22471. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22472. /**
  22473. * Gets the sibling of the given output
  22474. * @param current defines the current output
  22475. * @returns the next output in the list or null
  22476. */
  22477. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22478. /**
  22479. * Connect current block with another block
  22480. * @param other defines the block to connect with
  22481. * @param options define the various options to help pick the right connections
  22482. * @returns the current block
  22483. */
  22484. connectTo(other: NodeMaterialBlock, options?: {
  22485. input?: string;
  22486. output?: string;
  22487. outputSwizzle?: string;
  22488. }): this | undefined;
  22489. protected _buildBlock(state: NodeMaterialBuildState): void;
  22490. /**
  22491. * Add uniforms, samplers and uniform buffers at compilation time
  22492. * @param state defines the state to update
  22493. * @param nodeMaterial defines the node material requesting the update
  22494. * @param defines defines the material defines to update
  22495. * @param uniformBuffers defines the list of uniform buffer names
  22496. */
  22497. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22498. /**
  22499. * Add potential fallbacks if shader compilation fails
  22500. * @param mesh defines the mesh to be rendered
  22501. * @param fallbacks defines the current prioritized list of fallbacks
  22502. */
  22503. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22504. /**
  22505. * Initialize defines for shader compilation
  22506. * @param mesh defines the mesh to be rendered
  22507. * @param nodeMaterial defines the node material requesting the update
  22508. * @param defines defines the material defines to update
  22509. * @param useInstances specifies that instances should be used
  22510. */
  22511. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22512. /**
  22513. * Update defines for shader compilation
  22514. * @param mesh defines the mesh to be rendered
  22515. * @param nodeMaterial defines the node material requesting the update
  22516. * @param defines defines the material defines to update
  22517. * @param useInstances specifies that instances should be used
  22518. * @param subMesh defines which submesh to render
  22519. */
  22520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22521. /**
  22522. * Lets the block try to connect some inputs automatically
  22523. * @param material defines the hosting NodeMaterial
  22524. */
  22525. autoConfigure(material: NodeMaterial): void;
  22526. /**
  22527. * Function called when a block is declared as repeatable content generator
  22528. * @param vertexShaderState defines the current compilation state for the vertex shader
  22529. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22530. * @param mesh defines the mesh to be rendered
  22531. * @param defines defines the material defines to update
  22532. */
  22533. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22534. /**
  22535. * Checks if the block is ready
  22536. * @param mesh defines the mesh to be rendered
  22537. * @param nodeMaterial defines the node material requesting the update
  22538. * @param defines defines the material defines to update
  22539. * @param useInstances specifies that instances should be used
  22540. * @returns true if the block is ready
  22541. */
  22542. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22543. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22544. private _processBuild;
  22545. /**
  22546. * Validates the new name for the block node.
  22547. * @param newName the new name to be given to the node.
  22548. * @returns false if the name is a reserve word, else true.
  22549. */
  22550. validateBlockName(newName: string): boolean;
  22551. /**
  22552. * Compile the current node and generate the shader code
  22553. * @param state defines the current compilation state (uniforms, samplers, current string)
  22554. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22555. * @returns true if already built
  22556. */
  22557. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22558. protected _inputRename(name: string): string;
  22559. protected _outputRename(name: string): string;
  22560. protected _dumpPropertiesCode(): string;
  22561. /** @hidden */
  22562. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22563. /** @hidden */
  22564. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22565. /**
  22566. * Clone the current block to a new identical block
  22567. * @param scene defines the hosting scene
  22568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22569. * @returns a copy of the current block
  22570. */
  22571. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22572. /**
  22573. * Serializes this block in a JSON representation
  22574. * @returns the serialized block object
  22575. */
  22576. serialize(): any;
  22577. /** @hidden */
  22578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22579. private _deserializePortDisplayNamesAndExposedOnFrame;
  22580. /**
  22581. * Release resources
  22582. */
  22583. dispose(): void;
  22584. }
  22585. }
  22586. declare module "babylonjs/Materials/pushMaterial" {
  22587. import { Nullable } from "babylonjs/types";
  22588. import { Scene } from "babylonjs/scene";
  22589. import { Matrix } from "babylonjs/Maths/math.vector";
  22590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22591. import { Mesh } from "babylonjs/Meshes/mesh";
  22592. import { Material } from "babylonjs/Materials/material";
  22593. import { Effect } from "babylonjs/Materials/effect";
  22594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22595. /**
  22596. * Base class of materials working in push mode in babylon JS
  22597. * @hidden
  22598. */
  22599. export class PushMaterial extends Material {
  22600. protected _activeEffect: Effect;
  22601. protected _normalMatrix: Matrix;
  22602. constructor(name: string, scene: Scene);
  22603. getEffect(): Effect;
  22604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22605. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22606. /**
  22607. * Binds the given world matrix to the active effect
  22608. *
  22609. * @param world the matrix to bind
  22610. */
  22611. bindOnlyWorldMatrix(world: Matrix): void;
  22612. /**
  22613. * Binds the given normal matrix to the active effect
  22614. *
  22615. * @param normalMatrix the matrix to bind
  22616. */
  22617. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22618. bind(world: Matrix, mesh?: Mesh): void;
  22619. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22620. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22621. }
  22622. }
  22623. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22625. /**
  22626. * Root class for all node material optimizers
  22627. */
  22628. export class NodeMaterialOptimizer {
  22629. /**
  22630. * Function used to optimize a NodeMaterial graph
  22631. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22632. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22633. */
  22634. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22635. }
  22636. }
  22637. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22641. import { Scene } from "babylonjs/scene";
  22642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22644. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22645. /**
  22646. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22647. */
  22648. export class TransformBlock extends NodeMaterialBlock {
  22649. /**
  22650. * Defines the value to use to complement W value to transform it to a Vector4
  22651. */
  22652. complementW: number;
  22653. /**
  22654. * Defines the value to use to complement z value to transform it to a Vector4
  22655. */
  22656. complementZ: number;
  22657. /**
  22658. * Creates a new TransformBlock
  22659. * @param name defines the block name
  22660. */
  22661. constructor(name: string);
  22662. /**
  22663. * Gets the current class name
  22664. * @returns the class name
  22665. */
  22666. getClassName(): string;
  22667. /**
  22668. * Gets the vector input
  22669. */
  22670. get vector(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the output component
  22673. */
  22674. get output(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the xyz output component
  22677. */
  22678. get xyz(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the matrix transform input
  22681. */
  22682. get transform(): NodeMaterialConnectionPoint;
  22683. protected _buildBlock(state: NodeMaterialBuildState): this;
  22684. /**
  22685. * Update defines for shader compilation
  22686. * @param mesh defines the mesh to be rendered
  22687. * @param nodeMaterial defines the node material requesting the update
  22688. * @param defines defines the material defines to update
  22689. * @param useInstances specifies that instances should be used
  22690. * @param subMesh defines which submesh to render
  22691. */
  22692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22693. serialize(): any;
  22694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22695. protected _dumpPropertiesCode(): string;
  22696. }
  22697. }
  22698. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22702. /**
  22703. * Block used to output the vertex position
  22704. */
  22705. export class VertexOutputBlock extends NodeMaterialBlock {
  22706. /**
  22707. * Creates a new VertexOutputBlock
  22708. * @param name defines the block name
  22709. */
  22710. constructor(name: string);
  22711. /**
  22712. * Gets the current class name
  22713. * @returns the class name
  22714. */
  22715. getClassName(): string;
  22716. /**
  22717. * Gets the vector input component
  22718. */
  22719. get vector(): NodeMaterialConnectionPoint;
  22720. protected _buildBlock(state: NodeMaterialBuildState): this;
  22721. }
  22722. }
  22723. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22727. /**
  22728. * Block used to output the final color
  22729. */
  22730. export class FragmentOutputBlock extends NodeMaterialBlock {
  22731. /**
  22732. * Create a new FragmentOutputBlock
  22733. * @param name defines the block name
  22734. */
  22735. constructor(name: string);
  22736. /**
  22737. * Gets the current class name
  22738. * @returns the class name
  22739. */
  22740. getClassName(): string;
  22741. /**
  22742. * Gets the rgba input component
  22743. */
  22744. get rgba(): NodeMaterialConnectionPoint;
  22745. /**
  22746. * Gets the rgb input component
  22747. */
  22748. get rgb(): NodeMaterialConnectionPoint;
  22749. /**
  22750. * Gets the a input component
  22751. */
  22752. get a(): NodeMaterialConnectionPoint;
  22753. protected _buildBlock(state: NodeMaterialBuildState): this;
  22754. }
  22755. }
  22756. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22760. /**
  22761. * Block used for the particle ramp gradient section
  22762. */
  22763. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22764. /**
  22765. * Create a new ParticleRampGradientBlock
  22766. * @param name defines the block name
  22767. */
  22768. constructor(name: string);
  22769. /**
  22770. * Gets the current class name
  22771. * @returns the class name
  22772. */
  22773. getClassName(): string;
  22774. /**
  22775. * Gets the color input component
  22776. */
  22777. get color(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the rampColor output component
  22780. */
  22781. get rampColor(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Initialize the block and prepare the context for build
  22784. * @param state defines the state that will be used for the build
  22785. */
  22786. initialize(state: NodeMaterialBuildState): void;
  22787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22788. }
  22789. }
  22790. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22794. /**
  22795. * Block used for the particle blend multiply section
  22796. */
  22797. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22798. /**
  22799. * Create a new ParticleBlendMultiplyBlock
  22800. * @param name defines the block name
  22801. */
  22802. constructor(name: string);
  22803. /**
  22804. * Gets the current class name
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Gets the color input component
  22810. */
  22811. get color(): NodeMaterialConnectionPoint;
  22812. /**
  22813. * Gets the alphaTexture input component
  22814. */
  22815. get alphaTexture(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the alphaColor input component
  22818. */
  22819. get alphaColor(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the blendColor output component
  22822. */
  22823. get blendColor(): NodeMaterialConnectionPoint;
  22824. /**
  22825. * Initialize the block and prepare the context for build
  22826. * @param state defines the state that will be used for the build
  22827. */
  22828. initialize(state: NodeMaterialBuildState): void;
  22829. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22830. }
  22831. }
  22832. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22836. /**
  22837. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22838. */
  22839. export class VectorMergerBlock extends NodeMaterialBlock {
  22840. /**
  22841. * Create a new VectorMergerBlock
  22842. * @param name defines the block name
  22843. */
  22844. constructor(name: string);
  22845. /**
  22846. * Gets the current class name
  22847. * @returns the class name
  22848. */
  22849. getClassName(): string;
  22850. /**
  22851. * Gets the xyz component (input)
  22852. */
  22853. get xyzIn(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the xy component (input)
  22856. */
  22857. get xyIn(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the x component (input)
  22860. */
  22861. get x(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the y component (input)
  22864. */
  22865. get y(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the z component (input)
  22868. */
  22869. get z(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the w component (input)
  22872. */
  22873. get w(): NodeMaterialConnectionPoint;
  22874. /**
  22875. * Gets the xyzw component (output)
  22876. */
  22877. get xyzw(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the xyz component (output)
  22880. */
  22881. get xyzOut(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the xy component (output)
  22884. */
  22885. get xyOut(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the xy component (output)
  22888. * @deprecated Please use xyOut instead.
  22889. */
  22890. get xy(): NodeMaterialConnectionPoint;
  22891. /**
  22892. * Gets the xyz component (output)
  22893. * @deprecated Please use xyzOut instead.
  22894. */
  22895. get xyz(): NodeMaterialConnectionPoint;
  22896. protected _buildBlock(state: NodeMaterialBuildState): this;
  22897. }
  22898. }
  22899. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22903. import { Vector2 } from "babylonjs/Maths/math.vector";
  22904. import { Scene } from "babylonjs/scene";
  22905. /**
  22906. * Block used to remap a float from a range to a new one
  22907. */
  22908. export class RemapBlock extends NodeMaterialBlock {
  22909. /**
  22910. * Gets or sets the source range
  22911. */
  22912. sourceRange: Vector2;
  22913. /**
  22914. * Gets or sets the target range
  22915. */
  22916. targetRange: Vector2;
  22917. /**
  22918. * Creates a new RemapBlock
  22919. * @param name defines the block name
  22920. */
  22921. constructor(name: string);
  22922. /**
  22923. * Gets the current class name
  22924. * @returns the class name
  22925. */
  22926. getClassName(): string;
  22927. /**
  22928. * Gets the input component
  22929. */
  22930. get input(): NodeMaterialConnectionPoint;
  22931. /**
  22932. * Gets the source min input component
  22933. */
  22934. get sourceMin(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the source max input component
  22937. */
  22938. get sourceMax(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the target min input component
  22941. */
  22942. get targetMin(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the target max input component
  22945. */
  22946. get targetMax(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the output component
  22949. */
  22950. get output(): NodeMaterialConnectionPoint;
  22951. protected _buildBlock(state: NodeMaterialBuildState): this;
  22952. protected _dumpPropertiesCode(): string;
  22953. serialize(): any;
  22954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22955. }
  22956. }
  22957. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22961. /**
  22962. * Block used to multiply 2 values
  22963. */
  22964. export class MultiplyBlock extends NodeMaterialBlock {
  22965. /**
  22966. * Creates a new MultiplyBlock
  22967. * @param name defines the block name
  22968. */
  22969. constructor(name: string);
  22970. /**
  22971. * Gets the current class name
  22972. * @returns the class name
  22973. */
  22974. getClassName(): string;
  22975. /**
  22976. * Gets the left operand input component
  22977. */
  22978. get left(): NodeMaterialConnectionPoint;
  22979. /**
  22980. * Gets the right operand input component
  22981. */
  22982. get right(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the output component
  22985. */
  22986. get output(): NodeMaterialConnectionPoint;
  22987. protected _buildBlock(state: NodeMaterialBuildState): this;
  22988. }
  22989. }
  22990. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22994. /**
  22995. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22996. */
  22997. export class ColorSplitterBlock extends NodeMaterialBlock {
  22998. /**
  22999. * Create a new ColorSplitterBlock
  23000. * @param name defines the block name
  23001. */
  23002. constructor(name: string);
  23003. /**
  23004. * Gets the current class name
  23005. * @returns the class name
  23006. */
  23007. getClassName(): string;
  23008. /**
  23009. * Gets the rgba component (input)
  23010. */
  23011. get rgba(): NodeMaterialConnectionPoint;
  23012. /**
  23013. * Gets the rgb component (input)
  23014. */
  23015. get rgbIn(): NodeMaterialConnectionPoint;
  23016. /**
  23017. * Gets the rgb component (output)
  23018. */
  23019. get rgbOut(): NodeMaterialConnectionPoint;
  23020. /**
  23021. * Gets the r component (output)
  23022. */
  23023. get r(): NodeMaterialConnectionPoint;
  23024. /**
  23025. * Gets the g component (output)
  23026. */
  23027. get g(): NodeMaterialConnectionPoint;
  23028. /**
  23029. * Gets the b component (output)
  23030. */
  23031. get b(): NodeMaterialConnectionPoint;
  23032. /**
  23033. * Gets the a component (output)
  23034. */
  23035. get a(): NodeMaterialConnectionPoint;
  23036. protected _inputRename(name: string): string;
  23037. protected _outputRename(name: string): string;
  23038. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23039. }
  23040. }
  23041. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23045. import { Scene } from "babylonjs/scene";
  23046. /**
  23047. * Operations supported by the Trigonometry block
  23048. */
  23049. export enum TrigonometryBlockOperations {
  23050. /** Cos */
  23051. Cos = 0,
  23052. /** Sin */
  23053. Sin = 1,
  23054. /** Abs */
  23055. Abs = 2,
  23056. /** Exp */
  23057. Exp = 3,
  23058. /** Exp2 */
  23059. Exp2 = 4,
  23060. /** Round */
  23061. Round = 5,
  23062. /** Floor */
  23063. Floor = 6,
  23064. /** Ceiling */
  23065. Ceiling = 7,
  23066. /** Square root */
  23067. Sqrt = 8,
  23068. /** Log */
  23069. Log = 9,
  23070. /** Tangent */
  23071. Tan = 10,
  23072. /** Arc tangent */
  23073. ArcTan = 11,
  23074. /** Arc cosinus */
  23075. ArcCos = 12,
  23076. /** Arc sinus */
  23077. ArcSin = 13,
  23078. /** Fraction */
  23079. Fract = 14,
  23080. /** Sign */
  23081. Sign = 15,
  23082. /** To radians (from degrees) */
  23083. Radians = 16,
  23084. /** To degrees (from radians) */
  23085. Degrees = 17
  23086. }
  23087. /**
  23088. * Block used to apply trigonometry operation to floats
  23089. */
  23090. export class TrigonometryBlock extends NodeMaterialBlock {
  23091. /**
  23092. * Gets or sets the operation applied by the block
  23093. */
  23094. operation: TrigonometryBlockOperations;
  23095. /**
  23096. * Creates a new TrigonometryBlock
  23097. * @param name defines the block name
  23098. */
  23099. constructor(name: string);
  23100. /**
  23101. * Gets the current class name
  23102. * @returns the class name
  23103. */
  23104. getClassName(): string;
  23105. /**
  23106. * Gets the input component
  23107. */
  23108. get input(): NodeMaterialConnectionPoint;
  23109. /**
  23110. * Gets the output component
  23111. */
  23112. get output(): NodeMaterialConnectionPoint;
  23113. protected _buildBlock(state: NodeMaterialBuildState): this;
  23114. serialize(): any;
  23115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23116. protected _dumpPropertiesCode(): string;
  23117. }
  23118. }
  23119. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23121. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23122. import { Scene } from "babylonjs/scene";
  23123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23124. import { Matrix } from "babylonjs/Maths/math.vector";
  23125. import { Mesh } from "babylonjs/Meshes/mesh";
  23126. import { Engine } from "babylonjs/Engines/engine";
  23127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23128. import { Observable } from "babylonjs/Misc/observable";
  23129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23130. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23131. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23132. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23133. import { Nullable } from "babylonjs/types";
  23134. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23135. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23136. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23137. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23138. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23139. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23140. import { Effect } from "babylonjs/Materials/effect";
  23141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23142. import { Camera } from "babylonjs/Cameras/camera";
  23143. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23145. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23146. /**
  23147. * Interface used to configure the node material editor
  23148. */
  23149. export interface INodeMaterialEditorOptions {
  23150. /** Define the URl to load node editor script */
  23151. editorURL?: string;
  23152. }
  23153. /** @hidden */
  23154. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23155. NORMAL: boolean;
  23156. TANGENT: boolean;
  23157. UV1: boolean;
  23158. /** BONES */
  23159. NUM_BONE_INFLUENCERS: number;
  23160. BonesPerMesh: number;
  23161. BONETEXTURE: boolean;
  23162. /** MORPH TARGETS */
  23163. MORPHTARGETS: boolean;
  23164. MORPHTARGETS_NORMAL: boolean;
  23165. MORPHTARGETS_TANGENT: boolean;
  23166. MORPHTARGETS_UV: boolean;
  23167. NUM_MORPH_INFLUENCERS: number;
  23168. /** IMAGE PROCESSING */
  23169. IMAGEPROCESSING: boolean;
  23170. VIGNETTE: boolean;
  23171. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23172. VIGNETTEBLENDMODEOPAQUE: boolean;
  23173. TONEMAPPING: boolean;
  23174. TONEMAPPING_ACES: boolean;
  23175. CONTRAST: boolean;
  23176. EXPOSURE: boolean;
  23177. COLORCURVES: boolean;
  23178. COLORGRADING: boolean;
  23179. COLORGRADING3D: boolean;
  23180. SAMPLER3DGREENDEPTH: boolean;
  23181. SAMPLER3DBGRMAP: boolean;
  23182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23183. /** MISC. */
  23184. BUMPDIRECTUV: number;
  23185. constructor();
  23186. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23187. }
  23188. /**
  23189. * Class used to configure NodeMaterial
  23190. */
  23191. export interface INodeMaterialOptions {
  23192. /**
  23193. * Defines if blocks should emit comments
  23194. */
  23195. emitComments: boolean;
  23196. }
  23197. /**
  23198. * Class used to create a node based material built by assembling shader blocks
  23199. */
  23200. export class NodeMaterial extends PushMaterial {
  23201. private static _BuildIdGenerator;
  23202. private _options;
  23203. private _vertexCompilationState;
  23204. private _fragmentCompilationState;
  23205. private _sharedData;
  23206. private _buildId;
  23207. private _buildWasSuccessful;
  23208. private _cachedWorldViewMatrix;
  23209. private _cachedWorldViewProjectionMatrix;
  23210. private _optimizers;
  23211. private _animationFrame;
  23212. /** Define the Url to load node editor script */
  23213. static EditorURL: string;
  23214. /** Define the Url to load snippets */
  23215. static SnippetUrl: string;
  23216. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23217. static IgnoreTexturesAtLoadTime: boolean;
  23218. private BJSNODEMATERIALEDITOR;
  23219. /** Get the inspector from bundle or global */
  23220. private _getGlobalNodeMaterialEditor;
  23221. /**
  23222. * Snippet ID if the material was created from the snippet server
  23223. */
  23224. snippetId: string;
  23225. /**
  23226. * Gets or sets data used by visual editor
  23227. * @see https://nme.babylonjs.com
  23228. */
  23229. editorData: any;
  23230. /**
  23231. * 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)
  23232. */
  23233. ignoreAlpha: boolean;
  23234. /**
  23235. * Defines the maximum number of lights that can be used in the material
  23236. */
  23237. maxSimultaneousLights: number;
  23238. /**
  23239. * Observable raised when the material is built
  23240. */
  23241. onBuildObservable: Observable<NodeMaterial>;
  23242. /**
  23243. * Gets or sets the root nodes of the material vertex shader
  23244. */
  23245. _vertexOutputNodes: NodeMaterialBlock[];
  23246. /**
  23247. * Gets or sets the root nodes of the material fragment (pixel) shader
  23248. */
  23249. _fragmentOutputNodes: NodeMaterialBlock[];
  23250. /** Gets or sets options to control the node material overall behavior */
  23251. get options(): INodeMaterialOptions;
  23252. set options(options: INodeMaterialOptions);
  23253. /**
  23254. * Default configuration related to image processing available in the standard Material.
  23255. */
  23256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23257. /**
  23258. * Gets the image processing configuration used either in this material.
  23259. */
  23260. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23261. /**
  23262. * Sets the Default image processing configuration used either in the this material.
  23263. *
  23264. * If sets to null, the scene one is in use.
  23265. */
  23266. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23267. /**
  23268. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23269. */
  23270. attachedBlocks: NodeMaterialBlock[];
  23271. /**
  23272. * Specifies the mode of the node material
  23273. * @hidden
  23274. */
  23275. _mode: NodeMaterialModes;
  23276. /**
  23277. * Gets the mode property
  23278. */
  23279. get mode(): NodeMaterialModes;
  23280. /**
  23281. * Create a new node based material
  23282. * @param name defines the material name
  23283. * @param scene defines the hosting scene
  23284. * @param options defines creation option
  23285. */
  23286. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23287. /**
  23288. * Gets the current class name of the material e.g. "NodeMaterial"
  23289. * @returns the class name
  23290. */
  23291. getClassName(): string;
  23292. /**
  23293. * Keep track of the image processing observer to allow dispose and replace.
  23294. */
  23295. private _imageProcessingObserver;
  23296. /**
  23297. * Attaches a new image processing configuration to the Standard Material.
  23298. * @param configuration
  23299. */
  23300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23301. /**
  23302. * Get a block by its name
  23303. * @param name defines the name of the block to retrieve
  23304. * @returns the required block or null if not found
  23305. */
  23306. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23307. /**
  23308. * Get a block by its name
  23309. * @param predicate defines the predicate used to find the good candidate
  23310. * @returns the required block or null if not found
  23311. */
  23312. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23313. /**
  23314. * Get an input block by its name
  23315. * @param predicate defines the predicate used to find the good candidate
  23316. * @returns the required input block or null if not found
  23317. */
  23318. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23319. /**
  23320. * Gets the list of input blocks attached to this material
  23321. * @returns an array of InputBlocks
  23322. */
  23323. getInputBlocks(): InputBlock[];
  23324. /**
  23325. * Adds a new optimizer to the list of optimizers
  23326. * @param optimizer defines the optimizers to add
  23327. * @returns the current material
  23328. */
  23329. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23330. /**
  23331. * Remove an optimizer from the list of optimizers
  23332. * @param optimizer defines the optimizers to remove
  23333. * @returns the current material
  23334. */
  23335. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23336. /**
  23337. * Add a new block to the list of output nodes
  23338. * @param node defines the node to add
  23339. * @returns the current material
  23340. */
  23341. addOutputNode(node: NodeMaterialBlock): this;
  23342. /**
  23343. * Remove a block from the list of root nodes
  23344. * @param node defines the node to remove
  23345. * @returns the current material
  23346. */
  23347. removeOutputNode(node: NodeMaterialBlock): this;
  23348. private _addVertexOutputNode;
  23349. private _removeVertexOutputNode;
  23350. private _addFragmentOutputNode;
  23351. private _removeFragmentOutputNode;
  23352. /**
  23353. * Specifies if the material will require alpha blending
  23354. * @returns a boolean specifying if alpha blending is needed
  23355. */
  23356. needAlphaBlending(): boolean;
  23357. /**
  23358. * Specifies if this material should be rendered in alpha test mode
  23359. * @returns a boolean specifying if an alpha test is needed.
  23360. */
  23361. needAlphaTesting(): boolean;
  23362. private _initializeBlock;
  23363. private _resetDualBlocks;
  23364. /**
  23365. * Remove a block from the current node material
  23366. * @param block defines the block to remove
  23367. */
  23368. removeBlock(block: NodeMaterialBlock): void;
  23369. /**
  23370. * Build the material and generates the inner effect
  23371. * @param verbose defines if the build should log activity
  23372. */
  23373. build(verbose?: boolean): void;
  23374. /**
  23375. * Runs an otpimization phase to try to improve the shader code
  23376. */
  23377. optimize(): void;
  23378. private _prepareDefinesForAttributes;
  23379. /**
  23380. * Create a post process from the material
  23381. * @param camera The camera to apply the render pass to.
  23382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23384. * @param engine The engine which the post process will be applied. (default: current engine)
  23385. * @param reusable If the post process can be reused on the same frame. (default: false)
  23386. * @param textureType Type of textures used when performing the post process. (default: 0)
  23387. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23388. * @returns the post process created
  23389. */
  23390. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23391. /**
  23392. * Create the post process effect from the material
  23393. * @param postProcess The post process to create the effect for
  23394. */
  23395. createEffectForPostProcess(postProcess: PostProcess): void;
  23396. private _createEffectForPostProcess;
  23397. /**
  23398. * Create a new procedural texture based on this node material
  23399. * @param size defines the size of the texture
  23400. * @param scene defines the hosting scene
  23401. * @returns the new procedural texture attached to this node material
  23402. */
  23403. createProceduralTexture(size: number | {
  23404. width: number;
  23405. height: number;
  23406. layers?: number;
  23407. }, scene: Scene): Nullable<ProceduralTexture>;
  23408. private _createEffectForParticles;
  23409. private _checkInternals;
  23410. /**
  23411. * Create the effect to be used as the custom effect for a particle system
  23412. * @param particleSystem Particle system to create the effect for
  23413. * @param onCompiled defines a function to call when the effect creation is successful
  23414. * @param onError defines a function to call when the effect creation has failed
  23415. */
  23416. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23417. private _processDefines;
  23418. /**
  23419. * Get if the submesh is ready to be used and all its information available.
  23420. * Child classes can use it to update shaders
  23421. * @param mesh defines the mesh to check
  23422. * @param subMesh defines which submesh to check
  23423. * @param useInstances specifies that instances should be used
  23424. * @returns a boolean indicating that the submesh is ready or not
  23425. */
  23426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23427. /**
  23428. * Get a string representing the shaders built by the current node graph
  23429. */
  23430. get compiledShaders(): string;
  23431. /**
  23432. * Binds the world matrix to the material
  23433. * @param world defines the world transformation matrix
  23434. */
  23435. bindOnlyWorldMatrix(world: Matrix): void;
  23436. /**
  23437. * Binds the submesh to this material by preparing the effect and shader to draw
  23438. * @param world defines the world transformation matrix
  23439. * @param mesh defines the mesh containing the submesh
  23440. * @param subMesh defines the submesh to bind the material to
  23441. */
  23442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23443. /**
  23444. * Gets the active textures from the material
  23445. * @returns an array of textures
  23446. */
  23447. getActiveTextures(): BaseTexture[];
  23448. /**
  23449. * Gets the list of texture blocks
  23450. * @returns an array of texture blocks
  23451. */
  23452. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23453. /**
  23454. * Specifies if the material uses a texture
  23455. * @param texture defines the texture to check against the material
  23456. * @returns a boolean specifying if the material uses the texture
  23457. */
  23458. hasTexture(texture: BaseTexture): boolean;
  23459. /**
  23460. * Disposes the material
  23461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23464. */
  23465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23466. /** Creates the node editor window. */
  23467. private _createNodeEditor;
  23468. /**
  23469. * Launch the node material editor
  23470. * @param config Define the configuration of the editor
  23471. * @return a promise fulfilled when the node editor is visible
  23472. */
  23473. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23474. /**
  23475. * Clear the current material
  23476. */
  23477. clear(): void;
  23478. /**
  23479. * Clear the current material and set it to a default state
  23480. */
  23481. setToDefault(): void;
  23482. /**
  23483. * Clear the current material and set it to a default state for post process
  23484. */
  23485. setToDefaultPostProcess(): void;
  23486. /**
  23487. * Clear the current material and set it to a default state for procedural texture
  23488. */
  23489. setToDefaultProceduralTexture(): void;
  23490. /**
  23491. * Clear the current material and set it to a default state for particle
  23492. */
  23493. setToDefaultParticle(): void;
  23494. /**
  23495. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23496. * @param url defines the url to load from
  23497. * @returns a promise that will fullfil when the material is fully loaded
  23498. */
  23499. loadAsync(url: string): Promise<void>;
  23500. private _gatherBlocks;
  23501. /**
  23502. * Generate a string containing the code declaration required to create an equivalent of this material
  23503. * @returns a string
  23504. */
  23505. generateCode(): string;
  23506. /**
  23507. * Serializes this material in a JSON representation
  23508. * @returns the serialized material object
  23509. */
  23510. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23511. private _restoreConnections;
  23512. /**
  23513. * Clear the current graph and load a new one from a serialization object
  23514. * @param source defines the JSON representation of the material
  23515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23516. * @param merge defines whether or not the source must be merged or replace the current content
  23517. */
  23518. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23519. /**
  23520. * Makes a duplicate of the current material.
  23521. * @param name - name to use for the new material.
  23522. */
  23523. clone(name: string): NodeMaterial;
  23524. /**
  23525. * Creates a node material from parsed material data
  23526. * @param source defines the JSON representation of the material
  23527. * @param scene defines the hosting scene
  23528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23529. * @returns a new node material
  23530. */
  23531. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23532. /**
  23533. * Creates a node material from a snippet saved in a remote file
  23534. * @param name defines the name of the material to create
  23535. * @param url defines the url to load from
  23536. * @param scene defines the hosting scene
  23537. * @returns a promise that will resolve to the new node material
  23538. */
  23539. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23540. /**
  23541. * Creates a node material from a snippet saved by the node material editor
  23542. * @param snippetId defines the snippet to load
  23543. * @param scene defines the hosting scene
  23544. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23545. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23546. * @returns a promise that will resolve to the new node material
  23547. */
  23548. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23549. /**
  23550. * Creates a new node material set to default basic configuration
  23551. * @param name defines the name of the material
  23552. * @param scene defines the hosting scene
  23553. * @returns a new NodeMaterial
  23554. */
  23555. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23556. }
  23557. }
  23558. declare module "babylonjs/PostProcesses/postProcess" {
  23559. import { Nullable } from "babylonjs/types";
  23560. import { SmartArray } from "babylonjs/Misc/smartArray";
  23561. import { Observable } from "babylonjs/Misc/observable";
  23562. import { Vector2 } from "babylonjs/Maths/math.vector";
  23563. import { Camera } from "babylonjs/Cameras/camera";
  23564. import { Effect } from "babylonjs/Materials/effect";
  23565. import "babylonjs/Shaders/postprocess.vertex";
  23566. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23567. import { Engine } from "babylonjs/Engines/engine";
  23568. import { Color4 } from "babylonjs/Maths/math.color";
  23569. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23570. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23571. import { Scene } from "babylonjs/scene";
  23572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23573. /**
  23574. * Size options for a post process
  23575. */
  23576. export type PostProcessOptions = {
  23577. width: number;
  23578. height: number;
  23579. };
  23580. /**
  23581. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23583. */
  23584. export class PostProcess {
  23585. /**
  23586. * Gets or sets the unique id of the post process
  23587. */
  23588. uniqueId: number;
  23589. /** Name of the PostProcess. */
  23590. name: string;
  23591. /**
  23592. * Width of the texture to apply the post process on
  23593. */
  23594. width: number;
  23595. /**
  23596. * Height of the texture to apply the post process on
  23597. */
  23598. height: number;
  23599. /**
  23600. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23601. */
  23602. nodeMaterialSource: Nullable<NodeMaterial>;
  23603. /**
  23604. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23605. * @hidden
  23606. */
  23607. _outputTexture: Nullable<InternalTexture>;
  23608. /**
  23609. * Sampling mode used by the shader
  23610. * See https://doc.babylonjs.com/classes/3.1/texture
  23611. */
  23612. renderTargetSamplingMode: number;
  23613. /**
  23614. * Clear color to use when screen clearing
  23615. */
  23616. clearColor: Color4;
  23617. /**
  23618. * If the buffer needs to be cleared before applying the post process. (default: true)
  23619. * Should be set to false if shader will overwrite all previous pixels.
  23620. */
  23621. autoClear: boolean;
  23622. /**
  23623. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23624. */
  23625. alphaMode: number;
  23626. /**
  23627. * Sets the setAlphaBlendConstants of the babylon engine
  23628. */
  23629. alphaConstants: Color4;
  23630. /**
  23631. * Animations to be used for the post processing
  23632. */
  23633. animations: import("babylonjs/Animations/animation").Animation[];
  23634. /**
  23635. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23636. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23637. */
  23638. enablePixelPerfectMode: boolean;
  23639. /**
  23640. * Force the postprocess to be applied without taking in account viewport
  23641. */
  23642. forceFullscreenViewport: boolean;
  23643. /**
  23644. * List of inspectable custom properties (used by the Inspector)
  23645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23646. */
  23647. inspectableCustomProperties: IInspectable[];
  23648. /**
  23649. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23650. *
  23651. * | Value | Type | Description |
  23652. * | ----- | ----------------------------------- | ----------- |
  23653. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23654. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23655. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23656. *
  23657. */
  23658. scaleMode: number;
  23659. /**
  23660. * Force textures to be a power of two (default: false)
  23661. */
  23662. alwaysForcePOT: boolean;
  23663. private _samples;
  23664. /**
  23665. * Number of sample textures (default: 1)
  23666. */
  23667. get samples(): number;
  23668. set samples(n: number);
  23669. /**
  23670. * Modify the scale of the post process to be the same as the viewport (default: false)
  23671. */
  23672. adaptScaleToCurrentViewport: boolean;
  23673. private _camera;
  23674. protected _scene: Scene;
  23675. private _engine;
  23676. private _options;
  23677. private _reusable;
  23678. private _textureType;
  23679. private _textureFormat;
  23680. /**
  23681. * Smart array of input and output textures for the post process.
  23682. * @hidden
  23683. */
  23684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23685. /**
  23686. * The index in _textures that corresponds to the output texture.
  23687. * @hidden
  23688. */
  23689. _currentRenderTextureInd: number;
  23690. private _effect;
  23691. private _samplers;
  23692. private _fragmentUrl;
  23693. private _vertexUrl;
  23694. private _parameters;
  23695. private _scaleRatio;
  23696. protected _indexParameters: any;
  23697. private _shareOutputWithPostProcess;
  23698. private _texelSize;
  23699. private _forcedOutputTexture;
  23700. /**
  23701. * Returns the fragment url or shader name used in the post process.
  23702. * @returns the fragment url or name in the shader store.
  23703. */
  23704. getEffectName(): string;
  23705. /**
  23706. * An event triggered when the postprocess is activated.
  23707. */
  23708. onActivateObservable: Observable<Camera>;
  23709. private _onActivateObserver;
  23710. /**
  23711. * A function that is added to the onActivateObservable
  23712. */
  23713. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23714. /**
  23715. * An event triggered when the postprocess changes its size.
  23716. */
  23717. onSizeChangedObservable: Observable<PostProcess>;
  23718. private _onSizeChangedObserver;
  23719. /**
  23720. * A function that is added to the onSizeChangedObservable
  23721. */
  23722. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23723. /**
  23724. * An event triggered when the postprocess applies its effect.
  23725. */
  23726. onApplyObservable: Observable<Effect>;
  23727. private _onApplyObserver;
  23728. /**
  23729. * A function that is added to the onApplyObservable
  23730. */
  23731. set onApply(callback: (effect: Effect) => void);
  23732. /**
  23733. * An event triggered before rendering the postprocess
  23734. */
  23735. onBeforeRenderObservable: Observable<Effect>;
  23736. private _onBeforeRenderObserver;
  23737. /**
  23738. * A function that is added to the onBeforeRenderObservable
  23739. */
  23740. set onBeforeRender(callback: (effect: Effect) => void);
  23741. /**
  23742. * An event triggered after rendering the postprocess
  23743. */
  23744. onAfterRenderObservable: Observable<Effect>;
  23745. private _onAfterRenderObserver;
  23746. /**
  23747. * A function that is added to the onAfterRenderObservable
  23748. */
  23749. set onAfterRender(callback: (efect: Effect) => void);
  23750. /**
  23751. * 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
  23752. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23753. */
  23754. get inputTexture(): InternalTexture;
  23755. set inputTexture(value: InternalTexture);
  23756. /**
  23757. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23758. * the only way to unset it is to use this function to restore its internal state
  23759. */
  23760. restoreDefaultInputTexture(): void;
  23761. /**
  23762. * Gets the camera which post process is applied to.
  23763. * @returns The camera the post process is applied to.
  23764. */
  23765. getCamera(): Camera;
  23766. /**
  23767. * Gets the texel size of the postprocess.
  23768. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23769. */
  23770. get texelSize(): Vector2;
  23771. /**
  23772. * Creates a new instance PostProcess
  23773. * @param name The name of the PostProcess.
  23774. * @param fragmentUrl The url of the fragment shader to be used.
  23775. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23776. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23777. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23778. * @param camera The camera to apply the render pass to.
  23779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23780. * @param engine The engine which the post process will be applied. (default: current engine)
  23781. * @param reusable If the post process can be reused on the same frame. (default: false)
  23782. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23783. * @param textureType Type of textures used when performing the post process. (default: 0)
  23784. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23785. * @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
  23786. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23787. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23788. */
  23789. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  23790. /**
  23791. * Gets a string identifying the name of the class
  23792. * @returns "PostProcess" string
  23793. */
  23794. getClassName(): string;
  23795. /**
  23796. * Gets the engine which this post process belongs to.
  23797. * @returns The engine the post process was enabled with.
  23798. */
  23799. getEngine(): Engine;
  23800. /**
  23801. * The effect that is created when initializing the post process.
  23802. * @returns The created effect corresponding the the postprocess.
  23803. */
  23804. getEffect(): Effect;
  23805. /**
  23806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23807. * @param postProcess The post process to share the output with.
  23808. * @returns This post process.
  23809. */
  23810. shareOutputWith(postProcess: PostProcess): PostProcess;
  23811. /**
  23812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23814. */
  23815. useOwnOutput(): void;
  23816. /**
  23817. * Updates the effect with the current post process compile time values and recompiles the shader.
  23818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23821. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23822. * @param onCompiled Called when the shader has been compiled.
  23823. * @param onError Called if there is an error when compiling a shader.
  23824. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23825. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23826. */
  23827. 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;
  23828. /**
  23829. * The post process is reusable if it can be used multiple times within one frame.
  23830. * @returns If the post process is reusable
  23831. */
  23832. isReusable(): boolean;
  23833. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23834. markTextureDirty(): void;
  23835. /**
  23836. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23837. * 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.
  23838. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23839. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23840. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23841. * @returns The target texture that was bound to be written to.
  23842. */
  23843. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23844. /**
  23845. * If the post process is supported.
  23846. */
  23847. get isSupported(): boolean;
  23848. /**
  23849. * The aspect ratio of the output texture.
  23850. */
  23851. get aspectRatio(): number;
  23852. /**
  23853. * Get a value indicating if the post-process is ready to be used
  23854. * @returns true if the post-process is ready (shader is compiled)
  23855. */
  23856. isReady(): boolean;
  23857. /**
  23858. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23859. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23860. */
  23861. apply(): Nullable<Effect>;
  23862. private _disposeTextures;
  23863. /**
  23864. * Disposes the post process.
  23865. * @param camera The camera to dispose the post process on.
  23866. */
  23867. dispose(camera?: Camera): void;
  23868. /**
  23869. * Serializes the particle system to a JSON object
  23870. * @returns the JSON object
  23871. */
  23872. serialize(): any;
  23873. /**
  23874. * Creates a material from parsed material data
  23875. * @param parsedPostProcess defines parsed post process data
  23876. * @param scene defines the hosting scene
  23877. * @param rootUrl defines the root URL to use to load textures
  23878. * @returns a new post process
  23879. */
  23880. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23881. }
  23882. }
  23883. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23884. /** @hidden */
  23885. export var kernelBlurVaryingDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23891. /** @hidden */
  23892. export var kernelBlurFragment: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23898. /** @hidden */
  23899. export var kernelBlurFragment2: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23905. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23906. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23907. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23909. /** @hidden */
  23910. export var kernelBlurPixelShader: {
  23911. name: string;
  23912. shader: string;
  23913. };
  23914. }
  23915. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23916. /** @hidden */
  23917. export var kernelBlurVertex: {
  23918. name: string;
  23919. shader: string;
  23920. };
  23921. }
  23922. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23923. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23925. /** @hidden */
  23926. export var kernelBlurVertexShader: {
  23927. name: string;
  23928. shader: string;
  23929. };
  23930. }
  23931. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23932. import { Vector2 } from "babylonjs/Maths/math.vector";
  23933. import { Nullable } from "babylonjs/types";
  23934. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23935. import { Camera } from "babylonjs/Cameras/camera";
  23936. import { Effect } from "babylonjs/Materials/effect";
  23937. import { Engine } from "babylonjs/Engines/engine";
  23938. import "babylonjs/Shaders/kernelBlur.fragment";
  23939. import "babylonjs/Shaders/kernelBlur.vertex";
  23940. import { Scene } from "babylonjs/scene";
  23941. /**
  23942. * The Blur Post Process which blurs an image based on a kernel and direction.
  23943. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23944. */
  23945. export class BlurPostProcess extends PostProcess {
  23946. private blockCompilation;
  23947. protected _kernel: number;
  23948. protected _idealKernel: number;
  23949. protected _packedFloat: boolean;
  23950. private _staticDefines;
  23951. /** The direction in which to blur the image. */
  23952. direction: Vector2;
  23953. /**
  23954. * Sets the length in pixels of the blur sample region
  23955. */
  23956. set kernel(v: number);
  23957. /**
  23958. * Gets the length in pixels of the blur sample region
  23959. */
  23960. get kernel(): number;
  23961. /**
  23962. * Sets wether or not the blur needs to unpack/repack floats
  23963. */
  23964. set packedFloat(v: boolean);
  23965. /**
  23966. * Gets wether or not the blur is unpacking/repacking floats
  23967. */
  23968. get packedFloat(): boolean;
  23969. /**
  23970. * Gets a string identifying the name of the class
  23971. * @returns "BlurPostProcess" string
  23972. */
  23973. getClassName(): string;
  23974. /**
  23975. * Creates a new instance BlurPostProcess
  23976. * @param name The name of the effect.
  23977. * @param direction The direction in which to blur the image.
  23978. * @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.
  23979. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23980. * @param camera The camera to apply the render pass to.
  23981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23982. * @param engine The engine which the post process will be applied. (default: current engine)
  23983. * @param reusable If the post process can be reused on the same frame. (default: false)
  23984. * @param textureType Type of textures used when performing the post process. (default: 0)
  23985. * @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)
  23986. */
  23987. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23988. /**
  23989. * Updates the effect with the current post process compile time values and recompiles the shader.
  23990. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23991. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23992. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23993. * @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
  23994. * @param onCompiled Called when the shader has been compiled.
  23995. * @param onError Called if there is an error when compiling a shader.
  23996. */
  23997. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23998. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23999. /**
  24000. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24001. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24002. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24003. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24004. * The gaps between physical kernels are compensated for in the weighting of the samples
  24005. * @param idealKernel Ideal blur kernel.
  24006. * @return Nearest best kernel.
  24007. */
  24008. protected _nearestBestKernel(idealKernel: number): number;
  24009. /**
  24010. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24011. * @param x The point on the Gaussian distribution to sample.
  24012. * @return the value of the Gaussian function at x.
  24013. */
  24014. protected _gaussianWeight(x: number): number;
  24015. /**
  24016. * Generates a string that can be used as a floating point number in GLSL.
  24017. * @param x Value to print.
  24018. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24019. * @return GLSL float string.
  24020. */
  24021. protected _glslFloat(x: number, decimalFigures?: number): string;
  24022. /** @hidden */
  24023. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24024. }
  24025. }
  24026. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24027. import { Scene } from "babylonjs/scene";
  24028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24029. import { Plane } from "babylonjs/Maths/math.plane";
  24030. /**
  24031. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24032. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24033. * You can then easily use it as a reflectionTexture on a flat surface.
  24034. * In case the surface is not a plane, please consider relying on reflection probes.
  24035. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24036. */
  24037. export class MirrorTexture extends RenderTargetTexture {
  24038. private scene;
  24039. /**
  24040. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24041. * 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.
  24042. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24043. */
  24044. mirrorPlane: Plane;
  24045. /**
  24046. * Define the blur ratio used to blur the reflection if needed.
  24047. */
  24048. set blurRatio(value: number);
  24049. get blurRatio(): number;
  24050. /**
  24051. * Define the adaptive blur kernel used to blur the reflection if needed.
  24052. * This will autocompute the closest best match for the `blurKernel`
  24053. */
  24054. set adaptiveBlurKernel(value: number);
  24055. /**
  24056. * Define the blur kernel used to blur the reflection if needed.
  24057. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24058. */
  24059. set blurKernel(value: number);
  24060. /**
  24061. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24063. */
  24064. set blurKernelX(value: number);
  24065. get blurKernelX(): number;
  24066. /**
  24067. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24069. */
  24070. set blurKernelY(value: number);
  24071. get blurKernelY(): number;
  24072. private _autoComputeBlurKernel;
  24073. protected _onRatioRescale(): void;
  24074. private _updateGammaSpace;
  24075. private _imageProcessingConfigChangeObserver;
  24076. private _transformMatrix;
  24077. private _mirrorMatrix;
  24078. private _savedViewMatrix;
  24079. private _blurX;
  24080. private _blurY;
  24081. private _adaptiveBlurKernel;
  24082. private _blurKernelX;
  24083. private _blurKernelY;
  24084. private _blurRatio;
  24085. /**
  24086. * Instantiates a Mirror Texture.
  24087. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24088. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24089. * You can then easily use it as a reflectionTexture on a flat surface.
  24090. * In case the surface is not a plane, please consider relying on reflection probes.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24092. * @param name
  24093. * @param size
  24094. * @param scene
  24095. * @param generateMipMaps
  24096. * @param type
  24097. * @param samplingMode
  24098. * @param generateDepthBuffer
  24099. */
  24100. constructor(name: string, size: number | {
  24101. width: number;
  24102. height: number;
  24103. } | {
  24104. ratio: number;
  24105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24106. private _preparePostProcesses;
  24107. /**
  24108. * Clone the mirror texture.
  24109. * @returns the cloned texture
  24110. */
  24111. clone(): MirrorTexture;
  24112. /**
  24113. * Serialize the texture to a JSON representation you could use in Parse later on
  24114. * @returns the serialized JSON representation
  24115. */
  24116. serialize(): any;
  24117. /**
  24118. * Dispose the texture and release its associated resources.
  24119. */
  24120. dispose(): void;
  24121. }
  24122. }
  24123. declare module "babylonjs/Materials/Textures/texture" {
  24124. import { Observable } from "babylonjs/Misc/observable";
  24125. import { Nullable } from "babylonjs/types";
  24126. import { Matrix } from "babylonjs/Maths/math.vector";
  24127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24128. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24130. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24131. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24133. import { Scene } from "babylonjs/scene";
  24134. /**
  24135. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24136. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24137. */
  24138. export class Texture extends BaseTexture {
  24139. /**
  24140. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24141. */
  24142. static SerializeBuffers: boolean;
  24143. /** @hidden */
  24144. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24145. /** @hidden */
  24146. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24147. /** @hidden */
  24148. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24149. /** nearest is mag = nearest and min = nearest and mip = linear */
  24150. static readonly NEAREST_SAMPLINGMODE: number;
  24151. /** nearest is mag = nearest and min = nearest and mip = linear */
  24152. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24154. static readonly BILINEAR_SAMPLINGMODE: number;
  24155. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24156. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24157. /** Trilinear is mag = linear and min = linear and mip = linear */
  24158. static readonly TRILINEAR_SAMPLINGMODE: number;
  24159. /** Trilinear is mag = linear and min = linear and mip = linear */
  24160. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24161. /** mag = nearest and min = nearest and mip = nearest */
  24162. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24163. /** mag = nearest and min = linear and mip = nearest */
  24164. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24165. /** mag = nearest and min = linear and mip = linear */
  24166. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24167. /** mag = nearest and min = linear and mip = none */
  24168. static readonly NEAREST_LINEAR: number;
  24169. /** mag = nearest and min = nearest and mip = none */
  24170. static readonly NEAREST_NEAREST: number;
  24171. /** mag = linear and min = nearest and mip = nearest */
  24172. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24173. /** mag = linear and min = nearest and mip = linear */
  24174. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24175. /** mag = linear and min = linear and mip = none */
  24176. static readonly LINEAR_LINEAR: number;
  24177. /** mag = linear and min = nearest and mip = none */
  24178. static readonly LINEAR_NEAREST: number;
  24179. /** Explicit coordinates mode */
  24180. static readonly EXPLICIT_MODE: number;
  24181. /** Spherical coordinates mode */
  24182. static readonly SPHERICAL_MODE: number;
  24183. /** Planar coordinates mode */
  24184. static readonly PLANAR_MODE: number;
  24185. /** Cubic coordinates mode */
  24186. static readonly CUBIC_MODE: number;
  24187. /** Projection coordinates mode */
  24188. static readonly PROJECTION_MODE: number;
  24189. /** Inverse Cubic coordinates mode */
  24190. static readonly SKYBOX_MODE: number;
  24191. /** Inverse Cubic coordinates mode */
  24192. static readonly INVCUBIC_MODE: number;
  24193. /** Equirectangular coordinates mode */
  24194. static readonly EQUIRECTANGULAR_MODE: number;
  24195. /** Equirectangular Fixed coordinates mode */
  24196. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24197. /** Equirectangular Fixed Mirrored coordinates mode */
  24198. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24199. /** Texture is not repeating outside of 0..1 UVs */
  24200. static readonly CLAMP_ADDRESSMODE: number;
  24201. /** Texture is repeating outside of 0..1 UVs */
  24202. static readonly WRAP_ADDRESSMODE: number;
  24203. /** Texture is repeating and mirrored */
  24204. static readonly MIRROR_ADDRESSMODE: number;
  24205. /**
  24206. * 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
  24207. */
  24208. static UseSerializedUrlIfAny: boolean;
  24209. /**
  24210. * Define the url of the texture.
  24211. */
  24212. url: Nullable<string>;
  24213. /**
  24214. * Define an offset on the texture to offset the u coordinates of the UVs
  24215. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24216. */
  24217. uOffset: number;
  24218. /**
  24219. * Define an offset on the texture to offset the v coordinates of the UVs
  24220. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24221. */
  24222. vOffset: number;
  24223. /**
  24224. * Define an offset on the texture to scale the u coordinates of the UVs
  24225. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24226. */
  24227. uScale: number;
  24228. /**
  24229. * Define an offset on the texture to scale the v coordinates of the UVs
  24230. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24231. */
  24232. vScale: number;
  24233. /**
  24234. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24235. * @see https://doc.babylonjs.com/how_to/more_materials
  24236. */
  24237. uAng: number;
  24238. /**
  24239. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24240. * @see https://doc.babylonjs.com/how_to/more_materials
  24241. */
  24242. vAng: number;
  24243. /**
  24244. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24245. * @see https://doc.babylonjs.com/how_to/more_materials
  24246. */
  24247. wAng: number;
  24248. /**
  24249. * Defines the center of rotation (U)
  24250. */
  24251. uRotationCenter: number;
  24252. /**
  24253. * Defines the center of rotation (V)
  24254. */
  24255. vRotationCenter: number;
  24256. /**
  24257. * Defines the center of rotation (W)
  24258. */
  24259. wRotationCenter: number;
  24260. /**
  24261. * Are mip maps generated for this texture or not.
  24262. */
  24263. get noMipmap(): boolean;
  24264. /**
  24265. * List of inspectable custom properties (used by the Inspector)
  24266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24267. */
  24268. inspectableCustomProperties: Nullable<IInspectable[]>;
  24269. private _noMipmap;
  24270. /** @hidden */
  24271. _invertY: boolean;
  24272. private _rowGenerationMatrix;
  24273. private _cachedTextureMatrix;
  24274. private _projectionModeMatrix;
  24275. private _t0;
  24276. private _t1;
  24277. private _t2;
  24278. private _cachedUOffset;
  24279. private _cachedVOffset;
  24280. private _cachedUScale;
  24281. private _cachedVScale;
  24282. private _cachedUAng;
  24283. private _cachedVAng;
  24284. private _cachedWAng;
  24285. private _cachedProjectionMatrixId;
  24286. private _cachedCoordinatesMode;
  24287. /** @hidden */
  24288. protected _initialSamplingMode: number;
  24289. /** @hidden */
  24290. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24291. private _deleteBuffer;
  24292. protected _format: Nullable<number>;
  24293. private _delayedOnLoad;
  24294. private _delayedOnError;
  24295. private _mimeType?;
  24296. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24297. get mimeType(): string | undefined;
  24298. /**
  24299. * Observable triggered once the texture has been loaded.
  24300. */
  24301. onLoadObservable: Observable<Texture>;
  24302. protected _isBlocking: boolean;
  24303. /**
  24304. * Is the texture preventing material to render while loading.
  24305. * If false, a default texture will be used instead of the loading one during the preparation step.
  24306. */
  24307. set isBlocking(value: boolean);
  24308. get isBlocking(): boolean;
  24309. /**
  24310. * Get the current sampling mode associated with the texture.
  24311. */
  24312. get samplingMode(): number;
  24313. /**
  24314. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24315. */
  24316. get invertY(): boolean;
  24317. /**
  24318. * Instantiates a new texture.
  24319. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24320. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24321. * @param url defines the url of the picture to load as a texture
  24322. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24323. * @param noMipmap defines if the texture will require mip maps or not
  24324. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24325. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24326. * @param onLoad defines a callback triggered when the texture has been loaded
  24327. * @param onError defines a callback triggered when an error occurred during the loading session
  24328. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24329. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24330. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24331. * @param mimeType defines an optional mime type information
  24332. */
  24333. 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);
  24334. /**
  24335. * Update the url (and optional buffer) of this texture if url was null during construction.
  24336. * @param url the url of the texture
  24337. * @param buffer the buffer of the texture (defaults to null)
  24338. * @param onLoad callback called when the texture is loaded (defaults to null)
  24339. */
  24340. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24341. /**
  24342. * Finish the loading sequence of a texture flagged as delayed load.
  24343. * @hidden
  24344. */
  24345. delayLoad(): void;
  24346. private _prepareRowForTextureGeneration;
  24347. /**
  24348. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24349. * @returns the transform matrix of the texture.
  24350. */
  24351. getTextureMatrix(uBase?: number): Matrix;
  24352. /**
  24353. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24354. * @returns The reflection texture transform
  24355. */
  24356. getReflectionTextureMatrix(): Matrix;
  24357. /**
  24358. * Clones the texture.
  24359. * @returns the cloned texture
  24360. */
  24361. clone(): Texture;
  24362. /**
  24363. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24364. * @returns The JSON representation of the texture
  24365. */
  24366. serialize(): any;
  24367. /**
  24368. * Get the current class name of the texture useful for serialization or dynamic coding.
  24369. * @returns "Texture"
  24370. */
  24371. getClassName(): string;
  24372. /**
  24373. * Dispose the texture and release its associated resources.
  24374. */
  24375. dispose(): void;
  24376. /**
  24377. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24378. * @param parsedTexture Define the JSON representation of the texture
  24379. * @param scene Define the scene the parsed texture should be instantiated in
  24380. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24381. * @returns The parsed texture if successful
  24382. */
  24383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24384. /**
  24385. * Creates a texture from its base 64 representation.
  24386. * @param data Define the base64 payload without the data: prefix
  24387. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24388. * @param scene Define the scene the texture should belong to
  24389. * @param noMipmap Forces the texture to not create mip map information if true
  24390. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24391. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24392. * @param onLoad define a callback triggered when the texture has been loaded
  24393. * @param onError define a callback triggered when an error occurred during the loading session
  24394. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24395. * @returns the created texture
  24396. */
  24397. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24398. /**
  24399. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24400. * @param data Define the base64 payload without the data: prefix
  24401. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24402. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24403. * @param scene Define the scene the texture should belong to
  24404. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24405. * @param noMipmap Forces the texture to not create mip map information if true
  24406. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24407. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24408. * @param onLoad define a callback triggered when the texture has been loaded
  24409. * @param onError define a callback triggered when an error occurred during the loading session
  24410. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24411. * @returns the created texture
  24412. */
  24413. 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;
  24414. }
  24415. }
  24416. declare module "babylonjs/PostProcesses/postProcessManager" {
  24417. import { Nullable } from "babylonjs/types";
  24418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24420. import { Scene } from "babylonjs/scene";
  24421. /**
  24422. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24423. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24424. */
  24425. export class PostProcessManager {
  24426. private _scene;
  24427. private _indexBuffer;
  24428. private _vertexBuffers;
  24429. /**
  24430. * Creates a new instance PostProcess
  24431. * @param scene The scene that the post process is associated with.
  24432. */
  24433. constructor(scene: Scene);
  24434. private _prepareBuffers;
  24435. private _buildIndexBuffer;
  24436. /**
  24437. * Rebuilds the vertex buffers of the manager.
  24438. * @hidden
  24439. */
  24440. _rebuild(): void;
  24441. /**
  24442. * Prepares a frame to be run through a post process.
  24443. * @param sourceTexture The input texture to the post procesess. (default: null)
  24444. * @param postProcesses An array of post processes to be run. (default: null)
  24445. * @returns True if the post processes were able to be run.
  24446. * @hidden
  24447. */
  24448. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24449. /**
  24450. * Manually render a set of post processes to a texture.
  24451. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24452. * @param postProcesses An array of post processes to be run.
  24453. * @param targetTexture The target texture to render to.
  24454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24455. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24456. * @param lodLevel defines which lod of the texture to render to
  24457. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24458. */
  24459. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24460. /**
  24461. * Finalize the result of the output of the postprocesses.
  24462. * @param doNotPresent If true the result will not be displayed to the screen.
  24463. * @param targetTexture The target texture to render to.
  24464. * @param faceIndex The index of the face to bind the target texture to.
  24465. * @param postProcesses The array of post processes to render.
  24466. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24467. * @hidden
  24468. */
  24469. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24470. /**
  24471. * Disposes of the post process manager.
  24472. */
  24473. dispose(): void;
  24474. }
  24475. }
  24476. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24477. import { Observable } from "babylonjs/Misc/observable";
  24478. import { SmartArray } from "babylonjs/Misc/smartArray";
  24479. import { Nullable, Immutable } from "babylonjs/types";
  24480. import { Camera } from "babylonjs/Cameras/camera";
  24481. import { Scene } from "babylonjs/scene";
  24482. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24483. import { Color4 } from "babylonjs/Maths/math.color";
  24484. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24488. import { Texture } from "babylonjs/Materials/Textures/texture";
  24489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24490. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24491. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24492. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24493. import { Engine } from "babylonjs/Engines/engine";
  24494. /**
  24495. * This Helps creating a texture that will be created from a camera in your scene.
  24496. * It is basically a dynamic texture that could be used to create special effects for instance.
  24497. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24498. */
  24499. export class RenderTargetTexture extends Texture {
  24500. /**
  24501. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24502. */
  24503. static readonly REFRESHRATE_RENDER_ONCE: number;
  24504. /**
  24505. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24506. */
  24507. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24508. /**
  24509. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24510. * the central point of your effect and can save a lot of performances.
  24511. */
  24512. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24513. /**
  24514. * Use this predicate to dynamically define the list of mesh you want to render.
  24515. * If set, the renderList property will be overwritten.
  24516. */
  24517. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24518. private _renderList;
  24519. /**
  24520. * Use this list to define the list of mesh you want to render.
  24521. */
  24522. get renderList(): Nullable<Array<AbstractMesh>>;
  24523. set renderList(value: Nullable<Array<AbstractMesh>>);
  24524. /**
  24525. * Use this function to overload the renderList array at rendering time.
  24526. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24527. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24528. * the cube (if the RTT is a cube, else layerOrFace=0).
  24529. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24530. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24531. * hold dummy elements!
  24532. */
  24533. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24534. private _hookArray;
  24535. /**
  24536. * Define if particles should be rendered in your texture.
  24537. */
  24538. renderParticles: boolean;
  24539. /**
  24540. * Define if sprites should be rendered in your texture.
  24541. */
  24542. renderSprites: boolean;
  24543. /**
  24544. * Define the camera used to render the texture.
  24545. */
  24546. activeCamera: Nullable<Camera>;
  24547. /**
  24548. * Override the mesh isReady function with your own one.
  24549. */
  24550. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24551. /**
  24552. * Override the render function of the texture with your own one.
  24553. */
  24554. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24555. /**
  24556. * Define if camera post processes should be use while rendering the texture.
  24557. */
  24558. useCameraPostProcesses: boolean;
  24559. /**
  24560. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24561. */
  24562. ignoreCameraViewport: boolean;
  24563. private _postProcessManager;
  24564. private _postProcesses;
  24565. private _resizeObserver;
  24566. /**
  24567. * An event triggered when the texture is unbind.
  24568. */
  24569. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24570. /**
  24571. * An event triggered when the texture is unbind.
  24572. */
  24573. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24574. private _onAfterUnbindObserver;
  24575. /**
  24576. * Set a after unbind callback in the texture.
  24577. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24578. */
  24579. set onAfterUnbind(callback: () => void);
  24580. /**
  24581. * An event triggered before rendering the texture
  24582. */
  24583. onBeforeRenderObservable: Observable<number>;
  24584. private _onBeforeRenderObserver;
  24585. /**
  24586. * Set a before render callback in the texture.
  24587. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24588. */
  24589. set onBeforeRender(callback: (faceIndex: number) => void);
  24590. /**
  24591. * An event triggered after rendering the texture
  24592. */
  24593. onAfterRenderObservable: Observable<number>;
  24594. private _onAfterRenderObserver;
  24595. /**
  24596. * Set a after render callback in the texture.
  24597. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24598. */
  24599. set onAfterRender(callback: (faceIndex: number) => void);
  24600. /**
  24601. * An event triggered after the texture clear
  24602. */
  24603. onClearObservable: Observable<Engine>;
  24604. private _onClearObserver;
  24605. /**
  24606. * Set a clear callback in the texture.
  24607. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24608. */
  24609. set onClear(callback: (Engine: Engine) => void);
  24610. /**
  24611. * An event triggered when the texture is resized.
  24612. */
  24613. onResizeObservable: Observable<RenderTargetTexture>;
  24614. /**
  24615. * Define the clear color of the Render Target if it should be different from the scene.
  24616. */
  24617. clearColor: Color4;
  24618. protected _size: number | {
  24619. width: number;
  24620. height: number;
  24621. layers?: number;
  24622. };
  24623. protected _initialSizeParameter: number | {
  24624. width: number;
  24625. height: number;
  24626. } | {
  24627. ratio: number;
  24628. };
  24629. protected _sizeRatio: Nullable<number>;
  24630. /** @hidden */
  24631. _generateMipMaps: boolean;
  24632. protected _renderingManager: RenderingManager;
  24633. /** @hidden */
  24634. _waitingRenderList?: string[];
  24635. protected _doNotChangeAspectRatio: boolean;
  24636. protected _currentRefreshId: number;
  24637. protected _refreshRate: number;
  24638. protected _textureMatrix: Matrix;
  24639. protected _samples: number;
  24640. protected _renderTargetOptions: RenderTargetCreationOptions;
  24641. /**
  24642. * Gets render target creation options that were used.
  24643. */
  24644. get renderTargetOptions(): RenderTargetCreationOptions;
  24645. protected _onRatioRescale(): void;
  24646. /**
  24647. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24648. * It must define where the camera used to render the texture is set
  24649. */
  24650. boundingBoxPosition: Vector3;
  24651. private _boundingBoxSize;
  24652. /**
  24653. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24654. * When defined, the cubemap will switch to local mode
  24655. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24656. * @example https://www.babylonjs-playground.com/#RNASML
  24657. */
  24658. set boundingBoxSize(value: Vector3);
  24659. get boundingBoxSize(): Vector3;
  24660. /**
  24661. * In case the RTT has been created with a depth texture, get the associated
  24662. * depth texture.
  24663. * Otherwise, return null.
  24664. */
  24665. get depthStencilTexture(): Nullable<InternalTexture>;
  24666. /**
  24667. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24668. * or used a shadow, depth texture...
  24669. * @param name The friendly name of the texture
  24670. * @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)
  24671. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24672. * @param generateMipMaps True if mip maps need to be generated after render.
  24673. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24674. * @param type The type of the buffer in the RTT (int, half float, float...)
  24675. * @param isCube True if a cube texture needs to be created
  24676. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24677. * @param generateDepthBuffer True to generate a depth buffer
  24678. * @param generateStencilBuffer True to generate a stencil buffer
  24679. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24680. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24681. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24682. */
  24683. constructor(name: string, size: number | {
  24684. width: number;
  24685. height: number;
  24686. layers?: number;
  24687. } | {
  24688. ratio: number;
  24689. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24690. /**
  24691. * Creates a depth stencil texture.
  24692. * This is only available in WebGL 2 or with the depth texture extension available.
  24693. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24694. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24695. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24696. */
  24697. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24698. private _processSizeParameter;
  24699. /**
  24700. * Define the number of samples to use in case of MSAA.
  24701. * It defaults to one meaning no MSAA has been enabled.
  24702. */
  24703. get samples(): number;
  24704. set samples(value: number);
  24705. /**
  24706. * Resets the refresh counter of the texture and start bak from scratch.
  24707. * Could be useful to regenerate the texture if it is setup to render only once.
  24708. */
  24709. resetRefreshCounter(): void;
  24710. /**
  24711. * Define the refresh rate of the texture or the rendering frequency.
  24712. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24713. */
  24714. get refreshRate(): number;
  24715. set refreshRate(value: number);
  24716. /**
  24717. * Adds a post process to the render target rendering passes.
  24718. * @param postProcess define the post process to add
  24719. */
  24720. addPostProcess(postProcess: PostProcess): void;
  24721. /**
  24722. * Clear all the post processes attached to the render target
  24723. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24724. */
  24725. clearPostProcesses(dispose?: boolean): void;
  24726. /**
  24727. * Remove one of the post process from the list of attached post processes to the texture
  24728. * @param postProcess define the post process to remove from the list
  24729. */
  24730. removePostProcess(postProcess: PostProcess): void;
  24731. /** @hidden */
  24732. _shouldRender(): boolean;
  24733. /**
  24734. * Gets the actual render size of the texture.
  24735. * @returns the width of the render size
  24736. */
  24737. getRenderSize(): number;
  24738. /**
  24739. * Gets the actual render width of the texture.
  24740. * @returns the width of the render size
  24741. */
  24742. getRenderWidth(): number;
  24743. /**
  24744. * Gets the actual render height of the texture.
  24745. * @returns the height of the render size
  24746. */
  24747. getRenderHeight(): number;
  24748. /**
  24749. * Gets the actual number of layers of the texture.
  24750. * @returns the number of layers
  24751. */
  24752. getRenderLayers(): number;
  24753. /**
  24754. * Get if the texture can be rescaled or not.
  24755. */
  24756. get canRescale(): boolean;
  24757. /**
  24758. * Resize the texture using a ratio.
  24759. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24760. */
  24761. scale(ratio: number): void;
  24762. /**
  24763. * Get the texture reflection matrix used to rotate/transform the reflection.
  24764. * @returns the reflection matrix
  24765. */
  24766. getReflectionTextureMatrix(): Matrix;
  24767. /**
  24768. * Resize the texture to a new desired size.
  24769. * Be carrefull as it will recreate all the data in the new texture.
  24770. * @param size Define the new size. It can be:
  24771. * - a number for squared texture,
  24772. * - an object containing { width: number, height: number }
  24773. * - or an object containing a ratio { ratio: number }
  24774. */
  24775. resize(size: number | {
  24776. width: number;
  24777. height: number;
  24778. } | {
  24779. ratio: number;
  24780. }): void;
  24781. private _defaultRenderListPrepared;
  24782. /**
  24783. * Renders all the objects from the render list into the texture.
  24784. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24785. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24786. */
  24787. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24788. private _bestReflectionRenderTargetDimension;
  24789. private _prepareRenderingManager;
  24790. /**
  24791. * @hidden
  24792. * @param faceIndex face index to bind to if this is a cubetexture
  24793. * @param layer defines the index of the texture to bind in the array
  24794. */
  24795. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24797. private renderToTarget;
  24798. /**
  24799. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24800. * This allowed control for front to back rendering or reversly depending of the special needs.
  24801. *
  24802. * @param renderingGroupId The rendering group id corresponding to its index
  24803. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24804. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24805. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24806. */
  24807. 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;
  24808. /**
  24809. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24810. *
  24811. * @param renderingGroupId The rendering group id corresponding to its index
  24812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24813. */
  24814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24815. /**
  24816. * Clones the texture.
  24817. * @returns the cloned texture
  24818. */
  24819. clone(): RenderTargetTexture;
  24820. /**
  24821. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24822. * @returns The JSON representation of the texture
  24823. */
  24824. serialize(): any;
  24825. /**
  24826. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24827. */
  24828. disposeFramebufferObjects(): void;
  24829. /**
  24830. * Dispose the texture and release its associated resources.
  24831. */
  24832. dispose(): void;
  24833. /** @hidden */
  24834. _rebuild(): void;
  24835. /**
  24836. * Clear the info related to rendering groups preventing retention point in material dispose.
  24837. */
  24838. freeRenderingGroups(): void;
  24839. /**
  24840. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24841. * @returns the view count
  24842. */
  24843. getViewCount(): number;
  24844. }
  24845. }
  24846. declare module "babylonjs/Misc/guid" {
  24847. /**
  24848. * Class used to manipulate GUIDs
  24849. */
  24850. export class GUID {
  24851. /**
  24852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24853. * Be aware Math.random() could cause collisions, but:
  24854. * "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"
  24855. * @returns a pseudo random id
  24856. */
  24857. static RandomId(): string;
  24858. }
  24859. }
  24860. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24861. import { Nullable } from "babylonjs/types";
  24862. import { Scene } from "babylonjs/scene";
  24863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24864. import { Material } from "babylonjs/Materials/material";
  24865. import { Effect } from "babylonjs/Materials/effect";
  24866. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24867. /**
  24868. * Options to be used when creating a shadow depth material
  24869. */
  24870. export interface IIOptionShadowDepthMaterial {
  24871. /** Variables in the vertex shader code that need to have their names remapped.
  24872. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24873. * "var_name" should be either: worldPos or vNormalW
  24874. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24875. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24876. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24877. */
  24878. remappedVariables?: string[];
  24879. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24880. standalone?: boolean;
  24881. }
  24882. /**
  24883. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24884. */
  24885. export class ShadowDepthWrapper {
  24886. private _scene;
  24887. private _options?;
  24888. private _baseMaterial;
  24889. private _onEffectCreatedObserver;
  24890. private _subMeshToEffect;
  24891. private _subMeshToDepthEffect;
  24892. private _meshes;
  24893. /** @hidden */
  24894. _matriceNames: any;
  24895. /** Gets the standalone status of the wrapper */
  24896. get standalone(): boolean;
  24897. /** Gets the base material the wrapper is built upon */
  24898. get baseMaterial(): Material;
  24899. /**
  24900. * Instantiate a new shadow depth wrapper.
  24901. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24902. * generate the shadow depth map. For more information, please refer to the documentation:
  24903. * https://doc.babylonjs.com/babylon101/shadows
  24904. * @param baseMaterial Material to wrap
  24905. * @param scene Define the scene the material belongs to
  24906. * @param options Options used to create the wrapper
  24907. */
  24908. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24909. /**
  24910. * Gets the effect to use to generate the depth map
  24911. * @param subMesh subMesh to get the effect for
  24912. * @param shadowGenerator shadow generator to get the effect for
  24913. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24914. */
  24915. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24916. /**
  24917. * Specifies that the submesh is ready to be used for depth rendering
  24918. * @param subMesh submesh to check
  24919. * @param defines the list of defines to take into account when checking the effect
  24920. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24921. * @param useInstances specifies that instances should be used
  24922. * @returns a boolean indicating that the submesh is ready or not
  24923. */
  24924. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24925. /**
  24926. * Disposes the resources
  24927. */
  24928. dispose(): void;
  24929. private _makeEffect;
  24930. }
  24931. }
  24932. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24934. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24935. import { Nullable } from "babylonjs/types";
  24936. module "babylonjs/Engines/thinEngine" {
  24937. interface ThinEngine {
  24938. /**
  24939. * Unbind a list of render target textures from the webGL context
  24940. * This is used only when drawBuffer extension or webGL2 are active
  24941. * @param textures defines the render target textures to unbind
  24942. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24943. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24944. */
  24945. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24946. /**
  24947. * Create a multi render target texture
  24948. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24949. * @param size defines the size of the texture
  24950. * @param options defines the creation options
  24951. * @returns the cube texture as an InternalTexture
  24952. */
  24953. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24954. /**
  24955. * Update the sample count for a given multiple render target texture
  24956. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24957. * @param textures defines the textures to update
  24958. * @param samples defines the sample count to set
  24959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24960. */
  24961. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24962. /**
  24963. * Select a subsets of attachments to draw to.
  24964. * @param attachments gl attachments
  24965. */
  24966. bindAttachments(attachments: number[]): void;
  24967. }
  24968. }
  24969. }
  24970. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24971. import { Scene } from "babylonjs/scene";
  24972. import { Engine } from "babylonjs/Engines/engine";
  24973. import { Texture } from "babylonjs/Materials/Textures/texture";
  24974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24975. import "babylonjs/Engines/Extensions/engine.multiRender";
  24976. /**
  24977. * Creation options of the multi render target texture.
  24978. */
  24979. export interface IMultiRenderTargetOptions {
  24980. /**
  24981. * Define if the texture needs to create mip maps after render.
  24982. */
  24983. generateMipMaps?: boolean;
  24984. /**
  24985. * Define the types of all the draw buffers we want to create
  24986. */
  24987. types?: number[];
  24988. /**
  24989. * Define the sampling modes of all the draw buffers we want to create
  24990. */
  24991. samplingModes?: number[];
  24992. /**
  24993. * Define if a depth buffer is required
  24994. */
  24995. generateDepthBuffer?: boolean;
  24996. /**
  24997. * Define if a stencil buffer is required
  24998. */
  24999. generateStencilBuffer?: boolean;
  25000. /**
  25001. * Define if a depth texture is required instead of a depth buffer
  25002. */
  25003. generateDepthTexture?: boolean;
  25004. /**
  25005. * Define the number of desired draw buffers
  25006. */
  25007. textureCount?: number;
  25008. /**
  25009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25010. */
  25011. doNotChangeAspectRatio?: boolean;
  25012. /**
  25013. * Define the default type of the buffers we are creating
  25014. */
  25015. defaultType?: number;
  25016. }
  25017. /**
  25018. * A multi render target, like a render target provides the ability to render to a texture.
  25019. * Unlike the render target, it can render to several draw buffers in one draw.
  25020. * This is specially interesting in deferred rendering or for any effects requiring more than
  25021. * just one color from a single pass.
  25022. */
  25023. export class MultiRenderTarget extends RenderTargetTexture {
  25024. private _internalTextures;
  25025. private _textures;
  25026. private _multiRenderTargetOptions;
  25027. private _count;
  25028. /**
  25029. * Get if draw buffers are currently supported by the used hardware and browser.
  25030. */
  25031. get isSupported(): boolean;
  25032. /**
  25033. * Get the list of textures generated by the multi render target.
  25034. */
  25035. get textures(): Texture[];
  25036. /**
  25037. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25038. */
  25039. get count(): number;
  25040. /**
  25041. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25042. */
  25043. get depthTexture(): Texture;
  25044. /**
  25045. * Set the wrapping mode on U of all the textures we are rendering to.
  25046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25047. */
  25048. set wrapU(wrap: number);
  25049. /**
  25050. * Set the wrapping mode on V of all the textures we are rendering to.
  25051. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25052. */
  25053. set wrapV(wrap: number);
  25054. /**
  25055. * Instantiate a new multi render target texture.
  25056. * A multi render target, like a render target provides the ability to render to a texture.
  25057. * Unlike the render target, it can render to several draw buffers in one draw.
  25058. * This is specially interesting in deferred rendering or for any effects requiring more than
  25059. * just one color from a single pass.
  25060. * @param name Define the name of the texture
  25061. * @param size Define the size of the buffers to render to
  25062. * @param count Define the number of target we are rendering into
  25063. * @param scene Define the scene the texture belongs to
  25064. * @param options Define the options used to create the multi render target
  25065. */
  25066. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25067. private _initTypes;
  25068. /** @hidden */
  25069. _rebuild(forceFullRebuild?: boolean): void;
  25070. private _createInternalTextures;
  25071. private _createTextures;
  25072. /**
  25073. * Define the number of samples used if MSAA is enabled.
  25074. */
  25075. get samples(): number;
  25076. set samples(value: number);
  25077. /**
  25078. * Resize all the textures in the multi render target.
  25079. * Be careful as it will recreate all the data in the new texture.
  25080. * @param size Define the new size
  25081. */
  25082. resize(size: any): void;
  25083. /**
  25084. * Changes the number of render targets in this MRT
  25085. * Be careful as it will recreate all the data in the new texture.
  25086. * @param count new texture count
  25087. * @param options Specifies texture types and sampling modes for new textures
  25088. */
  25089. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25090. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25091. /**
  25092. * Dispose the render targets and their associated resources
  25093. */
  25094. dispose(): void;
  25095. /**
  25096. * Release all the underlying texture used as draw buffers.
  25097. */
  25098. releaseInternalTextures(): void;
  25099. }
  25100. }
  25101. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25102. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25104. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25105. /** @hidden */
  25106. export var imageProcessingPixelShader: {
  25107. name: string;
  25108. shader: string;
  25109. };
  25110. }
  25111. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25112. import { Nullable } from "babylonjs/types";
  25113. import { Color4 } from "babylonjs/Maths/math.color";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25116. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25117. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25119. import { Engine } from "babylonjs/Engines/engine";
  25120. import "babylonjs/Shaders/imageProcessing.fragment";
  25121. import "babylonjs/Shaders/postprocess.vertex";
  25122. /**
  25123. * ImageProcessingPostProcess
  25124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25125. */
  25126. export class ImageProcessingPostProcess extends PostProcess {
  25127. /**
  25128. * Default configuration related to image processing available in the PBR Material.
  25129. */
  25130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25131. /**
  25132. * Gets the image processing configuration used either in this material.
  25133. */
  25134. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25135. /**
  25136. * Sets the Default image processing configuration used either in the this material.
  25137. *
  25138. * If sets to null, the scene one is in use.
  25139. */
  25140. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25141. /**
  25142. * Keep track of the image processing observer to allow dispose and replace.
  25143. */
  25144. private _imageProcessingObserver;
  25145. /**
  25146. * Attaches a new image processing configuration to the PBR Material.
  25147. * @param configuration
  25148. */
  25149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25150. /**
  25151. * If the post process is supported.
  25152. */
  25153. get isSupported(): boolean;
  25154. /**
  25155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25156. */
  25157. get colorCurves(): Nullable<ColorCurves>;
  25158. /**
  25159. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25160. */
  25161. set colorCurves(value: Nullable<ColorCurves>);
  25162. /**
  25163. * Gets wether the color curves effect is enabled.
  25164. */
  25165. get colorCurvesEnabled(): boolean;
  25166. /**
  25167. * Sets wether the color curves effect is enabled.
  25168. */
  25169. set colorCurvesEnabled(value: boolean);
  25170. /**
  25171. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25172. */
  25173. get colorGradingTexture(): Nullable<BaseTexture>;
  25174. /**
  25175. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25176. */
  25177. set colorGradingTexture(value: Nullable<BaseTexture>);
  25178. /**
  25179. * Gets wether the color grading effect is enabled.
  25180. */
  25181. get colorGradingEnabled(): boolean;
  25182. /**
  25183. * Gets wether the color grading effect is enabled.
  25184. */
  25185. set colorGradingEnabled(value: boolean);
  25186. /**
  25187. * Gets exposure used in the effect.
  25188. */
  25189. get exposure(): number;
  25190. /**
  25191. * Sets exposure used in the effect.
  25192. */
  25193. set exposure(value: number);
  25194. /**
  25195. * Gets wether tonemapping is enabled or not.
  25196. */
  25197. get toneMappingEnabled(): boolean;
  25198. /**
  25199. * Sets wether tonemapping is enabled or not
  25200. */
  25201. set toneMappingEnabled(value: boolean);
  25202. /**
  25203. * Gets the type of tone mapping effect.
  25204. */
  25205. get toneMappingType(): number;
  25206. /**
  25207. * Sets the type of tone mapping effect.
  25208. */
  25209. set toneMappingType(value: number);
  25210. /**
  25211. * Gets contrast used in the effect.
  25212. */
  25213. get contrast(): number;
  25214. /**
  25215. * Sets contrast used in the effect.
  25216. */
  25217. set contrast(value: number);
  25218. /**
  25219. * Gets Vignette stretch size.
  25220. */
  25221. get vignetteStretch(): number;
  25222. /**
  25223. * Sets Vignette stretch size.
  25224. */
  25225. set vignetteStretch(value: number);
  25226. /**
  25227. * Gets Vignette centre X Offset.
  25228. */
  25229. get vignetteCentreX(): number;
  25230. /**
  25231. * Sets Vignette centre X Offset.
  25232. */
  25233. set vignetteCentreX(value: number);
  25234. /**
  25235. * Gets Vignette centre Y Offset.
  25236. */
  25237. get vignetteCentreY(): number;
  25238. /**
  25239. * Sets Vignette centre Y Offset.
  25240. */
  25241. set vignetteCentreY(value: number);
  25242. /**
  25243. * Gets Vignette weight or intensity of the vignette effect.
  25244. */
  25245. get vignetteWeight(): number;
  25246. /**
  25247. * Sets Vignette weight or intensity of the vignette effect.
  25248. */
  25249. set vignetteWeight(value: number);
  25250. /**
  25251. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25252. * if vignetteEnabled is set to true.
  25253. */
  25254. get vignetteColor(): Color4;
  25255. /**
  25256. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25257. * if vignetteEnabled is set to true.
  25258. */
  25259. set vignetteColor(value: Color4);
  25260. /**
  25261. * Gets Camera field of view used by the Vignette effect.
  25262. */
  25263. get vignetteCameraFov(): number;
  25264. /**
  25265. * Sets Camera field of view used by the Vignette effect.
  25266. */
  25267. set vignetteCameraFov(value: number);
  25268. /**
  25269. * Gets the vignette blend mode allowing different kind of effect.
  25270. */
  25271. get vignetteBlendMode(): number;
  25272. /**
  25273. * Sets the vignette blend mode allowing different kind of effect.
  25274. */
  25275. set vignetteBlendMode(value: number);
  25276. /**
  25277. * Gets wether the vignette effect is enabled.
  25278. */
  25279. get vignetteEnabled(): boolean;
  25280. /**
  25281. * Sets wether the vignette effect is enabled.
  25282. */
  25283. set vignetteEnabled(value: boolean);
  25284. private _fromLinearSpace;
  25285. /**
  25286. * Gets wether the input of the processing is in Gamma or Linear Space.
  25287. */
  25288. get fromLinearSpace(): boolean;
  25289. /**
  25290. * Sets wether the input of the processing is in Gamma or Linear Space.
  25291. */
  25292. set fromLinearSpace(value: boolean);
  25293. /**
  25294. * Defines cache preventing GC.
  25295. */
  25296. private _defines;
  25297. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25298. /**
  25299. * "ImageProcessingPostProcess"
  25300. * @returns "ImageProcessingPostProcess"
  25301. */
  25302. getClassName(): string;
  25303. /**
  25304. * @hidden
  25305. */
  25306. _updateParameters(): void;
  25307. dispose(camera?: Camera): void;
  25308. }
  25309. }
  25310. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25311. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25312. /**
  25313. * Interface for defining prepass effects in the prepass post-process pipeline
  25314. */
  25315. export interface PrePassEffectConfiguration {
  25316. /**
  25317. * Name of the effect
  25318. */
  25319. name: string;
  25320. /**
  25321. * Post process to attach for this effect
  25322. */
  25323. postProcess?: PostProcess;
  25324. /**
  25325. * Textures required in the MRT
  25326. */
  25327. texturesRequired: number[];
  25328. /**
  25329. * Is the effect enabled
  25330. */
  25331. enabled: boolean;
  25332. /**
  25333. * Disposes the effect configuration
  25334. */
  25335. dispose(): void;
  25336. /**
  25337. * Creates the associated post process
  25338. */
  25339. createPostProcess?: () => PostProcess;
  25340. }
  25341. }
  25342. declare module "babylonjs/Rendering/prePassRenderer" {
  25343. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25344. import { Scene } from "babylonjs/scene";
  25345. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25346. import { Effect } from "babylonjs/Materials/effect";
  25347. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25348. /**
  25349. * Renders a pre pass of the scene
  25350. * This means every mesh in the scene will be rendered to a render target texture
  25351. * And then this texture will be composited to the rendering canvas with post processes
  25352. * It is necessary for effects like subsurface scattering or deferred shading
  25353. */
  25354. export class PrePassRenderer {
  25355. /** @hidden */
  25356. static _SceneComponentInitialization: (scene: Scene) => void;
  25357. private _textureFormats;
  25358. private _textureIndices;
  25359. private _scene;
  25360. private _engine;
  25361. private _isDirty;
  25362. /**
  25363. * Number of textures in the multi render target texture where the scene is directly rendered
  25364. */
  25365. mrtCount: number;
  25366. /**
  25367. * The render target where the scene is directly rendered
  25368. */
  25369. prePassRT: MultiRenderTarget;
  25370. private _multiRenderAttachments;
  25371. private _defaultAttachments;
  25372. private _clearAttachments;
  25373. private _postProcesses;
  25374. private readonly _clearColor;
  25375. /**
  25376. * Image processing post process for composition
  25377. */
  25378. imageProcessingPostProcess: ImageProcessingPostProcess;
  25379. /**
  25380. * Configuration for prepass effects
  25381. */
  25382. private _effectConfigurations;
  25383. /**
  25384. * Should materials render their geometry on the MRT
  25385. */
  25386. materialsShouldRenderGeometry: boolean;
  25387. /**
  25388. * Should materials render the irradiance information on the MRT
  25389. */
  25390. materialsShouldRenderIrradiance: boolean;
  25391. private _mrtFormats;
  25392. private _mrtLayout;
  25393. private _enabled;
  25394. /**
  25395. * Indicates if the prepass is enabled
  25396. */
  25397. get enabled(): boolean;
  25398. /**
  25399. * How many samples are used for MSAA of the scene render target
  25400. */
  25401. get samples(): number;
  25402. set samples(n: number);
  25403. /**
  25404. * Instanciates a prepass renderer
  25405. * @param scene The scene
  25406. */
  25407. constructor(scene: Scene);
  25408. private _initializeAttachments;
  25409. private _createCompositionEffect;
  25410. /**
  25411. * Indicates if rendering a prepass is supported
  25412. */
  25413. get isSupported(): boolean;
  25414. /**
  25415. * Sets the proper output textures to draw in the engine.
  25416. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25417. */
  25418. bindAttachmentsForEffect(effect: Effect): void;
  25419. /**
  25420. * @hidden
  25421. */
  25422. _beforeCameraDraw(): void;
  25423. /**
  25424. * @hidden
  25425. */
  25426. _afterCameraDraw(): void;
  25427. private _checkRTSize;
  25428. private _bindFrameBuffer;
  25429. /**
  25430. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25431. */
  25432. clear(): void;
  25433. private _setState;
  25434. private _checkTextureType;
  25435. /**
  25436. * Adds an effect configuration to the prepass.
  25437. * If an effect has already been added, it won't add it twice and will return the configuration
  25438. * already present.
  25439. * @param cfg the effect configuration
  25440. * @return the effect configuration now used by the prepass
  25441. */
  25442. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25443. /**
  25444. * Returns the index of a texture in the multi render target texture array.
  25445. * @param type Texture type
  25446. * @return The index
  25447. */
  25448. getIndex(type: number): number;
  25449. private _enable;
  25450. private _disable;
  25451. private _resetLayout;
  25452. private _resetPostProcessChain;
  25453. private _bindPostProcessChain;
  25454. /**
  25455. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25456. */
  25457. markAsDirty(): void;
  25458. /**
  25459. * Enables a texture on the MultiRenderTarget for prepass
  25460. */
  25461. private _enableTextures;
  25462. private _update;
  25463. /**
  25464. * Disposes the prepass renderer.
  25465. */
  25466. dispose(): void;
  25467. }
  25468. }
  25469. declare module "babylonjs/Materials/material" {
  25470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25471. import { SmartArray } from "babylonjs/Misc/smartArray";
  25472. import { Observable } from "babylonjs/Misc/observable";
  25473. import { Nullable } from "babylonjs/types";
  25474. import { Scene } from "babylonjs/scene";
  25475. import { Matrix } from "babylonjs/Maths/math.vector";
  25476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25479. import { Effect } from "babylonjs/Materials/effect";
  25480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25482. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25483. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25484. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25485. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25486. import { Mesh } from "babylonjs/Meshes/mesh";
  25487. import { Animation } from "babylonjs/Animations/animation";
  25488. /**
  25489. * Options for compiling materials.
  25490. */
  25491. export interface IMaterialCompilationOptions {
  25492. /**
  25493. * Defines whether clip planes are enabled.
  25494. */
  25495. clipPlane: boolean;
  25496. /**
  25497. * Defines whether instances are enabled.
  25498. */
  25499. useInstances: boolean;
  25500. }
  25501. /**
  25502. * Options passed when calling customShaderNameResolve
  25503. */
  25504. export interface ICustomShaderNameResolveOptions {
  25505. /**
  25506. * 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
  25507. */
  25508. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25509. }
  25510. /**
  25511. * Base class for the main features of a material in Babylon.js
  25512. */
  25513. export class Material implements IAnimatable {
  25514. /**
  25515. * Returns the triangle fill mode
  25516. */
  25517. static readonly TriangleFillMode: number;
  25518. /**
  25519. * Returns the wireframe mode
  25520. */
  25521. static readonly WireFrameFillMode: number;
  25522. /**
  25523. * Returns the point fill mode
  25524. */
  25525. static readonly PointFillMode: number;
  25526. /**
  25527. * Returns the point list draw mode
  25528. */
  25529. static readonly PointListDrawMode: number;
  25530. /**
  25531. * Returns the line list draw mode
  25532. */
  25533. static readonly LineListDrawMode: number;
  25534. /**
  25535. * Returns the line loop draw mode
  25536. */
  25537. static readonly LineLoopDrawMode: number;
  25538. /**
  25539. * Returns the line strip draw mode
  25540. */
  25541. static readonly LineStripDrawMode: number;
  25542. /**
  25543. * Returns the triangle strip draw mode
  25544. */
  25545. static readonly TriangleStripDrawMode: number;
  25546. /**
  25547. * Returns the triangle fan draw mode
  25548. */
  25549. static readonly TriangleFanDrawMode: number;
  25550. /**
  25551. * Stores the clock-wise side orientation
  25552. */
  25553. static readonly ClockWiseSideOrientation: number;
  25554. /**
  25555. * Stores the counter clock-wise side orientation
  25556. */
  25557. static readonly CounterClockWiseSideOrientation: number;
  25558. /**
  25559. * The dirty texture flag value
  25560. */
  25561. static readonly TextureDirtyFlag: number;
  25562. /**
  25563. * The dirty light flag value
  25564. */
  25565. static readonly LightDirtyFlag: number;
  25566. /**
  25567. * The dirty fresnel flag value
  25568. */
  25569. static readonly FresnelDirtyFlag: number;
  25570. /**
  25571. * The dirty attribute flag value
  25572. */
  25573. static readonly AttributesDirtyFlag: number;
  25574. /**
  25575. * The dirty misc flag value
  25576. */
  25577. static readonly MiscDirtyFlag: number;
  25578. /**
  25579. * The all dirty flag value
  25580. */
  25581. static readonly AllDirtyFlag: number;
  25582. /**
  25583. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25584. */
  25585. static readonly MATERIAL_OPAQUE: number;
  25586. /**
  25587. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25588. */
  25589. static readonly MATERIAL_ALPHATEST: number;
  25590. /**
  25591. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25592. */
  25593. static readonly MATERIAL_ALPHABLEND: number;
  25594. /**
  25595. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25596. * They are also discarded below the alpha cutoff threshold to improve performances.
  25597. */
  25598. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25599. /**
  25600. * The Whiteout method is used to blend normals.
  25601. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25602. */
  25603. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25604. /**
  25605. * The Reoriented Normal Mapping method is used to blend normals.
  25606. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25607. */
  25608. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25609. /**
  25610. * Custom callback helping to override the default shader used in the material.
  25611. */
  25612. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25613. /**
  25614. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25615. */
  25616. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25617. /**
  25618. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25619. * This means that the material can keep using a previous shader while a new one is being compiled.
  25620. * This is mostly used when shader parallel compilation is supported (true by default)
  25621. */
  25622. allowShaderHotSwapping: boolean;
  25623. /**
  25624. * The ID of the material
  25625. */
  25626. id: string;
  25627. /**
  25628. * Gets or sets the unique id of the material
  25629. */
  25630. uniqueId: number;
  25631. /**
  25632. * The name of the material
  25633. */
  25634. name: string;
  25635. /**
  25636. * Gets or sets user defined metadata
  25637. */
  25638. metadata: any;
  25639. /**
  25640. * For internal use only. Please do not use.
  25641. */
  25642. reservedDataStore: any;
  25643. /**
  25644. * Specifies if the ready state should be checked on each call
  25645. */
  25646. checkReadyOnEveryCall: boolean;
  25647. /**
  25648. * Specifies if the ready state should be checked once
  25649. */
  25650. checkReadyOnlyOnce: boolean;
  25651. /**
  25652. * The state of the material
  25653. */
  25654. state: string;
  25655. /**
  25656. * If the material can be rendered to several textures with MRT extension
  25657. */
  25658. get canRenderToMRT(): boolean;
  25659. /**
  25660. * The alpha value of the material
  25661. */
  25662. protected _alpha: number;
  25663. /**
  25664. * List of inspectable custom properties (used by the Inspector)
  25665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25666. */
  25667. inspectableCustomProperties: IInspectable[];
  25668. /**
  25669. * Sets the alpha value of the material
  25670. */
  25671. set alpha(value: number);
  25672. /**
  25673. * Gets the alpha value of the material
  25674. */
  25675. get alpha(): number;
  25676. /**
  25677. * Specifies if back face culling is enabled
  25678. */
  25679. protected _backFaceCulling: boolean;
  25680. /**
  25681. * Sets the back-face culling state
  25682. */
  25683. set backFaceCulling(value: boolean);
  25684. /**
  25685. * Gets the back-face culling state
  25686. */
  25687. get backFaceCulling(): boolean;
  25688. /**
  25689. * Stores the value for side orientation
  25690. */
  25691. sideOrientation: number;
  25692. /**
  25693. * Callback triggered when the material is compiled
  25694. */
  25695. onCompiled: Nullable<(effect: Effect) => void>;
  25696. /**
  25697. * Callback triggered when an error occurs
  25698. */
  25699. onError: Nullable<(effect: Effect, errors: string) => void>;
  25700. /**
  25701. * Callback triggered to get the render target textures
  25702. */
  25703. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25704. /**
  25705. * Gets a boolean indicating that current material needs to register RTT
  25706. */
  25707. get hasRenderTargetTextures(): boolean;
  25708. /**
  25709. * Specifies if the material should be serialized
  25710. */
  25711. doNotSerialize: boolean;
  25712. /**
  25713. * @hidden
  25714. */
  25715. _storeEffectOnSubMeshes: boolean;
  25716. /**
  25717. * Stores the animations for the material
  25718. */
  25719. animations: Nullable<Array<Animation>>;
  25720. /**
  25721. * An event triggered when the material is disposed
  25722. */
  25723. onDisposeObservable: Observable<Material>;
  25724. /**
  25725. * An observer which watches for dispose events
  25726. */
  25727. private _onDisposeObserver;
  25728. private _onUnBindObservable;
  25729. /**
  25730. * Called during a dispose event
  25731. */
  25732. set onDispose(callback: () => void);
  25733. private _onBindObservable;
  25734. /**
  25735. * An event triggered when the material is bound
  25736. */
  25737. get onBindObservable(): Observable<AbstractMesh>;
  25738. /**
  25739. * An observer which watches for bind events
  25740. */
  25741. private _onBindObserver;
  25742. /**
  25743. * Called during a bind event
  25744. */
  25745. set onBind(callback: (Mesh: AbstractMesh) => void);
  25746. /**
  25747. * An event triggered when the material is unbound
  25748. */
  25749. get onUnBindObservable(): Observable<Material>;
  25750. protected _onEffectCreatedObservable: Nullable<Observable<{
  25751. effect: Effect;
  25752. subMesh: Nullable<SubMesh>;
  25753. }>>;
  25754. /**
  25755. * An event triggered when the effect is (re)created
  25756. */
  25757. get onEffectCreatedObservable(): Observable<{
  25758. effect: Effect;
  25759. subMesh: Nullable<SubMesh>;
  25760. }>;
  25761. /**
  25762. * Stores the value of the alpha mode
  25763. */
  25764. private _alphaMode;
  25765. /**
  25766. * Sets the value of the alpha mode.
  25767. *
  25768. * | Value | Type | Description |
  25769. * | --- | --- | --- |
  25770. * | 0 | ALPHA_DISABLE | |
  25771. * | 1 | ALPHA_ADD | |
  25772. * | 2 | ALPHA_COMBINE | |
  25773. * | 3 | ALPHA_SUBTRACT | |
  25774. * | 4 | ALPHA_MULTIPLY | |
  25775. * | 5 | ALPHA_MAXIMIZED | |
  25776. * | 6 | ALPHA_ONEONE | |
  25777. * | 7 | ALPHA_PREMULTIPLIED | |
  25778. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25779. * | 9 | ALPHA_INTERPOLATE | |
  25780. * | 10 | ALPHA_SCREENMODE | |
  25781. *
  25782. */
  25783. set alphaMode(value: number);
  25784. /**
  25785. * Gets the value of the alpha mode
  25786. */
  25787. get alphaMode(): number;
  25788. /**
  25789. * Stores the state of the need depth pre-pass value
  25790. */
  25791. private _needDepthPrePass;
  25792. /**
  25793. * Sets the need depth pre-pass value
  25794. */
  25795. set needDepthPrePass(value: boolean);
  25796. /**
  25797. * Gets the depth pre-pass value
  25798. */
  25799. get needDepthPrePass(): boolean;
  25800. /**
  25801. * Specifies if depth writing should be disabled
  25802. */
  25803. disableDepthWrite: boolean;
  25804. /**
  25805. * Specifies if color writing should be disabled
  25806. */
  25807. disableColorWrite: boolean;
  25808. /**
  25809. * Specifies if depth writing should be forced
  25810. */
  25811. forceDepthWrite: boolean;
  25812. /**
  25813. * Specifies the depth function that should be used. 0 means the default engine function
  25814. */
  25815. depthFunction: number;
  25816. /**
  25817. * Specifies if there should be a separate pass for culling
  25818. */
  25819. separateCullingPass: boolean;
  25820. /**
  25821. * Stores the state specifing if fog should be enabled
  25822. */
  25823. private _fogEnabled;
  25824. /**
  25825. * Sets the state for enabling fog
  25826. */
  25827. set fogEnabled(value: boolean);
  25828. /**
  25829. * Gets the value of the fog enabled state
  25830. */
  25831. get fogEnabled(): boolean;
  25832. /**
  25833. * Stores the size of points
  25834. */
  25835. pointSize: number;
  25836. /**
  25837. * Stores the z offset value
  25838. */
  25839. zOffset: number;
  25840. get wireframe(): boolean;
  25841. /**
  25842. * Sets the state of wireframe mode
  25843. */
  25844. set wireframe(value: boolean);
  25845. /**
  25846. * Gets the value specifying if point clouds are enabled
  25847. */
  25848. get pointsCloud(): boolean;
  25849. /**
  25850. * Sets the state of point cloud mode
  25851. */
  25852. set pointsCloud(value: boolean);
  25853. /**
  25854. * Gets the material fill mode
  25855. */
  25856. get fillMode(): number;
  25857. /**
  25858. * Sets the material fill mode
  25859. */
  25860. set fillMode(value: number);
  25861. /**
  25862. * @hidden
  25863. * Stores the effects for the material
  25864. */
  25865. _effect: Nullable<Effect>;
  25866. /**
  25867. * Specifies if uniform buffers should be used
  25868. */
  25869. private _useUBO;
  25870. /**
  25871. * Stores a reference to the scene
  25872. */
  25873. private _scene;
  25874. /**
  25875. * Stores the fill mode state
  25876. */
  25877. private _fillMode;
  25878. /**
  25879. * Specifies if the depth write state should be cached
  25880. */
  25881. private _cachedDepthWriteState;
  25882. /**
  25883. * Specifies if the color write state should be cached
  25884. */
  25885. private _cachedColorWriteState;
  25886. /**
  25887. * Specifies if the depth function state should be cached
  25888. */
  25889. private _cachedDepthFunctionState;
  25890. /**
  25891. * Stores the uniform buffer
  25892. */
  25893. protected _uniformBuffer: UniformBuffer;
  25894. /** @hidden */
  25895. _indexInSceneMaterialArray: number;
  25896. /** @hidden */
  25897. meshMap: Nullable<{
  25898. [id: string]: AbstractMesh | undefined;
  25899. }>;
  25900. /**
  25901. * Creates a material instance
  25902. * @param name defines the name of the material
  25903. * @param scene defines the scene to reference
  25904. * @param doNotAdd specifies if the material should be added to the scene
  25905. */
  25906. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25907. /**
  25908. * Returns a string representation of the current material
  25909. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25910. * @returns a string with material information
  25911. */
  25912. toString(fullDetails?: boolean): string;
  25913. /**
  25914. * Gets the class name of the material
  25915. * @returns a string with the class name of the material
  25916. */
  25917. getClassName(): string;
  25918. /**
  25919. * Specifies if updates for the material been locked
  25920. */
  25921. get isFrozen(): boolean;
  25922. /**
  25923. * Locks updates for the material
  25924. */
  25925. freeze(): void;
  25926. /**
  25927. * Unlocks updates for the material
  25928. */
  25929. unfreeze(): void;
  25930. /**
  25931. * Specifies if the material is ready to be used
  25932. * @param mesh defines the mesh to check
  25933. * @param useInstances specifies if instances should be used
  25934. * @returns a boolean indicating if the material is ready to be used
  25935. */
  25936. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25937. /**
  25938. * Specifies that the submesh is ready to be used
  25939. * @param mesh defines the mesh to check
  25940. * @param subMesh defines which submesh to check
  25941. * @param useInstances specifies that instances should be used
  25942. * @returns a boolean indicating that the submesh is ready or not
  25943. */
  25944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25945. /**
  25946. * Returns the material effect
  25947. * @returns the effect associated with the material
  25948. */
  25949. getEffect(): Nullable<Effect>;
  25950. /**
  25951. * Returns the current scene
  25952. * @returns a Scene
  25953. */
  25954. getScene(): Scene;
  25955. /**
  25956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25957. */
  25958. protected _forceAlphaTest: boolean;
  25959. /**
  25960. * The transparency mode of the material.
  25961. */
  25962. protected _transparencyMode: Nullable<number>;
  25963. /**
  25964. * Gets the current transparency mode.
  25965. */
  25966. get transparencyMode(): Nullable<number>;
  25967. /**
  25968. * Sets the transparency mode of the material.
  25969. *
  25970. * | Value | Type | Description |
  25971. * | ----- | ----------------------------------- | ----------- |
  25972. * | 0 | OPAQUE | |
  25973. * | 1 | ALPHATEST | |
  25974. * | 2 | ALPHABLEND | |
  25975. * | 3 | ALPHATESTANDBLEND | |
  25976. *
  25977. */
  25978. set transparencyMode(value: Nullable<number>);
  25979. /**
  25980. * Returns true if alpha blending should be disabled.
  25981. */
  25982. protected get _disableAlphaBlending(): boolean;
  25983. /**
  25984. * Specifies whether or not this material should be rendered in alpha blend mode.
  25985. * @returns a boolean specifying if alpha blending is needed
  25986. */
  25987. needAlphaBlending(): boolean;
  25988. /**
  25989. * Specifies if the mesh will require alpha blending
  25990. * @param mesh defines the mesh to check
  25991. * @returns a boolean specifying if alpha blending is needed for the mesh
  25992. */
  25993. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25994. /**
  25995. * Specifies whether or not this material should be rendered in alpha test mode.
  25996. * @returns a boolean specifying if an alpha test is needed.
  25997. */
  25998. needAlphaTesting(): boolean;
  25999. /**
  26000. * Specifies if material alpha testing should be turned on for the mesh
  26001. * @param mesh defines the mesh to check
  26002. */
  26003. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26004. /**
  26005. * Gets the texture used for the alpha test
  26006. * @returns the texture to use for alpha testing
  26007. */
  26008. getAlphaTestTexture(): Nullable<BaseTexture>;
  26009. /**
  26010. * Marks the material to indicate that it needs to be re-calculated
  26011. */
  26012. markDirty(): void;
  26013. /** @hidden */
  26014. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26015. /**
  26016. * Binds the material to the mesh
  26017. * @param world defines the world transformation matrix
  26018. * @param mesh defines the mesh to bind the material to
  26019. */
  26020. bind(world: Matrix, mesh?: Mesh): void;
  26021. /**
  26022. * Binds the submesh to the material
  26023. * @param world defines the world transformation matrix
  26024. * @param mesh defines the mesh containing the submesh
  26025. * @param subMesh defines the submesh to bind the material to
  26026. */
  26027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26028. /**
  26029. * Binds the world matrix to the material
  26030. * @param world defines the world transformation matrix
  26031. */
  26032. bindOnlyWorldMatrix(world: Matrix): void;
  26033. /**
  26034. * Binds the scene's uniform buffer to the effect.
  26035. * @param effect defines the effect to bind to the scene uniform buffer
  26036. * @param sceneUbo defines the uniform buffer storing scene data
  26037. */
  26038. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26039. /**
  26040. * Binds the view matrix to the effect
  26041. * @param effect defines the effect to bind the view matrix to
  26042. */
  26043. bindView(effect: Effect): void;
  26044. /**
  26045. * Binds the view projection matrix to the effect
  26046. * @param effect defines the effect to bind the view projection matrix to
  26047. */
  26048. bindViewProjection(effect: Effect): void;
  26049. /**
  26050. * Processes to execute after binding the material to a mesh
  26051. * @param mesh defines the rendered mesh
  26052. */
  26053. protected _afterBind(mesh?: Mesh): void;
  26054. /**
  26055. * Unbinds the material from the mesh
  26056. */
  26057. unbind(): void;
  26058. /**
  26059. * Gets the active textures from the material
  26060. * @returns an array of textures
  26061. */
  26062. getActiveTextures(): BaseTexture[];
  26063. /**
  26064. * Specifies if the material uses a texture
  26065. * @param texture defines the texture to check against the material
  26066. * @returns a boolean specifying if the material uses the texture
  26067. */
  26068. hasTexture(texture: BaseTexture): boolean;
  26069. /**
  26070. * Makes a duplicate of the material, and gives it a new name
  26071. * @param name defines the new name for the duplicated material
  26072. * @returns the cloned material
  26073. */
  26074. clone(name: string): Nullable<Material>;
  26075. /**
  26076. * Gets the meshes bound to the material
  26077. * @returns an array of meshes bound to the material
  26078. */
  26079. getBindedMeshes(): AbstractMesh[];
  26080. /**
  26081. * Force shader compilation
  26082. * @param mesh defines the mesh associated with this material
  26083. * @param onCompiled defines a function to execute once the material is compiled
  26084. * @param options defines the options to configure the compilation
  26085. * @param onError defines a function to execute if the material fails compiling
  26086. */
  26087. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26088. /**
  26089. * Force shader compilation
  26090. * @param mesh defines the mesh that will use this material
  26091. * @param options defines additional options for compiling the shaders
  26092. * @returns a promise that resolves when the compilation completes
  26093. */
  26094. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26095. private static readonly _AllDirtyCallBack;
  26096. private static readonly _ImageProcessingDirtyCallBack;
  26097. private static readonly _TextureDirtyCallBack;
  26098. private static readonly _FresnelDirtyCallBack;
  26099. private static readonly _MiscDirtyCallBack;
  26100. private static readonly _LightsDirtyCallBack;
  26101. private static readonly _AttributeDirtyCallBack;
  26102. private static _FresnelAndMiscDirtyCallBack;
  26103. private static _TextureAndMiscDirtyCallBack;
  26104. private static readonly _DirtyCallbackArray;
  26105. private static readonly _RunDirtyCallBacks;
  26106. /**
  26107. * Marks a define in the material to indicate that it needs to be re-computed
  26108. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26109. */
  26110. markAsDirty(flag: number): void;
  26111. /**
  26112. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26113. * @param func defines a function which checks material defines against the submeshes
  26114. */
  26115. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26116. /**
  26117. * Indicates that the scene should check if the rendering now needs a prepass
  26118. */
  26119. protected _markScenePrePassDirty(): void;
  26120. /**
  26121. * Indicates that we need to re-calculated for all submeshes
  26122. */
  26123. protected _markAllSubMeshesAsAllDirty(): void;
  26124. /**
  26125. * Indicates that image processing needs to be re-calculated for all submeshes
  26126. */
  26127. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26128. /**
  26129. * Indicates that textures need to be re-calculated for all submeshes
  26130. */
  26131. protected _markAllSubMeshesAsTexturesDirty(): void;
  26132. /**
  26133. * Indicates that fresnel needs to be re-calculated for all submeshes
  26134. */
  26135. protected _markAllSubMeshesAsFresnelDirty(): void;
  26136. /**
  26137. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26138. */
  26139. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26140. /**
  26141. * Indicates that lights need to be re-calculated for all submeshes
  26142. */
  26143. protected _markAllSubMeshesAsLightsDirty(): void;
  26144. /**
  26145. * Indicates that attributes need to be re-calculated for all submeshes
  26146. */
  26147. protected _markAllSubMeshesAsAttributesDirty(): void;
  26148. /**
  26149. * Indicates that misc needs to be re-calculated for all submeshes
  26150. */
  26151. protected _markAllSubMeshesAsMiscDirty(): void;
  26152. /**
  26153. * Indicates that textures and misc need to be re-calculated for all submeshes
  26154. */
  26155. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26156. /**
  26157. * Sets the required values to the prepass renderer.
  26158. * @param prePassRenderer defines the prepass renderer to setup.
  26159. * @returns true if the pre pass is needed.
  26160. */
  26161. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26162. /**
  26163. * Disposes the material
  26164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26166. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26167. */
  26168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26169. /** @hidden */
  26170. private releaseVertexArrayObject;
  26171. /**
  26172. * Serializes this material
  26173. * @returns the serialized material object
  26174. */
  26175. serialize(): any;
  26176. /**
  26177. * Creates a material from parsed material data
  26178. * @param parsedMaterial defines parsed material data
  26179. * @param scene defines the hosting scene
  26180. * @param rootUrl defines the root URL to use to load textures
  26181. * @returns a new material
  26182. */
  26183. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26184. }
  26185. }
  26186. declare module "babylonjs/Materials/multiMaterial" {
  26187. import { Nullable } from "babylonjs/types";
  26188. import { Scene } from "babylonjs/scene";
  26189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26192. import { Material } from "babylonjs/Materials/material";
  26193. /**
  26194. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26195. * separate meshes. This can be use to improve performances.
  26196. * @see https://doc.babylonjs.com/how_to/multi_materials
  26197. */
  26198. export class MultiMaterial extends Material {
  26199. private _subMaterials;
  26200. /**
  26201. * Gets or Sets the list of Materials used within the multi material.
  26202. * They need to be ordered according to the submeshes order in the associated mesh
  26203. */
  26204. get subMaterials(): Nullable<Material>[];
  26205. set subMaterials(value: Nullable<Material>[]);
  26206. /**
  26207. * Function used to align with Node.getChildren()
  26208. * @returns the list of Materials used within the multi material
  26209. */
  26210. getChildren(): Nullable<Material>[];
  26211. /**
  26212. * Instantiates a new Multi Material
  26213. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26214. * separate meshes. This can be use to improve performances.
  26215. * @see https://doc.babylonjs.com/how_to/multi_materials
  26216. * @param name Define the name in the scene
  26217. * @param scene Define the scene the material belongs to
  26218. */
  26219. constructor(name: string, scene: Scene);
  26220. private _hookArray;
  26221. /**
  26222. * Get one of the submaterial by its index in the submaterials array
  26223. * @param index The index to look the sub material at
  26224. * @returns The Material if the index has been defined
  26225. */
  26226. getSubMaterial(index: number): Nullable<Material>;
  26227. /**
  26228. * Get the list of active textures for the whole sub materials list.
  26229. * @returns All the textures that will be used during the rendering
  26230. */
  26231. getActiveTextures(): BaseTexture[];
  26232. /**
  26233. * Gets the current class name of the material e.g. "MultiMaterial"
  26234. * Mainly use in serialization.
  26235. * @returns the class name
  26236. */
  26237. getClassName(): string;
  26238. /**
  26239. * Checks if the material is ready to render the requested sub mesh
  26240. * @param mesh Define the mesh the submesh belongs to
  26241. * @param subMesh Define the sub mesh to look readyness for
  26242. * @param useInstances Define whether or not the material is used with instances
  26243. * @returns true if ready, otherwise false
  26244. */
  26245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26246. /**
  26247. * Clones the current material and its related sub materials
  26248. * @param name Define the name of the newly cloned material
  26249. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26250. * @returns the cloned material
  26251. */
  26252. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26253. /**
  26254. * Serializes the materials into a JSON representation.
  26255. * @returns the JSON representation
  26256. */
  26257. serialize(): any;
  26258. /**
  26259. * Dispose the material and release its associated resources
  26260. * @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)
  26261. * @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)
  26262. * @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)
  26263. */
  26264. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26265. /**
  26266. * Creates a MultiMaterial from parsed MultiMaterial data.
  26267. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26268. * @param scene defines the hosting scene
  26269. * @returns a new MultiMaterial
  26270. */
  26271. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26272. }
  26273. }
  26274. declare module "babylonjs/Meshes/subMesh" {
  26275. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26276. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26277. import { Engine } from "babylonjs/Engines/engine";
  26278. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26279. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26280. import { Effect } from "babylonjs/Materials/effect";
  26281. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26282. import { Plane } from "babylonjs/Maths/math.plane";
  26283. import { Collider } from "babylonjs/Collisions/collider";
  26284. import { Material } from "babylonjs/Materials/material";
  26285. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26287. import { Mesh } from "babylonjs/Meshes/mesh";
  26288. import { Ray } from "babylonjs/Culling/ray";
  26289. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26290. /**
  26291. * Defines a subdivision inside a mesh
  26292. */
  26293. export class SubMesh implements ICullable {
  26294. /** the material index to use */
  26295. materialIndex: number;
  26296. /** vertex index start */
  26297. verticesStart: number;
  26298. /** vertices count */
  26299. verticesCount: number;
  26300. /** index start */
  26301. indexStart: number;
  26302. /** indices count */
  26303. indexCount: number;
  26304. /** @hidden */
  26305. _materialDefines: Nullable<MaterialDefines>;
  26306. /** @hidden */
  26307. _materialEffect: Nullable<Effect>;
  26308. /** @hidden */
  26309. _effectOverride: Nullable<Effect>;
  26310. /**
  26311. * Gets material defines used by the effect associated to the sub mesh
  26312. */
  26313. get materialDefines(): Nullable<MaterialDefines>;
  26314. /**
  26315. * Sets material defines used by the effect associated to the sub mesh
  26316. */
  26317. set materialDefines(defines: Nullable<MaterialDefines>);
  26318. /**
  26319. * Gets associated effect
  26320. */
  26321. get effect(): Nullable<Effect>;
  26322. /**
  26323. * Sets associated effect (effect used to render this submesh)
  26324. * @param effect defines the effect to associate with
  26325. * @param defines defines the set of defines used to compile this effect
  26326. */
  26327. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26328. /** @hidden */
  26329. _linesIndexCount: number;
  26330. private _mesh;
  26331. private _renderingMesh;
  26332. private _boundingInfo;
  26333. private _linesIndexBuffer;
  26334. /** @hidden */
  26335. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26336. /** @hidden */
  26337. _trianglePlanes: Plane[];
  26338. /** @hidden */
  26339. _lastColliderTransformMatrix: Nullable<Matrix>;
  26340. /** @hidden */
  26341. _renderId: number;
  26342. /** @hidden */
  26343. _alphaIndex: number;
  26344. /** @hidden */
  26345. _distanceToCamera: number;
  26346. /** @hidden */
  26347. _id: number;
  26348. private _currentMaterial;
  26349. /**
  26350. * Add a new submesh to a mesh
  26351. * @param materialIndex defines the material index to use
  26352. * @param verticesStart defines vertex index start
  26353. * @param verticesCount defines vertices count
  26354. * @param indexStart defines index start
  26355. * @param indexCount defines indices count
  26356. * @param mesh defines the parent mesh
  26357. * @param renderingMesh defines an optional rendering mesh
  26358. * @param createBoundingBox defines if bounding box should be created for this submesh
  26359. * @returns the new submesh
  26360. */
  26361. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26362. /**
  26363. * Creates a new submesh
  26364. * @param materialIndex defines the material index to use
  26365. * @param verticesStart defines vertex index start
  26366. * @param verticesCount defines vertices count
  26367. * @param indexStart defines index start
  26368. * @param indexCount defines indices count
  26369. * @param mesh defines the parent mesh
  26370. * @param renderingMesh defines an optional rendering mesh
  26371. * @param createBoundingBox defines if bounding box should be created for this submesh
  26372. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26373. */
  26374. constructor(
  26375. /** the material index to use */
  26376. materialIndex: number,
  26377. /** vertex index start */
  26378. verticesStart: number,
  26379. /** vertices count */
  26380. verticesCount: number,
  26381. /** index start */
  26382. indexStart: number,
  26383. /** indices count */
  26384. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26385. /**
  26386. * Returns true if this submesh covers the entire parent mesh
  26387. * @ignorenaming
  26388. */
  26389. get IsGlobal(): boolean;
  26390. /**
  26391. * Returns the submesh BoudingInfo object
  26392. * @returns current bounding info (or mesh's one if the submesh is global)
  26393. */
  26394. getBoundingInfo(): BoundingInfo;
  26395. /**
  26396. * Sets the submesh BoundingInfo
  26397. * @param boundingInfo defines the new bounding info to use
  26398. * @returns the SubMesh
  26399. */
  26400. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26401. /**
  26402. * Returns the mesh of the current submesh
  26403. * @return the parent mesh
  26404. */
  26405. getMesh(): AbstractMesh;
  26406. /**
  26407. * Returns the rendering mesh of the submesh
  26408. * @returns the rendering mesh (could be different from parent mesh)
  26409. */
  26410. getRenderingMesh(): Mesh;
  26411. /**
  26412. * Returns the replacement mesh of the submesh
  26413. * @returns the replacement mesh (could be different from parent mesh)
  26414. */
  26415. getReplacementMesh(): Nullable<AbstractMesh>;
  26416. /**
  26417. * Returns the effective mesh of the submesh
  26418. * @returns the effective mesh (could be different from parent mesh)
  26419. */
  26420. getEffectiveMesh(): AbstractMesh;
  26421. /**
  26422. * Returns the submesh material
  26423. * @returns null or the current material
  26424. */
  26425. getMaterial(): Nullable<Material>;
  26426. private _IsMultiMaterial;
  26427. /**
  26428. * Sets a new updated BoundingInfo object to the submesh
  26429. * @param data defines an optional position array to use to determine the bounding info
  26430. * @returns the SubMesh
  26431. */
  26432. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26433. /** @hidden */
  26434. _checkCollision(collider: Collider): boolean;
  26435. /**
  26436. * Updates the submesh BoundingInfo
  26437. * @param world defines the world matrix to use to update the bounding info
  26438. * @returns the submesh
  26439. */
  26440. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26441. /**
  26442. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26443. * @param frustumPlanes defines the frustum planes
  26444. * @returns true if the submesh is intersecting with the frustum
  26445. */
  26446. isInFrustum(frustumPlanes: Plane[]): boolean;
  26447. /**
  26448. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26449. * @param frustumPlanes defines the frustum planes
  26450. * @returns true if the submesh is inside the frustum
  26451. */
  26452. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26453. /**
  26454. * Renders the submesh
  26455. * @param enableAlphaMode defines if alpha needs to be used
  26456. * @returns the submesh
  26457. */
  26458. render(enableAlphaMode: boolean): SubMesh;
  26459. /**
  26460. * @hidden
  26461. */
  26462. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26463. /**
  26464. * Checks if the submesh intersects with a ray
  26465. * @param ray defines the ray to test
  26466. * @returns true is the passed ray intersects the submesh bounding box
  26467. */
  26468. canIntersects(ray: Ray): boolean;
  26469. /**
  26470. * Intersects current submesh with a ray
  26471. * @param ray defines the ray to test
  26472. * @param positions defines mesh's positions array
  26473. * @param indices defines mesh's indices array
  26474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26476. * @returns intersection info or null if no intersection
  26477. */
  26478. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26479. /** @hidden */
  26480. private _intersectLines;
  26481. /** @hidden */
  26482. private _intersectUnIndexedLines;
  26483. /** @hidden */
  26484. private _intersectTriangles;
  26485. /** @hidden */
  26486. private _intersectUnIndexedTriangles;
  26487. /** @hidden */
  26488. _rebuild(): void;
  26489. /**
  26490. * Creates a new submesh from the passed mesh
  26491. * @param newMesh defines the new hosting mesh
  26492. * @param newRenderingMesh defines an optional rendering mesh
  26493. * @returns the new submesh
  26494. */
  26495. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26496. /**
  26497. * Release associated resources
  26498. */
  26499. dispose(): void;
  26500. /**
  26501. * Gets the class name
  26502. * @returns the string "SubMesh".
  26503. */
  26504. getClassName(): string;
  26505. /**
  26506. * Creates a new submesh from indices data
  26507. * @param materialIndex the index of the main mesh material
  26508. * @param startIndex the index where to start the copy in the mesh indices array
  26509. * @param indexCount the number of indices to copy then from the startIndex
  26510. * @param mesh the main mesh to create the submesh from
  26511. * @param renderingMesh the optional rendering mesh
  26512. * @returns a new submesh
  26513. */
  26514. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26515. }
  26516. }
  26517. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26518. /**
  26519. * Class used to represent data loading progression
  26520. */
  26521. export class SceneLoaderFlags {
  26522. private static _ForceFullSceneLoadingForIncremental;
  26523. private static _ShowLoadingScreen;
  26524. private static _CleanBoneMatrixWeights;
  26525. private static _loggingLevel;
  26526. /**
  26527. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26528. */
  26529. static get ForceFullSceneLoadingForIncremental(): boolean;
  26530. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26531. /**
  26532. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26533. */
  26534. static get ShowLoadingScreen(): boolean;
  26535. static set ShowLoadingScreen(value: boolean);
  26536. /**
  26537. * Defines the current logging level (while loading the scene)
  26538. * @ignorenaming
  26539. */
  26540. static get loggingLevel(): number;
  26541. static set loggingLevel(value: number);
  26542. /**
  26543. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26544. */
  26545. static get CleanBoneMatrixWeights(): boolean;
  26546. static set CleanBoneMatrixWeights(value: boolean);
  26547. }
  26548. }
  26549. declare module "babylonjs/Meshes/geometry" {
  26550. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26551. import { Scene } from "babylonjs/scene";
  26552. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26553. import { Engine } from "babylonjs/Engines/engine";
  26554. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26555. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26556. import { Effect } from "babylonjs/Materials/effect";
  26557. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26559. import { Mesh } from "babylonjs/Meshes/mesh";
  26560. /**
  26561. * Class used to store geometry data (vertex buffers + index buffer)
  26562. */
  26563. export class Geometry implements IGetSetVerticesData {
  26564. /**
  26565. * Gets or sets the ID of the geometry
  26566. */
  26567. id: string;
  26568. /**
  26569. * Gets or sets the unique ID of the geometry
  26570. */
  26571. uniqueId: number;
  26572. /**
  26573. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26574. */
  26575. delayLoadState: number;
  26576. /**
  26577. * Gets the file containing the data to load when running in delay load state
  26578. */
  26579. delayLoadingFile: Nullable<string>;
  26580. /**
  26581. * Callback called when the geometry is updated
  26582. */
  26583. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26584. private _scene;
  26585. private _engine;
  26586. private _meshes;
  26587. private _totalVertices;
  26588. /** @hidden */
  26589. _indices: IndicesArray;
  26590. /** @hidden */
  26591. _vertexBuffers: {
  26592. [key: string]: VertexBuffer;
  26593. };
  26594. private _isDisposed;
  26595. private _extend;
  26596. private _boundingBias;
  26597. /** @hidden */
  26598. _delayInfo: Array<string>;
  26599. private _indexBuffer;
  26600. private _indexBufferIsUpdatable;
  26601. /** @hidden */
  26602. _boundingInfo: Nullable<BoundingInfo>;
  26603. /** @hidden */
  26604. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26605. /** @hidden */
  26606. _softwareSkinningFrameId: number;
  26607. private _vertexArrayObjects;
  26608. private _updatable;
  26609. /** @hidden */
  26610. _positions: Nullable<Vector3[]>;
  26611. /**
  26612. * 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
  26613. */
  26614. get boundingBias(): Vector2;
  26615. /**
  26616. * 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
  26617. */
  26618. set boundingBias(value: Vector2);
  26619. /**
  26620. * Static function used to attach a new empty geometry to a mesh
  26621. * @param mesh defines the mesh to attach the geometry to
  26622. * @returns the new Geometry
  26623. */
  26624. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26625. /** Get the list of meshes using this geometry */
  26626. get meshes(): Mesh[];
  26627. /**
  26628. * 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
  26629. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26630. */
  26631. useBoundingInfoFromGeometry: boolean;
  26632. /**
  26633. * Creates a new geometry
  26634. * @param id defines the unique ID
  26635. * @param scene defines the hosting scene
  26636. * @param vertexData defines the VertexData used to get geometry data
  26637. * @param updatable defines if geometry must be updatable (false by default)
  26638. * @param mesh defines the mesh that will be associated with the geometry
  26639. */
  26640. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26641. /**
  26642. * Gets the current extend of the geometry
  26643. */
  26644. get extend(): {
  26645. minimum: Vector3;
  26646. maximum: Vector3;
  26647. };
  26648. /**
  26649. * Gets the hosting scene
  26650. * @returns the hosting Scene
  26651. */
  26652. getScene(): Scene;
  26653. /**
  26654. * Gets the hosting engine
  26655. * @returns the hosting Engine
  26656. */
  26657. getEngine(): Engine;
  26658. /**
  26659. * Defines if the geometry is ready to use
  26660. * @returns true if the geometry is ready to be used
  26661. */
  26662. isReady(): boolean;
  26663. /**
  26664. * Gets a value indicating that the geometry should not be serialized
  26665. */
  26666. get doNotSerialize(): boolean;
  26667. /** @hidden */
  26668. _rebuild(): void;
  26669. /**
  26670. * Affects all geometry data in one call
  26671. * @param vertexData defines the geometry data
  26672. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26673. */
  26674. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26675. /**
  26676. * Set specific vertex data
  26677. * @param kind defines the data kind (Position, normal, etc...)
  26678. * @param data defines the vertex data to use
  26679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26681. */
  26682. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26683. /**
  26684. * Removes a specific vertex data
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. */
  26687. removeVerticesData(kind: string): void;
  26688. /**
  26689. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26690. * @param buffer defines the vertex buffer to use
  26691. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26692. */
  26693. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26694. /**
  26695. * Update a specific vertex buffer
  26696. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26697. * It will do nothing if the buffer is not updatable
  26698. * @param kind defines the data kind (Position, normal, etc...)
  26699. * @param data defines the data to use
  26700. * @param offset defines the offset in the target buffer where to store the data
  26701. * @param useBytes set to true if the offset is in bytes
  26702. */
  26703. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26704. /**
  26705. * Update a specific vertex buffer
  26706. * This function will create a new buffer if the current one is not updatable
  26707. * @param kind defines the data kind (Position, normal, etc...)
  26708. * @param data defines the data to use
  26709. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26710. */
  26711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26712. private _updateBoundingInfo;
  26713. /** @hidden */
  26714. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26715. /**
  26716. * Gets total number of vertices
  26717. * @returns the total number of vertices
  26718. */
  26719. getTotalVertices(): number;
  26720. /**
  26721. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26722. * @param kind defines the data kind (Position, normal, etc...)
  26723. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26724. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26725. * @returns a float array containing vertex data
  26726. */
  26727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26728. /**
  26729. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26730. * @param kind defines the data kind (Position, normal, etc...)
  26731. * @returns true if the vertex buffer with the specified kind is updatable
  26732. */
  26733. isVertexBufferUpdatable(kind: string): boolean;
  26734. /**
  26735. * Gets a specific vertex buffer
  26736. * @param kind defines the data kind (Position, normal, etc...)
  26737. * @returns a VertexBuffer
  26738. */
  26739. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26740. /**
  26741. * Returns all vertex buffers
  26742. * @return an object holding all vertex buffers indexed by kind
  26743. */
  26744. getVertexBuffers(): Nullable<{
  26745. [key: string]: VertexBuffer;
  26746. }>;
  26747. /**
  26748. * Gets a boolean indicating if specific vertex buffer is present
  26749. * @param kind defines the data kind (Position, normal, etc...)
  26750. * @returns true if data is present
  26751. */
  26752. isVerticesDataPresent(kind: string): boolean;
  26753. /**
  26754. * Gets a list of all attached data kinds (Position, normal, etc...)
  26755. * @returns a list of string containing all kinds
  26756. */
  26757. getVerticesDataKinds(): string[];
  26758. /**
  26759. * Update index buffer
  26760. * @param indices defines the indices to store in the index buffer
  26761. * @param offset defines the offset in the target buffer where to store the data
  26762. * @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)
  26763. */
  26764. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26765. /**
  26766. * Creates a new index buffer
  26767. * @param indices defines the indices to store in the index buffer
  26768. * @param totalVertices defines the total number of vertices (could be null)
  26769. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26770. */
  26771. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26772. /**
  26773. * Return the total number of indices
  26774. * @returns the total number of indices
  26775. */
  26776. getTotalIndices(): number;
  26777. /**
  26778. * Gets the index buffer array
  26779. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26780. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26781. * @returns the index buffer array
  26782. */
  26783. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26784. /**
  26785. * Gets the index buffer
  26786. * @return the index buffer
  26787. */
  26788. getIndexBuffer(): Nullable<DataBuffer>;
  26789. /** @hidden */
  26790. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26791. /**
  26792. * Release the associated resources for a specific mesh
  26793. * @param mesh defines the source mesh
  26794. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26795. */
  26796. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26797. /**
  26798. * Apply current geometry to a given mesh
  26799. * @param mesh defines the mesh to apply geometry to
  26800. */
  26801. applyToMesh(mesh: Mesh): void;
  26802. private _updateExtend;
  26803. private _applyToMesh;
  26804. private notifyUpdate;
  26805. /**
  26806. * Load the geometry if it was flagged as delay loaded
  26807. * @param scene defines the hosting scene
  26808. * @param onLoaded defines a callback called when the geometry is loaded
  26809. */
  26810. load(scene: Scene, onLoaded?: () => void): void;
  26811. private _queueLoad;
  26812. /**
  26813. * Invert the geometry to move from a right handed system to a left handed one.
  26814. */
  26815. toLeftHanded(): void;
  26816. /** @hidden */
  26817. _resetPointsArrayCache(): void;
  26818. /** @hidden */
  26819. _generatePointsArray(): boolean;
  26820. /**
  26821. * Gets a value indicating if the geometry is disposed
  26822. * @returns true if the geometry was disposed
  26823. */
  26824. isDisposed(): boolean;
  26825. private _disposeVertexArrayObjects;
  26826. /**
  26827. * Free all associated resources
  26828. */
  26829. dispose(): void;
  26830. /**
  26831. * Clone the current geometry into a new geometry
  26832. * @param id defines the unique ID of the new geometry
  26833. * @returns a new geometry object
  26834. */
  26835. copy(id: string): Geometry;
  26836. /**
  26837. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26838. * @return a JSON representation of the current geometry data (without the vertices data)
  26839. */
  26840. serialize(): any;
  26841. private toNumberArray;
  26842. /**
  26843. * Serialize all vertices data into a JSON oject
  26844. * @returns a JSON representation of the current geometry data
  26845. */
  26846. serializeVerticeData(): any;
  26847. /**
  26848. * Extracts a clone of a mesh geometry
  26849. * @param mesh defines the source mesh
  26850. * @param id defines the unique ID of the new geometry object
  26851. * @returns the new geometry object
  26852. */
  26853. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26854. /**
  26855. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26857. * Be aware Math.random() could cause collisions, but:
  26858. * "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"
  26859. * @returns a string containing a new GUID
  26860. */
  26861. static RandomId(): string;
  26862. /** @hidden */
  26863. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26864. private static _CleanMatricesWeights;
  26865. /**
  26866. * Create a new geometry from persisted data (Using .babylon file format)
  26867. * @param parsedVertexData defines the persisted data
  26868. * @param scene defines the hosting scene
  26869. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26870. * @returns the new geometry object
  26871. */
  26872. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26873. }
  26874. }
  26875. declare module "babylonjs/Meshes/mesh.vertexData" {
  26876. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26877. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26878. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26879. import { Geometry } from "babylonjs/Meshes/geometry";
  26880. import { Mesh } from "babylonjs/Meshes/mesh";
  26881. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26882. /**
  26883. * Define an interface for all classes that will get and set the data on vertices
  26884. */
  26885. export interface IGetSetVerticesData {
  26886. /**
  26887. * Gets a boolean indicating if specific vertex data is present
  26888. * @param kind defines the vertex data kind to use
  26889. * @returns true is data kind is present
  26890. */
  26891. isVerticesDataPresent(kind: string): boolean;
  26892. /**
  26893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26894. * @param kind defines the data kind (Position, normal, etc...)
  26895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26897. * @returns a float array containing vertex data
  26898. */
  26899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26900. /**
  26901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26902. * @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.
  26903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26904. * @returns the indices array or an empty array if the mesh has no geometry
  26905. */
  26906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26907. /**
  26908. * Set specific vertex data
  26909. * @param kind defines the data kind (Position, normal, etc...)
  26910. * @param data defines the vertex data to use
  26911. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26912. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26913. */
  26914. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26915. /**
  26916. * Update a specific associated vertex buffer
  26917. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26918. * - VertexBuffer.PositionKind
  26919. * - VertexBuffer.UVKind
  26920. * - VertexBuffer.UV2Kind
  26921. * - VertexBuffer.UV3Kind
  26922. * - VertexBuffer.UV4Kind
  26923. * - VertexBuffer.UV5Kind
  26924. * - VertexBuffer.UV6Kind
  26925. * - VertexBuffer.ColorKind
  26926. * - VertexBuffer.MatricesIndicesKind
  26927. * - VertexBuffer.MatricesIndicesExtraKind
  26928. * - VertexBuffer.MatricesWeightsKind
  26929. * - VertexBuffer.MatricesWeightsExtraKind
  26930. * @param data defines the data source
  26931. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26932. * @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)
  26933. */
  26934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26935. /**
  26936. * Creates a new index buffer
  26937. * @param indices defines the indices to store in the index buffer
  26938. * @param totalVertices defines the total number of vertices (could be null)
  26939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26940. */
  26941. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26942. }
  26943. /**
  26944. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26945. */
  26946. export class VertexData {
  26947. /**
  26948. * Mesh side orientation : usually the external or front surface
  26949. */
  26950. static readonly FRONTSIDE: number;
  26951. /**
  26952. * Mesh side orientation : usually the internal or back surface
  26953. */
  26954. static readonly BACKSIDE: number;
  26955. /**
  26956. * Mesh side orientation : both internal and external or front and back surfaces
  26957. */
  26958. static readonly DOUBLESIDE: number;
  26959. /**
  26960. * Mesh side orientation : by default, `FRONTSIDE`
  26961. */
  26962. static readonly DEFAULTSIDE: number;
  26963. /**
  26964. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26965. */
  26966. positions: Nullable<FloatArray>;
  26967. /**
  26968. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26969. */
  26970. normals: Nullable<FloatArray>;
  26971. /**
  26972. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26973. */
  26974. tangents: Nullable<FloatArray>;
  26975. /**
  26976. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26977. */
  26978. uvs: Nullable<FloatArray>;
  26979. /**
  26980. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26981. */
  26982. uvs2: Nullable<FloatArray>;
  26983. /**
  26984. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26985. */
  26986. uvs3: Nullable<FloatArray>;
  26987. /**
  26988. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26989. */
  26990. uvs4: Nullable<FloatArray>;
  26991. /**
  26992. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26993. */
  26994. uvs5: Nullable<FloatArray>;
  26995. /**
  26996. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26997. */
  26998. uvs6: Nullable<FloatArray>;
  26999. /**
  27000. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27001. */
  27002. colors: Nullable<FloatArray>;
  27003. /**
  27004. * 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).
  27005. */
  27006. matricesIndices: Nullable<FloatArray>;
  27007. /**
  27008. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27009. */
  27010. matricesWeights: Nullable<FloatArray>;
  27011. /**
  27012. * An array extending the number of possible indices
  27013. */
  27014. matricesIndicesExtra: Nullable<FloatArray>;
  27015. /**
  27016. * An array extending the number of possible weights when the number of indices is extended
  27017. */
  27018. matricesWeightsExtra: Nullable<FloatArray>;
  27019. /**
  27020. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27021. */
  27022. indices: Nullable<IndicesArray>;
  27023. /**
  27024. * Uses the passed data array to set the set the values for the specified kind of data
  27025. * @param data a linear array of floating numbers
  27026. * @param kind the type of data that is being set, eg positions, colors etc
  27027. */
  27028. set(data: FloatArray, kind: string): void;
  27029. /**
  27030. * Associates the vertexData to the passed Mesh.
  27031. * Sets it as updatable or not (default `false`)
  27032. * @param mesh the mesh the vertexData is applied to
  27033. * @param updatable when used and having the value true allows new data to update the vertexData
  27034. * @returns the VertexData
  27035. */
  27036. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27037. /**
  27038. * Associates the vertexData to the passed Geometry.
  27039. * Sets it as updatable or not (default `false`)
  27040. * @param geometry the geometry the vertexData is applied to
  27041. * @param updatable when used and having the value true allows new data to update the vertexData
  27042. * @returns VertexData
  27043. */
  27044. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27045. /**
  27046. * Updates the associated mesh
  27047. * @param mesh the mesh to be updated
  27048. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27049. * @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
  27050. * @returns VertexData
  27051. */
  27052. updateMesh(mesh: Mesh): VertexData;
  27053. /**
  27054. * Updates the associated geometry
  27055. * @param geometry the geometry to be updated
  27056. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27057. * @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
  27058. * @returns VertexData.
  27059. */
  27060. updateGeometry(geometry: Geometry): VertexData;
  27061. private _applyTo;
  27062. private _update;
  27063. /**
  27064. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27065. * @param matrix the transforming matrix
  27066. * @returns the VertexData
  27067. */
  27068. transform(matrix: Matrix): VertexData;
  27069. /**
  27070. * Merges the passed VertexData into the current one
  27071. * @param other the VertexData to be merged into the current one
  27072. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27073. * @returns the modified VertexData
  27074. */
  27075. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27076. private _mergeElement;
  27077. private _validate;
  27078. /**
  27079. * Serializes the VertexData
  27080. * @returns a serialized object
  27081. */
  27082. serialize(): any;
  27083. /**
  27084. * Extracts the vertexData from a mesh
  27085. * @param mesh the mesh from which to extract the VertexData
  27086. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27088. * @returns the object VertexData associated to the passed mesh
  27089. */
  27090. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27091. /**
  27092. * Extracts the vertexData from the geometry
  27093. * @param geometry the geometry from which to extract the VertexData
  27094. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27096. * @returns the object VertexData associated to the passed mesh
  27097. */
  27098. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27099. private static _ExtractFrom;
  27100. /**
  27101. * Creates the VertexData for a Ribbon
  27102. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27103. * * pathArray array of paths, each of which an array of successive Vector3
  27104. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27105. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27106. * * 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
  27107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27108. * * 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)
  27109. * * 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)
  27110. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27111. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27112. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27113. * @returns the VertexData of the ribbon
  27114. */
  27115. static CreateRibbon(options: {
  27116. pathArray: Vector3[][];
  27117. closeArray?: boolean;
  27118. closePath?: boolean;
  27119. offset?: number;
  27120. sideOrientation?: number;
  27121. frontUVs?: Vector4;
  27122. backUVs?: Vector4;
  27123. invertUV?: boolean;
  27124. uvs?: Vector2[];
  27125. colors?: Color4[];
  27126. }): VertexData;
  27127. /**
  27128. * Creates the VertexData for a box
  27129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27130. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27131. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27132. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27133. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27137. * * 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)
  27138. * * 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)
  27139. * @returns the VertexData of the box
  27140. */
  27141. static CreateBox(options: {
  27142. size?: number;
  27143. width?: number;
  27144. height?: number;
  27145. depth?: number;
  27146. faceUV?: Vector4[];
  27147. faceColors?: Color4[];
  27148. sideOrientation?: number;
  27149. frontUVs?: Vector4;
  27150. backUVs?: Vector4;
  27151. }): VertexData;
  27152. /**
  27153. * Creates the VertexData for a tiled box
  27154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27155. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27156. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27157. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27159. * @returns the VertexData of the box
  27160. */
  27161. static CreateTiledBox(options: {
  27162. pattern?: number;
  27163. width?: number;
  27164. height?: number;
  27165. depth?: number;
  27166. tileSize?: number;
  27167. tileWidth?: number;
  27168. tileHeight?: number;
  27169. alignHorizontal?: number;
  27170. alignVertical?: number;
  27171. faceUV?: Vector4[];
  27172. faceColors?: Color4[];
  27173. sideOrientation?: number;
  27174. }): VertexData;
  27175. /**
  27176. * Creates the VertexData for a tiled plane
  27177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27178. * * pattern a limited pattern arrangement depending on the number
  27179. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27180. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27181. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27183. * * 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)
  27184. * * 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)
  27185. * @returns the VertexData of the tiled plane
  27186. */
  27187. static CreateTiledPlane(options: {
  27188. pattern?: number;
  27189. tileSize?: number;
  27190. tileWidth?: number;
  27191. tileHeight?: number;
  27192. size?: number;
  27193. width?: number;
  27194. height?: number;
  27195. alignHorizontal?: number;
  27196. alignVertical?: number;
  27197. sideOrientation?: number;
  27198. frontUVs?: Vector4;
  27199. backUVs?: Vector4;
  27200. }): VertexData;
  27201. /**
  27202. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27204. * * segments sets the number of horizontal strips optional, default 32
  27205. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27206. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27207. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27208. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27209. * * 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
  27210. * * 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
  27211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27212. * * 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)
  27213. * * 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)
  27214. * @returns the VertexData of the ellipsoid
  27215. */
  27216. static CreateSphere(options: {
  27217. segments?: number;
  27218. diameter?: number;
  27219. diameterX?: number;
  27220. diameterY?: number;
  27221. diameterZ?: number;
  27222. arc?: number;
  27223. slice?: number;
  27224. sideOrientation?: number;
  27225. frontUVs?: Vector4;
  27226. backUVs?: Vector4;
  27227. }): VertexData;
  27228. /**
  27229. * Creates the VertexData for a cylinder, cone or prism
  27230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27231. * * height sets the height (y direction) of the cylinder, optional, default 2
  27232. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27233. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27234. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27236. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27237. * * 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
  27238. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27239. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27240. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27241. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27243. * * 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)
  27244. * * 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)
  27245. * @returns the VertexData of the cylinder, cone or prism
  27246. */
  27247. static CreateCylinder(options: {
  27248. height?: number;
  27249. diameterTop?: number;
  27250. diameterBottom?: number;
  27251. diameter?: number;
  27252. tessellation?: number;
  27253. subdivisions?: number;
  27254. arc?: number;
  27255. faceColors?: Color4[];
  27256. faceUV?: Vector4[];
  27257. hasRings?: boolean;
  27258. enclose?: boolean;
  27259. sideOrientation?: number;
  27260. frontUVs?: Vector4;
  27261. backUVs?: Vector4;
  27262. }): VertexData;
  27263. /**
  27264. * Creates the VertexData for a torus
  27265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27266. * * diameter the diameter of the torus, optional default 1
  27267. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27268. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27270. * * 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)
  27271. * * 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)
  27272. * @returns the VertexData of the torus
  27273. */
  27274. static CreateTorus(options: {
  27275. diameter?: number;
  27276. thickness?: number;
  27277. tessellation?: number;
  27278. sideOrientation?: number;
  27279. frontUVs?: Vector4;
  27280. backUVs?: Vector4;
  27281. }): VertexData;
  27282. /**
  27283. * Creates the VertexData of the LineSystem
  27284. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27285. * - lines an array of lines, each line being an array of successive Vector3
  27286. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27287. * @returns the VertexData of the LineSystem
  27288. */
  27289. static CreateLineSystem(options: {
  27290. lines: Vector3[][];
  27291. colors?: Nullable<Color4[][]>;
  27292. }): VertexData;
  27293. /**
  27294. * Create the VertexData for a DashedLines
  27295. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27296. * - points an array successive Vector3
  27297. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27298. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27299. * - dashNb the intended total number of dashes, optional, default 200
  27300. * @returns the VertexData for the DashedLines
  27301. */
  27302. static CreateDashedLines(options: {
  27303. points: Vector3[];
  27304. dashSize?: number;
  27305. gapSize?: number;
  27306. dashNb?: number;
  27307. }): VertexData;
  27308. /**
  27309. * Creates the VertexData for a Ground
  27310. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27311. * - width the width (x direction) of the ground, optional, default 1
  27312. * - height the height (z direction) of the ground, optional, default 1
  27313. * - subdivisions the number of subdivisions per side, optional, default 1
  27314. * @returns the VertexData of the Ground
  27315. */
  27316. static CreateGround(options: {
  27317. width?: number;
  27318. height?: number;
  27319. subdivisions?: number;
  27320. subdivisionsX?: number;
  27321. subdivisionsY?: number;
  27322. }): VertexData;
  27323. /**
  27324. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27325. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27326. * * xmin the ground minimum X coordinate, optional, default -1
  27327. * * zmin the ground minimum Z coordinate, optional, default -1
  27328. * * xmax the ground maximum X coordinate, optional, default 1
  27329. * * zmax the ground maximum Z coordinate, optional, default 1
  27330. * * 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}
  27331. * * 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}
  27332. * @returns the VertexData of the TiledGround
  27333. */
  27334. static CreateTiledGround(options: {
  27335. xmin: number;
  27336. zmin: number;
  27337. xmax: number;
  27338. zmax: number;
  27339. subdivisions?: {
  27340. w: number;
  27341. h: number;
  27342. };
  27343. precision?: {
  27344. w: number;
  27345. h: number;
  27346. };
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData of the Ground designed from a heightmap
  27350. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27351. * * width the width (x direction) of the ground
  27352. * * height the height (z direction) of the ground
  27353. * * subdivisions the number of subdivisions per side
  27354. * * minHeight the minimum altitude on the ground, optional, default 0
  27355. * * maxHeight the maximum altitude on the ground, optional default 1
  27356. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27357. * * buffer the array holding the image color data
  27358. * * bufferWidth the width of image
  27359. * * bufferHeight the height of image
  27360. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27361. * @returns the VertexData of the Ground designed from a heightmap
  27362. */
  27363. static CreateGroundFromHeightMap(options: {
  27364. width: number;
  27365. height: number;
  27366. subdivisions: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. colorFilter: Color3;
  27370. buffer: Uint8Array;
  27371. bufferWidth: number;
  27372. bufferHeight: number;
  27373. alphaFilter: number;
  27374. }): VertexData;
  27375. /**
  27376. * Creates the VertexData for a Plane
  27377. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27378. * * size sets the width and height of the plane to the value of size, optional default 1
  27379. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27380. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27382. * * 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)
  27383. * * 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)
  27384. * @returns the VertexData of the box
  27385. */
  27386. static CreatePlane(options: {
  27387. size?: number;
  27388. width?: number;
  27389. height?: number;
  27390. sideOrientation?: number;
  27391. frontUVs?: Vector4;
  27392. backUVs?: Vector4;
  27393. }): VertexData;
  27394. /**
  27395. * Creates the VertexData of the Disc or regular Polygon
  27396. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27397. * * radius the radius of the disc, optional default 0.5
  27398. * * tessellation the number of polygon sides, optional, default 64
  27399. * * 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
  27400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27401. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27402. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27403. * @returns the VertexData of the box
  27404. */
  27405. static CreateDisc(options: {
  27406. radius?: number;
  27407. tessellation?: number;
  27408. arc?: number;
  27409. sideOrientation?: number;
  27410. frontUVs?: Vector4;
  27411. backUVs?: Vector4;
  27412. }): VertexData;
  27413. /**
  27414. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27415. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27416. * @param polygon a mesh built from polygonTriangulation.build()
  27417. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27418. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27419. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27420. * @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)
  27421. * @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)
  27422. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27423. * @returns the VertexData of the Polygon
  27424. */
  27425. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27426. /**
  27427. * Creates the VertexData of the IcoSphere
  27428. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27429. * * radius the radius of the IcoSphere, optional default 1
  27430. * * radiusX allows stretching in the x direction, optional, default radius
  27431. * * radiusY allows stretching in the y direction, optional, default radius
  27432. * * radiusZ allows stretching in the z direction, optional, default radius
  27433. * * flat when true creates a flat shaded mesh, optional, default true
  27434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27436. * * 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)
  27437. * * 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)
  27438. * @returns the VertexData of the IcoSphere
  27439. */
  27440. static CreateIcoSphere(options: {
  27441. radius?: number;
  27442. radiusX?: number;
  27443. radiusY?: number;
  27444. radiusZ?: number;
  27445. flat?: boolean;
  27446. subdivisions?: number;
  27447. sideOrientation?: number;
  27448. frontUVs?: Vector4;
  27449. backUVs?: Vector4;
  27450. }): VertexData;
  27451. /**
  27452. * Creates the VertexData for a Polyhedron
  27453. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27454. * * type provided types are:
  27455. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27456. * * 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)
  27457. * * size the size of the IcoSphere, optional default 1
  27458. * * sizeX allows stretching in the x direction, optional, default size
  27459. * * sizeY allows stretching in the y direction, optional, default size
  27460. * * sizeZ allows stretching in the z direction, optional, default size
  27461. * * 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
  27462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27463. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27464. * * flat when true creates a flat shaded mesh, optional, default true
  27465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27467. * * 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)
  27468. * * 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)
  27469. * @returns the VertexData of the Polyhedron
  27470. */
  27471. static CreatePolyhedron(options: {
  27472. type?: number;
  27473. size?: number;
  27474. sizeX?: number;
  27475. sizeY?: number;
  27476. sizeZ?: number;
  27477. custom?: any;
  27478. faceUV?: Vector4[];
  27479. faceColors?: Color4[];
  27480. flat?: boolean;
  27481. sideOrientation?: number;
  27482. frontUVs?: Vector4;
  27483. backUVs?: Vector4;
  27484. }): VertexData;
  27485. /**
  27486. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27487. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27488. * @returns the VertexData of the Capsule
  27489. */
  27490. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27491. /**
  27492. * Creates the VertexData for a TorusKnot
  27493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27494. * * radius the radius of the torus knot, optional, default 2
  27495. * * tube the thickness of the tube, optional, default 0.5
  27496. * * radialSegments the number of sides on each tube segments, optional, default 32
  27497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27498. * * p the number of windings around the z axis, optional, default 2
  27499. * * q the number of windings around the x axis, optional, default 3
  27500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27501. * * 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)
  27502. * * 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)
  27503. * @returns the VertexData of the Torus Knot
  27504. */
  27505. static CreateTorusKnot(options: {
  27506. radius?: number;
  27507. tube?: number;
  27508. radialSegments?: number;
  27509. tubularSegments?: number;
  27510. p?: number;
  27511. q?: number;
  27512. sideOrientation?: number;
  27513. frontUVs?: Vector4;
  27514. backUVs?: Vector4;
  27515. }): VertexData;
  27516. /**
  27517. * Compute normals for given positions and indices
  27518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27522. * * facetNormals : optional array of facet normals (vector3)
  27523. * * facetPositions : optional array of facet positions (vector3)
  27524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27526. * * bInfo : optional bounding info, required for facetPartitioning computation
  27527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27529. * * useRightHandedSystem: optional boolean to for right handed system computation
  27530. * * depthSort : optional boolean to enable the facet depth sort computation
  27531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27533. */
  27534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27535. facetNormals?: any;
  27536. facetPositions?: any;
  27537. facetPartitioning?: any;
  27538. ratio?: number;
  27539. bInfo?: any;
  27540. bbSize?: Vector3;
  27541. subDiv?: any;
  27542. useRightHandedSystem?: boolean;
  27543. depthSort?: boolean;
  27544. distanceTo?: Vector3;
  27545. depthSortedFacets?: any;
  27546. }): void;
  27547. /** @hidden */
  27548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27549. /**
  27550. * Applies VertexData created from the imported parameters to the geometry
  27551. * @param parsedVertexData the parsed data from an imported file
  27552. * @param geometry the geometry to apply the VertexData to
  27553. */
  27554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27555. }
  27556. }
  27557. declare module "babylonjs/Morph/morphTarget" {
  27558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27559. import { Observable } from "babylonjs/Misc/observable";
  27560. import { Nullable, FloatArray } from "babylonjs/types";
  27561. import { Scene } from "babylonjs/scene";
  27562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27563. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27564. /**
  27565. * Defines a target to use with MorphTargetManager
  27566. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27567. */
  27568. export class MorphTarget implements IAnimatable {
  27569. /** defines the name of the target */
  27570. name: string;
  27571. /**
  27572. * Gets or sets the list of animations
  27573. */
  27574. animations: import("babylonjs/Animations/animation").Animation[];
  27575. private _scene;
  27576. private _positions;
  27577. private _normals;
  27578. private _tangents;
  27579. private _uvs;
  27580. private _influence;
  27581. private _uniqueId;
  27582. /**
  27583. * Observable raised when the influence changes
  27584. */
  27585. onInfluenceChanged: Observable<boolean>;
  27586. /** @hidden */
  27587. _onDataLayoutChanged: Observable<void>;
  27588. /**
  27589. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27590. */
  27591. get influence(): number;
  27592. set influence(influence: number);
  27593. /**
  27594. * Gets or sets the id of the morph Target
  27595. */
  27596. id: string;
  27597. private _animationPropertiesOverride;
  27598. /**
  27599. * Gets or sets the animation properties override
  27600. */
  27601. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27602. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27603. /**
  27604. * Creates a new MorphTarget
  27605. * @param name defines the name of the target
  27606. * @param influence defines the influence to use
  27607. * @param scene defines the scene the morphtarget belongs to
  27608. */
  27609. constructor(
  27610. /** defines the name of the target */
  27611. name: string, influence?: number, scene?: Nullable<Scene>);
  27612. /**
  27613. * Gets the unique ID of this manager
  27614. */
  27615. get uniqueId(): number;
  27616. /**
  27617. * Gets a boolean defining if the target contains position data
  27618. */
  27619. get hasPositions(): boolean;
  27620. /**
  27621. * Gets a boolean defining if the target contains normal data
  27622. */
  27623. get hasNormals(): boolean;
  27624. /**
  27625. * Gets a boolean defining if the target contains tangent data
  27626. */
  27627. get hasTangents(): boolean;
  27628. /**
  27629. * Gets a boolean defining if the target contains texture coordinates data
  27630. */
  27631. get hasUVs(): boolean;
  27632. /**
  27633. * Affects position data to this target
  27634. * @param data defines the position data to use
  27635. */
  27636. setPositions(data: Nullable<FloatArray>): void;
  27637. /**
  27638. * Gets the position data stored in this target
  27639. * @returns a FloatArray containing the position data (or null if not present)
  27640. */
  27641. getPositions(): Nullable<FloatArray>;
  27642. /**
  27643. * Affects normal data to this target
  27644. * @param data defines the normal data to use
  27645. */
  27646. setNormals(data: Nullable<FloatArray>): void;
  27647. /**
  27648. * Gets the normal data stored in this target
  27649. * @returns a FloatArray containing the normal data (or null if not present)
  27650. */
  27651. getNormals(): Nullable<FloatArray>;
  27652. /**
  27653. * Affects tangent data to this target
  27654. * @param data defines the tangent data to use
  27655. */
  27656. setTangents(data: Nullable<FloatArray>): void;
  27657. /**
  27658. * Gets the tangent data stored in this target
  27659. * @returns a FloatArray containing the tangent data (or null if not present)
  27660. */
  27661. getTangents(): Nullable<FloatArray>;
  27662. /**
  27663. * Affects texture coordinates data to this target
  27664. * @param data defines the texture coordinates data to use
  27665. */
  27666. setUVs(data: Nullable<FloatArray>): void;
  27667. /**
  27668. * Gets the texture coordinates data stored in this target
  27669. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27670. */
  27671. getUVs(): Nullable<FloatArray>;
  27672. /**
  27673. * Clone the current target
  27674. * @returns a new MorphTarget
  27675. */
  27676. clone(): MorphTarget;
  27677. /**
  27678. * Serializes the current target into a Serialization object
  27679. * @returns the serialized object
  27680. */
  27681. serialize(): any;
  27682. /**
  27683. * Returns the string "MorphTarget"
  27684. * @returns "MorphTarget"
  27685. */
  27686. getClassName(): string;
  27687. /**
  27688. * Creates a new target from serialized data
  27689. * @param serializationObject defines the serialized data to use
  27690. * @returns a new MorphTarget
  27691. */
  27692. static Parse(serializationObject: any): MorphTarget;
  27693. /**
  27694. * Creates a MorphTarget from mesh data
  27695. * @param mesh defines the source mesh
  27696. * @param name defines the name to use for the new target
  27697. * @param influence defines the influence to attach to the target
  27698. * @returns a new MorphTarget
  27699. */
  27700. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27701. }
  27702. }
  27703. declare module "babylonjs/Morph/morphTargetManager" {
  27704. import { Nullable } from "babylonjs/types";
  27705. import { Scene } from "babylonjs/scene";
  27706. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27707. /**
  27708. * This class is used to deform meshes using morphing between different targets
  27709. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27710. */
  27711. export class MorphTargetManager {
  27712. private _targets;
  27713. private _targetInfluenceChangedObservers;
  27714. private _targetDataLayoutChangedObservers;
  27715. private _activeTargets;
  27716. private _scene;
  27717. private _influences;
  27718. private _supportsNormals;
  27719. private _supportsTangents;
  27720. private _supportsUVs;
  27721. private _vertexCount;
  27722. private _uniqueId;
  27723. private _tempInfluences;
  27724. /**
  27725. * Gets or sets a boolean indicating if normals must be morphed
  27726. */
  27727. enableNormalMorphing: boolean;
  27728. /**
  27729. * Gets or sets a boolean indicating if tangents must be morphed
  27730. */
  27731. enableTangentMorphing: boolean;
  27732. /**
  27733. * Gets or sets a boolean indicating if UV must be morphed
  27734. */
  27735. enableUVMorphing: boolean;
  27736. /**
  27737. * Creates a new MorphTargetManager
  27738. * @param scene defines the current scene
  27739. */
  27740. constructor(scene?: Nullable<Scene>);
  27741. /**
  27742. * Gets the unique ID of this manager
  27743. */
  27744. get uniqueId(): number;
  27745. /**
  27746. * Gets the number of vertices handled by this manager
  27747. */
  27748. get vertexCount(): number;
  27749. /**
  27750. * Gets a boolean indicating if this manager supports morphing of normals
  27751. */
  27752. get supportsNormals(): boolean;
  27753. /**
  27754. * Gets a boolean indicating if this manager supports morphing of tangents
  27755. */
  27756. get supportsTangents(): boolean;
  27757. /**
  27758. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27759. */
  27760. get supportsUVs(): boolean;
  27761. /**
  27762. * Gets the number of targets stored in this manager
  27763. */
  27764. get numTargets(): number;
  27765. /**
  27766. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27767. */
  27768. get numInfluencers(): number;
  27769. /**
  27770. * Gets the list of influences (one per target)
  27771. */
  27772. get influences(): Float32Array;
  27773. /**
  27774. * Gets the active target at specified index. An active target is a target with an influence > 0
  27775. * @param index defines the index to check
  27776. * @returns the requested target
  27777. */
  27778. getActiveTarget(index: number): MorphTarget;
  27779. /**
  27780. * Gets the target at specified index
  27781. * @param index defines the index to check
  27782. * @returns the requested target
  27783. */
  27784. getTarget(index: number): MorphTarget;
  27785. /**
  27786. * Add a new target to this manager
  27787. * @param target defines the target to add
  27788. */
  27789. addTarget(target: MorphTarget): void;
  27790. /**
  27791. * Removes a target from the manager
  27792. * @param target defines the target to remove
  27793. */
  27794. removeTarget(target: MorphTarget): void;
  27795. /**
  27796. * Clone the current manager
  27797. * @returns a new MorphTargetManager
  27798. */
  27799. clone(): MorphTargetManager;
  27800. /**
  27801. * Serializes the current manager into a Serialization object
  27802. * @returns the serialized object
  27803. */
  27804. serialize(): any;
  27805. private _syncActiveTargets;
  27806. /**
  27807. * Syncrhonize the targets with all the meshes using this morph target manager
  27808. */
  27809. synchronize(): void;
  27810. /**
  27811. * Creates a new MorphTargetManager from serialized data
  27812. * @param serializationObject defines the serialized data
  27813. * @param scene defines the hosting scene
  27814. * @returns the new MorphTargetManager
  27815. */
  27816. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27817. }
  27818. }
  27819. declare module "babylonjs/Meshes/meshLODLevel" {
  27820. import { Mesh } from "babylonjs/Meshes/mesh";
  27821. import { Nullable } from "babylonjs/types";
  27822. /**
  27823. * Class used to represent a specific level of detail of a mesh
  27824. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27825. */
  27826. export class MeshLODLevel {
  27827. /** Defines the distance where this level should start being displayed */
  27828. distance: number;
  27829. /** Defines the mesh to use to render this level */
  27830. mesh: Nullable<Mesh>;
  27831. /**
  27832. * Creates a new LOD level
  27833. * @param distance defines the distance where this level should star being displayed
  27834. * @param mesh defines the mesh to use to render this level
  27835. */
  27836. constructor(
  27837. /** Defines the distance where this level should start being displayed */
  27838. distance: number,
  27839. /** Defines the mesh to use to render this level */
  27840. mesh: Nullable<Mesh>);
  27841. }
  27842. }
  27843. declare module "babylonjs/Misc/canvasGenerator" {
  27844. /**
  27845. * Helper class used to generate a canvas to manipulate images
  27846. */
  27847. export class CanvasGenerator {
  27848. /**
  27849. * Create a new canvas (or offscreen canvas depending on the context)
  27850. * @param width defines the expected width
  27851. * @param height defines the expected height
  27852. * @return a new canvas or offscreen canvas
  27853. */
  27854. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27855. }
  27856. }
  27857. declare module "babylonjs/Meshes/groundMesh" {
  27858. import { Scene } from "babylonjs/scene";
  27859. import { Vector3 } from "babylonjs/Maths/math.vector";
  27860. import { Mesh } from "babylonjs/Meshes/mesh";
  27861. /**
  27862. * Mesh representing the gorund
  27863. */
  27864. export class GroundMesh extends Mesh {
  27865. /** If octree should be generated */
  27866. generateOctree: boolean;
  27867. private _heightQuads;
  27868. /** @hidden */
  27869. _subdivisionsX: number;
  27870. /** @hidden */
  27871. _subdivisionsY: number;
  27872. /** @hidden */
  27873. _width: number;
  27874. /** @hidden */
  27875. _height: number;
  27876. /** @hidden */
  27877. _minX: number;
  27878. /** @hidden */
  27879. _maxX: number;
  27880. /** @hidden */
  27881. _minZ: number;
  27882. /** @hidden */
  27883. _maxZ: number;
  27884. constructor(name: string, scene: Scene);
  27885. /**
  27886. * "GroundMesh"
  27887. * @returns "GroundMesh"
  27888. */
  27889. getClassName(): string;
  27890. /**
  27891. * The minimum of x and y subdivisions
  27892. */
  27893. get subdivisions(): number;
  27894. /**
  27895. * X subdivisions
  27896. */
  27897. get subdivisionsX(): number;
  27898. /**
  27899. * Y subdivisions
  27900. */
  27901. get subdivisionsY(): number;
  27902. /**
  27903. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27905. * @param chunksCount the number of subdivisions for x and y
  27906. * @param octreeBlocksSize (Default: 32)
  27907. */
  27908. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27909. /**
  27910. * Returns a height (y) value in the Worl system :
  27911. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27912. * @param x x coordinate
  27913. * @param z z coordinate
  27914. * @returns the ground y position if (x, z) are outside the ground surface.
  27915. */
  27916. getHeightAtCoordinates(x: number, z: number): number;
  27917. /**
  27918. * Returns a normalized vector (Vector3) orthogonal to the ground
  27919. * at the ground coordinates (x, z) expressed in the World system.
  27920. * @param x x coordinate
  27921. * @param z z coordinate
  27922. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27923. */
  27924. getNormalAtCoordinates(x: number, z: number): Vector3;
  27925. /**
  27926. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27927. * at the ground coordinates (x, z) expressed in the World system.
  27928. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27929. * @param x x coordinate
  27930. * @param z z coordinate
  27931. * @param ref vector to store the result
  27932. * @returns the GroundMesh.
  27933. */
  27934. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27935. /**
  27936. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27937. * if the ground has been updated.
  27938. * This can be used in the render loop.
  27939. * @returns the GroundMesh.
  27940. */
  27941. updateCoordinateHeights(): GroundMesh;
  27942. private _getFacetAt;
  27943. private _initHeightQuads;
  27944. private _computeHeightQuads;
  27945. /**
  27946. * Serializes this ground mesh
  27947. * @param serializationObject object to write serialization to
  27948. */
  27949. serialize(serializationObject: any): void;
  27950. /**
  27951. * Parses a serialized ground mesh
  27952. * @param parsedMesh the serialized mesh
  27953. * @param scene the scene to create the ground mesh in
  27954. * @returns the created ground mesh
  27955. */
  27956. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27957. }
  27958. }
  27959. declare module "babylonjs/Physics/physicsJoint" {
  27960. import { Vector3 } from "babylonjs/Maths/math.vector";
  27961. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27962. /**
  27963. * Interface for Physics-Joint data
  27964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27965. */
  27966. export interface PhysicsJointData {
  27967. /**
  27968. * The main pivot of the joint
  27969. */
  27970. mainPivot?: Vector3;
  27971. /**
  27972. * The connected pivot of the joint
  27973. */
  27974. connectedPivot?: Vector3;
  27975. /**
  27976. * The main axis of the joint
  27977. */
  27978. mainAxis?: Vector3;
  27979. /**
  27980. * The connected axis of the joint
  27981. */
  27982. connectedAxis?: Vector3;
  27983. /**
  27984. * The collision of the joint
  27985. */
  27986. collision?: boolean;
  27987. /**
  27988. * Native Oimo/Cannon/Energy data
  27989. */
  27990. nativeParams?: any;
  27991. }
  27992. /**
  27993. * This is a holder class for the physics joint created by the physics plugin
  27994. * It holds a set of functions to control the underlying joint
  27995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27996. */
  27997. export class PhysicsJoint {
  27998. /**
  27999. * The type of the physics joint
  28000. */
  28001. type: number;
  28002. /**
  28003. * The data for the physics joint
  28004. */
  28005. jointData: PhysicsJointData;
  28006. private _physicsJoint;
  28007. protected _physicsPlugin: IPhysicsEnginePlugin;
  28008. /**
  28009. * Initializes the physics joint
  28010. * @param type The type of the physics joint
  28011. * @param jointData The data for the physics joint
  28012. */
  28013. constructor(
  28014. /**
  28015. * The type of the physics joint
  28016. */
  28017. type: number,
  28018. /**
  28019. * The data for the physics joint
  28020. */
  28021. jointData: PhysicsJointData);
  28022. /**
  28023. * Gets the physics joint
  28024. */
  28025. get physicsJoint(): any;
  28026. /**
  28027. * Sets the physics joint
  28028. */
  28029. set physicsJoint(newJoint: any);
  28030. /**
  28031. * Sets the physics plugin
  28032. */
  28033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28034. /**
  28035. * Execute a function that is physics-plugin specific.
  28036. * @param {Function} func the function that will be executed.
  28037. * It accepts two parameters: the physics world and the physics joint
  28038. */
  28039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28040. /**
  28041. * Distance-Joint type
  28042. */
  28043. static DistanceJoint: number;
  28044. /**
  28045. * Hinge-Joint type
  28046. */
  28047. static HingeJoint: number;
  28048. /**
  28049. * Ball-and-Socket joint type
  28050. */
  28051. static BallAndSocketJoint: number;
  28052. /**
  28053. * Wheel-Joint type
  28054. */
  28055. static WheelJoint: number;
  28056. /**
  28057. * Slider-Joint type
  28058. */
  28059. static SliderJoint: number;
  28060. /**
  28061. * Prismatic-Joint type
  28062. */
  28063. static PrismaticJoint: number;
  28064. /**
  28065. * Universal-Joint type
  28066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28067. */
  28068. static UniversalJoint: number;
  28069. /**
  28070. * Hinge-Joint 2 type
  28071. */
  28072. static Hinge2Joint: number;
  28073. /**
  28074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28075. */
  28076. static PointToPointJoint: number;
  28077. /**
  28078. * Spring-Joint type
  28079. */
  28080. static SpringJoint: number;
  28081. /**
  28082. * Lock-Joint type
  28083. */
  28084. static LockJoint: number;
  28085. }
  28086. /**
  28087. * A class representing a physics distance joint
  28088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28089. */
  28090. export class DistanceJoint extends PhysicsJoint {
  28091. /**
  28092. *
  28093. * @param jointData The data for the Distance-Joint
  28094. */
  28095. constructor(jointData: DistanceJointData);
  28096. /**
  28097. * Update the predefined distance.
  28098. * @param maxDistance The maximum preferred distance
  28099. * @param minDistance The minimum preferred distance
  28100. */
  28101. updateDistance(maxDistance: number, minDistance?: number): void;
  28102. }
  28103. /**
  28104. * Represents a Motor-Enabled Joint
  28105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28106. */
  28107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28108. /**
  28109. * Initializes the Motor-Enabled Joint
  28110. * @param type The type of the joint
  28111. * @param jointData The physica joint data for the joint
  28112. */
  28113. constructor(type: number, jointData: PhysicsJointData);
  28114. /**
  28115. * Set the motor values.
  28116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28117. * @param force the force to apply
  28118. * @param maxForce max force for this motor.
  28119. */
  28120. setMotor(force?: number, maxForce?: number): void;
  28121. /**
  28122. * Set the motor's limits.
  28123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28124. * @param upperLimit The upper limit of the motor
  28125. * @param lowerLimit The lower limit of the motor
  28126. */
  28127. setLimit(upperLimit: number, lowerLimit?: number): void;
  28128. }
  28129. /**
  28130. * This class represents a single physics Hinge-Joint
  28131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28132. */
  28133. export class HingeJoint extends MotorEnabledJoint {
  28134. /**
  28135. * Initializes the Hinge-Joint
  28136. * @param jointData The joint data for the Hinge-Joint
  28137. */
  28138. constructor(jointData: PhysicsJointData);
  28139. /**
  28140. * Set the motor values.
  28141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28142. * @param {number} force the force to apply
  28143. * @param {number} maxForce max force for this motor.
  28144. */
  28145. setMotor(force?: number, maxForce?: number): void;
  28146. /**
  28147. * Set the motor's limits.
  28148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28149. * @param upperLimit The upper limit of the motor
  28150. * @param lowerLimit The lower limit of the motor
  28151. */
  28152. setLimit(upperLimit: number, lowerLimit?: number): void;
  28153. }
  28154. /**
  28155. * This class represents a dual hinge physics joint (same as wheel joint)
  28156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28157. */
  28158. export class Hinge2Joint extends MotorEnabledJoint {
  28159. /**
  28160. * Initializes the Hinge2-Joint
  28161. * @param jointData The joint data for the Hinge2-Joint
  28162. */
  28163. constructor(jointData: PhysicsJointData);
  28164. /**
  28165. * Set the motor values.
  28166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28167. * @param {number} targetSpeed the speed the motor is to reach
  28168. * @param {number} maxForce max force for this motor.
  28169. * @param {motorIndex} the motor's index, 0 or 1.
  28170. */
  28171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28172. /**
  28173. * Set the motor limits.
  28174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28175. * @param {number} upperLimit the upper limit
  28176. * @param {number} lowerLimit lower limit
  28177. * @param {motorIndex} the motor's index, 0 or 1.
  28178. */
  28179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28180. }
  28181. /**
  28182. * Interface for a motor enabled joint
  28183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28184. */
  28185. export interface IMotorEnabledJoint {
  28186. /**
  28187. * Physics joint
  28188. */
  28189. physicsJoint: any;
  28190. /**
  28191. * Sets the motor of the motor-enabled joint
  28192. * @param force The force of the motor
  28193. * @param maxForce The maximum force of the motor
  28194. * @param motorIndex The index of the motor
  28195. */
  28196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28197. /**
  28198. * Sets the limit of the motor
  28199. * @param upperLimit The upper limit of the motor
  28200. * @param lowerLimit The lower limit of the motor
  28201. * @param motorIndex The index of the motor
  28202. */
  28203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28204. }
  28205. /**
  28206. * Joint data for a Distance-Joint
  28207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28208. */
  28209. export interface DistanceJointData extends PhysicsJointData {
  28210. /**
  28211. * Max distance the 2 joint objects can be apart
  28212. */
  28213. maxDistance: number;
  28214. }
  28215. /**
  28216. * Joint data from a spring joint
  28217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28218. */
  28219. export interface SpringJointData extends PhysicsJointData {
  28220. /**
  28221. * Length of the spring
  28222. */
  28223. length: number;
  28224. /**
  28225. * Stiffness of the spring
  28226. */
  28227. stiffness: number;
  28228. /**
  28229. * Damping of the spring
  28230. */
  28231. damping: number;
  28232. /** this callback will be called when applying the force to the impostors. */
  28233. forceApplicationCallback: () => void;
  28234. }
  28235. }
  28236. declare module "babylonjs/Physics/physicsRaycastResult" {
  28237. import { Vector3 } from "babylonjs/Maths/math.vector";
  28238. /**
  28239. * Holds the data for the raycast result
  28240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28241. */
  28242. export class PhysicsRaycastResult {
  28243. private _hasHit;
  28244. private _hitDistance;
  28245. private _hitNormalWorld;
  28246. private _hitPointWorld;
  28247. private _rayFromWorld;
  28248. private _rayToWorld;
  28249. /**
  28250. * Gets if there was a hit
  28251. */
  28252. get hasHit(): boolean;
  28253. /**
  28254. * Gets the distance from the hit
  28255. */
  28256. get hitDistance(): number;
  28257. /**
  28258. * Gets the hit normal/direction in the world
  28259. */
  28260. get hitNormalWorld(): Vector3;
  28261. /**
  28262. * Gets the hit point in the world
  28263. */
  28264. get hitPointWorld(): Vector3;
  28265. /**
  28266. * Gets the ray "start point" of the ray in the world
  28267. */
  28268. get rayFromWorld(): Vector3;
  28269. /**
  28270. * Gets the ray "end point" of the ray in the world
  28271. */
  28272. get rayToWorld(): Vector3;
  28273. /**
  28274. * Sets the hit data (normal & point in world space)
  28275. * @param hitNormalWorld defines the normal in world space
  28276. * @param hitPointWorld defines the point in world space
  28277. */
  28278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28279. /**
  28280. * Sets the distance from the start point to the hit point
  28281. * @param distance
  28282. */
  28283. setHitDistance(distance: number): void;
  28284. /**
  28285. * Calculates the distance manually
  28286. */
  28287. calculateHitDistance(): void;
  28288. /**
  28289. * Resets all the values to default
  28290. * @param from The from point on world space
  28291. * @param to The to point on world space
  28292. */
  28293. reset(from?: Vector3, to?: Vector3): void;
  28294. }
  28295. /**
  28296. * Interface for the size containing width and height
  28297. */
  28298. interface IXYZ {
  28299. /**
  28300. * X
  28301. */
  28302. x: number;
  28303. /**
  28304. * Y
  28305. */
  28306. y: number;
  28307. /**
  28308. * Z
  28309. */
  28310. z: number;
  28311. }
  28312. }
  28313. declare module "babylonjs/Physics/IPhysicsEngine" {
  28314. import { Nullable } from "babylonjs/types";
  28315. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28317. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28319. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28320. /**
  28321. * Interface used to describe a physics joint
  28322. */
  28323. export interface PhysicsImpostorJoint {
  28324. /** Defines the main impostor to which the joint is linked */
  28325. mainImpostor: PhysicsImpostor;
  28326. /** Defines the impostor that is connected to the main impostor using this joint */
  28327. connectedImpostor: PhysicsImpostor;
  28328. /** Defines the joint itself */
  28329. joint: PhysicsJoint;
  28330. }
  28331. /** @hidden */
  28332. export interface IPhysicsEnginePlugin {
  28333. world: any;
  28334. name: string;
  28335. setGravity(gravity: Vector3): void;
  28336. setTimeStep(timeStep: number): void;
  28337. getTimeStep(): number;
  28338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28342. removePhysicsBody(impostor: PhysicsImpostor): void;
  28343. generateJoint(joint: PhysicsImpostorJoint): void;
  28344. removeJoint(joint: PhysicsImpostorJoint): void;
  28345. isSupported(): boolean;
  28346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28348. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28349. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28350. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28351. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28352. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28353. getBodyMass(impostor: PhysicsImpostor): number;
  28354. getBodyFriction(impostor: PhysicsImpostor): number;
  28355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28356. getBodyRestitution(impostor: PhysicsImpostor): number;
  28357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28358. getBodyPressure?(impostor: PhysicsImpostor): number;
  28359. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28360. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28361. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28362. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28363. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28364. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28365. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28366. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28367. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28368. sleepBody(impostor: PhysicsImpostor): void;
  28369. wakeUpBody(impostor: PhysicsImpostor): void;
  28370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28372. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28374. getRadius(impostor: PhysicsImpostor): number;
  28375. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28377. dispose(): void;
  28378. }
  28379. /**
  28380. * Interface used to define a physics engine
  28381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28382. */
  28383. export interface IPhysicsEngine {
  28384. /**
  28385. * Gets the gravity vector used by the simulation
  28386. */
  28387. gravity: Vector3;
  28388. /**
  28389. * Sets the gravity vector used by the simulation
  28390. * @param gravity defines the gravity vector to use
  28391. */
  28392. setGravity(gravity: Vector3): void;
  28393. /**
  28394. * Set the time step of the physics engine.
  28395. * Default is 1/60.
  28396. * To slow it down, enter 1/600 for example.
  28397. * To speed it up, 1/30
  28398. * @param newTimeStep the new timestep to apply to this world.
  28399. */
  28400. setTimeStep(newTimeStep: number): void;
  28401. /**
  28402. * Get the time step of the physics engine.
  28403. * @returns the current time step
  28404. */
  28405. getTimeStep(): number;
  28406. /**
  28407. * Set the sub time step of the physics engine.
  28408. * Default is 0 meaning there is no sub steps
  28409. * To increase physics resolution precision, set a small value (like 1 ms)
  28410. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28411. */
  28412. setSubTimeStep(subTimeStep: number): void;
  28413. /**
  28414. * Get the sub time step of the physics engine.
  28415. * @returns the current sub time step
  28416. */
  28417. getSubTimeStep(): number;
  28418. /**
  28419. * Release all resources
  28420. */
  28421. dispose(): void;
  28422. /**
  28423. * Gets the name of the current physics plugin
  28424. * @returns the name of the plugin
  28425. */
  28426. getPhysicsPluginName(): string;
  28427. /**
  28428. * Adding a new impostor for the impostor tracking.
  28429. * This will be done by the impostor itself.
  28430. * @param impostor the impostor to add
  28431. */
  28432. addImpostor(impostor: PhysicsImpostor): void;
  28433. /**
  28434. * Remove an impostor from the engine.
  28435. * This impostor and its mesh will not longer be updated by the physics engine.
  28436. * @param impostor the impostor to remove
  28437. */
  28438. removeImpostor(impostor: PhysicsImpostor): void;
  28439. /**
  28440. * Add a joint to the physics engine
  28441. * @param mainImpostor defines the main impostor to which the joint is added.
  28442. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28443. * @param joint defines the joint that will connect both impostors.
  28444. */
  28445. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28446. /**
  28447. * Removes a joint from the simulation
  28448. * @param mainImpostor defines the impostor used with the joint
  28449. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28450. * @param joint defines the joint to remove
  28451. */
  28452. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28453. /**
  28454. * Gets the current plugin used to run the simulation
  28455. * @returns current plugin
  28456. */
  28457. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28458. /**
  28459. * Gets the list of physic impostors
  28460. * @returns an array of PhysicsImpostor
  28461. */
  28462. getImpostors(): Array<PhysicsImpostor>;
  28463. /**
  28464. * Gets the impostor for a physics enabled object
  28465. * @param object defines the object impersonated by the impostor
  28466. * @returns the PhysicsImpostor or null if not found
  28467. */
  28468. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28469. /**
  28470. * Gets the impostor for a physics body object
  28471. * @param body defines physics body used by the impostor
  28472. * @returns the PhysicsImpostor or null if not found
  28473. */
  28474. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28475. /**
  28476. * Does a raycast in the physics world
  28477. * @param from when should the ray start?
  28478. * @param to when should the ray end?
  28479. * @returns PhysicsRaycastResult
  28480. */
  28481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28482. /**
  28483. * Called by the scene. No need to call it.
  28484. * @param delta defines the timespam between frames
  28485. */
  28486. _step(delta: number): void;
  28487. }
  28488. }
  28489. declare module "babylonjs/Physics/physicsImpostor" {
  28490. import { Nullable, IndicesArray } from "babylonjs/types";
  28491. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28494. import { Scene } from "babylonjs/scene";
  28495. import { Bone } from "babylonjs/Bones/bone";
  28496. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28497. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28498. import { Space } from "babylonjs/Maths/math.axis";
  28499. /**
  28500. * The interface for the physics imposter parameters
  28501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28502. */
  28503. export interface PhysicsImpostorParameters {
  28504. /**
  28505. * The mass of the physics imposter
  28506. */
  28507. mass: number;
  28508. /**
  28509. * The friction of the physics imposter
  28510. */
  28511. friction?: number;
  28512. /**
  28513. * The coefficient of restitution of the physics imposter
  28514. */
  28515. restitution?: number;
  28516. /**
  28517. * The native options of the physics imposter
  28518. */
  28519. nativeOptions?: any;
  28520. /**
  28521. * Specifies if the parent should be ignored
  28522. */
  28523. ignoreParent?: boolean;
  28524. /**
  28525. * Specifies if bi-directional transformations should be disabled
  28526. */
  28527. disableBidirectionalTransformation?: boolean;
  28528. /**
  28529. * The pressure inside the physics imposter, soft object only
  28530. */
  28531. pressure?: number;
  28532. /**
  28533. * The stiffness the physics imposter, soft object only
  28534. */
  28535. stiffness?: number;
  28536. /**
  28537. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28538. */
  28539. velocityIterations?: number;
  28540. /**
  28541. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28542. */
  28543. positionIterations?: number;
  28544. /**
  28545. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28546. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28547. * Add to fix multiple points
  28548. */
  28549. fixedPoints?: number;
  28550. /**
  28551. * The collision margin around a soft object
  28552. */
  28553. margin?: number;
  28554. /**
  28555. * The collision margin around a soft object
  28556. */
  28557. damping?: number;
  28558. /**
  28559. * The path for a rope based on an extrusion
  28560. */
  28561. path?: any;
  28562. /**
  28563. * The shape of an extrusion used for a rope based on an extrusion
  28564. */
  28565. shape?: any;
  28566. }
  28567. /**
  28568. * Interface for a physics-enabled object
  28569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28570. */
  28571. export interface IPhysicsEnabledObject {
  28572. /**
  28573. * The position of the physics-enabled object
  28574. */
  28575. position: Vector3;
  28576. /**
  28577. * The rotation of the physics-enabled object
  28578. */
  28579. rotationQuaternion: Nullable<Quaternion>;
  28580. /**
  28581. * The scale of the physics-enabled object
  28582. */
  28583. scaling: Vector3;
  28584. /**
  28585. * The rotation of the physics-enabled object
  28586. */
  28587. rotation?: Vector3;
  28588. /**
  28589. * The parent of the physics-enabled object
  28590. */
  28591. parent?: any;
  28592. /**
  28593. * The bounding info of the physics-enabled object
  28594. * @returns The bounding info of the physics-enabled object
  28595. */
  28596. getBoundingInfo(): BoundingInfo;
  28597. /**
  28598. * Computes the world matrix
  28599. * @param force Specifies if the world matrix should be computed by force
  28600. * @returns A world matrix
  28601. */
  28602. computeWorldMatrix(force: boolean): Matrix;
  28603. /**
  28604. * Gets the world matrix
  28605. * @returns A world matrix
  28606. */
  28607. getWorldMatrix?(): Matrix;
  28608. /**
  28609. * Gets the child meshes
  28610. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28611. * @returns An array of abstract meshes
  28612. */
  28613. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28614. /**
  28615. * Gets the vertex data
  28616. * @param kind The type of vertex data
  28617. * @returns A nullable array of numbers, or a float32 array
  28618. */
  28619. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28620. /**
  28621. * Gets the indices from the mesh
  28622. * @returns A nullable array of index arrays
  28623. */
  28624. getIndices?(): Nullable<IndicesArray>;
  28625. /**
  28626. * Gets the scene from the mesh
  28627. * @returns the indices array or null
  28628. */
  28629. getScene?(): Scene;
  28630. /**
  28631. * Gets the absolute position from the mesh
  28632. * @returns the absolute position
  28633. */
  28634. getAbsolutePosition(): Vector3;
  28635. /**
  28636. * Gets the absolute pivot point from the mesh
  28637. * @returns the absolute pivot point
  28638. */
  28639. getAbsolutePivotPoint(): Vector3;
  28640. /**
  28641. * Rotates the mesh
  28642. * @param axis The axis of rotation
  28643. * @param amount The amount of rotation
  28644. * @param space The space of the rotation
  28645. * @returns The rotation transform node
  28646. */
  28647. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28648. /**
  28649. * Translates the mesh
  28650. * @param axis The axis of translation
  28651. * @param distance The distance of translation
  28652. * @param space The space of the translation
  28653. * @returns The transform node
  28654. */
  28655. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28656. /**
  28657. * Sets the absolute position of the mesh
  28658. * @param absolutePosition The absolute position of the mesh
  28659. * @returns The transform node
  28660. */
  28661. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28662. /**
  28663. * Gets the class name of the mesh
  28664. * @returns The class name
  28665. */
  28666. getClassName(): string;
  28667. }
  28668. /**
  28669. * Represents a physics imposter
  28670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28671. */
  28672. export class PhysicsImpostor {
  28673. /**
  28674. * The physics-enabled object used as the physics imposter
  28675. */
  28676. object: IPhysicsEnabledObject;
  28677. /**
  28678. * The type of the physics imposter
  28679. */
  28680. type: number;
  28681. private _options;
  28682. private _scene?;
  28683. /**
  28684. * The default object size of the imposter
  28685. */
  28686. static DEFAULT_OBJECT_SIZE: Vector3;
  28687. /**
  28688. * The identity quaternion of the imposter
  28689. */
  28690. static IDENTITY_QUATERNION: Quaternion;
  28691. /** @hidden */
  28692. _pluginData: any;
  28693. private _physicsEngine;
  28694. private _physicsBody;
  28695. private _bodyUpdateRequired;
  28696. private _onBeforePhysicsStepCallbacks;
  28697. private _onAfterPhysicsStepCallbacks;
  28698. /** @hidden */
  28699. _onPhysicsCollideCallbacks: Array<{
  28700. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28701. otherImpostors: Array<PhysicsImpostor>;
  28702. }>;
  28703. private _deltaPosition;
  28704. private _deltaRotation;
  28705. private _deltaRotationConjugated;
  28706. /** @hidden */
  28707. _isFromLine: boolean;
  28708. private _parent;
  28709. private _isDisposed;
  28710. private static _tmpVecs;
  28711. private static _tmpQuat;
  28712. /**
  28713. * Specifies if the physics imposter is disposed
  28714. */
  28715. get isDisposed(): boolean;
  28716. /**
  28717. * Gets the mass of the physics imposter
  28718. */
  28719. get mass(): number;
  28720. set mass(value: number);
  28721. /**
  28722. * Gets the coefficient of friction
  28723. */
  28724. get friction(): number;
  28725. /**
  28726. * Sets the coefficient of friction
  28727. */
  28728. set friction(value: number);
  28729. /**
  28730. * Gets the coefficient of restitution
  28731. */
  28732. get restitution(): number;
  28733. /**
  28734. * Sets the coefficient of restitution
  28735. */
  28736. set restitution(value: number);
  28737. /**
  28738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28739. */
  28740. get pressure(): number;
  28741. /**
  28742. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28743. */
  28744. set pressure(value: number);
  28745. /**
  28746. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28747. */
  28748. get stiffness(): number;
  28749. /**
  28750. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28751. */
  28752. set stiffness(value: number);
  28753. /**
  28754. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28755. */
  28756. get velocityIterations(): number;
  28757. /**
  28758. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28759. */
  28760. set velocityIterations(value: number);
  28761. /**
  28762. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28763. */
  28764. get positionIterations(): number;
  28765. /**
  28766. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28767. */
  28768. set positionIterations(value: number);
  28769. /**
  28770. * The unique id of the physics imposter
  28771. * set by the physics engine when adding this impostor to the array
  28772. */
  28773. uniqueId: number;
  28774. /**
  28775. * @hidden
  28776. */
  28777. soft: boolean;
  28778. /**
  28779. * @hidden
  28780. */
  28781. segments: number;
  28782. private _joints;
  28783. /**
  28784. * Initializes the physics imposter
  28785. * @param object The physics-enabled object used as the physics imposter
  28786. * @param type The type of the physics imposter
  28787. * @param _options The options for the physics imposter
  28788. * @param _scene The Babylon scene
  28789. */
  28790. constructor(
  28791. /**
  28792. * The physics-enabled object used as the physics imposter
  28793. */
  28794. object: IPhysicsEnabledObject,
  28795. /**
  28796. * The type of the physics imposter
  28797. */
  28798. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28799. /**
  28800. * This function will completly initialize this impostor.
  28801. * It will create a new body - but only if this mesh has no parent.
  28802. * If it has, this impostor will not be used other than to define the impostor
  28803. * of the child mesh.
  28804. * @hidden
  28805. */
  28806. _init(): void;
  28807. private _getPhysicsParent;
  28808. /**
  28809. * Should a new body be generated.
  28810. * @returns boolean specifying if body initialization is required
  28811. */
  28812. isBodyInitRequired(): boolean;
  28813. /**
  28814. * Sets the updated scaling
  28815. * @param updated Specifies if the scaling is updated
  28816. */
  28817. setScalingUpdated(): void;
  28818. /**
  28819. * Force a regeneration of this or the parent's impostor's body.
  28820. * Use under cautious - This will remove all joints already implemented.
  28821. */
  28822. forceUpdate(): void;
  28823. /**
  28824. * Gets the body that holds this impostor. Either its own, or its parent.
  28825. */
  28826. get physicsBody(): any;
  28827. /**
  28828. * Get the parent of the physics imposter
  28829. * @returns Physics imposter or null
  28830. */
  28831. get parent(): Nullable<PhysicsImpostor>;
  28832. /**
  28833. * Sets the parent of the physics imposter
  28834. */
  28835. set parent(value: Nullable<PhysicsImpostor>);
  28836. /**
  28837. * Set the physics body. Used mainly by the physics engine/plugin
  28838. */
  28839. set physicsBody(physicsBody: any);
  28840. /**
  28841. * Resets the update flags
  28842. */
  28843. resetUpdateFlags(): void;
  28844. /**
  28845. * Gets the object extend size
  28846. * @returns the object extend size
  28847. */
  28848. getObjectExtendSize(): Vector3;
  28849. /**
  28850. * Gets the object center
  28851. * @returns The object center
  28852. */
  28853. getObjectCenter(): Vector3;
  28854. /**
  28855. * Get a specific parameter from the options parameters
  28856. * @param paramName The object parameter name
  28857. * @returns The object parameter
  28858. */
  28859. getParam(paramName: string): any;
  28860. /**
  28861. * Sets a specific parameter in the options given to the physics plugin
  28862. * @param paramName The parameter name
  28863. * @param value The value of the parameter
  28864. */
  28865. setParam(paramName: string, value: number): void;
  28866. /**
  28867. * Specifically change the body's mass option. Won't recreate the physics body object
  28868. * @param mass The mass of the physics imposter
  28869. */
  28870. setMass(mass: number): void;
  28871. /**
  28872. * Gets the linear velocity
  28873. * @returns linear velocity or null
  28874. */
  28875. getLinearVelocity(): Nullable<Vector3>;
  28876. /**
  28877. * Sets the linear velocity
  28878. * @param velocity linear velocity or null
  28879. */
  28880. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28881. /**
  28882. * Gets the angular velocity
  28883. * @returns angular velocity or null
  28884. */
  28885. getAngularVelocity(): Nullable<Vector3>;
  28886. /**
  28887. * Sets the angular velocity
  28888. * @param velocity The velocity or null
  28889. */
  28890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28891. /**
  28892. * Execute a function with the physics plugin native code
  28893. * Provide a function the will have two variables - the world object and the physics body object
  28894. * @param func The function to execute with the physics plugin native code
  28895. */
  28896. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28897. /**
  28898. * Register a function that will be executed before the physics world is stepping forward
  28899. * @param func The function to execute before the physics world is stepped forward
  28900. */
  28901. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28902. /**
  28903. * Unregister a function that will be executed before the physics world is stepping forward
  28904. * @param func The function to execute before the physics world is stepped forward
  28905. */
  28906. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28907. /**
  28908. * Register a function that will be executed after the physics step
  28909. * @param func The function to execute after physics step
  28910. */
  28911. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28912. /**
  28913. * Unregisters a function that will be executed after the physics step
  28914. * @param func The function to execute after physics step
  28915. */
  28916. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28917. /**
  28918. * register a function that will be executed when this impostor collides against a different body
  28919. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28920. * @param func Callback that is executed on collision
  28921. */
  28922. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28923. /**
  28924. * Unregisters the physics imposter on contact
  28925. * @param collideAgainst The physics object to collide against
  28926. * @param func Callback to execute on collision
  28927. */
  28928. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28929. private _tmpQuat;
  28930. private _tmpQuat2;
  28931. /**
  28932. * Get the parent rotation
  28933. * @returns The parent rotation
  28934. */
  28935. getParentsRotation(): Quaternion;
  28936. /**
  28937. * this function is executed by the physics engine.
  28938. */
  28939. beforeStep: () => void;
  28940. /**
  28941. * this function is executed by the physics engine
  28942. */
  28943. afterStep: () => void;
  28944. /**
  28945. * Legacy collision detection event support
  28946. */
  28947. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28948. /**
  28949. * event and body object due to cannon's event-based architecture.
  28950. */
  28951. onCollide: (e: {
  28952. body: any;
  28953. }) => void;
  28954. /**
  28955. * Apply a force
  28956. * @param force The force to apply
  28957. * @param contactPoint The contact point for the force
  28958. * @returns The physics imposter
  28959. */
  28960. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28961. /**
  28962. * Apply an impulse
  28963. * @param force The impulse force
  28964. * @param contactPoint The contact point for the impulse force
  28965. * @returns The physics imposter
  28966. */
  28967. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28968. /**
  28969. * A help function to create a joint
  28970. * @param otherImpostor A physics imposter used to create a joint
  28971. * @param jointType The type of joint
  28972. * @param jointData The data for the joint
  28973. * @returns The physics imposter
  28974. */
  28975. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28976. /**
  28977. * Add a joint to this impostor with a different impostor
  28978. * @param otherImpostor A physics imposter used to add a joint
  28979. * @param joint The joint to add
  28980. * @returns The physics imposter
  28981. */
  28982. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28983. /**
  28984. * Add an anchor to a cloth impostor
  28985. * @param otherImpostor rigid impostor to anchor to
  28986. * @param width ratio across width from 0 to 1
  28987. * @param height ratio up height from 0 to 1
  28988. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28989. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28990. * @returns impostor the soft imposter
  28991. */
  28992. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28993. /**
  28994. * Add a hook to a rope impostor
  28995. * @param otherImpostor rigid impostor to anchor to
  28996. * @param length ratio across rope from 0 to 1
  28997. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28998. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28999. * @returns impostor the rope imposter
  29000. */
  29001. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29002. /**
  29003. * Will keep this body still, in a sleep mode.
  29004. * @returns the physics imposter
  29005. */
  29006. sleep(): PhysicsImpostor;
  29007. /**
  29008. * Wake the body up.
  29009. * @returns The physics imposter
  29010. */
  29011. wakeUp(): PhysicsImpostor;
  29012. /**
  29013. * Clones the physics imposter
  29014. * @param newObject The physics imposter clones to this physics-enabled object
  29015. * @returns A nullable physics imposter
  29016. */
  29017. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29018. /**
  29019. * Disposes the physics imposter
  29020. */
  29021. dispose(): void;
  29022. /**
  29023. * Sets the delta position
  29024. * @param position The delta position amount
  29025. */
  29026. setDeltaPosition(position: Vector3): void;
  29027. /**
  29028. * Sets the delta rotation
  29029. * @param rotation The delta rotation amount
  29030. */
  29031. setDeltaRotation(rotation: Quaternion): void;
  29032. /**
  29033. * Gets the box size of the physics imposter and stores the result in the input parameter
  29034. * @param result Stores the box size
  29035. * @returns The physics imposter
  29036. */
  29037. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29038. /**
  29039. * Gets the radius of the physics imposter
  29040. * @returns Radius of the physics imposter
  29041. */
  29042. getRadius(): number;
  29043. /**
  29044. * Sync a bone with this impostor
  29045. * @param bone The bone to sync to the impostor.
  29046. * @param boneMesh The mesh that the bone is influencing.
  29047. * @param jointPivot The pivot of the joint / bone in local space.
  29048. * @param distToJoint Optional distance from the impostor to the joint.
  29049. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29050. */
  29051. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29052. /**
  29053. * Sync impostor to a bone
  29054. * @param bone The bone that the impostor will be synced to.
  29055. * @param boneMesh The mesh that the bone is influencing.
  29056. * @param jointPivot The pivot of the joint / bone in local space.
  29057. * @param distToJoint Optional distance from the impostor to the joint.
  29058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29059. * @param boneAxis Optional vector3 axis the bone is aligned with
  29060. */
  29061. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29062. /**
  29063. * No-Imposter type
  29064. */
  29065. static NoImpostor: number;
  29066. /**
  29067. * Sphere-Imposter type
  29068. */
  29069. static SphereImpostor: number;
  29070. /**
  29071. * Box-Imposter type
  29072. */
  29073. static BoxImpostor: number;
  29074. /**
  29075. * Plane-Imposter type
  29076. */
  29077. static PlaneImpostor: number;
  29078. /**
  29079. * Mesh-imposter type
  29080. */
  29081. static MeshImpostor: number;
  29082. /**
  29083. * Capsule-Impostor type (Ammo.js plugin only)
  29084. */
  29085. static CapsuleImpostor: number;
  29086. /**
  29087. * Cylinder-Imposter type
  29088. */
  29089. static CylinderImpostor: number;
  29090. /**
  29091. * Particle-Imposter type
  29092. */
  29093. static ParticleImpostor: number;
  29094. /**
  29095. * Heightmap-Imposter type
  29096. */
  29097. static HeightmapImpostor: number;
  29098. /**
  29099. * ConvexHull-Impostor type (Ammo.js plugin only)
  29100. */
  29101. static ConvexHullImpostor: number;
  29102. /**
  29103. * Custom-Imposter type (Ammo.js plugin only)
  29104. */
  29105. static CustomImpostor: number;
  29106. /**
  29107. * Rope-Imposter type
  29108. */
  29109. static RopeImpostor: number;
  29110. /**
  29111. * Cloth-Imposter type
  29112. */
  29113. static ClothImpostor: number;
  29114. /**
  29115. * Softbody-Imposter type
  29116. */
  29117. static SoftbodyImpostor: number;
  29118. }
  29119. }
  29120. declare module "babylonjs/Meshes/mesh" {
  29121. import { Observable } from "babylonjs/Misc/observable";
  29122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29123. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29124. import { Camera } from "babylonjs/Cameras/camera";
  29125. import { Scene } from "babylonjs/scene";
  29126. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29127. import { Color4 } from "babylonjs/Maths/math.color";
  29128. import { Engine } from "babylonjs/Engines/engine";
  29129. import { Node } from "babylonjs/node";
  29130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29131. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29132. import { Buffer } from "babylonjs/Meshes/buffer";
  29133. import { Geometry } from "babylonjs/Meshes/geometry";
  29134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29137. import { Effect } from "babylonjs/Materials/effect";
  29138. import { Material } from "babylonjs/Materials/material";
  29139. import { Skeleton } from "babylonjs/Bones/skeleton";
  29140. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29141. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29142. import { Path3D } from "babylonjs/Maths/math.path";
  29143. import { Plane } from "babylonjs/Maths/math.plane";
  29144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29145. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29146. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29147. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29148. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29149. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29150. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29151. /**
  29152. * @hidden
  29153. **/
  29154. export class _CreationDataStorage {
  29155. closePath?: boolean;
  29156. closeArray?: boolean;
  29157. idx: number[];
  29158. dashSize: number;
  29159. gapSize: number;
  29160. path3D: Path3D;
  29161. pathArray: Vector3[][];
  29162. arc: number;
  29163. radius: number;
  29164. cap: number;
  29165. tessellation: number;
  29166. }
  29167. /**
  29168. * @hidden
  29169. **/
  29170. class _InstanceDataStorage {
  29171. visibleInstances: any;
  29172. batchCache: _InstancesBatch;
  29173. instancesBufferSize: number;
  29174. instancesBuffer: Nullable<Buffer>;
  29175. instancesData: Float32Array;
  29176. overridenInstanceCount: number;
  29177. isFrozen: boolean;
  29178. previousBatch: Nullable<_InstancesBatch>;
  29179. hardwareInstancedRendering: boolean;
  29180. sideOrientation: number;
  29181. manualUpdate: boolean;
  29182. previousRenderId: number;
  29183. }
  29184. /**
  29185. * @hidden
  29186. **/
  29187. export class _InstancesBatch {
  29188. mustReturn: boolean;
  29189. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29190. renderSelf: boolean[];
  29191. hardwareInstancedRendering: boolean[];
  29192. }
  29193. /**
  29194. * @hidden
  29195. **/
  29196. class _ThinInstanceDataStorage {
  29197. instancesCount: number;
  29198. matrixBuffer: Nullable<Buffer>;
  29199. matrixBufferSize: number;
  29200. matrixData: Nullable<Float32Array>;
  29201. boundingVectors: Array<Vector3>;
  29202. worldMatrices: Nullable<Matrix[]>;
  29203. }
  29204. /**
  29205. * Class used to represent renderable models
  29206. */
  29207. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29208. /**
  29209. * Mesh side orientation : usually the external or front surface
  29210. */
  29211. static readonly FRONTSIDE: number;
  29212. /**
  29213. * Mesh side orientation : usually the internal or back surface
  29214. */
  29215. static readonly BACKSIDE: number;
  29216. /**
  29217. * Mesh side orientation : both internal and external or front and back surfaces
  29218. */
  29219. static readonly DOUBLESIDE: number;
  29220. /**
  29221. * Mesh side orientation : by default, `FRONTSIDE`
  29222. */
  29223. static readonly DEFAULTSIDE: number;
  29224. /**
  29225. * Mesh cap setting : no cap
  29226. */
  29227. static readonly NO_CAP: number;
  29228. /**
  29229. * Mesh cap setting : one cap at the beginning of the mesh
  29230. */
  29231. static readonly CAP_START: number;
  29232. /**
  29233. * Mesh cap setting : one cap at the end of the mesh
  29234. */
  29235. static readonly CAP_END: number;
  29236. /**
  29237. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29238. */
  29239. static readonly CAP_ALL: number;
  29240. /**
  29241. * Mesh pattern setting : no flip or rotate
  29242. */
  29243. static readonly NO_FLIP: number;
  29244. /**
  29245. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29246. */
  29247. static readonly FLIP_TILE: number;
  29248. /**
  29249. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29250. */
  29251. static readonly ROTATE_TILE: number;
  29252. /**
  29253. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29254. */
  29255. static readonly FLIP_ROW: number;
  29256. /**
  29257. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29258. */
  29259. static readonly ROTATE_ROW: number;
  29260. /**
  29261. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29262. */
  29263. static readonly FLIP_N_ROTATE_TILE: number;
  29264. /**
  29265. * Mesh pattern setting : rotate pattern and rotate
  29266. */
  29267. static readonly FLIP_N_ROTATE_ROW: number;
  29268. /**
  29269. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29270. */
  29271. static readonly CENTER: number;
  29272. /**
  29273. * Mesh tile positioning : part tiles on left
  29274. */
  29275. static readonly LEFT: number;
  29276. /**
  29277. * Mesh tile positioning : part tiles on right
  29278. */
  29279. static readonly RIGHT: number;
  29280. /**
  29281. * Mesh tile positioning : part tiles on top
  29282. */
  29283. static readonly TOP: number;
  29284. /**
  29285. * Mesh tile positioning : part tiles on bottom
  29286. */
  29287. static readonly BOTTOM: number;
  29288. /**
  29289. * Gets the default side orientation.
  29290. * @param orientation the orientation to value to attempt to get
  29291. * @returns the default orientation
  29292. * @hidden
  29293. */
  29294. static _GetDefaultSideOrientation(orientation?: number): number;
  29295. private _internalMeshDataInfo;
  29296. get computeBonesUsingShaders(): boolean;
  29297. set computeBonesUsingShaders(value: boolean);
  29298. /**
  29299. * An event triggered before rendering the mesh
  29300. */
  29301. get onBeforeRenderObservable(): Observable<Mesh>;
  29302. /**
  29303. * An event triggered before binding the mesh
  29304. */
  29305. get onBeforeBindObservable(): Observable<Mesh>;
  29306. /**
  29307. * An event triggered after rendering the mesh
  29308. */
  29309. get onAfterRenderObservable(): Observable<Mesh>;
  29310. /**
  29311. * An event triggered before drawing the mesh
  29312. */
  29313. get onBeforeDrawObservable(): Observable<Mesh>;
  29314. private _onBeforeDrawObserver;
  29315. /**
  29316. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29317. */
  29318. set onBeforeDraw(callback: () => void);
  29319. get hasInstances(): boolean;
  29320. get hasThinInstances(): boolean;
  29321. /**
  29322. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29323. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29324. */
  29325. delayLoadState: number;
  29326. /**
  29327. * Gets the list of instances created from this mesh
  29328. * it is not supposed to be modified manually.
  29329. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29331. */
  29332. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29333. /**
  29334. * Gets the file containing delay loading data for this mesh
  29335. */
  29336. delayLoadingFile: string;
  29337. /** @hidden */
  29338. _binaryInfo: any;
  29339. /**
  29340. * User defined function used to change how LOD level selection is done
  29341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29342. */
  29343. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29344. /**
  29345. * Gets or sets the morph target manager
  29346. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29347. */
  29348. get morphTargetManager(): Nullable<MorphTargetManager>;
  29349. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29350. /** @hidden */
  29351. _creationDataStorage: Nullable<_CreationDataStorage>;
  29352. /** @hidden */
  29353. _geometry: Nullable<Geometry>;
  29354. /** @hidden */
  29355. _delayInfo: Array<string>;
  29356. /** @hidden */
  29357. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29358. /** @hidden */
  29359. _instanceDataStorage: _InstanceDataStorage;
  29360. /** @hidden */
  29361. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29362. private _effectiveMaterial;
  29363. /** @hidden */
  29364. _shouldGenerateFlatShading: boolean;
  29365. /** @hidden */
  29366. _originalBuilderSideOrientation: number;
  29367. /**
  29368. * Use this property to change the original side orientation defined at construction time
  29369. */
  29370. overrideMaterialSideOrientation: Nullable<number>;
  29371. /**
  29372. * Gets the source mesh (the one used to clone this one from)
  29373. */
  29374. get source(): Nullable<Mesh>;
  29375. /**
  29376. * Gets the list of clones of this mesh
  29377. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29378. * Note that useClonedMeshMap=true is the default setting
  29379. */
  29380. get cloneMeshMap(): Nullable<{
  29381. [id: string]: Mesh | undefined;
  29382. }>;
  29383. /**
  29384. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29385. */
  29386. get isUnIndexed(): boolean;
  29387. set isUnIndexed(value: boolean);
  29388. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29389. get worldMatrixInstancedBuffer(): Float32Array;
  29390. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29391. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29392. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29393. /**
  29394. * @constructor
  29395. * @param name The value used by scene.getMeshByName() to do a lookup.
  29396. * @param scene The scene to add this mesh to.
  29397. * @param parent The parent of this mesh, if it has one
  29398. * @param source An optional Mesh from which geometry is shared, cloned.
  29399. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29400. * When false, achieved by calling a clone(), also passing False.
  29401. * This will make creation of children, recursive.
  29402. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29403. */
  29404. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29405. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29406. doNotInstantiate: boolean;
  29407. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29408. /**
  29409. * Gets the class name
  29410. * @returns the string "Mesh".
  29411. */
  29412. getClassName(): string;
  29413. /** @hidden */
  29414. get _isMesh(): boolean;
  29415. /**
  29416. * Returns a description of this mesh
  29417. * @param fullDetails define if full details about this mesh must be used
  29418. * @returns a descriptive string representing this mesh
  29419. */
  29420. toString(fullDetails?: boolean): string;
  29421. /** @hidden */
  29422. _unBindEffect(): void;
  29423. /**
  29424. * Gets a boolean indicating if this mesh has LOD
  29425. */
  29426. get hasLODLevels(): boolean;
  29427. /**
  29428. * Gets the list of MeshLODLevel associated with the current mesh
  29429. * @returns an array of MeshLODLevel
  29430. */
  29431. getLODLevels(): MeshLODLevel[];
  29432. private _sortLODLevels;
  29433. /**
  29434. * Add a mesh as LOD level triggered at the given distance.
  29435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29436. * @param distance The distance from the center of the object to show this level
  29437. * @param mesh The mesh to be added as LOD level (can be null)
  29438. * @return This mesh (for chaining)
  29439. */
  29440. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29441. /**
  29442. * Returns the LOD level mesh at the passed distance or null if not found.
  29443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29444. * @param distance The distance from the center of the object to show this level
  29445. * @returns a Mesh or `null`
  29446. */
  29447. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29448. /**
  29449. * Remove a mesh from the LOD array
  29450. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29451. * @param mesh defines the mesh to be removed
  29452. * @return This mesh (for chaining)
  29453. */
  29454. removeLODLevel(mesh: Mesh): Mesh;
  29455. /**
  29456. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29457. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29458. * @param camera defines the camera to use to compute distance
  29459. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29460. * @return This mesh (for chaining)
  29461. */
  29462. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29463. /**
  29464. * Gets the mesh internal Geometry object
  29465. */
  29466. get geometry(): Nullable<Geometry>;
  29467. /**
  29468. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29469. * @returns the total number of vertices
  29470. */
  29471. getTotalVertices(): number;
  29472. /**
  29473. * Returns the content of an associated vertex buffer
  29474. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29475. * - VertexBuffer.PositionKind
  29476. * - VertexBuffer.UVKind
  29477. * - VertexBuffer.UV2Kind
  29478. * - VertexBuffer.UV3Kind
  29479. * - VertexBuffer.UV4Kind
  29480. * - VertexBuffer.UV5Kind
  29481. * - VertexBuffer.UV6Kind
  29482. * - VertexBuffer.ColorKind
  29483. * - VertexBuffer.MatricesIndicesKind
  29484. * - VertexBuffer.MatricesIndicesExtraKind
  29485. * - VertexBuffer.MatricesWeightsKind
  29486. * - VertexBuffer.MatricesWeightsExtraKind
  29487. * @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
  29488. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29489. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29490. */
  29491. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29492. /**
  29493. * Returns the mesh VertexBuffer object from the requested `kind`
  29494. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29495. * - VertexBuffer.PositionKind
  29496. * - VertexBuffer.NormalKind
  29497. * - VertexBuffer.UVKind
  29498. * - VertexBuffer.UV2Kind
  29499. * - VertexBuffer.UV3Kind
  29500. * - VertexBuffer.UV4Kind
  29501. * - VertexBuffer.UV5Kind
  29502. * - VertexBuffer.UV6Kind
  29503. * - VertexBuffer.ColorKind
  29504. * - VertexBuffer.MatricesIndicesKind
  29505. * - VertexBuffer.MatricesIndicesExtraKind
  29506. * - VertexBuffer.MatricesWeightsKind
  29507. * - VertexBuffer.MatricesWeightsExtraKind
  29508. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29509. */
  29510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29511. /**
  29512. * Tests if a specific vertex buffer is associated with this mesh
  29513. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29514. * - VertexBuffer.PositionKind
  29515. * - VertexBuffer.NormalKind
  29516. * - VertexBuffer.UVKind
  29517. * - VertexBuffer.UV2Kind
  29518. * - VertexBuffer.UV3Kind
  29519. * - VertexBuffer.UV4Kind
  29520. * - VertexBuffer.UV5Kind
  29521. * - VertexBuffer.UV6Kind
  29522. * - VertexBuffer.ColorKind
  29523. * - VertexBuffer.MatricesIndicesKind
  29524. * - VertexBuffer.MatricesIndicesExtraKind
  29525. * - VertexBuffer.MatricesWeightsKind
  29526. * - VertexBuffer.MatricesWeightsExtraKind
  29527. * @returns a boolean
  29528. */
  29529. isVerticesDataPresent(kind: string): boolean;
  29530. /**
  29531. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29532. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29533. * - VertexBuffer.PositionKind
  29534. * - VertexBuffer.UVKind
  29535. * - VertexBuffer.UV2Kind
  29536. * - VertexBuffer.UV3Kind
  29537. * - VertexBuffer.UV4Kind
  29538. * - VertexBuffer.UV5Kind
  29539. * - VertexBuffer.UV6Kind
  29540. * - VertexBuffer.ColorKind
  29541. * - VertexBuffer.MatricesIndicesKind
  29542. * - VertexBuffer.MatricesIndicesExtraKind
  29543. * - VertexBuffer.MatricesWeightsKind
  29544. * - VertexBuffer.MatricesWeightsExtraKind
  29545. * @returns a boolean
  29546. */
  29547. isVertexBufferUpdatable(kind: string): boolean;
  29548. /**
  29549. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29550. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29551. * - VertexBuffer.PositionKind
  29552. * - VertexBuffer.NormalKind
  29553. * - VertexBuffer.UVKind
  29554. * - VertexBuffer.UV2Kind
  29555. * - VertexBuffer.UV3Kind
  29556. * - VertexBuffer.UV4Kind
  29557. * - VertexBuffer.UV5Kind
  29558. * - VertexBuffer.UV6Kind
  29559. * - VertexBuffer.ColorKind
  29560. * - VertexBuffer.MatricesIndicesKind
  29561. * - VertexBuffer.MatricesIndicesExtraKind
  29562. * - VertexBuffer.MatricesWeightsKind
  29563. * - VertexBuffer.MatricesWeightsExtraKind
  29564. * @returns an array of strings
  29565. */
  29566. getVerticesDataKinds(): string[];
  29567. /**
  29568. * Returns a positive integer : the total number of indices in this mesh geometry.
  29569. * @returns the numner of indices or zero if the mesh has no geometry.
  29570. */
  29571. getTotalIndices(): number;
  29572. /**
  29573. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29574. * @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.
  29575. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29576. * @returns the indices array or an empty array if the mesh has no geometry
  29577. */
  29578. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29579. get isBlocked(): boolean;
  29580. /**
  29581. * Determine if the current mesh is ready to be rendered
  29582. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29583. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29584. * @returns true if all associated assets are ready (material, textures, shaders)
  29585. */
  29586. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29587. /**
  29588. * 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.
  29589. */
  29590. get areNormalsFrozen(): boolean;
  29591. /**
  29592. * 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.
  29593. * @returns the current mesh
  29594. */
  29595. freezeNormals(): Mesh;
  29596. /**
  29597. * 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
  29598. * @returns the current mesh
  29599. */
  29600. unfreezeNormals(): Mesh;
  29601. /**
  29602. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29603. */
  29604. set overridenInstanceCount(count: number);
  29605. /** @hidden */
  29606. _preActivate(): Mesh;
  29607. /** @hidden */
  29608. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29609. /** @hidden */
  29610. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29611. protected _afterComputeWorldMatrix(): void;
  29612. /** @hidden */
  29613. _postActivate(): void;
  29614. /**
  29615. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29616. * This means the mesh underlying bounding box and sphere are recomputed.
  29617. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29618. * @returns the current mesh
  29619. */
  29620. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29621. /** @hidden */
  29622. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29623. /**
  29624. * This function will subdivide the mesh into multiple submeshes
  29625. * @param count defines the expected number of submeshes
  29626. */
  29627. subdivide(count: number): void;
  29628. /**
  29629. * Copy a FloatArray into a specific associated vertex buffer
  29630. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29631. * - VertexBuffer.PositionKind
  29632. * - VertexBuffer.UVKind
  29633. * - VertexBuffer.UV2Kind
  29634. * - VertexBuffer.UV3Kind
  29635. * - VertexBuffer.UV4Kind
  29636. * - VertexBuffer.UV5Kind
  29637. * - VertexBuffer.UV6Kind
  29638. * - VertexBuffer.ColorKind
  29639. * - VertexBuffer.MatricesIndicesKind
  29640. * - VertexBuffer.MatricesIndicesExtraKind
  29641. * - VertexBuffer.MatricesWeightsKind
  29642. * - VertexBuffer.MatricesWeightsExtraKind
  29643. * @param data defines the data source
  29644. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29645. * @param stride defines the data stride size (can be null)
  29646. * @returns the current mesh
  29647. */
  29648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29649. /**
  29650. * Delete a vertex buffer associated with this mesh
  29651. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29652. * - VertexBuffer.PositionKind
  29653. * - VertexBuffer.UVKind
  29654. * - VertexBuffer.UV2Kind
  29655. * - VertexBuffer.UV3Kind
  29656. * - VertexBuffer.UV4Kind
  29657. * - VertexBuffer.UV5Kind
  29658. * - VertexBuffer.UV6Kind
  29659. * - VertexBuffer.ColorKind
  29660. * - VertexBuffer.MatricesIndicesKind
  29661. * - VertexBuffer.MatricesIndicesExtraKind
  29662. * - VertexBuffer.MatricesWeightsKind
  29663. * - VertexBuffer.MatricesWeightsExtraKind
  29664. */
  29665. removeVerticesData(kind: string): void;
  29666. /**
  29667. * Flags an associated vertex buffer as updatable
  29668. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29669. * - VertexBuffer.PositionKind
  29670. * - VertexBuffer.UVKind
  29671. * - VertexBuffer.UV2Kind
  29672. * - VertexBuffer.UV3Kind
  29673. * - VertexBuffer.UV4Kind
  29674. * - VertexBuffer.UV5Kind
  29675. * - VertexBuffer.UV6Kind
  29676. * - VertexBuffer.ColorKind
  29677. * - VertexBuffer.MatricesIndicesKind
  29678. * - VertexBuffer.MatricesIndicesExtraKind
  29679. * - VertexBuffer.MatricesWeightsKind
  29680. * - VertexBuffer.MatricesWeightsExtraKind
  29681. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29682. */
  29683. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29684. /**
  29685. * Sets the mesh global Vertex Buffer
  29686. * @param buffer defines the buffer to use
  29687. * @returns the current mesh
  29688. */
  29689. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29690. /**
  29691. * Update a specific associated vertex buffer
  29692. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29693. * - VertexBuffer.PositionKind
  29694. * - VertexBuffer.UVKind
  29695. * - VertexBuffer.UV2Kind
  29696. * - VertexBuffer.UV3Kind
  29697. * - VertexBuffer.UV4Kind
  29698. * - VertexBuffer.UV5Kind
  29699. * - VertexBuffer.UV6Kind
  29700. * - VertexBuffer.ColorKind
  29701. * - VertexBuffer.MatricesIndicesKind
  29702. * - VertexBuffer.MatricesIndicesExtraKind
  29703. * - VertexBuffer.MatricesWeightsKind
  29704. * - VertexBuffer.MatricesWeightsExtraKind
  29705. * @param data defines the data source
  29706. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29707. * @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)
  29708. * @returns the current mesh
  29709. */
  29710. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29711. /**
  29712. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29713. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29714. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29715. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29716. * @returns the current mesh
  29717. */
  29718. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29719. /**
  29720. * Creates a un-shared specific occurence of the geometry for the mesh.
  29721. * @returns the current mesh
  29722. */
  29723. makeGeometryUnique(): Mesh;
  29724. /**
  29725. * Set the index buffer of this mesh
  29726. * @param indices defines the source data
  29727. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29728. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29729. * @returns the current mesh
  29730. */
  29731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29732. /**
  29733. * Update the current index buffer
  29734. * @param indices defines the source data
  29735. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29736. * @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)
  29737. * @returns the current mesh
  29738. */
  29739. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29740. /**
  29741. * Invert the geometry to move from a right handed system to a left handed one.
  29742. * @returns the current mesh
  29743. */
  29744. toLeftHanded(): Mesh;
  29745. /** @hidden */
  29746. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29747. /** @hidden */
  29748. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29749. /**
  29750. * Registers for this mesh a javascript function called just before the rendering process
  29751. * @param func defines the function to call before rendering this mesh
  29752. * @returns the current mesh
  29753. */
  29754. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29755. /**
  29756. * Disposes a previously registered javascript function called before the rendering
  29757. * @param func defines the function to remove
  29758. * @returns the current mesh
  29759. */
  29760. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29761. /**
  29762. * Registers for this mesh a javascript function called just after the rendering is complete
  29763. * @param func defines the function to call after rendering this mesh
  29764. * @returns the current mesh
  29765. */
  29766. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29767. /**
  29768. * Disposes a previously registered javascript function called after the rendering.
  29769. * @param func defines the function to remove
  29770. * @returns the current mesh
  29771. */
  29772. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29773. /** @hidden */
  29774. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29775. /** @hidden */
  29776. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29777. /** @hidden */
  29778. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29779. /** @hidden */
  29780. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29781. /** @hidden */
  29782. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29783. /** @hidden */
  29784. _rebuild(): void;
  29785. /** @hidden */
  29786. _freeze(): void;
  29787. /** @hidden */
  29788. _unFreeze(): void;
  29789. /**
  29790. * 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
  29791. * @param subMesh defines the subMesh to render
  29792. * @param enableAlphaMode defines if alpha mode can be changed
  29793. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29794. * @returns the current mesh
  29795. */
  29796. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29797. private _onBeforeDraw;
  29798. /**
  29799. * Renormalize the mesh and patch it up if there are no weights
  29800. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29801. * However in the case of zero weights then we set just a single influence to 1.
  29802. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29803. */
  29804. cleanMatrixWeights(): void;
  29805. private normalizeSkinFourWeights;
  29806. private normalizeSkinWeightsAndExtra;
  29807. /**
  29808. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29809. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29810. * the user know there was an issue with importing the mesh
  29811. * @returns a validation object with skinned, valid and report string
  29812. */
  29813. validateSkinning(): {
  29814. skinned: boolean;
  29815. valid: boolean;
  29816. report: string;
  29817. };
  29818. /** @hidden */
  29819. _checkDelayState(): Mesh;
  29820. private _queueLoad;
  29821. /**
  29822. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29823. * A mesh is in the frustum if its bounding box intersects the frustum
  29824. * @param frustumPlanes defines the frustum to test
  29825. * @returns true if the mesh is in the frustum planes
  29826. */
  29827. isInFrustum(frustumPlanes: Plane[]): boolean;
  29828. /**
  29829. * Sets the mesh material by the material or multiMaterial `id` property
  29830. * @param id is a string identifying the material or the multiMaterial
  29831. * @returns the current mesh
  29832. */
  29833. setMaterialByID(id: string): Mesh;
  29834. /**
  29835. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29836. * @returns an array of IAnimatable
  29837. */
  29838. getAnimatables(): IAnimatable[];
  29839. /**
  29840. * Modifies the mesh geometry according to the passed transformation matrix.
  29841. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29842. * The mesh normals are modified using the same transformation.
  29843. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29844. * @param transform defines the transform matrix to use
  29845. * @see https://doc.babylonjs.com/resources/baking_transformations
  29846. * @returns the current mesh
  29847. */
  29848. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29849. /**
  29850. * Modifies the mesh geometry according to its own current World Matrix.
  29851. * The mesh World Matrix is then reset.
  29852. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29853. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29854. * @see https://doc.babylonjs.com/resources/baking_transformations
  29855. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29856. * @returns the current mesh
  29857. */
  29858. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29859. /** @hidden */
  29860. get _positions(): Nullable<Vector3[]>;
  29861. /** @hidden */
  29862. _resetPointsArrayCache(): Mesh;
  29863. /** @hidden */
  29864. _generatePointsArray(): boolean;
  29865. /**
  29866. * Returns a new Mesh object generated from the current mesh properties.
  29867. * This method must not get confused with createInstance()
  29868. * @param name is a string, the name given to the new mesh
  29869. * @param newParent can be any Node object (default `null`)
  29870. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29871. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29872. * @returns a new mesh
  29873. */
  29874. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29875. /**
  29876. * Releases resources associated with this mesh.
  29877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29879. */
  29880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29881. /** @hidden */
  29882. _disposeInstanceSpecificData(): void;
  29883. /** @hidden */
  29884. _disposeThinInstanceSpecificData(): void;
  29885. /**
  29886. * Modifies the mesh geometry according to a displacement map.
  29887. * 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.
  29888. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29889. * @param url is a string, the URL from the image file is to be downloaded.
  29890. * @param minHeight is the lower limit of the displacement.
  29891. * @param maxHeight is the upper limit of the displacement.
  29892. * @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.
  29893. * @param uvOffset is an optional vector2 used to offset UV.
  29894. * @param uvScale is an optional vector2 used to scale UV.
  29895. * @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.
  29896. * @returns the Mesh.
  29897. */
  29898. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29899. /**
  29900. * Modifies the mesh geometry according to a displacementMap buffer.
  29901. * 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.
  29902. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29903. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29904. * @param heightMapWidth is the width of the buffer image.
  29905. * @param heightMapHeight is the height of the buffer image.
  29906. * @param minHeight is the lower limit of the displacement.
  29907. * @param maxHeight is the upper limit of the displacement.
  29908. * @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.
  29909. * @param uvOffset is an optional vector2 used to offset UV.
  29910. * @param uvScale is an optional vector2 used to scale UV.
  29911. * @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.
  29912. * @returns the Mesh.
  29913. */
  29914. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29915. /**
  29916. * Modify the mesh to get a flat shading rendering.
  29917. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29918. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29919. * @returns current mesh
  29920. */
  29921. convertToFlatShadedMesh(): Mesh;
  29922. /**
  29923. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29924. * In other words, more vertices, no more indices and a single bigger VBO.
  29925. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29926. * @returns current mesh
  29927. */
  29928. convertToUnIndexedMesh(): Mesh;
  29929. /**
  29930. * Inverses facet orientations.
  29931. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29932. * @param flipNormals will also inverts the normals
  29933. * @returns current mesh
  29934. */
  29935. flipFaces(flipNormals?: boolean): Mesh;
  29936. /**
  29937. * Increase the number of facets and hence vertices in a mesh
  29938. * Vertex normals are interpolated from existing vertex normals
  29939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29940. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29941. */
  29942. increaseVertices(numberPerEdge: number): void;
  29943. /**
  29944. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29945. * This will undo any application of covertToFlatShadedMesh
  29946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29947. */
  29948. forceSharedVertices(): void;
  29949. /** @hidden */
  29950. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29951. /** @hidden */
  29952. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29953. /**
  29954. * Creates a new InstancedMesh object from the mesh model.
  29955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29956. * @param name defines the name of the new instance
  29957. * @returns a new InstancedMesh
  29958. */
  29959. createInstance(name: string): InstancedMesh;
  29960. /**
  29961. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29962. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29963. * @returns the current mesh
  29964. */
  29965. synchronizeInstances(): Mesh;
  29966. /**
  29967. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29968. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29969. * This should be used together with the simplification to avoid disappearing triangles.
  29970. * @param successCallback an optional success callback to be called after the optimization finished.
  29971. * @returns the current mesh
  29972. */
  29973. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29974. /**
  29975. * Serialize current mesh
  29976. * @param serializationObject defines the object which will receive the serialization data
  29977. */
  29978. serialize(serializationObject: any): void;
  29979. /** @hidden */
  29980. _syncGeometryWithMorphTargetManager(): void;
  29981. /** @hidden */
  29982. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29983. /**
  29984. * Returns a new Mesh object parsed from the source provided.
  29985. * @param parsedMesh is the source
  29986. * @param scene defines the hosting scene
  29987. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29988. * @returns a new Mesh
  29989. */
  29990. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29991. /**
  29992. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29994. * @param name defines the name of the mesh to create
  29995. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29996. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29997. * @param closePath creates a seam between the first and the last points of each path of the path array
  29998. * @param offset is taken in account only if the `pathArray` is containing a single path
  29999. * @param scene defines the hosting scene
  30000. * @param updatable defines if the mesh must be flagged as updatable
  30001. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30002. * @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)
  30003. * @returns a new Mesh
  30004. */
  30005. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30006. /**
  30007. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30008. * @param name defines the name of the mesh to create
  30009. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30010. * @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
  30011. * @param scene defines the hosting scene
  30012. * @param updatable defines if the mesh must be flagged as updatable
  30013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30014. * @returns a new Mesh
  30015. */
  30016. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30017. /**
  30018. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30019. * @param name defines the name of the mesh to create
  30020. * @param size sets the size (float) of each box side (default 1)
  30021. * @param scene defines the hosting scene
  30022. * @param updatable defines if the mesh must be flagged as updatable
  30023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30024. * @returns a new Mesh
  30025. */
  30026. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30027. /**
  30028. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30029. * @param name defines the name of the mesh to create
  30030. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30031. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30032. * @param scene defines the hosting scene
  30033. * @param updatable defines if the mesh must be flagged as updatable
  30034. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30038. /**
  30039. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30040. * @param name defines the name of the mesh to create
  30041. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30042. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30043. * @param scene defines the hosting scene
  30044. * @returns a new Mesh
  30045. */
  30046. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30047. /**
  30048. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30049. * @param name defines the name of the mesh to create
  30050. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30051. * @param diameterTop set the top cap diameter (floats, default 1)
  30052. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30053. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30054. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30055. * @param scene defines the hosting scene
  30056. * @param updatable defines if the mesh must be flagged as updatable
  30057. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30058. * @returns a new Mesh
  30059. */
  30060. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30061. /**
  30062. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30063. * @param name defines the name of the mesh to create
  30064. * @param diameter sets the diameter size (float) of the torus (default 1)
  30065. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30066. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30067. * @param scene defines the hosting scene
  30068. * @param updatable defines if the mesh must be flagged as updatable
  30069. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30070. * @returns a new Mesh
  30071. */
  30072. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30073. /**
  30074. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30075. * @param name defines the name of the mesh to create
  30076. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30077. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30078. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30079. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30080. * @param p the number of windings on X axis (positive integers, default 2)
  30081. * @param q the number of windings on Y axis (positive integers, default 3)
  30082. * @param scene defines the hosting scene
  30083. * @param updatable defines if the mesh must be flagged as updatable
  30084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30085. * @returns a new Mesh
  30086. */
  30087. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30088. /**
  30089. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30090. * @param name defines the name of the mesh to create
  30091. * @param points is an array successive Vector3
  30092. * @param scene defines the hosting scene
  30093. * @param updatable defines if the mesh must be flagged as updatable
  30094. * @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).
  30095. * @returns a new Mesh
  30096. */
  30097. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30098. /**
  30099. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30100. * @param name defines the name of the mesh to create
  30101. * @param points is an array successive Vector3
  30102. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30103. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30104. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30105. * @param scene defines the hosting scene
  30106. * @param updatable defines if the mesh must be flagged as updatable
  30107. * @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)
  30108. * @returns a new Mesh
  30109. */
  30110. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30111. /**
  30112. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30114. * 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.
  30115. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30117. * Remember you can only change the shape positions, not their number when updating a polygon.
  30118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30119. * @param name defines the name of the mesh to create
  30120. * @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
  30121. * @param scene defines the hosting scene
  30122. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30123. * @param updatable defines if the mesh must be flagged as updatable
  30124. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30125. * @param earcutInjection can be used to inject your own earcut reference
  30126. * @returns a new Mesh
  30127. */
  30128. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30129. /**
  30130. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30132. * @param name defines the name of the mesh to create
  30133. * @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
  30134. * @param depth defines the height of extrusion
  30135. * @param scene defines the hosting scene
  30136. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30137. * @param updatable defines if the mesh must be flagged as updatable
  30138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30139. * @param earcutInjection can be used to inject your own earcut reference
  30140. * @returns a new Mesh
  30141. */
  30142. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30143. /**
  30144. * Creates an extruded shape mesh.
  30145. * 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
  30146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30148. * @param name defines the name of the mesh to create
  30149. * @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
  30150. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30151. * @param scale is the value to scale the shape
  30152. * @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
  30153. * @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
  30154. * @param scene defines the hosting scene
  30155. * @param updatable defines if the mesh must be flagged as updatable
  30156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30157. * @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)
  30158. * @returns a new Mesh
  30159. */
  30160. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30161. /**
  30162. * Creates an custom extruded shape mesh.
  30163. * The custom extrusion is a parametric shape.
  30164. * It has no predefined shape. Its final shape will depend on the input parameters.
  30165. * Please consider using the same method from the MeshBuilder class instead
  30166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30167. * @param name defines the name of the mesh to create
  30168. * @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
  30169. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30170. * @param scaleFunction is a custom Javascript function called on each path point
  30171. * @param rotationFunction is a custom Javascript function called on each path point
  30172. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30173. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30174. * @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
  30175. * @param scene defines the hosting scene
  30176. * @param updatable defines if the mesh must be flagged as updatable
  30177. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30178. * @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)
  30179. * @returns a new Mesh
  30180. */
  30181. 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;
  30182. /**
  30183. * Creates lathe mesh.
  30184. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30185. * Please consider using the same method from the MeshBuilder class instead
  30186. * @param name defines the name of the mesh to create
  30187. * @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
  30188. * @param radius is the radius value of the lathe
  30189. * @param tessellation is the side number of the lathe.
  30190. * @param scene defines the hosting scene
  30191. * @param updatable defines if the mesh must be flagged as updatable
  30192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30193. * @returns a new Mesh
  30194. */
  30195. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30196. /**
  30197. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30198. * @param name defines the name of the mesh to create
  30199. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30200. * @param scene defines the hosting scene
  30201. * @param updatable defines if the mesh must be flagged as updatable
  30202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30203. * @returns a new Mesh
  30204. */
  30205. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30206. /**
  30207. * Creates a ground mesh.
  30208. * Please consider using the same method from the MeshBuilder class instead
  30209. * @param name defines the name of the mesh to create
  30210. * @param width set the width of the ground
  30211. * @param height set the height of the ground
  30212. * @param subdivisions sets the number of subdivisions per side
  30213. * @param scene defines the hosting scene
  30214. * @param updatable defines if the mesh must be flagged as updatable
  30215. * @returns a new Mesh
  30216. */
  30217. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30218. /**
  30219. * Creates a tiled ground mesh.
  30220. * Please consider using the same method from the MeshBuilder class instead
  30221. * @param name defines the name of the mesh to create
  30222. * @param xmin set the ground minimum X coordinate
  30223. * @param zmin set the ground minimum Y coordinate
  30224. * @param xmax set the ground maximum X coordinate
  30225. * @param zmax set the ground maximum Z coordinate
  30226. * @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
  30227. * @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
  30228. * @param scene defines the hosting scene
  30229. * @param updatable defines if the mesh must be flagged as updatable
  30230. * @returns a new Mesh
  30231. */
  30232. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30233. w: number;
  30234. h: number;
  30235. }, precision: {
  30236. w: number;
  30237. h: number;
  30238. }, scene: Scene, updatable?: boolean): Mesh;
  30239. /**
  30240. * Creates a ground mesh from a height map.
  30241. * Please consider using the same method from the MeshBuilder class instead
  30242. * @see https://doc.babylonjs.com/babylon101/height_map
  30243. * @param name defines the name of the mesh to create
  30244. * @param url sets the URL of the height map image resource
  30245. * @param width set the ground width size
  30246. * @param height set the ground height size
  30247. * @param subdivisions sets the number of subdivision per side
  30248. * @param minHeight is the minimum altitude on the ground
  30249. * @param maxHeight is the maximum altitude on the ground
  30250. * @param scene defines the hosting scene
  30251. * @param updatable defines if the mesh must be flagged as updatable
  30252. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30253. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30254. * @returns a new Mesh
  30255. */
  30256. 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;
  30257. /**
  30258. * Creates a tube mesh.
  30259. * The tube is a parametric shape.
  30260. * It has no predefined shape. Its final shape will depend on the input parameters.
  30261. * Please consider using the same method from the MeshBuilder class instead
  30262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30263. * @param name defines the name of the mesh to create
  30264. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30265. * @param radius sets the tube radius size
  30266. * @param tessellation is the number of sides on the tubular surface
  30267. * @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
  30268. * @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
  30269. * @param scene defines the hosting scene
  30270. * @param updatable defines if the mesh must be flagged as updatable
  30271. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30272. * @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)
  30273. * @returns a new Mesh
  30274. */
  30275. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30276. (i: number, distance: number): number;
  30277. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30278. /**
  30279. * Creates a polyhedron mesh.
  30280. * Please consider using the same method from the MeshBuilder class instead.
  30281. * * 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
  30282. * * The parameter `size` (positive float, default 1) sets the polygon size
  30283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30284. * * 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`
  30285. * * 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
  30286. * * 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)`)
  30287. * * 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
  30288. * * 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
  30289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30292. * @param name defines the name of the mesh to create
  30293. * @param options defines the options used to create the mesh
  30294. * @param scene defines the hosting scene
  30295. * @returns a new Mesh
  30296. */
  30297. static CreatePolyhedron(name: string, options: {
  30298. type?: number;
  30299. size?: number;
  30300. sizeX?: number;
  30301. sizeY?: number;
  30302. sizeZ?: number;
  30303. custom?: any;
  30304. faceUV?: Vector4[];
  30305. faceColors?: Color4[];
  30306. updatable?: boolean;
  30307. sideOrientation?: number;
  30308. }, scene: Scene): Mesh;
  30309. /**
  30310. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30311. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30312. * * 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`)
  30313. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30314. * * 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
  30315. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30318. * @param name defines the name of the mesh
  30319. * @param options defines the options used to create the mesh
  30320. * @param scene defines the hosting scene
  30321. * @returns a new Mesh
  30322. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30323. */
  30324. static CreateIcoSphere(name: string, options: {
  30325. radius?: number;
  30326. flat?: boolean;
  30327. subdivisions?: number;
  30328. sideOrientation?: number;
  30329. updatable?: boolean;
  30330. }, scene: Scene): Mesh;
  30331. /**
  30332. * Creates a decal mesh.
  30333. * Please consider using the same method from the MeshBuilder class instead.
  30334. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30335. * @param name defines the name of the mesh
  30336. * @param sourceMesh defines the mesh receiving the decal
  30337. * @param position sets the position of the decal in world coordinates
  30338. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30339. * @param size sets the decal scaling
  30340. * @param angle sets the angle to rotate the decal
  30341. * @returns a new Mesh
  30342. */
  30343. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30344. /** Creates a Capsule Mesh
  30345. * @param name defines the name of the mesh.
  30346. * @param options the constructors options used to shape the mesh.
  30347. * @param scene defines the scene the mesh is scoped to.
  30348. * @returns the capsule mesh
  30349. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30350. */
  30351. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30352. /**
  30353. * Prepare internal position array for software CPU skinning
  30354. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30355. */
  30356. setPositionsForCPUSkinning(): Float32Array;
  30357. /**
  30358. * Prepare internal normal array for software CPU skinning
  30359. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30360. */
  30361. setNormalsForCPUSkinning(): Float32Array;
  30362. /**
  30363. * Updates the vertex buffer by applying transformation from the bones
  30364. * @param skeleton defines the skeleton to apply to current mesh
  30365. * @returns the current mesh
  30366. */
  30367. applySkeleton(skeleton: Skeleton): Mesh;
  30368. /**
  30369. * 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
  30370. * @param meshes defines the list of meshes to scan
  30371. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30372. */
  30373. static MinMax(meshes: AbstractMesh[]): {
  30374. min: Vector3;
  30375. max: Vector3;
  30376. };
  30377. /**
  30378. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30379. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30380. * @returns a vector3
  30381. */
  30382. static Center(meshesOrMinMaxVector: {
  30383. min: Vector3;
  30384. max: Vector3;
  30385. } | AbstractMesh[]): Vector3;
  30386. /**
  30387. * Merge the array of meshes into a single mesh for performance reasons.
  30388. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30389. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30390. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30391. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30392. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30393. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30394. * @returns a new mesh
  30395. */
  30396. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30397. /** @hidden */
  30398. addInstance(instance: InstancedMesh): void;
  30399. /** @hidden */
  30400. removeInstance(instance: InstancedMesh): void;
  30401. }
  30402. }
  30403. declare module "babylonjs/Cameras/camera" {
  30404. import { SmartArray } from "babylonjs/Misc/smartArray";
  30405. import { Observable } from "babylonjs/Misc/observable";
  30406. import { Nullable } from "babylonjs/types";
  30407. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30408. import { Scene } from "babylonjs/scene";
  30409. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30410. import { Node } from "babylonjs/node";
  30411. import { Mesh } from "babylonjs/Meshes/mesh";
  30412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30413. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30414. import { Viewport } from "babylonjs/Maths/math.viewport";
  30415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30416. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30418. import { Ray } from "babylonjs/Culling/ray";
  30419. /**
  30420. * This is the base class of all the camera used in the application.
  30421. * @see https://doc.babylonjs.com/features/cameras
  30422. */
  30423. export class Camera extends Node {
  30424. /** @hidden */
  30425. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30426. /**
  30427. * This is the default projection mode used by the cameras.
  30428. * It helps recreating a feeling of perspective and better appreciate depth.
  30429. * This is the best way to simulate real life cameras.
  30430. */
  30431. static readonly PERSPECTIVE_CAMERA: number;
  30432. /**
  30433. * This helps creating camera with an orthographic mode.
  30434. * 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.
  30435. */
  30436. static readonly ORTHOGRAPHIC_CAMERA: number;
  30437. /**
  30438. * This is the default FOV mode for perspective cameras.
  30439. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30440. */
  30441. static readonly FOVMODE_VERTICAL_FIXED: number;
  30442. /**
  30443. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30446. /**
  30447. * This specifies ther is no need for a camera rig.
  30448. * Basically only one eye is rendered corresponding to the camera.
  30449. */
  30450. static readonly RIG_MODE_NONE: number;
  30451. /**
  30452. * Simulates a camera Rig with one blue eye and one red eye.
  30453. * This can be use with 3d blue and red glasses.
  30454. */
  30455. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30456. /**
  30457. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered over under each other.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30468. /**
  30469. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30470. */
  30471. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30472. /**
  30473. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30474. */
  30475. static readonly RIG_MODE_VR: number;
  30476. /**
  30477. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30478. */
  30479. static readonly RIG_MODE_WEBVR: number;
  30480. /**
  30481. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30482. */
  30483. static readonly RIG_MODE_CUSTOM: number;
  30484. /**
  30485. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30486. */
  30487. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30488. /**
  30489. * Define the input manager associated with the camera.
  30490. */
  30491. inputs: CameraInputsManager<Camera>;
  30492. /** @hidden */
  30493. _position: Vector3;
  30494. /**
  30495. * Define the current local position of the camera in the scene
  30496. */
  30497. get position(): Vector3;
  30498. set position(newPosition: Vector3);
  30499. protected _upVector: Vector3;
  30500. /**
  30501. * The vector the camera should consider as up.
  30502. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30503. */
  30504. set upVector(vec: Vector3);
  30505. get upVector(): Vector3;
  30506. /**
  30507. * Define the current limit on the left side for an orthographic camera
  30508. * In scene unit
  30509. */
  30510. orthoLeft: Nullable<number>;
  30511. /**
  30512. * Define the current limit on the right side for an orthographic camera
  30513. * In scene unit
  30514. */
  30515. orthoRight: Nullable<number>;
  30516. /**
  30517. * Define the current limit on the bottom side for an orthographic camera
  30518. * In scene unit
  30519. */
  30520. orthoBottom: Nullable<number>;
  30521. /**
  30522. * Define the current limit on the top side for an orthographic camera
  30523. * In scene unit
  30524. */
  30525. orthoTop: Nullable<number>;
  30526. /**
  30527. * Field Of View is set in Radians. (default is 0.8)
  30528. */
  30529. fov: number;
  30530. /**
  30531. * Define the minimum distance the camera can see from.
  30532. * This is important to note that the depth buffer are not infinite and the closer it starts
  30533. * the more your scene might encounter depth fighting issue.
  30534. */
  30535. minZ: number;
  30536. /**
  30537. * Define the maximum distance the camera can see to.
  30538. * This is important to note that the depth buffer are not infinite and the further it end
  30539. * the more your scene might encounter depth fighting issue.
  30540. */
  30541. maxZ: number;
  30542. /**
  30543. * Define the default inertia of the camera.
  30544. * This helps giving a smooth feeling to the camera movement.
  30545. */
  30546. inertia: number;
  30547. /**
  30548. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30549. */
  30550. mode: number;
  30551. /**
  30552. * Define whether the camera is intermediate.
  30553. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30554. */
  30555. isIntermediate: boolean;
  30556. /**
  30557. * Define the viewport of the camera.
  30558. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30559. */
  30560. viewport: Viewport;
  30561. /**
  30562. * Restricts the camera to viewing objects with the same layerMask.
  30563. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30564. */
  30565. layerMask: number;
  30566. /**
  30567. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30568. */
  30569. fovMode: number;
  30570. /**
  30571. * Rig mode of the camera.
  30572. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30573. * This is normally controlled byt the camera themselves as internal use.
  30574. */
  30575. cameraRigMode: number;
  30576. /**
  30577. * Defines the distance between both "eyes" in case of a RIG
  30578. */
  30579. interaxialDistance: number;
  30580. /**
  30581. * Defines if stereoscopic rendering is done side by side or over under.
  30582. */
  30583. isStereoscopicSideBySide: boolean;
  30584. /**
  30585. * 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
  30586. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30587. * else in the scene. (Eg. security camera)
  30588. *
  30589. * 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)
  30590. */
  30591. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30592. /**
  30593. * When set, the camera will render to this render target instead of the default canvas
  30594. *
  30595. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30596. */
  30597. outputRenderTarget: Nullable<RenderTargetTexture>;
  30598. /**
  30599. * Observable triggered when the camera view matrix has changed.
  30600. */
  30601. onViewMatrixChangedObservable: Observable<Camera>;
  30602. /**
  30603. * Observable triggered when the camera Projection matrix has changed.
  30604. */
  30605. onProjectionMatrixChangedObservable: Observable<Camera>;
  30606. /**
  30607. * Observable triggered when the inputs have been processed.
  30608. */
  30609. onAfterCheckInputsObservable: Observable<Camera>;
  30610. /**
  30611. * Observable triggered when reset has been called and applied to the camera.
  30612. */
  30613. onRestoreStateObservable: Observable<Camera>;
  30614. /**
  30615. * Is this camera a part of a rig system?
  30616. */
  30617. isRigCamera: boolean;
  30618. /**
  30619. * If isRigCamera set to true this will be set with the parent camera.
  30620. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30621. */
  30622. rigParent?: Camera;
  30623. /** @hidden */
  30624. _cameraRigParams: any;
  30625. /** @hidden */
  30626. _rigCameras: Camera[];
  30627. /** @hidden */
  30628. _rigPostProcess: Nullable<PostProcess>;
  30629. protected _webvrViewMatrix: Matrix;
  30630. /** @hidden */
  30631. _skipRendering: boolean;
  30632. /** @hidden */
  30633. _projectionMatrix: Matrix;
  30634. /** @hidden */
  30635. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30636. /** @hidden */
  30637. _activeMeshes: SmartArray<AbstractMesh>;
  30638. protected _globalPosition: Vector3;
  30639. /** @hidden */
  30640. _computedViewMatrix: Matrix;
  30641. private _doNotComputeProjectionMatrix;
  30642. private _transformMatrix;
  30643. private _frustumPlanes;
  30644. private _refreshFrustumPlanes;
  30645. private _storedFov;
  30646. private _stateStored;
  30647. /**
  30648. * Instantiates a new camera object.
  30649. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30650. * @see https://doc.babylonjs.com/features/cameras
  30651. * @param name Defines the name of the camera in the scene
  30652. * @param position Defines the position of the camera
  30653. * @param scene Defines the scene the camera belongs too
  30654. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30655. */
  30656. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30657. /**
  30658. * Store current camera state (fov, position, etc..)
  30659. * @returns the camera
  30660. */
  30661. storeState(): Camera;
  30662. /**
  30663. * Restores the camera state values if it has been stored. You must call storeState() first
  30664. */
  30665. protected _restoreStateValues(): boolean;
  30666. /**
  30667. * Restored camera state. You must call storeState() first.
  30668. * @returns true if restored and false otherwise
  30669. */
  30670. restoreState(): boolean;
  30671. /**
  30672. * Gets the class name of the camera.
  30673. * @returns the class name
  30674. */
  30675. getClassName(): string;
  30676. /** @hidden */
  30677. readonly _isCamera: boolean;
  30678. /**
  30679. * Gets a string representation of the camera useful for debug purpose.
  30680. * @param fullDetails Defines that a more verboe level of logging is required
  30681. * @returns the string representation
  30682. */
  30683. toString(fullDetails?: boolean): string;
  30684. /**
  30685. * Gets the current world space position of the camera.
  30686. */
  30687. get globalPosition(): Vector3;
  30688. /**
  30689. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30690. * @returns the active meshe list
  30691. */
  30692. getActiveMeshes(): SmartArray<AbstractMesh>;
  30693. /**
  30694. * Check whether a mesh is part of the current active mesh list of the camera
  30695. * @param mesh Defines the mesh to check
  30696. * @returns true if active, false otherwise
  30697. */
  30698. isActiveMesh(mesh: Mesh): boolean;
  30699. /**
  30700. * Is this camera ready to be used/rendered
  30701. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30702. * @return true if the camera is ready
  30703. */
  30704. isReady(completeCheck?: boolean): boolean;
  30705. /** @hidden */
  30706. _initCache(): void;
  30707. /** @hidden */
  30708. _updateCache(ignoreParentClass?: boolean): void;
  30709. /** @hidden */
  30710. _isSynchronized(): boolean;
  30711. /** @hidden */
  30712. _isSynchronizedViewMatrix(): boolean;
  30713. /** @hidden */
  30714. _isSynchronizedProjectionMatrix(): boolean;
  30715. /**
  30716. * Attach the input controls to a specific dom element to get the input from.
  30717. * @param element Defines the element the controls should be listened from
  30718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30719. */
  30720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30721. /**
  30722. * Detach the current controls from the specified dom element.
  30723. * @param element Defines the element to stop listening the inputs from
  30724. */
  30725. detachControl(element: HTMLElement): void;
  30726. /**
  30727. * Update the camera state according to the different inputs gathered during the frame.
  30728. */
  30729. update(): void;
  30730. /** @hidden */
  30731. _checkInputs(): void;
  30732. /** @hidden */
  30733. get rigCameras(): Camera[];
  30734. /**
  30735. * Gets the post process used by the rig cameras
  30736. */
  30737. get rigPostProcess(): Nullable<PostProcess>;
  30738. /**
  30739. * Internal, gets the first post proces.
  30740. * @returns the first post process to be run on this camera.
  30741. */
  30742. _getFirstPostProcess(): Nullable<PostProcess>;
  30743. private _cascadePostProcessesToRigCams;
  30744. /**
  30745. * Attach a post process to the camera.
  30746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30747. * @param postProcess The post process to attach to the camera
  30748. * @param insertAt The position of the post process in case several of them are in use in the scene
  30749. * @returns the position the post process has been inserted at
  30750. */
  30751. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30752. /**
  30753. * Detach a post process to the camera.
  30754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30755. * @param postProcess The post process to detach from the camera
  30756. */
  30757. detachPostProcess(postProcess: PostProcess): void;
  30758. /**
  30759. * Gets the current world matrix of the camera
  30760. */
  30761. getWorldMatrix(): Matrix;
  30762. /** @hidden */
  30763. _getViewMatrix(): Matrix;
  30764. /**
  30765. * Gets the current view matrix of the camera.
  30766. * @param force forces the camera to recompute the matrix without looking at the cached state
  30767. * @returns the view matrix
  30768. */
  30769. getViewMatrix(force?: boolean): Matrix;
  30770. /**
  30771. * Freeze the projection matrix.
  30772. * It will prevent the cache check of the camera projection compute and can speed up perf
  30773. * if no parameter of the camera are meant to change
  30774. * @param projection Defines manually a projection if necessary
  30775. */
  30776. freezeProjectionMatrix(projection?: Matrix): void;
  30777. /**
  30778. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30779. */
  30780. unfreezeProjectionMatrix(): void;
  30781. /**
  30782. * Gets the current projection matrix of the camera.
  30783. * @param force forces the camera to recompute the matrix without looking at the cached state
  30784. * @returns the projection matrix
  30785. */
  30786. getProjectionMatrix(force?: boolean): Matrix;
  30787. /**
  30788. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30789. * @returns a Matrix
  30790. */
  30791. getTransformationMatrix(): Matrix;
  30792. private _updateFrustumPlanes;
  30793. /**
  30794. * Checks if a cullable object (mesh...) is in the camera frustum
  30795. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30796. * @param target The object to check
  30797. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30798. * @returns true if the object is in frustum otherwise false
  30799. */
  30800. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30801. /**
  30802. * Checks if a cullable object (mesh...) is in the camera frustum
  30803. * Unlike isInFrustum this cheks the full bounding box
  30804. * @param target The object to check
  30805. * @returns true if the object is in frustum otherwise false
  30806. */
  30807. isCompletelyInFrustum(target: ICullable): boolean;
  30808. /**
  30809. * Gets a ray in the forward direction from the camera.
  30810. * @param length Defines the length of the ray to create
  30811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30812. * @param origin Defines the start point of the ray which defaults to the camera position
  30813. * @returns the forward ray
  30814. */
  30815. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30816. /**
  30817. * Gets a ray in the forward direction from the camera.
  30818. * @param refRay the ray to (re)use when setting the values
  30819. * @param length Defines the length of the ray to create
  30820. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30821. * @param origin Defines the start point of the ray which defaults to the camera position
  30822. * @returns the forward ray
  30823. */
  30824. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30825. /**
  30826. * Releases resources associated with this node.
  30827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30829. */
  30830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30831. /** @hidden */
  30832. _isLeftCamera: boolean;
  30833. /**
  30834. * Gets the left camera of a rig setup in case of Rigged Camera
  30835. */
  30836. get isLeftCamera(): boolean;
  30837. /** @hidden */
  30838. _isRightCamera: boolean;
  30839. /**
  30840. * Gets the right camera of a rig setup in case of Rigged Camera
  30841. */
  30842. get isRightCamera(): boolean;
  30843. /**
  30844. * Gets the left camera of a rig setup in case of Rigged Camera
  30845. */
  30846. get leftCamera(): Nullable<FreeCamera>;
  30847. /**
  30848. * Gets the right camera of a rig setup in case of Rigged Camera
  30849. */
  30850. get rightCamera(): Nullable<FreeCamera>;
  30851. /**
  30852. * Gets the left camera target of a rig setup in case of Rigged Camera
  30853. * @returns the target position
  30854. */
  30855. getLeftTarget(): Nullable<Vector3>;
  30856. /**
  30857. * Gets the right camera target of a rig setup in case of Rigged Camera
  30858. * @returns the target position
  30859. */
  30860. getRightTarget(): Nullable<Vector3>;
  30861. /**
  30862. * @hidden
  30863. */
  30864. setCameraRigMode(mode: number, rigParams: any): void;
  30865. /** @hidden */
  30866. static _setStereoscopicRigMode(camera: Camera): void;
  30867. /** @hidden */
  30868. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30869. /** @hidden */
  30870. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30871. /** @hidden */
  30872. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30873. /** @hidden */
  30874. _getVRProjectionMatrix(): Matrix;
  30875. protected _updateCameraRotationMatrix(): void;
  30876. protected _updateWebVRCameraRotationMatrix(): void;
  30877. /**
  30878. * This function MUST be overwritten by the different WebVR cameras available.
  30879. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30880. * @hidden
  30881. */
  30882. _getWebVRProjectionMatrix(): Matrix;
  30883. /**
  30884. * This function MUST be overwritten by the different WebVR cameras available.
  30885. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30886. * @hidden
  30887. */
  30888. _getWebVRViewMatrix(): Matrix;
  30889. /** @hidden */
  30890. setCameraRigParameter(name: string, value: any): void;
  30891. /**
  30892. * needs to be overridden by children so sub has required properties to be copied
  30893. * @hidden
  30894. */
  30895. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30896. /**
  30897. * May need to be overridden by children
  30898. * @hidden
  30899. */
  30900. _updateRigCameras(): void;
  30901. /** @hidden */
  30902. _setupInputs(): void;
  30903. /**
  30904. * Serialiaze the camera setup to a json represention
  30905. * @returns the JSON representation
  30906. */
  30907. serialize(): any;
  30908. /**
  30909. * Clones the current camera.
  30910. * @param name The cloned camera name
  30911. * @returns the cloned camera
  30912. */
  30913. clone(name: string): Camera;
  30914. /**
  30915. * Gets the direction of the camera relative to a given local axis.
  30916. * @param localAxis Defines the reference axis to provide a relative direction.
  30917. * @return the direction
  30918. */
  30919. getDirection(localAxis: Vector3): Vector3;
  30920. /**
  30921. * Returns the current camera absolute rotation
  30922. */
  30923. get absoluteRotation(): Quaternion;
  30924. /**
  30925. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30926. * @param localAxis Defines the reference axis to provide a relative direction.
  30927. * @param result Defines the vector to store the result in
  30928. */
  30929. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30930. /**
  30931. * Gets a camera constructor for a given camera type
  30932. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30933. * @param name The name of the camera the result will be able to instantiate
  30934. * @param scene The scene the result will construct the camera in
  30935. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30936. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30937. * @returns a factory method to construc the camera
  30938. */
  30939. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30940. /**
  30941. * Compute the world matrix of the camera.
  30942. * @returns the camera world matrix
  30943. */
  30944. computeWorldMatrix(): Matrix;
  30945. /**
  30946. * Parse a JSON and creates the camera from the parsed information
  30947. * @param parsedCamera The JSON to parse
  30948. * @param scene The scene to instantiate the camera in
  30949. * @returns the newly constructed camera
  30950. */
  30951. static Parse(parsedCamera: any, scene: Scene): Camera;
  30952. }
  30953. }
  30954. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30955. import { Nullable } from "babylonjs/types";
  30956. import { Scene } from "babylonjs/scene";
  30957. import { Vector4 } from "babylonjs/Maths/math.vector";
  30958. import { Mesh } from "babylonjs/Meshes/mesh";
  30959. /**
  30960. * Class containing static functions to help procedurally build meshes
  30961. */
  30962. export class DiscBuilder {
  30963. /**
  30964. * Creates a plane polygonal mesh. By default, this is a disc
  30965. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30966. * * 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
  30967. * * 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
  30968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30971. * @param name defines the name of the mesh
  30972. * @param options defines the options used to create the mesh
  30973. * @param scene defines the hosting scene
  30974. * @returns the plane polygonal mesh
  30975. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30976. */
  30977. static CreateDisc(name: string, options: {
  30978. radius?: number;
  30979. tessellation?: number;
  30980. arc?: number;
  30981. updatable?: boolean;
  30982. sideOrientation?: number;
  30983. frontUVs?: Vector4;
  30984. backUVs?: Vector4;
  30985. }, scene?: Nullable<Scene>): Mesh;
  30986. }
  30987. }
  30988. declare module "babylonjs/Materials/fresnelParameters" {
  30989. import { DeepImmutable } from "babylonjs/types";
  30990. import { Color3 } from "babylonjs/Maths/math.color";
  30991. /**
  30992. * Options to be used when creating a FresnelParameters.
  30993. */
  30994. export type IFresnelParametersCreationOptions = {
  30995. /**
  30996. * Define the color used on edges (grazing angle)
  30997. */
  30998. leftColor?: Color3;
  30999. /**
  31000. * Define the color used on center
  31001. */
  31002. rightColor?: Color3;
  31003. /**
  31004. * Define bias applied to computed fresnel term
  31005. */
  31006. bias?: number;
  31007. /**
  31008. * Defined the power exponent applied to fresnel term
  31009. */
  31010. power?: number;
  31011. /**
  31012. * Define if the fresnel effect is enable or not.
  31013. */
  31014. isEnabled?: boolean;
  31015. };
  31016. /**
  31017. * Serialized format for FresnelParameters.
  31018. */
  31019. export type IFresnelParametersSerialized = {
  31020. /**
  31021. * Define the color used on edges (grazing angle) [as an array]
  31022. */
  31023. leftColor: number[];
  31024. /**
  31025. * Define the color used on center [as an array]
  31026. */
  31027. rightColor: number[];
  31028. /**
  31029. * Define bias applied to computed fresnel term
  31030. */
  31031. bias: number;
  31032. /**
  31033. * Defined the power exponent applied to fresnel term
  31034. */
  31035. power?: number;
  31036. /**
  31037. * Define if the fresnel effect is enable or not.
  31038. */
  31039. isEnabled: boolean;
  31040. };
  31041. /**
  31042. * This represents all the required information to add a fresnel effect on a material:
  31043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31044. */
  31045. export class FresnelParameters {
  31046. private _isEnabled;
  31047. /**
  31048. * Define if the fresnel effect is enable or not.
  31049. */
  31050. get isEnabled(): boolean;
  31051. set isEnabled(value: boolean);
  31052. /**
  31053. * Define the color used on edges (grazing angle)
  31054. */
  31055. leftColor: Color3;
  31056. /**
  31057. * Define the color used on center
  31058. */
  31059. rightColor: Color3;
  31060. /**
  31061. * Define bias applied to computed fresnel term
  31062. */
  31063. bias: number;
  31064. /**
  31065. * Defined the power exponent applied to fresnel term
  31066. */
  31067. power: number;
  31068. /**
  31069. * Creates a new FresnelParameters object.
  31070. *
  31071. * @param options provide your own settings to optionally to override defaults
  31072. */
  31073. constructor(options?: IFresnelParametersCreationOptions);
  31074. /**
  31075. * Clones the current fresnel and its valuues
  31076. * @returns a clone fresnel configuration
  31077. */
  31078. clone(): FresnelParameters;
  31079. /**
  31080. * Determines equality between FresnelParameters objects
  31081. * @param otherFresnelParameters defines the second operand
  31082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31083. */
  31084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31085. /**
  31086. * Serializes the current fresnel parameters to a JSON representation.
  31087. * @return the JSON serialization
  31088. */
  31089. serialize(): IFresnelParametersSerialized;
  31090. /**
  31091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31092. * @param parsedFresnelParameters Define the JSON representation
  31093. * @returns the parsed parameters
  31094. */
  31095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31096. }
  31097. }
  31098. declare module "babylonjs/Materials/materialFlags" {
  31099. /**
  31100. * This groups all the flags used to control the materials channel.
  31101. */
  31102. export class MaterialFlags {
  31103. private static _DiffuseTextureEnabled;
  31104. /**
  31105. * Are diffuse textures enabled in the application.
  31106. */
  31107. static get DiffuseTextureEnabled(): boolean;
  31108. static set DiffuseTextureEnabled(value: boolean);
  31109. private static _DetailTextureEnabled;
  31110. /**
  31111. * Are detail textures enabled in the application.
  31112. */
  31113. static get DetailTextureEnabled(): boolean;
  31114. static set DetailTextureEnabled(value: boolean);
  31115. private static _AmbientTextureEnabled;
  31116. /**
  31117. * Are ambient textures enabled in the application.
  31118. */
  31119. static get AmbientTextureEnabled(): boolean;
  31120. static set AmbientTextureEnabled(value: boolean);
  31121. private static _OpacityTextureEnabled;
  31122. /**
  31123. * Are opacity textures enabled in the application.
  31124. */
  31125. static get OpacityTextureEnabled(): boolean;
  31126. static set OpacityTextureEnabled(value: boolean);
  31127. private static _ReflectionTextureEnabled;
  31128. /**
  31129. * Are reflection textures enabled in the application.
  31130. */
  31131. static get ReflectionTextureEnabled(): boolean;
  31132. static set ReflectionTextureEnabled(value: boolean);
  31133. private static _EmissiveTextureEnabled;
  31134. /**
  31135. * Are emissive textures enabled in the application.
  31136. */
  31137. static get EmissiveTextureEnabled(): boolean;
  31138. static set EmissiveTextureEnabled(value: boolean);
  31139. private static _SpecularTextureEnabled;
  31140. /**
  31141. * Are specular textures enabled in the application.
  31142. */
  31143. static get SpecularTextureEnabled(): boolean;
  31144. static set SpecularTextureEnabled(value: boolean);
  31145. private static _BumpTextureEnabled;
  31146. /**
  31147. * Are bump textures enabled in the application.
  31148. */
  31149. static get BumpTextureEnabled(): boolean;
  31150. static set BumpTextureEnabled(value: boolean);
  31151. private static _LightmapTextureEnabled;
  31152. /**
  31153. * Are lightmap textures enabled in the application.
  31154. */
  31155. static get LightmapTextureEnabled(): boolean;
  31156. static set LightmapTextureEnabled(value: boolean);
  31157. private static _RefractionTextureEnabled;
  31158. /**
  31159. * Are refraction textures enabled in the application.
  31160. */
  31161. static get RefractionTextureEnabled(): boolean;
  31162. static set RefractionTextureEnabled(value: boolean);
  31163. private static _ColorGradingTextureEnabled;
  31164. /**
  31165. * Are color grading textures enabled in the application.
  31166. */
  31167. static get ColorGradingTextureEnabled(): boolean;
  31168. static set ColorGradingTextureEnabled(value: boolean);
  31169. private static _FresnelEnabled;
  31170. /**
  31171. * Are fresnels enabled in the application.
  31172. */
  31173. static get FresnelEnabled(): boolean;
  31174. static set FresnelEnabled(value: boolean);
  31175. private static _ClearCoatTextureEnabled;
  31176. /**
  31177. * Are clear coat textures enabled in the application.
  31178. */
  31179. static get ClearCoatTextureEnabled(): boolean;
  31180. static set ClearCoatTextureEnabled(value: boolean);
  31181. private static _ClearCoatBumpTextureEnabled;
  31182. /**
  31183. * Are clear coat bump textures enabled in the application.
  31184. */
  31185. static get ClearCoatBumpTextureEnabled(): boolean;
  31186. static set ClearCoatBumpTextureEnabled(value: boolean);
  31187. private static _ClearCoatTintTextureEnabled;
  31188. /**
  31189. * Are clear coat tint textures enabled in the application.
  31190. */
  31191. static get ClearCoatTintTextureEnabled(): boolean;
  31192. static set ClearCoatTintTextureEnabled(value: boolean);
  31193. private static _SheenTextureEnabled;
  31194. /**
  31195. * Are sheen textures enabled in the application.
  31196. */
  31197. static get SheenTextureEnabled(): boolean;
  31198. static set SheenTextureEnabled(value: boolean);
  31199. private static _AnisotropicTextureEnabled;
  31200. /**
  31201. * Are anisotropic textures enabled in the application.
  31202. */
  31203. static get AnisotropicTextureEnabled(): boolean;
  31204. static set AnisotropicTextureEnabled(value: boolean);
  31205. private static _ThicknessTextureEnabled;
  31206. /**
  31207. * Are thickness textures enabled in the application.
  31208. */
  31209. static get ThicknessTextureEnabled(): boolean;
  31210. static set ThicknessTextureEnabled(value: boolean);
  31211. }
  31212. }
  31213. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31214. /** @hidden */
  31215. export var defaultFragmentDeclaration: {
  31216. name: string;
  31217. shader: string;
  31218. };
  31219. }
  31220. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31221. /** @hidden */
  31222. export var defaultUboDeclaration: {
  31223. name: string;
  31224. shader: string;
  31225. };
  31226. }
  31227. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31228. /** @hidden */
  31229. export var prePassDeclaration: {
  31230. name: string;
  31231. shader: string;
  31232. };
  31233. }
  31234. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31235. /** @hidden */
  31236. export var lightFragmentDeclaration: {
  31237. name: string;
  31238. shader: string;
  31239. };
  31240. }
  31241. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31242. /** @hidden */
  31243. export var lightUboDeclaration: {
  31244. name: string;
  31245. shader: string;
  31246. };
  31247. }
  31248. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31249. /** @hidden */
  31250. export var lightsFragmentFunctions: {
  31251. name: string;
  31252. shader: string;
  31253. };
  31254. }
  31255. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31256. /** @hidden */
  31257. export var shadowsFragmentFunctions: {
  31258. name: string;
  31259. shader: string;
  31260. };
  31261. }
  31262. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31263. /** @hidden */
  31264. export var fresnelFunction: {
  31265. name: string;
  31266. shader: string;
  31267. };
  31268. }
  31269. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31270. /** @hidden */
  31271. export var bumpFragmentMainFunctions: {
  31272. name: string;
  31273. shader: string;
  31274. };
  31275. }
  31276. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31277. /** @hidden */
  31278. export var bumpFragmentFunctions: {
  31279. name: string;
  31280. shader: string;
  31281. };
  31282. }
  31283. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31284. /** @hidden */
  31285. export var logDepthDeclaration: {
  31286. name: string;
  31287. shader: string;
  31288. };
  31289. }
  31290. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31291. /** @hidden */
  31292. export var bumpFragment: {
  31293. name: string;
  31294. shader: string;
  31295. };
  31296. }
  31297. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31298. /** @hidden */
  31299. export var depthPrePass: {
  31300. name: string;
  31301. shader: string;
  31302. };
  31303. }
  31304. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31305. /** @hidden */
  31306. export var lightFragment: {
  31307. name: string;
  31308. shader: string;
  31309. };
  31310. }
  31311. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31312. /** @hidden */
  31313. export var logDepthFragment: {
  31314. name: string;
  31315. shader: string;
  31316. };
  31317. }
  31318. declare module "babylonjs/Shaders/default.fragment" {
  31319. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31320. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31323. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31326. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31328. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31329. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31330. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31331. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31333. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31334. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31335. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31336. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31337. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31338. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31339. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31340. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31342. /** @hidden */
  31343. export var defaultPixelShader: {
  31344. name: string;
  31345. shader: string;
  31346. };
  31347. }
  31348. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31349. /** @hidden */
  31350. export var defaultVertexDeclaration: {
  31351. name: string;
  31352. shader: string;
  31353. };
  31354. }
  31355. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31356. /** @hidden */
  31357. export var bumpVertexDeclaration: {
  31358. name: string;
  31359. shader: string;
  31360. };
  31361. }
  31362. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31363. /** @hidden */
  31364. export var bumpVertex: {
  31365. name: string;
  31366. shader: string;
  31367. };
  31368. }
  31369. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31370. /** @hidden */
  31371. export var fogVertex: {
  31372. name: string;
  31373. shader: string;
  31374. };
  31375. }
  31376. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31377. /** @hidden */
  31378. export var shadowsVertex: {
  31379. name: string;
  31380. shader: string;
  31381. };
  31382. }
  31383. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31384. /** @hidden */
  31385. export var pointCloudVertex: {
  31386. name: string;
  31387. shader: string;
  31388. };
  31389. }
  31390. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31391. /** @hidden */
  31392. export var logDepthVertex: {
  31393. name: string;
  31394. shader: string;
  31395. };
  31396. }
  31397. declare module "babylonjs/Shaders/default.vertex" {
  31398. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31399. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31412. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31413. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31414. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31415. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31420. /** @hidden */
  31421. export var defaultVertexShader: {
  31422. name: string;
  31423. shader: string;
  31424. };
  31425. }
  31426. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31427. import { Nullable } from "babylonjs/types";
  31428. import { Scene } from "babylonjs/scene";
  31429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31431. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31432. /**
  31433. * @hidden
  31434. */
  31435. export interface IMaterialDetailMapDefines {
  31436. DETAIL: boolean;
  31437. DETAILDIRECTUV: number;
  31438. DETAIL_NORMALBLENDMETHOD: number;
  31439. /** @hidden */
  31440. _areTexturesDirty: boolean;
  31441. }
  31442. /**
  31443. * Define the code related to the detail map parameters of a material
  31444. *
  31445. * Inspired from:
  31446. * 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
  31447. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31448. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31449. */
  31450. export class DetailMapConfiguration {
  31451. private _texture;
  31452. /**
  31453. * The detail texture of the material.
  31454. */
  31455. texture: Nullable<BaseTexture>;
  31456. /**
  31457. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31458. * Bigger values mean stronger blending
  31459. */
  31460. diffuseBlendLevel: number;
  31461. /**
  31462. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31463. * Bigger values mean stronger blending. Only used with PBR materials
  31464. */
  31465. roughnessBlendLevel: number;
  31466. /**
  31467. * Defines how strong the bump effect from the detail map is
  31468. * Bigger values mean stronger effect
  31469. */
  31470. bumpLevel: number;
  31471. private _normalBlendMethod;
  31472. /**
  31473. * The method used to blend the bump and detail normals together
  31474. */
  31475. normalBlendMethod: number;
  31476. private _isEnabled;
  31477. /**
  31478. * Enable or disable the detail map on this material
  31479. */
  31480. isEnabled: boolean;
  31481. /** @hidden */
  31482. private _internalMarkAllSubMeshesAsTexturesDirty;
  31483. /** @hidden */
  31484. _markAllSubMeshesAsTexturesDirty(): void;
  31485. /**
  31486. * Instantiate a new detail map
  31487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31488. */
  31489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31490. /**
  31491. * Gets whether the submesh is ready to be used or not.
  31492. * @param defines the list of "defines" to update.
  31493. * @param scene defines the scene the material belongs to.
  31494. * @returns - boolean indicating that the submesh is ready or not.
  31495. */
  31496. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31497. /**
  31498. * Update the defines for detail map usage
  31499. * @param defines the list of "defines" to update.
  31500. * @param scene defines the scene the material belongs to.
  31501. */
  31502. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31503. /**
  31504. * Binds the material data.
  31505. * @param uniformBuffer defines the Uniform buffer to fill in.
  31506. * @param scene defines the scene the material belongs to.
  31507. * @param isFrozen defines whether the material is frozen or not.
  31508. */
  31509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31510. /**
  31511. * Checks to see if a texture is used in the material.
  31512. * @param texture - Base texture to use.
  31513. * @returns - Boolean specifying if a texture is used in the material.
  31514. */
  31515. hasTexture(texture: BaseTexture): boolean;
  31516. /**
  31517. * Returns an array of the actively used textures.
  31518. * @param activeTextures Array of BaseTextures
  31519. */
  31520. getActiveTextures(activeTextures: BaseTexture[]): void;
  31521. /**
  31522. * Returns the animatable textures.
  31523. * @param animatables Array of animatable textures.
  31524. */
  31525. getAnimatables(animatables: IAnimatable[]): void;
  31526. /**
  31527. * Disposes the resources of the material.
  31528. * @param forceDisposeTextures - Forces the disposal of all textures.
  31529. */
  31530. dispose(forceDisposeTextures?: boolean): void;
  31531. /**
  31532. * Get the current class name useful for serialization or dynamic coding.
  31533. * @returns "DetailMap"
  31534. */
  31535. getClassName(): string;
  31536. /**
  31537. * Add the required uniforms to the current list.
  31538. * @param uniforms defines the current uniform list.
  31539. */
  31540. static AddUniforms(uniforms: string[]): void;
  31541. /**
  31542. * Add the required samplers to the current list.
  31543. * @param samplers defines the current sampler list.
  31544. */
  31545. static AddSamplers(samplers: string[]): void;
  31546. /**
  31547. * Add the required uniforms to the current buffer.
  31548. * @param uniformBuffer defines the current uniform buffer.
  31549. */
  31550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31551. /**
  31552. * Makes a duplicate of the current instance into another one.
  31553. * @param detailMap define the instance where to copy the info
  31554. */
  31555. copyTo(detailMap: DetailMapConfiguration): void;
  31556. /**
  31557. * Serializes this detail map instance
  31558. * @returns - An object with the serialized instance.
  31559. */
  31560. serialize(): any;
  31561. /**
  31562. * Parses a detail map setting from a serialized object.
  31563. * @param source - Serialized object.
  31564. * @param scene Defines the scene we are parsing for
  31565. * @param rootUrl Defines the rootUrl to load from
  31566. */
  31567. parse(source: any, scene: Scene, rootUrl: string): void;
  31568. }
  31569. }
  31570. declare module "babylonjs/Materials/standardMaterial" {
  31571. import { SmartArray } from "babylonjs/Misc/smartArray";
  31572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31573. import { Nullable } from "babylonjs/types";
  31574. import { Scene } from "babylonjs/scene";
  31575. import { Matrix } from "babylonjs/Maths/math.vector";
  31576. import { Color3 } from "babylonjs/Maths/math.color";
  31577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31579. import { Mesh } from "babylonjs/Meshes/mesh";
  31580. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31581. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31582. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31583. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31584. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31587. import "babylonjs/Shaders/default.fragment";
  31588. import "babylonjs/Shaders/default.vertex";
  31589. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31590. /** @hidden */
  31591. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31592. MAINUV1: boolean;
  31593. MAINUV2: boolean;
  31594. DIFFUSE: boolean;
  31595. DIFFUSEDIRECTUV: number;
  31596. DETAIL: boolean;
  31597. DETAILDIRECTUV: number;
  31598. DETAIL_NORMALBLENDMETHOD: number;
  31599. AMBIENT: boolean;
  31600. AMBIENTDIRECTUV: number;
  31601. OPACITY: boolean;
  31602. OPACITYDIRECTUV: number;
  31603. OPACITYRGB: boolean;
  31604. REFLECTION: boolean;
  31605. EMISSIVE: boolean;
  31606. EMISSIVEDIRECTUV: number;
  31607. SPECULAR: boolean;
  31608. SPECULARDIRECTUV: number;
  31609. BUMP: boolean;
  31610. BUMPDIRECTUV: number;
  31611. PARALLAX: boolean;
  31612. PARALLAXOCCLUSION: boolean;
  31613. SPECULAROVERALPHA: boolean;
  31614. CLIPPLANE: boolean;
  31615. CLIPPLANE2: boolean;
  31616. CLIPPLANE3: boolean;
  31617. CLIPPLANE4: boolean;
  31618. CLIPPLANE5: boolean;
  31619. CLIPPLANE6: boolean;
  31620. ALPHATEST: boolean;
  31621. DEPTHPREPASS: boolean;
  31622. ALPHAFROMDIFFUSE: boolean;
  31623. POINTSIZE: boolean;
  31624. FOG: boolean;
  31625. SPECULARTERM: boolean;
  31626. DIFFUSEFRESNEL: boolean;
  31627. OPACITYFRESNEL: boolean;
  31628. REFLECTIONFRESNEL: boolean;
  31629. REFRACTIONFRESNEL: boolean;
  31630. EMISSIVEFRESNEL: boolean;
  31631. FRESNEL: boolean;
  31632. NORMAL: boolean;
  31633. UV1: boolean;
  31634. UV2: boolean;
  31635. VERTEXCOLOR: boolean;
  31636. VERTEXALPHA: boolean;
  31637. NUM_BONE_INFLUENCERS: number;
  31638. BonesPerMesh: number;
  31639. BONETEXTURE: boolean;
  31640. INSTANCES: boolean;
  31641. THIN_INSTANCES: boolean;
  31642. GLOSSINESS: boolean;
  31643. ROUGHNESS: boolean;
  31644. EMISSIVEASILLUMINATION: boolean;
  31645. LINKEMISSIVEWITHDIFFUSE: boolean;
  31646. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31647. LIGHTMAP: boolean;
  31648. LIGHTMAPDIRECTUV: number;
  31649. OBJECTSPACE_NORMALMAP: boolean;
  31650. USELIGHTMAPASSHADOWMAP: boolean;
  31651. REFLECTIONMAP_3D: boolean;
  31652. REFLECTIONMAP_SPHERICAL: boolean;
  31653. REFLECTIONMAP_PLANAR: boolean;
  31654. REFLECTIONMAP_CUBIC: boolean;
  31655. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31656. REFLECTIONMAP_PROJECTION: boolean;
  31657. REFLECTIONMAP_SKYBOX: boolean;
  31658. REFLECTIONMAP_EXPLICIT: boolean;
  31659. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31660. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31661. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31662. INVERTCUBICMAP: boolean;
  31663. LOGARITHMICDEPTH: boolean;
  31664. REFRACTION: boolean;
  31665. REFRACTIONMAP_3D: boolean;
  31666. REFLECTIONOVERALPHA: boolean;
  31667. TWOSIDEDLIGHTING: boolean;
  31668. SHADOWFLOAT: boolean;
  31669. MORPHTARGETS: boolean;
  31670. MORPHTARGETS_NORMAL: boolean;
  31671. MORPHTARGETS_TANGENT: boolean;
  31672. MORPHTARGETS_UV: boolean;
  31673. NUM_MORPH_INFLUENCERS: number;
  31674. NONUNIFORMSCALING: boolean;
  31675. PREMULTIPLYALPHA: boolean;
  31676. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31677. ALPHABLEND: boolean;
  31678. PREPASS: boolean;
  31679. PREPASS_IRRADIANCE: boolean;
  31680. PREPASS_IRRADIANCE_INDEX: number;
  31681. PREPASS_ALBEDO: boolean;
  31682. PREPASS_ALBEDO_INDEX: number;
  31683. PREPASS_DEPTHNORMAL: boolean;
  31684. PREPASS_DEPTHNORMAL_INDEX: number;
  31685. SCENE_MRT_COUNT: number;
  31686. RGBDLIGHTMAP: boolean;
  31687. RGBDREFLECTION: boolean;
  31688. RGBDREFRACTION: boolean;
  31689. IMAGEPROCESSING: boolean;
  31690. VIGNETTE: boolean;
  31691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31692. VIGNETTEBLENDMODEOPAQUE: boolean;
  31693. TONEMAPPING: boolean;
  31694. TONEMAPPING_ACES: boolean;
  31695. CONTRAST: boolean;
  31696. COLORCURVES: boolean;
  31697. COLORGRADING: boolean;
  31698. COLORGRADING3D: boolean;
  31699. SAMPLER3DGREENDEPTH: boolean;
  31700. SAMPLER3DBGRMAP: boolean;
  31701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31702. MULTIVIEW: boolean;
  31703. /**
  31704. * If the reflection texture on this material is in linear color space
  31705. * @hidden
  31706. */
  31707. IS_REFLECTION_LINEAR: boolean;
  31708. /**
  31709. * If the refraction texture on this material is in linear color space
  31710. * @hidden
  31711. */
  31712. IS_REFRACTION_LINEAR: boolean;
  31713. EXPOSURE: boolean;
  31714. constructor();
  31715. setReflectionMode(modeToEnable: string): void;
  31716. }
  31717. /**
  31718. * This is the default material used in Babylon. It is the best trade off between quality
  31719. * and performances.
  31720. * @see https://doc.babylonjs.com/babylon101/materials
  31721. */
  31722. export class StandardMaterial extends PushMaterial {
  31723. private _diffuseTexture;
  31724. /**
  31725. * The basic texture of the material as viewed under a light.
  31726. */
  31727. diffuseTexture: Nullable<BaseTexture>;
  31728. private _ambientTexture;
  31729. /**
  31730. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31731. */
  31732. ambientTexture: Nullable<BaseTexture>;
  31733. private _opacityTexture;
  31734. /**
  31735. * Define the transparency of the material from a texture.
  31736. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31737. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31738. */
  31739. opacityTexture: Nullable<BaseTexture>;
  31740. private _reflectionTexture;
  31741. /**
  31742. * Define the texture used to display the reflection.
  31743. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31744. */
  31745. reflectionTexture: Nullable<BaseTexture>;
  31746. private _emissiveTexture;
  31747. /**
  31748. * Define texture of the material as if self lit.
  31749. * This will be mixed in the final result even in the absence of light.
  31750. */
  31751. emissiveTexture: Nullable<BaseTexture>;
  31752. private _specularTexture;
  31753. /**
  31754. * Define how the color and intensity of the highlight given by the light in the material.
  31755. */
  31756. specularTexture: Nullable<BaseTexture>;
  31757. private _bumpTexture;
  31758. /**
  31759. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31760. * 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.
  31761. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31762. */
  31763. bumpTexture: Nullable<BaseTexture>;
  31764. private _lightmapTexture;
  31765. /**
  31766. * Complex lighting can be computationally expensive to compute at runtime.
  31767. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31768. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31769. */
  31770. lightmapTexture: Nullable<BaseTexture>;
  31771. private _refractionTexture;
  31772. /**
  31773. * Define the texture used to display the refraction.
  31774. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31775. */
  31776. refractionTexture: Nullable<BaseTexture>;
  31777. /**
  31778. * The color of the material lit by the environmental background lighting.
  31779. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31780. */
  31781. ambientColor: Color3;
  31782. /**
  31783. * The basic color of the material as viewed under a light.
  31784. */
  31785. diffuseColor: Color3;
  31786. /**
  31787. * Define how the color and intensity of the highlight given by the light in the material.
  31788. */
  31789. specularColor: Color3;
  31790. /**
  31791. * Define the color of the material as if self lit.
  31792. * This will be mixed in the final result even in the absence of light.
  31793. */
  31794. emissiveColor: Color3;
  31795. /**
  31796. * Defines how sharp are the highlights in the material.
  31797. * The bigger the value the sharper giving a more glossy feeling to the result.
  31798. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31799. */
  31800. specularPower: number;
  31801. private _useAlphaFromDiffuseTexture;
  31802. /**
  31803. * Does the transparency come from the diffuse texture alpha channel.
  31804. */
  31805. useAlphaFromDiffuseTexture: boolean;
  31806. private _useEmissiveAsIllumination;
  31807. /**
  31808. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31809. */
  31810. useEmissiveAsIllumination: boolean;
  31811. private _linkEmissiveWithDiffuse;
  31812. /**
  31813. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31814. * the emissive level when the final color is close to one.
  31815. */
  31816. linkEmissiveWithDiffuse: boolean;
  31817. private _useSpecularOverAlpha;
  31818. /**
  31819. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31820. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31821. */
  31822. useSpecularOverAlpha: boolean;
  31823. private _useReflectionOverAlpha;
  31824. /**
  31825. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31826. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31827. */
  31828. useReflectionOverAlpha: boolean;
  31829. private _disableLighting;
  31830. /**
  31831. * Does lights from the scene impacts this material.
  31832. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31833. */
  31834. disableLighting: boolean;
  31835. private _useObjectSpaceNormalMap;
  31836. /**
  31837. * Allows using an object space normal map (instead of tangent space).
  31838. */
  31839. useObjectSpaceNormalMap: boolean;
  31840. private _useParallax;
  31841. /**
  31842. * Is parallax enabled or not.
  31843. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31844. */
  31845. useParallax: boolean;
  31846. private _useParallaxOcclusion;
  31847. /**
  31848. * Is parallax occlusion enabled or not.
  31849. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31850. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31851. */
  31852. useParallaxOcclusion: boolean;
  31853. /**
  31854. * 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.
  31855. */
  31856. parallaxScaleBias: number;
  31857. private _roughness;
  31858. /**
  31859. * Helps to define how blurry the reflections should appears in the material.
  31860. */
  31861. roughness: number;
  31862. /**
  31863. * In case of refraction, define the value of the index of refraction.
  31864. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31865. */
  31866. indexOfRefraction: number;
  31867. /**
  31868. * Invert the refraction texture alongside the y axis.
  31869. * It can be useful with procedural textures or probe for instance.
  31870. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31871. */
  31872. invertRefractionY: boolean;
  31873. /**
  31874. * Defines the alpha limits in alpha test mode.
  31875. */
  31876. alphaCutOff: number;
  31877. private _useLightmapAsShadowmap;
  31878. /**
  31879. * In case of light mapping, define whether the map contains light or shadow informations.
  31880. */
  31881. useLightmapAsShadowmap: boolean;
  31882. private _diffuseFresnelParameters;
  31883. /**
  31884. * Define the diffuse fresnel parameters of the material.
  31885. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31886. */
  31887. diffuseFresnelParameters: FresnelParameters;
  31888. private _opacityFresnelParameters;
  31889. /**
  31890. * Define the opacity fresnel parameters of the material.
  31891. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31892. */
  31893. opacityFresnelParameters: FresnelParameters;
  31894. private _reflectionFresnelParameters;
  31895. /**
  31896. * Define the reflection fresnel parameters of the material.
  31897. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31898. */
  31899. reflectionFresnelParameters: FresnelParameters;
  31900. private _refractionFresnelParameters;
  31901. /**
  31902. * Define the refraction fresnel parameters of the material.
  31903. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31904. */
  31905. refractionFresnelParameters: FresnelParameters;
  31906. private _emissiveFresnelParameters;
  31907. /**
  31908. * Define the emissive fresnel parameters of the material.
  31909. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31910. */
  31911. emissiveFresnelParameters: FresnelParameters;
  31912. private _useReflectionFresnelFromSpecular;
  31913. /**
  31914. * If true automatically deducts the fresnels values from the material specularity.
  31915. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31916. */
  31917. useReflectionFresnelFromSpecular: boolean;
  31918. private _useGlossinessFromSpecularMapAlpha;
  31919. /**
  31920. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31921. */
  31922. useGlossinessFromSpecularMapAlpha: boolean;
  31923. private _maxSimultaneousLights;
  31924. /**
  31925. * Defines the maximum number of lights that can be used in the material
  31926. */
  31927. maxSimultaneousLights: number;
  31928. private _invertNormalMapX;
  31929. /**
  31930. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31931. */
  31932. invertNormalMapX: boolean;
  31933. private _invertNormalMapY;
  31934. /**
  31935. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31936. */
  31937. invertNormalMapY: boolean;
  31938. private _twoSidedLighting;
  31939. /**
  31940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31941. */
  31942. twoSidedLighting: boolean;
  31943. /**
  31944. * Default configuration related to image processing available in the standard Material.
  31945. */
  31946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31947. /**
  31948. * Gets the image processing configuration used either in this material.
  31949. */
  31950. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31951. /**
  31952. * Sets the Default image processing configuration used either in the this material.
  31953. *
  31954. * If sets to null, the scene one is in use.
  31955. */
  31956. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31957. /**
  31958. * Keep track of the image processing observer to allow dispose and replace.
  31959. */
  31960. private _imageProcessingObserver;
  31961. /**
  31962. * Attaches a new image processing configuration to the Standard Material.
  31963. * @param configuration
  31964. */
  31965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31966. /**
  31967. * Gets wether the color curves effect is enabled.
  31968. */
  31969. get cameraColorCurvesEnabled(): boolean;
  31970. /**
  31971. * Sets wether the color curves effect is enabled.
  31972. */
  31973. set cameraColorCurvesEnabled(value: boolean);
  31974. /**
  31975. * Gets wether the color grading effect is enabled.
  31976. */
  31977. get cameraColorGradingEnabled(): boolean;
  31978. /**
  31979. * Gets wether the color grading effect is enabled.
  31980. */
  31981. set cameraColorGradingEnabled(value: boolean);
  31982. /**
  31983. * Gets wether tonemapping is enabled or not.
  31984. */
  31985. get cameraToneMappingEnabled(): boolean;
  31986. /**
  31987. * Sets wether tonemapping is enabled or not
  31988. */
  31989. set cameraToneMappingEnabled(value: boolean);
  31990. /**
  31991. * The camera exposure used on this material.
  31992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31993. * This corresponds to a photographic exposure.
  31994. */
  31995. get cameraExposure(): number;
  31996. /**
  31997. * The camera exposure used on this material.
  31998. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31999. * This corresponds to a photographic exposure.
  32000. */
  32001. set cameraExposure(value: number);
  32002. /**
  32003. * Gets The camera contrast used on this material.
  32004. */
  32005. get cameraContrast(): number;
  32006. /**
  32007. * Sets The camera contrast used on this material.
  32008. */
  32009. set cameraContrast(value: number);
  32010. /**
  32011. * Gets the Color Grading 2D Lookup Texture.
  32012. */
  32013. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32014. /**
  32015. * Sets the Color Grading 2D Lookup Texture.
  32016. */
  32017. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32018. /**
  32019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32021. * 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;
  32022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32023. */
  32024. get cameraColorCurves(): Nullable<ColorCurves>;
  32025. /**
  32026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32028. * 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;
  32029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32030. */
  32031. set cameraColorCurves(value: Nullable<ColorCurves>);
  32032. /**
  32033. * Can this material render to several textures at once
  32034. */
  32035. get canRenderToMRT(): boolean;
  32036. /**
  32037. * Defines the detail map parameters for the material.
  32038. */
  32039. readonly detailMap: DetailMapConfiguration;
  32040. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32041. protected _worldViewProjectionMatrix: Matrix;
  32042. protected _globalAmbientColor: Color3;
  32043. protected _useLogarithmicDepth: boolean;
  32044. protected _rebuildInParallel: boolean;
  32045. /**
  32046. * Instantiates a new standard material.
  32047. * This is the default material used in Babylon. It is the best trade off between quality
  32048. * and performances.
  32049. * @see https://doc.babylonjs.com/babylon101/materials
  32050. * @param name Define the name of the material in the scene
  32051. * @param scene Define the scene the material belong to
  32052. */
  32053. constructor(name: string, scene: Scene);
  32054. /**
  32055. * Gets a boolean indicating that current material needs to register RTT
  32056. */
  32057. get hasRenderTargetTextures(): boolean;
  32058. /**
  32059. * Gets the current class name of the material e.g. "StandardMaterial"
  32060. * Mainly use in serialization.
  32061. * @returns the class name
  32062. */
  32063. getClassName(): string;
  32064. /**
  32065. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32066. * You can try switching to logarithmic depth.
  32067. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32068. */
  32069. get useLogarithmicDepth(): boolean;
  32070. set useLogarithmicDepth(value: boolean);
  32071. /**
  32072. * Specifies if the material will require alpha blending
  32073. * @returns a boolean specifying if alpha blending is needed
  32074. */
  32075. needAlphaBlending(): boolean;
  32076. /**
  32077. * Specifies if this material should be rendered in alpha test mode
  32078. * @returns a boolean specifying if an alpha test is needed.
  32079. */
  32080. needAlphaTesting(): boolean;
  32081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32082. /**
  32083. * Get the texture used for alpha test purpose.
  32084. * @returns the diffuse texture in case of the standard material.
  32085. */
  32086. getAlphaTestTexture(): Nullable<BaseTexture>;
  32087. /**
  32088. * Get if the submesh is ready to be used and all its information available.
  32089. * Child classes can use it to update shaders
  32090. * @param mesh defines the mesh to check
  32091. * @param subMesh defines which submesh to check
  32092. * @param useInstances specifies that instances should be used
  32093. * @returns a boolean indicating that the submesh is ready or not
  32094. */
  32095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32096. /**
  32097. * Builds the material UBO layouts.
  32098. * Used internally during the effect preparation.
  32099. */
  32100. buildUniformLayout(): void;
  32101. /**
  32102. * Unbinds the material from the mesh
  32103. */
  32104. unbind(): void;
  32105. /**
  32106. * Binds the submesh to this material by preparing the effect and shader to draw
  32107. * @param world defines the world transformation matrix
  32108. * @param mesh defines the mesh containing the submesh
  32109. * @param subMesh defines the submesh to bind the material to
  32110. */
  32111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32112. /**
  32113. * Get the list of animatables in the material.
  32114. * @returns the list of animatables object used in the material
  32115. */
  32116. getAnimatables(): IAnimatable[];
  32117. /**
  32118. * Gets the active textures from the material
  32119. * @returns an array of textures
  32120. */
  32121. getActiveTextures(): BaseTexture[];
  32122. /**
  32123. * Specifies if the material uses a texture
  32124. * @param texture defines the texture to check against the material
  32125. * @returns a boolean specifying if the material uses the texture
  32126. */
  32127. hasTexture(texture: BaseTexture): boolean;
  32128. /**
  32129. * Disposes the material
  32130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32132. */
  32133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32134. /**
  32135. * Makes a duplicate of the material, and gives it a new name
  32136. * @param name defines the new name for the duplicated material
  32137. * @returns the cloned material
  32138. */
  32139. clone(name: string): StandardMaterial;
  32140. /**
  32141. * Serializes this material in a JSON representation
  32142. * @returns the serialized material object
  32143. */
  32144. serialize(): any;
  32145. /**
  32146. * Creates a standard material from parsed material data
  32147. * @param source defines the JSON representation of the material
  32148. * @param scene defines the hosting scene
  32149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32150. * @returns a new standard material
  32151. */
  32152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32153. /**
  32154. * Are diffuse textures enabled in the application.
  32155. */
  32156. static get DiffuseTextureEnabled(): boolean;
  32157. static set DiffuseTextureEnabled(value: boolean);
  32158. /**
  32159. * Are detail textures enabled in the application.
  32160. */
  32161. static get DetailTextureEnabled(): boolean;
  32162. static set DetailTextureEnabled(value: boolean);
  32163. /**
  32164. * Are ambient textures enabled in the application.
  32165. */
  32166. static get AmbientTextureEnabled(): boolean;
  32167. static set AmbientTextureEnabled(value: boolean);
  32168. /**
  32169. * Are opacity textures enabled in the application.
  32170. */
  32171. static get OpacityTextureEnabled(): boolean;
  32172. static set OpacityTextureEnabled(value: boolean);
  32173. /**
  32174. * Are reflection textures enabled in the application.
  32175. */
  32176. static get ReflectionTextureEnabled(): boolean;
  32177. static set ReflectionTextureEnabled(value: boolean);
  32178. /**
  32179. * Are emissive textures enabled in the application.
  32180. */
  32181. static get EmissiveTextureEnabled(): boolean;
  32182. static set EmissiveTextureEnabled(value: boolean);
  32183. /**
  32184. * Are specular textures enabled in the application.
  32185. */
  32186. static get SpecularTextureEnabled(): boolean;
  32187. static set SpecularTextureEnabled(value: boolean);
  32188. /**
  32189. * Are bump textures enabled in the application.
  32190. */
  32191. static get BumpTextureEnabled(): boolean;
  32192. static set BumpTextureEnabled(value: boolean);
  32193. /**
  32194. * Are lightmap textures enabled in the application.
  32195. */
  32196. static get LightmapTextureEnabled(): boolean;
  32197. static set LightmapTextureEnabled(value: boolean);
  32198. /**
  32199. * Are refraction textures enabled in the application.
  32200. */
  32201. static get RefractionTextureEnabled(): boolean;
  32202. static set RefractionTextureEnabled(value: boolean);
  32203. /**
  32204. * Are color grading textures enabled in the application.
  32205. */
  32206. static get ColorGradingTextureEnabled(): boolean;
  32207. static set ColorGradingTextureEnabled(value: boolean);
  32208. /**
  32209. * Are fresnels enabled in the application.
  32210. */
  32211. static get FresnelEnabled(): boolean;
  32212. static set FresnelEnabled(value: boolean);
  32213. }
  32214. }
  32215. declare module "babylonjs/Particles/solidParticleSystem" {
  32216. import { Nullable } from "babylonjs/types";
  32217. import { Mesh } from "babylonjs/Meshes/mesh";
  32218. import { Scene, IDisposable } from "babylonjs/scene";
  32219. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32220. import { Material } from "babylonjs/Materials/material";
  32221. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32222. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32223. /**
  32224. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32225. *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.
  32226. * The SPS is also a particle system. It provides some methods to manage the particles.
  32227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32228. *
  32229. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32230. */
  32231. export class SolidParticleSystem implements IDisposable {
  32232. /**
  32233. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32234. * Example : var p = SPS.particles[i];
  32235. */
  32236. particles: SolidParticle[];
  32237. /**
  32238. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32239. */
  32240. nbParticles: number;
  32241. /**
  32242. * If the particles must ever face the camera (default false). Useful for planar particles.
  32243. */
  32244. billboard: boolean;
  32245. /**
  32246. * Recompute normals when adding a shape
  32247. */
  32248. recomputeNormals: boolean;
  32249. /**
  32250. * This a counter ofr your own usage. It's not set by any SPS functions.
  32251. */
  32252. counter: number;
  32253. /**
  32254. * The SPS name. This name is also given to the underlying mesh.
  32255. */
  32256. name: string;
  32257. /**
  32258. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32259. */
  32260. mesh: Mesh;
  32261. /**
  32262. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32263. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32264. */
  32265. vars: any;
  32266. /**
  32267. * This array is populated when the SPS is set as 'pickable'.
  32268. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32269. * Each element of this array is an object `{idx: int, faceId: int}`.
  32270. * `idx` is the picked particle index in the `SPS.particles` array
  32271. * `faceId` is the picked face index counted within this particle.
  32272. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32273. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32274. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32275. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32276. */
  32277. pickedParticles: {
  32278. idx: number;
  32279. faceId: number;
  32280. }[];
  32281. /**
  32282. * This array is populated when the SPS is set as 'pickable'
  32283. * Each key of this array is a submesh index.
  32284. * Each element of this array is a second array defined like this :
  32285. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32286. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32287. * `idx` is the picked particle index in the `SPS.particles` array
  32288. * `faceId` is the picked face index counted within this particle.
  32289. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32290. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32291. */
  32292. pickedBySubMesh: {
  32293. idx: number;
  32294. faceId: number;
  32295. }[][];
  32296. /**
  32297. * This array is populated when `enableDepthSort` is set to true.
  32298. * Each element of this array is an instance of the class DepthSortedParticle.
  32299. */
  32300. depthSortedParticles: DepthSortedParticle[];
  32301. /**
  32302. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32303. * @hidden
  32304. */
  32305. _bSphereOnly: boolean;
  32306. /**
  32307. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32308. * @hidden
  32309. */
  32310. _bSphereRadiusFactor: number;
  32311. private _scene;
  32312. private _positions;
  32313. private _indices;
  32314. private _normals;
  32315. private _colors;
  32316. private _uvs;
  32317. private _indices32;
  32318. private _positions32;
  32319. private _normals32;
  32320. private _fixedNormal32;
  32321. private _colors32;
  32322. private _uvs32;
  32323. private _index;
  32324. private _updatable;
  32325. private _pickable;
  32326. private _isVisibilityBoxLocked;
  32327. private _alwaysVisible;
  32328. private _depthSort;
  32329. private _expandable;
  32330. private _shapeCounter;
  32331. private _copy;
  32332. private _color;
  32333. private _computeParticleColor;
  32334. private _computeParticleTexture;
  32335. private _computeParticleRotation;
  32336. private _computeParticleVertex;
  32337. private _computeBoundingBox;
  32338. private _depthSortParticles;
  32339. private _camera;
  32340. private _mustUnrotateFixedNormals;
  32341. private _particlesIntersect;
  32342. private _needs32Bits;
  32343. private _isNotBuilt;
  32344. private _lastParticleId;
  32345. private _idxOfId;
  32346. private _multimaterialEnabled;
  32347. private _useModelMaterial;
  32348. private _indicesByMaterial;
  32349. private _materialIndexes;
  32350. private _depthSortFunction;
  32351. private _materialSortFunction;
  32352. private _materials;
  32353. private _multimaterial;
  32354. private _materialIndexesById;
  32355. private _defaultMaterial;
  32356. private _autoUpdateSubMeshes;
  32357. private _tmpVertex;
  32358. /**
  32359. * Creates a SPS (Solid Particle System) object.
  32360. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32361. * @param scene (Scene) is the scene in which the SPS is added.
  32362. * @param options defines the options of the sps e.g.
  32363. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32364. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32365. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32366. * * 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.
  32367. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32368. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32369. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32370. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32371. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32372. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32373. */
  32374. constructor(name: string, scene: Scene, options?: {
  32375. updatable?: boolean;
  32376. isPickable?: boolean;
  32377. enableDepthSort?: boolean;
  32378. particleIntersection?: boolean;
  32379. boundingSphereOnly?: boolean;
  32380. bSphereRadiusFactor?: number;
  32381. expandable?: boolean;
  32382. useModelMaterial?: boolean;
  32383. enableMultiMaterial?: boolean;
  32384. });
  32385. /**
  32386. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32387. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32388. * @returns the created mesh
  32389. */
  32390. buildMesh(): Mesh;
  32391. /**
  32392. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32393. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32394. * Thus the particles generated from `digest()` have their property `position` set yet.
  32395. * @param mesh ( Mesh ) is the mesh to be digested
  32396. * @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
  32397. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32398. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32399. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32400. * @returns the current SPS
  32401. */
  32402. digest(mesh: Mesh, options?: {
  32403. facetNb?: number;
  32404. number?: number;
  32405. delta?: number;
  32406. storage?: [];
  32407. }): SolidParticleSystem;
  32408. /**
  32409. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32410. * @hidden
  32411. */
  32412. private _unrotateFixedNormals;
  32413. /**
  32414. * Resets the temporary working copy particle
  32415. * @hidden
  32416. */
  32417. private _resetCopy;
  32418. /**
  32419. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32420. * @param p the current index in the positions array to be updated
  32421. * @param ind the current index in the indices array
  32422. * @param shape a Vector3 array, the shape geometry
  32423. * @param positions the positions array to be updated
  32424. * @param meshInd the shape indices array
  32425. * @param indices the indices array to be updated
  32426. * @param meshUV the shape uv array
  32427. * @param uvs the uv array to be updated
  32428. * @param meshCol the shape color array
  32429. * @param colors the color array to be updated
  32430. * @param meshNor the shape normals array
  32431. * @param normals the normals array to be updated
  32432. * @param idx the particle index
  32433. * @param idxInShape the particle index in its shape
  32434. * @param options the addShape() method passed options
  32435. * @model the particle model
  32436. * @hidden
  32437. */
  32438. private _meshBuilder;
  32439. /**
  32440. * Returns a shape Vector3 array from positions float array
  32441. * @param positions float array
  32442. * @returns a vector3 array
  32443. * @hidden
  32444. */
  32445. private _posToShape;
  32446. /**
  32447. * Returns a shapeUV array from a float uvs (array deep copy)
  32448. * @param uvs as a float array
  32449. * @returns a shapeUV array
  32450. * @hidden
  32451. */
  32452. private _uvsToShapeUV;
  32453. /**
  32454. * Adds a new particle object in the particles array
  32455. * @param idx particle index in particles array
  32456. * @param id particle id
  32457. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32458. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32459. * @param model particle ModelShape object
  32460. * @param shapeId model shape identifier
  32461. * @param idxInShape index of the particle in the current model
  32462. * @param bInfo model bounding info object
  32463. * @param storage target storage array, if any
  32464. * @hidden
  32465. */
  32466. private _addParticle;
  32467. /**
  32468. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32469. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32470. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32471. * @param nb (positive integer) the number of particles to be created from this model
  32472. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32473. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32474. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32475. * @returns the number of shapes in the system
  32476. */
  32477. addShape(mesh: Mesh, nb: number, options?: {
  32478. positionFunction?: any;
  32479. vertexFunction?: any;
  32480. storage?: [];
  32481. }): number;
  32482. /**
  32483. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32484. * @hidden
  32485. */
  32486. private _rebuildParticle;
  32487. /**
  32488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32489. * @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.
  32490. * @returns the SPS.
  32491. */
  32492. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32493. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32494. * Returns an array with the removed particles.
  32495. * 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.
  32496. * The SPS can't be empty so at least one particle needs to remain in place.
  32497. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32498. * @param start index of the first particle to remove
  32499. * @param end index of the last particle to remove (included)
  32500. * @returns an array populated with the removed particles
  32501. */
  32502. removeParticles(start: number, end: number): SolidParticle[];
  32503. /**
  32504. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32505. * @param solidParticleArray an array populated with Solid Particles objects
  32506. * @returns the SPS
  32507. */
  32508. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32509. /**
  32510. * Creates a new particle and modifies the SPS mesh geometry :
  32511. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32512. * - calls _addParticle() to populate the particle array
  32513. * factorized code from addShape() and insertParticlesFromArray()
  32514. * @param idx particle index in the particles array
  32515. * @param i particle index in its shape
  32516. * @param modelShape particle ModelShape object
  32517. * @param shape shape vertex array
  32518. * @param meshInd shape indices array
  32519. * @param meshUV shape uv array
  32520. * @param meshCol shape color array
  32521. * @param meshNor shape normals array
  32522. * @param bbInfo shape bounding info
  32523. * @param storage target particle storage
  32524. * @options addShape() passed options
  32525. * @hidden
  32526. */
  32527. private _insertNewParticle;
  32528. /**
  32529. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32530. * This method calls `updateParticle()` for each particle of the SPS.
  32531. * For an animated SPS, it is usually called within the render loop.
  32532. * 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.
  32533. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32534. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32535. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32536. * @returns the SPS.
  32537. */
  32538. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32539. /**
  32540. * Disposes the SPS.
  32541. */
  32542. dispose(): void;
  32543. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32544. * idx is the particle index in the SPS
  32545. * faceId is the picked face index counted within this particle.
  32546. * Returns null if the pickInfo can't identify a picked particle.
  32547. * @param pickingInfo (PickingInfo object)
  32548. * @returns {idx: number, faceId: number} or null
  32549. */
  32550. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32551. idx: number;
  32552. faceId: number;
  32553. }>;
  32554. /**
  32555. * Returns a SolidParticle object from its identifier : particle.id
  32556. * @param id (integer) the particle Id
  32557. * @returns the searched particle or null if not found in the SPS.
  32558. */
  32559. getParticleById(id: number): Nullable<SolidParticle>;
  32560. /**
  32561. * Returns a new array populated with the particles having the passed shapeId.
  32562. * @param shapeId (integer) the shape identifier
  32563. * @returns a new solid particle array
  32564. */
  32565. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32566. /**
  32567. * Populates the passed array "ref" with the particles having the passed shapeId.
  32568. * @param shapeId the shape identifier
  32569. * @returns the SPS
  32570. * @param ref
  32571. */
  32572. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32573. /**
  32574. * Computes the required SubMeshes according the materials assigned to the particles.
  32575. * @returns the solid particle system.
  32576. * Does nothing if called before the SPS mesh is built.
  32577. */
  32578. computeSubMeshes(): SolidParticleSystem;
  32579. /**
  32580. * Sorts the solid particles by material when MultiMaterial is enabled.
  32581. * Updates the indices32 array.
  32582. * Updates the indicesByMaterial array.
  32583. * Updates the mesh indices array.
  32584. * @returns the SPS
  32585. * @hidden
  32586. */
  32587. private _sortParticlesByMaterial;
  32588. /**
  32589. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32590. * @hidden
  32591. */
  32592. private _setMaterialIndexesById;
  32593. /**
  32594. * Returns an array with unique values of Materials from the passed array
  32595. * @param array the material array to be checked and filtered
  32596. * @hidden
  32597. */
  32598. private _filterUniqueMaterialId;
  32599. /**
  32600. * Sets a new Standard Material as _defaultMaterial if not already set.
  32601. * @hidden
  32602. */
  32603. private _setDefaultMaterial;
  32604. /**
  32605. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32606. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32607. * @returns the SPS.
  32608. */
  32609. refreshVisibleSize(): SolidParticleSystem;
  32610. /**
  32611. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32612. * @param size the size (float) of the visibility box
  32613. * note : this doesn't lock the SPS mesh bounding box.
  32614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32615. */
  32616. setVisibilityBox(size: number): void;
  32617. /**
  32618. * Gets whether the SPS as always visible or not
  32619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32620. */
  32621. get isAlwaysVisible(): boolean;
  32622. /**
  32623. * Sets the SPS as always visible or not
  32624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32625. */
  32626. set isAlwaysVisible(val: boolean);
  32627. /**
  32628. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32630. */
  32631. set isVisibilityBoxLocked(val: boolean);
  32632. /**
  32633. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32634. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32635. */
  32636. get isVisibilityBoxLocked(): boolean;
  32637. /**
  32638. * Tells to `setParticles()` to compute the particle rotations or not.
  32639. * Default value : true. The SPS is faster when it's set to false.
  32640. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32641. */
  32642. set computeParticleRotation(val: boolean);
  32643. /**
  32644. * Tells to `setParticles()` to compute the particle colors or not.
  32645. * Default value : true. The SPS is faster when it's set to false.
  32646. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32647. */
  32648. set computeParticleColor(val: boolean);
  32649. set computeParticleTexture(val: boolean);
  32650. /**
  32651. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32652. * Default value : false. The SPS is faster when it's set to false.
  32653. * Note : the particle custom vertex positions aren't stored values.
  32654. */
  32655. set computeParticleVertex(val: boolean);
  32656. /**
  32657. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32658. */
  32659. set computeBoundingBox(val: boolean);
  32660. /**
  32661. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32662. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32663. * Default : `true`
  32664. */
  32665. set depthSortParticles(val: boolean);
  32666. /**
  32667. * Gets if `setParticles()` computes the particle rotations or not.
  32668. * Default value : true. The SPS is faster when it's set to false.
  32669. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32670. */
  32671. get computeParticleRotation(): boolean;
  32672. /**
  32673. * Gets if `setParticles()` computes the particle colors or not.
  32674. * Default value : true. The SPS is faster when it's set to false.
  32675. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32676. */
  32677. get computeParticleColor(): boolean;
  32678. /**
  32679. * Gets if `setParticles()` computes the particle textures or not.
  32680. * Default value : true. The SPS is faster when it's set to false.
  32681. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32682. */
  32683. get computeParticleTexture(): boolean;
  32684. /**
  32685. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32686. * Default value : false. The SPS is faster when it's set to false.
  32687. * Note : the particle custom vertex positions aren't stored values.
  32688. */
  32689. get computeParticleVertex(): boolean;
  32690. /**
  32691. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32692. */
  32693. get computeBoundingBox(): boolean;
  32694. /**
  32695. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32696. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32697. * Default : `true`
  32698. */
  32699. get depthSortParticles(): boolean;
  32700. /**
  32701. * Gets if the SPS is created as expandable at construction time.
  32702. * Default : `false`
  32703. */
  32704. get expandable(): boolean;
  32705. /**
  32706. * Gets if the SPS supports the Multi Materials
  32707. */
  32708. get multimaterialEnabled(): boolean;
  32709. /**
  32710. * Gets if the SPS uses the model materials for its own multimaterial.
  32711. */
  32712. get useModelMaterial(): boolean;
  32713. /**
  32714. * The SPS used material array.
  32715. */
  32716. get materials(): Material[];
  32717. /**
  32718. * Sets the SPS MultiMaterial from the passed materials.
  32719. * Note : the passed array is internally copied and not used then by reference.
  32720. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32721. */
  32722. setMultiMaterial(materials: Material[]): void;
  32723. /**
  32724. * The SPS computed multimaterial object
  32725. */
  32726. get multimaterial(): MultiMaterial;
  32727. set multimaterial(mm: MultiMaterial);
  32728. /**
  32729. * If the subMeshes must be updated on the next call to setParticles()
  32730. */
  32731. get autoUpdateSubMeshes(): boolean;
  32732. set autoUpdateSubMeshes(val: boolean);
  32733. /**
  32734. * This function does nothing. It may be overwritten to set all the particle first values.
  32735. * The SPS doesn't call this function, you may have to call it by your own.
  32736. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32737. */
  32738. initParticles(): void;
  32739. /**
  32740. * This function does nothing. It may be overwritten to recycle a particle.
  32741. * The SPS doesn't call this function, you may have to call it by your own.
  32742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32743. * @param particle The particle to recycle
  32744. * @returns the recycled particle
  32745. */
  32746. recycleParticle(particle: SolidParticle): SolidParticle;
  32747. /**
  32748. * Updates a particle : this function should be overwritten by the user.
  32749. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32750. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32751. * @example : just set a particle position or velocity and recycle conditions
  32752. * @param particle The particle to update
  32753. * @returns the updated particle
  32754. */
  32755. updateParticle(particle: SolidParticle): SolidParticle;
  32756. /**
  32757. * Updates a vertex of a particle : it can be overwritten by the user.
  32758. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32759. * @param particle the current particle
  32760. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32761. * @param pt the index of the current vertex in the particle shape
  32762. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32763. * @example : just set a vertex particle position or color
  32764. * @returns the sps
  32765. */
  32766. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32767. /**
  32768. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32769. * This does nothing and may be overwritten by the user.
  32770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param update the boolean update value actually passed to setParticles()
  32773. */
  32774. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32775. /**
  32776. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32777. * This will be passed three parameters.
  32778. * This does nothing and may be overwritten by the user.
  32779. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32780. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32781. * @param update the boolean update value actually passed to setParticles()
  32782. */
  32783. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32784. }
  32785. }
  32786. declare module "babylonjs/Particles/solidParticle" {
  32787. import { Nullable } from "babylonjs/types";
  32788. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32789. import { Color4 } from "babylonjs/Maths/math.color";
  32790. import { Mesh } from "babylonjs/Meshes/mesh";
  32791. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32792. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32793. import { Plane } from "babylonjs/Maths/math.plane";
  32794. import { Material } from "babylonjs/Materials/material";
  32795. /**
  32796. * Represents one particle of a solid particle system.
  32797. */
  32798. export class SolidParticle {
  32799. /**
  32800. * particle global index
  32801. */
  32802. idx: number;
  32803. /**
  32804. * particle identifier
  32805. */
  32806. id: number;
  32807. /**
  32808. * The color of the particle
  32809. */
  32810. color: Nullable<Color4>;
  32811. /**
  32812. * The world space position of the particle.
  32813. */
  32814. position: Vector3;
  32815. /**
  32816. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32817. */
  32818. rotation: Vector3;
  32819. /**
  32820. * The world space rotation quaternion of the particle.
  32821. */
  32822. rotationQuaternion: Nullable<Quaternion>;
  32823. /**
  32824. * The scaling of the particle.
  32825. */
  32826. scaling: Vector3;
  32827. /**
  32828. * The uvs of the particle.
  32829. */
  32830. uvs: Vector4;
  32831. /**
  32832. * The current speed of the particle.
  32833. */
  32834. velocity: Vector3;
  32835. /**
  32836. * The pivot point in the particle local space.
  32837. */
  32838. pivot: Vector3;
  32839. /**
  32840. * Must the particle be translated from its pivot point in its local space ?
  32841. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32842. * Default : false
  32843. */
  32844. translateFromPivot: boolean;
  32845. /**
  32846. * Is the particle active or not ?
  32847. */
  32848. alive: boolean;
  32849. /**
  32850. * Is the particle visible or not ?
  32851. */
  32852. isVisible: boolean;
  32853. /**
  32854. * Index of this particle in the global "positions" array (Internal use)
  32855. * @hidden
  32856. */
  32857. _pos: number;
  32858. /**
  32859. * @hidden Index of this particle in the global "indices" array (Internal use)
  32860. */
  32861. _ind: number;
  32862. /**
  32863. * @hidden ModelShape of this particle (Internal use)
  32864. */
  32865. _model: ModelShape;
  32866. /**
  32867. * ModelShape id of this particle
  32868. */
  32869. shapeId: number;
  32870. /**
  32871. * Index of the particle in its shape id
  32872. */
  32873. idxInShape: number;
  32874. /**
  32875. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32876. */
  32877. _modelBoundingInfo: BoundingInfo;
  32878. /**
  32879. * @hidden Particle BoundingInfo object (Internal use)
  32880. */
  32881. _boundingInfo: BoundingInfo;
  32882. /**
  32883. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32884. */
  32885. _sps: SolidParticleSystem;
  32886. /**
  32887. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32888. */
  32889. _stillInvisible: boolean;
  32890. /**
  32891. * @hidden Last computed particle rotation matrix
  32892. */
  32893. _rotationMatrix: number[];
  32894. /**
  32895. * Parent particle Id, if any.
  32896. * Default null.
  32897. */
  32898. parentId: Nullable<number>;
  32899. /**
  32900. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32901. */
  32902. materialIndex: Nullable<number>;
  32903. /**
  32904. * Custom object or properties.
  32905. */
  32906. props: Nullable<any>;
  32907. /**
  32908. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32909. * The possible values are :
  32910. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32911. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32912. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32914. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32915. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32916. * */
  32917. cullingStrategy: number;
  32918. /**
  32919. * @hidden Internal global position in the SPS.
  32920. */
  32921. _globalPosition: Vector3;
  32922. /**
  32923. * Creates a Solid Particle object.
  32924. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32925. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32926. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32927. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32928. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32929. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32930. * @param shapeId (integer) is the model shape identifier in the SPS.
  32931. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32932. * @param sps defines the sps it is associated to
  32933. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32934. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32935. */
  32936. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32937. /**
  32938. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32939. * @param target the particle target
  32940. * @returns the current particle
  32941. */
  32942. copyToRef(target: SolidParticle): SolidParticle;
  32943. /**
  32944. * Legacy support, changed scale to scaling
  32945. */
  32946. get scale(): Vector3;
  32947. /**
  32948. * Legacy support, changed scale to scaling
  32949. */
  32950. set scale(scale: Vector3);
  32951. /**
  32952. * Legacy support, changed quaternion to rotationQuaternion
  32953. */
  32954. get quaternion(): Nullable<Quaternion>;
  32955. /**
  32956. * Legacy support, changed quaternion to rotationQuaternion
  32957. */
  32958. set quaternion(q: Nullable<Quaternion>);
  32959. /**
  32960. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32961. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32962. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32963. * @returns true if it intersects
  32964. */
  32965. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32966. /**
  32967. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32968. * A particle is in the frustum if its bounding box intersects the frustum
  32969. * @param frustumPlanes defines the frustum to test
  32970. * @returns true if the particle is in the frustum planes
  32971. */
  32972. isInFrustum(frustumPlanes: Plane[]): boolean;
  32973. /**
  32974. * get the rotation matrix of the particle
  32975. * @hidden
  32976. */
  32977. getRotationMatrix(m: Matrix): void;
  32978. }
  32979. /**
  32980. * Represents the shape of the model used by one particle of a solid particle system.
  32981. * SPS internal tool, don't use it manually.
  32982. */
  32983. export class ModelShape {
  32984. /**
  32985. * The shape id
  32986. * @hidden
  32987. */
  32988. shapeID: number;
  32989. /**
  32990. * flat array of model positions (internal use)
  32991. * @hidden
  32992. */
  32993. _shape: Vector3[];
  32994. /**
  32995. * flat array of model UVs (internal use)
  32996. * @hidden
  32997. */
  32998. _shapeUV: number[];
  32999. /**
  33000. * color array of the model
  33001. * @hidden
  33002. */
  33003. _shapeColors: number[];
  33004. /**
  33005. * indices array of the model
  33006. * @hidden
  33007. */
  33008. _indices: number[];
  33009. /**
  33010. * normals array of the model
  33011. * @hidden
  33012. */
  33013. _normals: number[];
  33014. /**
  33015. * length of the shape in the model indices array (internal use)
  33016. * @hidden
  33017. */
  33018. _indicesLength: number;
  33019. /**
  33020. * Custom position function (internal use)
  33021. * @hidden
  33022. */
  33023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33024. /**
  33025. * Custom vertex function (internal use)
  33026. * @hidden
  33027. */
  33028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33029. /**
  33030. * Model material (internal use)
  33031. * @hidden
  33032. */
  33033. _material: Nullable<Material>;
  33034. /**
  33035. * 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.
  33036. * SPS internal tool, don't use it manually.
  33037. * @hidden
  33038. */
  33039. 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>);
  33040. }
  33041. /**
  33042. * Represents a Depth Sorted Particle in the solid particle system.
  33043. * @hidden
  33044. */
  33045. export class DepthSortedParticle {
  33046. /**
  33047. * Particle index
  33048. */
  33049. idx: number;
  33050. /**
  33051. * Index of the particle in the "indices" array
  33052. */
  33053. ind: number;
  33054. /**
  33055. * Length of the particle shape in the "indices" array
  33056. */
  33057. indicesLength: number;
  33058. /**
  33059. * Squared distance from the particle to the camera
  33060. */
  33061. sqDistance: number;
  33062. /**
  33063. * Material index when used with MultiMaterials
  33064. */
  33065. materialIndex: number;
  33066. /**
  33067. * Creates a new sorted particle
  33068. * @param materialIndex
  33069. */
  33070. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33071. }
  33072. /**
  33073. * Represents a solid particle vertex
  33074. */
  33075. export class SolidParticleVertex {
  33076. /**
  33077. * Vertex position
  33078. */
  33079. position: Vector3;
  33080. /**
  33081. * Vertex color
  33082. */
  33083. color: Color4;
  33084. /**
  33085. * Vertex UV
  33086. */
  33087. uv: Vector2;
  33088. /**
  33089. * Creates a new solid particle vertex
  33090. */
  33091. constructor();
  33092. /** Vertex x coordinate */
  33093. get x(): number;
  33094. set x(val: number);
  33095. /** Vertex y coordinate */
  33096. get y(): number;
  33097. set y(val: number);
  33098. /** Vertex z coordinate */
  33099. get z(): number;
  33100. set z(val: number);
  33101. }
  33102. }
  33103. declare module "babylonjs/Collisions/meshCollisionData" {
  33104. import { Collider } from "babylonjs/Collisions/collider";
  33105. import { Vector3 } from "babylonjs/Maths/math.vector";
  33106. import { Nullable } from "babylonjs/types";
  33107. import { Observer } from "babylonjs/Misc/observable";
  33108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33109. /**
  33110. * @hidden
  33111. */
  33112. export class _MeshCollisionData {
  33113. _checkCollisions: boolean;
  33114. _collisionMask: number;
  33115. _collisionGroup: number;
  33116. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33117. _collider: Nullable<Collider>;
  33118. _oldPositionForCollisions: Vector3;
  33119. _diffPositionForCollisions: Vector3;
  33120. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33121. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33122. _collisionResponse: boolean;
  33123. }
  33124. }
  33125. declare module "babylonjs/Meshes/abstractMesh" {
  33126. import { Observable } from "babylonjs/Misc/observable";
  33127. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33128. import { Camera } from "babylonjs/Cameras/camera";
  33129. import { Scene, IDisposable } from "babylonjs/scene";
  33130. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33131. import { Node } from "babylonjs/node";
  33132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33136. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33137. import { Material } from "babylonjs/Materials/material";
  33138. import { Light } from "babylonjs/Lights/light";
  33139. import { Skeleton } from "babylonjs/Bones/skeleton";
  33140. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33141. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33142. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33143. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33144. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33145. import { Plane } from "babylonjs/Maths/math.plane";
  33146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33147. import { Ray } from "babylonjs/Culling/ray";
  33148. import { Collider } from "babylonjs/Collisions/collider";
  33149. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33150. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33151. /** @hidden */
  33152. class _FacetDataStorage {
  33153. facetPositions: Vector3[];
  33154. facetNormals: Vector3[];
  33155. facetPartitioning: number[][];
  33156. facetNb: number;
  33157. partitioningSubdivisions: number;
  33158. partitioningBBoxRatio: number;
  33159. facetDataEnabled: boolean;
  33160. facetParameters: any;
  33161. bbSize: Vector3;
  33162. subDiv: {
  33163. max: number;
  33164. X: number;
  33165. Y: number;
  33166. Z: number;
  33167. };
  33168. facetDepthSort: boolean;
  33169. facetDepthSortEnabled: boolean;
  33170. depthSortedIndices: IndicesArray;
  33171. depthSortedFacets: {
  33172. ind: number;
  33173. sqDistance: number;
  33174. }[];
  33175. facetDepthSortFunction: (f1: {
  33176. ind: number;
  33177. sqDistance: number;
  33178. }, f2: {
  33179. ind: number;
  33180. sqDistance: number;
  33181. }) => number;
  33182. facetDepthSortFrom: Vector3;
  33183. facetDepthSortOrigin: Vector3;
  33184. invertedMatrix: Matrix;
  33185. }
  33186. /**
  33187. * @hidden
  33188. **/
  33189. class _InternalAbstractMeshDataInfo {
  33190. _hasVertexAlpha: boolean;
  33191. _useVertexColors: boolean;
  33192. _numBoneInfluencers: number;
  33193. _applyFog: boolean;
  33194. _receiveShadows: boolean;
  33195. _facetData: _FacetDataStorage;
  33196. _visibility: number;
  33197. _skeleton: Nullable<Skeleton>;
  33198. _layerMask: number;
  33199. _computeBonesUsingShaders: boolean;
  33200. _isActive: boolean;
  33201. _onlyForInstances: boolean;
  33202. _isActiveIntermediate: boolean;
  33203. _onlyForInstancesIntermediate: boolean;
  33204. _actAsRegularMesh: boolean;
  33205. }
  33206. /**
  33207. * Class used to store all common mesh properties
  33208. */
  33209. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33210. /** No occlusion */
  33211. static OCCLUSION_TYPE_NONE: number;
  33212. /** Occlusion set to optimisitic */
  33213. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33214. /** Occlusion set to strict */
  33215. static OCCLUSION_TYPE_STRICT: number;
  33216. /** Use an accurante occlusion algorithm */
  33217. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33218. /** Use a conservative occlusion algorithm */
  33219. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33220. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33221. * Test order :
  33222. * Is the bounding sphere outside the frustum ?
  33223. * If not, are the bounding box vertices outside the frustum ?
  33224. * It not, then the cullable object is in the frustum.
  33225. */
  33226. static readonly CULLINGSTRATEGY_STANDARD: number;
  33227. /** Culling strategy : Bounding Sphere Only.
  33228. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33229. * It's also less accurate than the standard because some not visible objects can still be selected.
  33230. * Test : is the bounding sphere outside the frustum ?
  33231. * If not, then the cullable object is in the frustum.
  33232. */
  33233. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33234. /** Culling strategy : Optimistic Inclusion.
  33235. * This in an inclusion test first, then the standard exclusion test.
  33236. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33237. * 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.
  33238. * Anyway, it's as accurate as the standard strategy.
  33239. * Test :
  33240. * Is the cullable object bounding sphere center in the frustum ?
  33241. * If not, apply the default culling strategy.
  33242. */
  33243. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33244. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33245. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33246. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33247. * 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.
  33248. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33249. * Test :
  33250. * Is the cullable object bounding sphere center in the frustum ?
  33251. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33252. */
  33253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33254. /**
  33255. * No billboard
  33256. */
  33257. static get BILLBOARDMODE_NONE(): number;
  33258. /** Billboard on X axis */
  33259. static get BILLBOARDMODE_X(): number;
  33260. /** Billboard on Y axis */
  33261. static get BILLBOARDMODE_Y(): number;
  33262. /** Billboard on Z axis */
  33263. static get BILLBOARDMODE_Z(): number;
  33264. /** Billboard on all axes */
  33265. static get BILLBOARDMODE_ALL(): number;
  33266. /** Billboard on using position instead of orientation */
  33267. static get BILLBOARDMODE_USE_POSITION(): number;
  33268. /** @hidden */
  33269. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33270. /**
  33271. * The culling strategy to use to check whether the mesh must be rendered or not.
  33272. * This value can be changed at any time and will be used on the next render mesh selection.
  33273. * The possible values are :
  33274. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33275. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33276. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33278. * Please read each static variable documentation to get details about the culling process.
  33279. * */
  33280. cullingStrategy: number;
  33281. /**
  33282. * Gets the number of facets in the mesh
  33283. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33284. */
  33285. get facetNb(): number;
  33286. /**
  33287. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33289. */
  33290. get partitioningSubdivisions(): number;
  33291. set partitioningSubdivisions(nb: number);
  33292. /**
  33293. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33294. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33295. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33296. */
  33297. get partitioningBBoxRatio(): number;
  33298. set partitioningBBoxRatio(ratio: number);
  33299. /**
  33300. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33301. * Works only for updatable meshes.
  33302. * Doesn't work with multi-materials
  33303. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33304. */
  33305. get mustDepthSortFacets(): boolean;
  33306. set mustDepthSortFacets(sort: boolean);
  33307. /**
  33308. * The location (Vector3) where the facet depth sort must be computed from.
  33309. * By default, the active camera position.
  33310. * Used only when facet depth sort is enabled
  33311. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33312. */
  33313. get facetDepthSortFrom(): Vector3;
  33314. set facetDepthSortFrom(location: Vector3);
  33315. /**
  33316. * gets a boolean indicating if facetData is enabled
  33317. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33318. */
  33319. get isFacetDataEnabled(): boolean;
  33320. /** @hidden */
  33321. _updateNonUniformScalingState(value: boolean): boolean;
  33322. /**
  33323. * An event triggered when this mesh collides with another one
  33324. */
  33325. onCollideObservable: Observable<AbstractMesh>;
  33326. /** Set a function to call when this mesh collides with another one */
  33327. set onCollide(callback: () => void);
  33328. /**
  33329. * An event triggered when the collision's position changes
  33330. */
  33331. onCollisionPositionChangeObservable: Observable<Vector3>;
  33332. /** Set a function to call when the collision's position changes */
  33333. set onCollisionPositionChange(callback: () => void);
  33334. /**
  33335. * An event triggered when material is changed
  33336. */
  33337. onMaterialChangedObservable: Observable<AbstractMesh>;
  33338. /**
  33339. * Gets or sets the orientation for POV movement & rotation
  33340. */
  33341. definedFacingForward: boolean;
  33342. /** @hidden */
  33343. _occlusionQuery: Nullable<WebGLQuery>;
  33344. /** @hidden */
  33345. _renderingGroup: Nullable<RenderingGroup>;
  33346. /**
  33347. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33348. */
  33349. get visibility(): number;
  33350. /**
  33351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33352. */
  33353. set visibility(value: number);
  33354. /** Gets or sets the alpha index used to sort transparent meshes
  33355. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33356. */
  33357. alphaIndex: number;
  33358. /**
  33359. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33360. */
  33361. isVisible: boolean;
  33362. /**
  33363. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33364. */
  33365. isPickable: boolean;
  33366. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33367. showSubMeshesBoundingBox: boolean;
  33368. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33369. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33370. */
  33371. isBlocker: boolean;
  33372. /**
  33373. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33374. */
  33375. enablePointerMoveEvents: boolean;
  33376. private _renderingGroupId;
  33377. /**
  33378. * Specifies the rendering group id for this mesh (0 by default)
  33379. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33380. */
  33381. get renderingGroupId(): number;
  33382. set renderingGroupId(value: number);
  33383. private _material;
  33384. /** Gets or sets current material */
  33385. get material(): Nullable<Material>;
  33386. set material(value: Nullable<Material>);
  33387. /**
  33388. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33389. * @see https://doc.babylonjs.com/babylon101/shadows
  33390. */
  33391. get receiveShadows(): boolean;
  33392. set receiveShadows(value: boolean);
  33393. /** Defines color to use when rendering outline */
  33394. outlineColor: Color3;
  33395. /** Define width to use when rendering outline */
  33396. outlineWidth: number;
  33397. /** Defines color to use when rendering overlay */
  33398. overlayColor: Color3;
  33399. /** Defines alpha to use when rendering overlay */
  33400. overlayAlpha: number;
  33401. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33402. get hasVertexAlpha(): boolean;
  33403. set hasVertexAlpha(value: boolean);
  33404. /** 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) */
  33405. get useVertexColors(): boolean;
  33406. set useVertexColors(value: boolean);
  33407. /**
  33408. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33409. */
  33410. get computeBonesUsingShaders(): boolean;
  33411. set computeBonesUsingShaders(value: boolean);
  33412. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33413. get numBoneInfluencers(): number;
  33414. set numBoneInfluencers(value: number);
  33415. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33416. get applyFog(): boolean;
  33417. set applyFog(value: boolean);
  33418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33419. useOctreeForRenderingSelection: boolean;
  33420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33421. useOctreeForPicking: boolean;
  33422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33423. useOctreeForCollisions: boolean;
  33424. /**
  33425. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33426. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33427. */
  33428. get layerMask(): number;
  33429. set layerMask(value: number);
  33430. /**
  33431. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33432. */
  33433. alwaysSelectAsActiveMesh: boolean;
  33434. /**
  33435. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33436. */
  33437. doNotSyncBoundingInfo: boolean;
  33438. /**
  33439. * Gets or sets the current action manager
  33440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33441. */
  33442. actionManager: Nullable<AbstractActionManager>;
  33443. private _meshCollisionData;
  33444. /**
  33445. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33446. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33447. */
  33448. ellipsoid: Vector3;
  33449. /**
  33450. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33452. */
  33453. ellipsoidOffset: Vector3;
  33454. /**
  33455. * Gets or sets a collision mask used to mask collisions (default is -1).
  33456. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33457. */
  33458. get collisionMask(): number;
  33459. set collisionMask(mask: number);
  33460. /**
  33461. * Gets or sets a collision response flag (default is true).
  33462. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33463. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33464. * to respond to the collision.
  33465. */
  33466. get collisionResponse(): boolean;
  33467. set collisionResponse(response: boolean);
  33468. /**
  33469. * Gets or sets the current collision group mask (-1 by default).
  33470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33471. */
  33472. get collisionGroup(): number;
  33473. set collisionGroup(mask: number);
  33474. /**
  33475. * Gets or sets current surrounding meshes (null by default).
  33476. *
  33477. * By default collision detection is tested against every mesh in the scene.
  33478. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33479. * meshes will be tested for the collision.
  33480. *
  33481. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33482. */
  33483. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33484. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33485. /**
  33486. * Defines edge width used when edgesRenderer is enabled
  33487. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33488. */
  33489. edgesWidth: number;
  33490. /**
  33491. * Defines edge color used when edgesRenderer is enabled
  33492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33493. */
  33494. edgesColor: Color4;
  33495. /** @hidden */
  33496. _edgesRenderer: Nullable<IEdgesRenderer>;
  33497. /** @hidden */
  33498. _masterMesh: Nullable<AbstractMesh>;
  33499. /** @hidden */
  33500. _boundingInfo: Nullable<BoundingInfo>;
  33501. /** @hidden */
  33502. _renderId: number;
  33503. /**
  33504. * Gets or sets the list of subMeshes
  33505. * @see https://doc.babylonjs.com/how_to/multi_materials
  33506. */
  33507. subMeshes: SubMesh[];
  33508. /** @hidden */
  33509. _intersectionsInProgress: AbstractMesh[];
  33510. /** @hidden */
  33511. _unIndexed: boolean;
  33512. /** @hidden */
  33513. _lightSources: Light[];
  33514. /** Gets the list of lights affecting that mesh */
  33515. get lightSources(): Light[];
  33516. /** @hidden */
  33517. get _positions(): Nullable<Vector3[]>;
  33518. /** @hidden */
  33519. _waitingData: {
  33520. lods: Nullable<any>;
  33521. actions: Nullable<any>;
  33522. freezeWorldMatrix: Nullable<boolean>;
  33523. };
  33524. /** @hidden */
  33525. _bonesTransformMatrices: Nullable<Float32Array>;
  33526. /** @hidden */
  33527. _transformMatrixTexture: Nullable<RawTexture>;
  33528. /**
  33529. * Gets or sets a skeleton to apply skining transformations
  33530. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33531. */
  33532. set skeleton(value: Nullable<Skeleton>);
  33533. get skeleton(): Nullable<Skeleton>;
  33534. /**
  33535. * An event triggered when the mesh is rebuilt.
  33536. */
  33537. onRebuildObservable: Observable<AbstractMesh>;
  33538. /**
  33539. * Creates a new AbstractMesh
  33540. * @param name defines the name of the mesh
  33541. * @param scene defines the hosting scene
  33542. */
  33543. constructor(name: string, scene?: Nullable<Scene>);
  33544. /**
  33545. * Returns the string "AbstractMesh"
  33546. * @returns "AbstractMesh"
  33547. */
  33548. getClassName(): string;
  33549. /**
  33550. * Gets a string representation of the current mesh
  33551. * @param fullDetails defines a boolean indicating if full details must be included
  33552. * @returns a string representation of the current mesh
  33553. */
  33554. toString(fullDetails?: boolean): string;
  33555. /**
  33556. * @hidden
  33557. */
  33558. protected _getEffectiveParent(): Nullable<Node>;
  33559. /** @hidden */
  33560. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33561. /** @hidden */
  33562. _rebuild(): void;
  33563. /** @hidden */
  33564. _resyncLightSources(): void;
  33565. /** @hidden */
  33566. _resyncLightSource(light: Light): void;
  33567. /** @hidden */
  33568. _unBindEffect(): void;
  33569. /** @hidden */
  33570. _removeLightSource(light: Light, dispose: boolean): void;
  33571. private _markSubMeshesAsDirty;
  33572. /** @hidden */
  33573. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33574. /** @hidden */
  33575. _markSubMeshesAsAttributesDirty(): void;
  33576. /** @hidden */
  33577. _markSubMeshesAsMiscDirty(): void;
  33578. /**
  33579. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33580. */
  33581. get scaling(): Vector3;
  33582. set scaling(newScaling: Vector3);
  33583. /**
  33584. * Returns true if the mesh is blocked. Implemented by child classes
  33585. */
  33586. get isBlocked(): boolean;
  33587. /**
  33588. * Returns the mesh itself by default. Implemented by child classes
  33589. * @param camera defines the camera to use to pick the right LOD level
  33590. * @returns the currentAbstractMesh
  33591. */
  33592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33593. /**
  33594. * Returns 0 by default. Implemented by child classes
  33595. * @returns an integer
  33596. */
  33597. getTotalVertices(): number;
  33598. /**
  33599. * Returns a positive integer : the total number of indices in this mesh geometry.
  33600. * @returns the numner of indices or zero if the mesh has no geometry.
  33601. */
  33602. getTotalIndices(): number;
  33603. /**
  33604. * Returns null by default. Implemented by child classes
  33605. * @returns null
  33606. */
  33607. getIndices(): Nullable<IndicesArray>;
  33608. /**
  33609. * Returns the array of the requested vertex data kind. Implemented by child classes
  33610. * @param kind defines the vertex data kind to use
  33611. * @returns null
  33612. */
  33613. getVerticesData(kind: string): Nullable<FloatArray>;
  33614. /**
  33615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33617. * Note that a new underlying VertexBuffer object is created each call.
  33618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33619. * @param kind defines vertex data kind:
  33620. * * VertexBuffer.PositionKind
  33621. * * VertexBuffer.UVKind
  33622. * * VertexBuffer.UV2Kind
  33623. * * VertexBuffer.UV3Kind
  33624. * * VertexBuffer.UV4Kind
  33625. * * VertexBuffer.UV5Kind
  33626. * * VertexBuffer.UV6Kind
  33627. * * VertexBuffer.ColorKind
  33628. * * VertexBuffer.MatricesIndicesKind
  33629. * * VertexBuffer.MatricesIndicesExtraKind
  33630. * * VertexBuffer.MatricesWeightsKind
  33631. * * VertexBuffer.MatricesWeightsExtraKind
  33632. * @param data defines the data source
  33633. * @param updatable defines if the data must be flagged as updatable (or static)
  33634. * @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
  33635. * @returns the current mesh
  33636. */
  33637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33638. /**
  33639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33640. * If the mesh has no geometry, it is simply returned as it is.
  33641. * @param kind defines vertex data kind:
  33642. * * VertexBuffer.PositionKind
  33643. * * VertexBuffer.UVKind
  33644. * * VertexBuffer.UV2Kind
  33645. * * VertexBuffer.UV3Kind
  33646. * * VertexBuffer.UV4Kind
  33647. * * VertexBuffer.UV5Kind
  33648. * * VertexBuffer.UV6Kind
  33649. * * VertexBuffer.ColorKind
  33650. * * VertexBuffer.MatricesIndicesKind
  33651. * * VertexBuffer.MatricesIndicesExtraKind
  33652. * * VertexBuffer.MatricesWeightsKind
  33653. * * VertexBuffer.MatricesWeightsExtraKind
  33654. * @param data defines the data source
  33655. * @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
  33656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33657. * @returns the current mesh
  33658. */
  33659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33660. /**
  33661. * Sets the mesh indices,
  33662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33664. * @param totalVertices Defines the total number of vertices
  33665. * @returns the current mesh
  33666. */
  33667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33668. /**
  33669. * Gets a boolean indicating if specific vertex data is present
  33670. * @param kind defines the vertex data kind to use
  33671. * @returns true is data kind is present
  33672. */
  33673. isVerticesDataPresent(kind: string): boolean;
  33674. /**
  33675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33678. * @returns a BoundingInfo
  33679. */
  33680. getBoundingInfo(): BoundingInfo;
  33681. /**
  33682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33686. * @returns the current mesh
  33687. */
  33688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33689. /**
  33690. * Overwrite the current bounding info
  33691. * @param boundingInfo defines the new bounding info
  33692. * @returns the current mesh
  33693. */
  33694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33696. get useBones(): boolean;
  33697. /** @hidden */
  33698. _preActivate(): void;
  33699. /** @hidden */
  33700. _preActivateForIntermediateRendering(renderId: number): void;
  33701. /** @hidden */
  33702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33703. /** @hidden */
  33704. _postActivate(): void;
  33705. /** @hidden */
  33706. _freeze(): void;
  33707. /** @hidden */
  33708. _unFreeze(): void;
  33709. /**
  33710. * Gets the current world matrix
  33711. * @returns a Matrix
  33712. */
  33713. getWorldMatrix(): Matrix;
  33714. /** @hidden */
  33715. _getWorldMatrixDeterminant(): number;
  33716. /**
  33717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33718. */
  33719. get isAnInstance(): boolean;
  33720. /**
  33721. * Gets a boolean indicating if this mesh has instances
  33722. */
  33723. get hasInstances(): boolean;
  33724. /**
  33725. * Gets a boolean indicating if this mesh has thin instances
  33726. */
  33727. get hasThinInstances(): boolean;
  33728. /**
  33729. * Perform relative position change from the point of view of behind the front of the mesh.
  33730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33731. * Supports definition of mesh facing forward or backward
  33732. * @param amountRight defines the distance on the right axis
  33733. * @param amountUp defines the distance on the up axis
  33734. * @param amountForward defines the distance on the forward axis
  33735. * @returns the current mesh
  33736. */
  33737. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33738. /**
  33739. * Calculate relative position change from the point of view of behind the front of the mesh.
  33740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33741. * Supports definition of mesh facing forward or backward
  33742. * @param amountRight defines the distance on the right axis
  33743. * @param amountUp defines the distance on the up axis
  33744. * @param amountForward defines the distance on the forward axis
  33745. * @returns the new displacement vector
  33746. */
  33747. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33748. /**
  33749. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33750. * Supports definition of mesh facing forward or backward
  33751. * @param flipBack defines the flip
  33752. * @param twirlClockwise defines the twirl
  33753. * @param tiltRight defines the tilt
  33754. * @returns the current mesh
  33755. */
  33756. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33757. /**
  33758. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33759. * Supports definition of mesh facing forward or backward.
  33760. * @param flipBack defines the flip
  33761. * @param twirlClockwise defines the twirl
  33762. * @param tiltRight defines the tilt
  33763. * @returns the new rotation vector
  33764. */
  33765. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33766. /**
  33767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33768. * This means the mesh underlying bounding box and sphere are recomputed.
  33769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33770. * @returns the current mesh
  33771. */
  33772. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33773. /** @hidden */
  33774. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33775. /** @hidden */
  33776. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33777. /** @hidden */
  33778. _updateBoundingInfo(): AbstractMesh;
  33779. /** @hidden */
  33780. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33781. /** @hidden */
  33782. protected _afterComputeWorldMatrix(): void;
  33783. /** @hidden */
  33784. get _effectiveMesh(): AbstractMesh;
  33785. /**
  33786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33787. * A mesh is in the frustum if its bounding box intersects the frustum
  33788. * @param frustumPlanes defines the frustum to test
  33789. * @returns true if the mesh is in the frustum planes
  33790. */
  33791. isInFrustum(frustumPlanes: Plane[]): boolean;
  33792. /**
  33793. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33794. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33795. * @param frustumPlanes defines the frustum to test
  33796. * @returns true if the mesh is completely in the frustum planes
  33797. */
  33798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33799. /**
  33800. * True if the mesh intersects another mesh or a SolidParticle object
  33801. * @param mesh defines a target mesh or SolidParticle to test
  33802. * @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)
  33803. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33804. * @returns true if there is an intersection
  33805. */
  33806. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33807. /**
  33808. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33809. * @param point defines the point to test
  33810. * @returns true if there is an intersection
  33811. */
  33812. intersectsPoint(point: Vector3): boolean;
  33813. /**
  33814. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33815. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33816. */
  33817. get checkCollisions(): boolean;
  33818. set checkCollisions(collisionEnabled: boolean);
  33819. /**
  33820. * Gets Collider object used to compute collisions (not physics)
  33821. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33822. */
  33823. get collider(): Nullable<Collider>;
  33824. /**
  33825. * Move the mesh using collision engine
  33826. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33827. * @param displacement defines the requested displacement vector
  33828. * @returns the current mesh
  33829. */
  33830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33831. private _onCollisionPositionChange;
  33832. /** @hidden */
  33833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33834. /** @hidden */
  33835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33836. /** @hidden */
  33837. _checkCollision(collider: Collider): AbstractMesh;
  33838. /** @hidden */
  33839. _generatePointsArray(): boolean;
  33840. /**
  33841. * Checks if the passed Ray intersects with the mesh
  33842. * @param ray defines the ray to use
  33843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33845. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33846. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33847. * @returns the picking info
  33848. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33849. */
  33850. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33851. /**
  33852. * Clones the current mesh
  33853. * @param name defines the mesh name
  33854. * @param newParent defines the new mesh parent
  33855. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33856. * @returns the new mesh
  33857. */
  33858. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33859. /**
  33860. * Disposes all the submeshes of the current meshnp
  33861. * @returns the current mesh
  33862. */
  33863. releaseSubMeshes(): AbstractMesh;
  33864. /**
  33865. * Releases resources associated with this abstract mesh.
  33866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33868. */
  33869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33870. /**
  33871. * Adds the passed mesh as a child to the current mesh
  33872. * @param mesh defines the child mesh
  33873. * @returns the current mesh
  33874. */
  33875. addChild(mesh: AbstractMesh): AbstractMesh;
  33876. /**
  33877. * Removes the passed mesh from the current mesh children list
  33878. * @param mesh defines the child mesh
  33879. * @returns the current mesh
  33880. */
  33881. removeChild(mesh: AbstractMesh): AbstractMesh;
  33882. /** @hidden */
  33883. private _initFacetData;
  33884. /**
  33885. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33886. * This method can be called within the render loop.
  33887. * 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
  33888. * @returns the current mesh
  33889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33890. */
  33891. updateFacetData(): AbstractMesh;
  33892. /**
  33893. * Returns the facetLocalNormals array.
  33894. * The normals are expressed in the mesh local spac
  33895. * @returns an array of Vector3
  33896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33897. */
  33898. getFacetLocalNormals(): Vector3[];
  33899. /**
  33900. * Returns the facetLocalPositions array.
  33901. * The facet positions are expressed in the mesh local space
  33902. * @returns an array of Vector3
  33903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33904. */
  33905. getFacetLocalPositions(): Vector3[];
  33906. /**
  33907. * Returns the facetLocalPartioning array
  33908. * @returns an array of array of numbers
  33909. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33910. */
  33911. getFacetLocalPartitioning(): number[][];
  33912. /**
  33913. * Returns the i-th facet position in the world system.
  33914. * This method allocates a new Vector3 per call
  33915. * @param i defines the facet index
  33916. * @returns a new Vector3
  33917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33918. */
  33919. getFacetPosition(i: number): Vector3;
  33920. /**
  33921. * Sets the reference Vector3 with the i-th facet position in the world system
  33922. * @param i defines the facet index
  33923. * @param ref defines the target vector
  33924. * @returns the current mesh
  33925. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33926. */
  33927. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33928. /**
  33929. * Returns the i-th facet normal in the world system.
  33930. * This method allocates a new Vector3 per call
  33931. * @param i defines the facet index
  33932. * @returns a new Vector3
  33933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33934. */
  33935. getFacetNormal(i: number): Vector3;
  33936. /**
  33937. * Sets the reference Vector3 with the i-th facet normal in the world system
  33938. * @param i defines the facet index
  33939. * @param ref defines the target vector
  33940. * @returns the current mesh
  33941. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33942. */
  33943. getFacetNormalToRef(i: number, ref: Vector3): this;
  33944. /**
  33945. * 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)
  33946. * @param x defines x coordinate
  33947. * @param y defines y coordinate
  33948. * @param z defines z coordinate
  33949. * @returns the array of facet indexes
  33950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33951. */
  33952. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33953. /**
  33954. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33955. * @param projected sets as the (x,y,z) world projection on the facet
  33956. * @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
  33957. * @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
  33958. * @param x defines x coordinate
  33959. * @param y defines y coordinate
  33960. * @param z defines z coordinate
  33961. * @returns the face index if found (or null instead)
  33962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33963. */
  33964. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33965. /**
  33966. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33967. * @param projected sets as the (x,y,z) local projection on the facet
  33968. * @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
  33969. * @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
  33970. * @param x defines x coordinate
  33971. * @param y defines y coordinate
  33972. * @param z defines z coordinate
  33973. * @returns the face index if found (or null instead)
  33974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33975. */
  33976. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33977. /**
  33978. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33979. * @returns the parameters
  33980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33981. */
  33982. getFacetDataParameters(): any;
  33983. /**
  33984. * Disables the feature FacetData and frees the related memory
  33985. * @returns the current mesh
  33986. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33987. */
  33988. disableFacetData(): AbstractMesh;
  33989. /**
  33990. * Updates the AbstractMesh indices array
  33991. * @param indices defines the data source
  33992. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33993. * @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)
  33994. * @returns the current mesh
  33995. */
  33996. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33997. /**
  33998. * Creates new normals data for the mesh
  33999. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34000. * @returns the current mesh
  34001. */
  34002. createNormals(updatable: boolean): AbstractMesh;
  34003. /**
  34004. * Align the mesh with a normal
  34005. * @param normal defines the normal to use
  34006. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34007. * @returns the current mesh
  34008. */
  34009. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34010. /** @hidden */
  34011. _checkOcclusionQuery(): boolean;
  34012. /**
  34013. * Disables the mesh edge rendering mode
  34014. * @returns the currentAbstractMesh
  34015. */
  34016. disableEdgesRendering(): AbstractMesh;
  34017. /**
  34018. * Enables the edge rendering mode on the mesh.
  34019. * This mode makes the mesh edges visible
  34020. * @param epsilon defines the maximal distance between two angles to detect a face
  34021. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34022. * @returns the currentAbstractMesh
  34023. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34024. */
  34025. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34026. /**
  34027. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34028. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34029. */
  34030. getConnectedParticleSystems(): IParticleSystem[];
  34031. }
  34032. }
  34033. declare module "babylonjs/Actions/actionEvent" {
  34034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34035. import { Nullable } from "babylonjs/types";
  34036. import { Sprite } from "babylonjs/Sprites/sprite";
  34037. import { Scene } from "babylonjs/scene";
  34038. import { Vector2 } from "babylonjs/Maths/math.vector";
  34039. /**
  34040. * Interface used to define ActionEvent
  34041. */
  34042. export interface IActionEvent {
  34043. /** The mesh or sprite that triggered the action */
  34044. source: any;
  34045. /** The X mouse cursor position at the time of the event */
  34046. pointerX: number;
  34047. /** The Y mouse cursor position at the time of the event */
  34048. pointerY: number;
  34049. /** The mesh that is currently pointed at (can be null) */
  34050. meshUnderPointer: Nullable<AbstractMesh>;
  34051. /** the original (browser) event that triggered the ActionEvent */
  34052. sourceEvent?: any;
  34053. /** additional data for the event */
  34054. additionalData?: any;
  34055. }
  34056. /**
  34057. * ActionEvent is the event being sent when an action is triggered.
  34058. */
  34059. export class ActionEvent implements IActionEvent {
  34060. /** The mesh or sprite that triggered the action */
  34061. source: any;
  34062. /** The X mouse cursor position at the time of the event */
  34063. pointerX: number;
  34064. /** The Y mouse cursor position at the time of the event */
  34065. pointerY: number;
  34066. /** The mesh that is currently pointed at (can be null) */
  34067. meshUnderPointer: Nullable<AbstractMesh>;
  34068. /** the original (browser) event that triggered the ActionEvent */
  34069. sourceEvent?: any;
  34070. /** additional data for the event */
  34071. additionalData?: any;
  34072. /**
  34073. * Creates a new ActionEvent
  34074. * @param source The mesh or sprite that triggered the action
  34075. * @param pointerX The X mouse cursor position at the time of the event
  34076. * @param pointerY The Y mouse cursor position at the time of the event
  34077. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34078. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34079. * @param additionalData additional data for the event
  34080. */
  34081. constructor(
  34082. /** The mesh or sprite that triggered the action */
  34083. source: any,
  34084. /** The X mouse cursor position at the time of the event */
  34085. pointerX: number,
  34086. /** The Y mouse cursor position at the time of the event */
  34087. pointerY: number,
  34088. /** The mesh that is currently pointed at (can be null) */
  34089. meshUnderPointer: Nullable<AbstractMesh>,
  34090. /** the original (browser) event that triggered the ActionEvent */
  34091. sourceEvent?: any,
  34092. /** additional data for the event */
  34093. additionalData?: any);
  34094. /**
  34095. * Helper function to auto-create an ActionEvent from a source mesh.
  34096. * @param source The source mesh that triggered the event
  34097. * @param evt The original (browser) event
  34098. * @param additionalData additional data for the event
  34099. * @returns the new ActionEvent
  34100. */
  34101. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34102. /**
  34103. * Helper function to auto-create an ActionEvent from a source sprite
  34104. * @param source The source sprite that triggered the event
  34105. * @param scene Scene associated with the sprite
  34106. * @param evt The original (browser) event
  34107. * @param additionalData additional data for the event
  34108. * @returns the new ActionEvent
  34109. */
  34110. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34111. /**
  34112. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34113. * @param scene the scene where the event occurred
  34114. * @param evt The original (browser) event
  34115. * @returns the new ActionEvent
  34116. */
  34117. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34118. /**
  34119. * Helper function to auto-create an ActionEvent from a primitive
  34120. * @param prim defines the target primitive
  34121. * @param pointerPos defines the pointer position
  34122. * @param evt The original (browser) event
  34123. * @param additionalData additional data for the event
  34124. * @returns the new ActionEvent
  34125. */
  34126. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34127. }
  34128. }
  34129. declare module "babylonjs/Actions/abstractActionManager" {
  34130. import { IDisposable } from "babylonjs/scene";
  34131. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34132. import { IAction } from "babylonjs/Actions/action";
  34133. import { Nullable } from "babylonjs/types";
  34134. /**
  34135. * Abstract class used to decouple action Manager from scene and meshes.
  34136. * Do not instantiate.
  34137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34138. */
  34139. export abstract class AbstractActionManager implements IDisposable {
  34140. /** Gets the list of active triggers */
  34141. static Triggers: {
  34142. [key: string]: number;
  34143. };
  34144. /** Gets the cursor to use when hovering items */
  34145. hoverCursor: string;
  34146. /** Gets the list of actions */
  34147. actions: IAction[];
  34148. /**
  34149. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34150. */
  34151. isRecursive: boolean;
  34152. /**
  34153. * Releases all associated resources
  34154. */
  34155. abstract dispose(): void;
  34156. /**
  34157. * Does this action manager has pointer triggers
  34158. */
  34159. abstract get hasPointerTriggers(): boolean;
  34160. /**
  34161. * Does this action manager has pick triggers
  34162. */
  34163. abstract get hasPickTriggers(): boolean;
  34164. /**
  34165. * Process a specific trigger
  34166. * @param trigger defines the trigger to process
  34167. * @param evt defines the event details to be processed
  34168. */
  34169. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34170. /**
  34171. * Does this action manager handles actions of any of the given triggers
  34172. * @param triggers defines the triggers to be tested
  34173. * @return a boolean indicating whether one (or more) of the triggers is handled
  34174. */
  34175. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34176. /**
  34177. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34178. * speed.
  34179. * @param triggerA defines the trigger to be tested
  34180. * @param triggerB defines the trigger to be tested
  34181. * @return a boolean indicating whether one (or more) of the triggers is handled
  34182. */
  34183. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34184. /**
  34185. * Does this action manager handles actions of a given trigger
  34186. * @param trigger defines the trigger to be tested
  34187. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34188. * @return whether the trigger is handled
  34189. */
  34190. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34191. /**
  34192. * Serialize this manager to a JSON object
  34193. * @param name defines the property name to store this manager
  34194. * @returns a JSON representation of this manager
  34195. */
  34196. abstract serialize(name: string): any;
  34197. /**
  34198. * Registers an action to this action manager
  34199. * @param action defines the action to be registered
  34200. * @return the action amended (prepared) after registration
  34201. */
  34202. abstract registerAction(action: IAction): Nullable<IAction>;
  34203. /**
  34204. * Unregisters an action to this action manager
  34205. * @param action defines the action to be unregistered
  34206. * @return a boolean indicating whether the action has been unregistered
  34207. */
  34208. abstract unregisterAction(action: IAction): Boolean;
  34209. /**
  34210. * Does exist one action manager with at least one trigger
  34211. **/
  34212. static get HasTriggers(): boolean;
  34213. /**
  34214. * Does exist one action manager with at least one pick trigger
  34215. **/
  34216. static get HasPickTriggers(): boolean;
  34217. /**
  34218. * Does exist one action manager that handles actions of a given trigger
  34219. * @param trigger defines the trigger to be tested
  34220. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34221. **/
  34222. static HasSpecificTrigger(trigger: number): boolean;
  34223. }
  34224. }
  34225. declare module "babylonjs/node" {
  34226. import { Scene } from "babylonjs/scene";
  34227. import { Nullable } from "babylonjs/types";
  34228. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34229. import { Engine } from "babylonjs/Engines/engine";
  34230. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34231. import { Observable } from "babylonjs/Misc/observable";
  34232. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34233. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34234. import { Animatable } from "babylonjs/Animations/animatable";
  34235. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34236. import { Animation } from "babylonjs/Animations/animation";
  34237. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34239. /**
  34240. * Defines how a node can be built from a string name.
  34241. */
  34242. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34243. /**
  34244. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34245. */
  34246. export class Node implements IBehaviorAware<Node> {
  34247. /** @hidden */
  34248. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34249. private static _NodeConstructors;
  34250. /**
  34251. * Add a new node constructor
  34252. * @param type defines the type name of the node to construct
  34253. * @param constructorFunc defines the constructor function
  34254. */
  34255. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34256. /**
  34257. * Returns a node constructor based on type name
  34258. * @param type defines the type name
  34259. * @param name defines the new node name
  34260. * @param scene defines the hosting scene
  34261. * @param options defines optional options to transmit to constructors
  34262. * @returns the new constructor or null
  34263. */
  34264. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34265. /**
  34266. * Gets or sets the name of the node
  34267. */
  34268. name: string;
  34269. /**
  34270. * Gets or sets the id of the node
  34271. */
  34272. id: string;
  34273. /**
  34274. * Gets or sets the unique id of the node
  34275. */
  34276. uniqueId: number;
  34277. /**
  34278. * Gets or sets a string used to store user defined state for the node
  34279. */
  34280. state: string;
  34281. /**
  34282. * Gets or sets an object used to store user defined information for the node
  34283. */
  34284. metadata: any;
  34285. /**
  34286. * For internal use only. Please do not use.
  34287. */
  34288. reservedDataStore: any;
  34289. /**
  34290. * List of inspectable custom properties (used by the Inspector)
  34291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34292. */
  34293. inspectableCustomProperties: IInspectable[];
  34294. private _doNotSerialize;
  34295. /**
  34296. * Gets or sets a boolean used to define if the node must be serialized
  34297. */
  34298. get doNotSerialize(): boolean;
  34299. set doNotSerialize(value: boolean);
  34300. /** @hidden */
  34301. _isDisposed: boolean;
  34302. /**
  34303. * Gets a list of Animations associated with the node
  34304. */
  34305. animations: import("babylonjs/Animations/animation").Animation[];
  34306. protected _ranges: {
  34307. [name: string]: Nullable<AnimationRange>;
  34308. };
  34309. /**
  34310. * Callback raised when the node is ready to be used
  34311. */
  34312. onReady: Nullable<(node: Node) => void>;
  34313. private _isEnabled;
  34314. private _isParentEnabled;
  34315. private _isReady;
  34316. /** @hidden */
  34317. _currentRenderId: number;
  34318. private _parentUpdateId;
  34319. /** @hidden */
  34320. _childUpdateId: number;
  34321. /** @hidden */
  34322. _waitingParentId: Nullable<string>;
  34323. /** @hidden */
  34324. _scene: Scene;
  34325. /** @hidden */
  34326. _cache: any;
  34327. private _parentNode;
  34328. private _children;
  34329. /** @hidden */
  34330. _worldMatrix: Matrix;
  34331. /** @hidden */
  34332. _worldMatrixDeterminant: number;
  34333. /** @hidden */
  34334. _worldMatrixDeterminantIsDirty: boolean;
  34335. /** @hidden */
  34336. private _sceneRootNodesIndex;
  34337. /**
  34338. * Gets a boolean indicating if the node has been disposed
  34339. * @returns true if the node was disposed
  34340. */
  34341. isDisposed(): boolean;
  34342. /**
  34343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34344. * @see https://doc.babylonjs.com/how_to/parenting
  34345. */
  34346. set parent(parent: Nullable<Node>);
  34347. get parent(): Nullable<Node>;
  34348. /** @hidden */
  34349. _addToSceneRootNodes(): void;
  34350. /** @hidden */
  34351. _removeFromSceneRootNodes(): void;
  34352. private _animationPropertiesOverride;
  34353. /**
  34354. * Gets or sets the animation properties override
  34355. */
  34356. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34357. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34358. /**
  34359. * Gets a string identifying the name of the class
  34360. * @returns "Node" string
  34361. */
  34362. getClassName(): string;
  34363. /** @hidden */
  34364. readonly _isNode: boolean;
  34365. /**
  34366. * An event triggered when the mesh is disposed
  34367. */
  34368. onDisposeObservable: Observable<Node>;
  34369. private _onDisposeObserver;
  34370. /**
  34371. * Sets a callback that will be raised when the node will be disposed
  34372. */
  34373. set onDispose(callback: () => void);
  34374. /**
  34375. * Creates a new Node
  34376. * @param name the name and id to be given to this node
  34377. * @param scene the scene this node will be added to
  34378. */
  34379. constructor(name: string, scene?: Nullable<Scene>);
  34380. /**
  34381. * Gets the scene of the node
  34382. * @returns a scene
  34383. */
  34384. getScene(): Scene;
  34385. /**
  34386. * Gets the engine of the node
  34387. * @returns a Engine
  34388. */
  34389. getEngine(): Engine;
  34390. private _behaviors;
  34391. /**
  34392. * Attach a behavior to the node
  34393. * @see https://doc.babylonjs.com/features/behaviour
  34394. * @param behavior defines the behavior to attach
  34395. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34396. * @returns the current Node
  34397. */
  34398. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34399. /**
  34400. * Remove an attached behavior
  34401. * @see https://doc.babylonjs.com/features/behaviour
  34402. * @param behavior defines the behavior to attach
  34403. * @returns the current Node
  34404. */
  34405. removeBehavior(behavior: Behavior<Node>): Node;
  34406. /**
  34407. * Gets the list of attached behaviors
  34408. * @see https://doc.babylonjs.com/features/behaviour
  34409. */
  34410. get behaviors(): Behavior<Node>[];
  34411. /**
  34412. * Gets an attached behavior by name
  34413. * @param name defines the name of the behavior to look for
  34414. * @see https://doc.babylonjs.com/features/behaviour
  34415. * @returns null if behavior was not found else the requested behavior
  34416. */
  34417. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34418. /**
  34419. * Returns the latest update of the World matrix
  34420. * @returns a Matrix
  34421. */
  34422. getWorldMatrix(): Matrix;
  34423. /** @hidden */
  34424. _getWorldMatrixDeterminant(): number;
  34425. /**
  34426. * Returns directly the latest state of the mesh World matrix.
  34427. * A Matrix is returned.
  34428. */
  34429. get worldMatrixFromCache(): Matrix;
  34430. /** @hidden */
  34431. _initCache(): void;
  34432. /** @hidden */
  34433. updateCache(force?: boolean): void;
  34434. /** @hidden */
  34435. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34436. /** @hidden */
  34437. _updateCache(ignoreParentClass?: boolean): void;
  34438. /** @hidden */
  34439. _isSynchronized(): boolean;
  34440. /** @hidden */
  34441. _markSyncedWithParent(): void;
  34442. /** @hidden */
  34443. isSynchronizedWithParent(): boolean;
  34444. /** @hidden */
  34445. isSynchronized(): boolean;
  34446. /**
  34447. * Is this node ready to be used/rendered
  34448. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34449. * @return true if the node is ready
  34450. */
  34451. isReady(completeCheck?: boolean): boolean;
  34452. /**
  34453. * Is this node enabled?
  34454. * 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
  34455. * @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
  34456. * @return whether this node (and its parent) is enabled
  34457. */
  34458. isEnabled(checkAncestors?: boolean): boolean;
  34459. /** @hidden */
  34460. protected _syncParentEnabledState(): void;
  34461. /**
  34462. * Set the enabled state of this node
  34463. * @param value defines the new enabled state
  34464. */
  34465. setEnabled(value: boolean): void;
  34466. /**
  34467. * Is this node a descendant of the given node?
  34468. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34469. * @param ancestor defines the parent node to inspect
  34470. * @returns a boolean indicating if this node is a descendant of the given node
  34471. */
  34472. isDescendantOf(ancestor: Node): boolean;
  34473. /** @hidden */
  34474. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34475. /**
  34476. * Will return all nodes that have this node as ascendant
  34477. * @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
  34478. * @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
  34479. * @return all children nodes of all types
  34480. */
  34481. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34482. /**
  34483. * Get all child-meshes of this node
  34484. * @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)
  34485. * @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
  34486. * @returns an array of AbstractMesh
  34487. */
  34488. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34489. /**
  34490. * Get all direct children of this node
  34491. * @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
  34492. * @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)
  34493. * @returns an array of Node
  34494. */
  34495. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34496. /** @hidden */
  34497. _setReady(state: boolean): void;
  34498. /**
  34499. * Get an animation by name
  34500. * @param name defines the name of the animation to look for
  34501. * @returns null if not found else the requested animation
  34502. */
  34503. getAnimationByName(name: string): Nullable<Animation>;
  34504. /**
  34505. * Creates an animation range for this node
  34506. * @param name defines the name of the range
  34507. * @param from defines the starting key
  34508. * @param to defines the end key
  34509. */
  34510. createAnimationRange(name: string, from: number, to: number): void;
  34511. /**
  34512. * Delete a specific animation range
  34513. * @param name defines the name of the range to delete
  34514. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34515. */
  34516. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34517. /**
  34518. * Get an animation range by name
  34519. * @param name defines the name of the animation range to look for
  34520. * @returns null if not found else the requested animation range
  34521. */
  34522. getAnimationRange(name: string): Nullable<AnimationRange>;
  34523. /**
  34524. * Gets the list of all animation ranges defined on this node
  34525. * @returns an array
  34526. */
  34527. getAnimationRanges(): Nullable<AnimationRange>[];
  34528. /**
  34529. * Will start the animation sequence
  34530. * @param name defines the range frames for animation sequence
  34531. * @param loop defines if the animation should loop (false by default)
  34532. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34533. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34534. * @returns the object created for this animation. If range does not exist, it will return null
  34535. */
  34536. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34537. /**
  34538. * Serialize animation ranges into a JSON compatible object
  34539. * @returns serialization object
  34540. */
  34541. serializeAnimationRanges(): any;
  34542. /**
  34543. * Computes the world matrix of the node
  34544. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34545. * @returns the world matrix
  34546. */
  34547. computeWorldMatrix(force?: boolean): Matrix;
  34548. /**
  34549. * Releases resources associated with this node.
  34550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34552. */
  34553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34554. /**
  34555. * Parse animation range data from a serialization object and store them into a given node
  34556. * @param node defines where to store the animation ranges
  34557. * @param parsedNode defines the serialization object to read data from
  34558. * @param scene defines the hosting scene
  34559. */
  34560. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34561. /**
  34562. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34563. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34564. * @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
  34565. * @returns the new bounding vectors
  34566. */
  34567. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34568. min: Vector3;
  34569. max: Vector3;
  34570. };
  34571. }
  34572. }
  34573. declare module "babylonjs/Animations/animation" {
  34574. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34575. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34576. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34577. import { Nullable } from "babylonjs/types";
  34578. import { Scene } from "babylonjs/scene";
  34579. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34580. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34581. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34582. import { Node } from "babylonjs/node";
  34583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34584. import { Size } from "babylonjs/Maths/math.size";
  34585. import { Animatable } from "babylonjs/Animations/animatable";
  34586. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34587. /**
  34588. * @hidden
  34589. */
  34590. export class _IAnimationState {
  34591. key: number;
  34592. repeatCount: number;
  34593. workValue?: any;
  34594. loopMode?: number;
  34595. offsetValue?: any;
  34596. highLimitValue?: any;
  34597. }
  34598. /**
  34599. * Class used to store any kind of animation
  34600. */
  34601. export class Animation {
  34602. /**Name of the animation */
  34603. name: string;
  34604. /**Property to animate */
  34605. targetProperty: string;
  34606. /**The frames per second of the animation */
  34607. framePerSecond: number;
  34608. /**The data type of the animation */
  34609. dataType: number;
  34610. /**The loop mode of the animation */
  34611. loopMode?: number | undefined;
  34612. /**Specifies if blending should be enabled */
  34613. enableBlending?: boolean | undefined;
  34614. /**
  34615. * Use matrix interpolation instead of using direct key value when animating matrices
  34616. */
  34617. static AllowMatricesInterpolation: boolean;
  34618. /**
  34619. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34620. */
  34621. static AllowMatrixDecomposeForInterpolation: boolean;
  34622. /** Define the Url to load snippets */
  34623. static SnippetUrl: string;
  34624. /** Snippet ID if the animation was created from the snippet server */
  34625. snippetId: string;
  34626. /**
  34627. * Stores the key frames of the animation
  34628. */
  34629. private _keys;
  34630. /**
  34631. * Stores the easing function of the animation
  34632. */
  34633. private _easingFunction;
  34634. /**
  34635. * @hidden Internal use only
  34636. */
  34637. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34638. /**
  34639. * The set of event that will be linked to this animation
  34640. */
  34641. private _events;
  34642. /**
  34643. * Stores an array of target property paths
  34644. */
  34645. targetPropertyPath: string[];
  34646. /**
  34647. * Stores the blending speed of the animation
  34648. */
  34649. blendingSpeed: number;
  34650. /**
  34651. * Stores the animation ranges for the animation
  34652. */
  34653. private _ranges;
  34654. /**
  34655. * @hidden Internal use
  34656. */
  34657. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34658. /**
  34659. * Sets up an animation
  34660. * @param property The property to animate
  34661. * @param animationType The animation type to apply
  34662. * @param framePerSecond The frames per second of the animation
  34663. * @param easingFunction The easing function used in the animation
  34664. * @returns The created animation
  34665. */
  34666. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34667. /**
  34668. * Create and start an animation on a node
  34669. * @param name defines the name of the global animation that will be run on all nodes
  34670. * @param node defines the root node where the animation will take place
  34671. * @param targetProperty defines property to animate
  34672. * @param framePerSecond defines the number of frame per second yo use
  34673. * @param totalFrame defines the number of frames in total
  34674. * @param from defines the initial value
  34675. * @param to defines the final value
  34676. * @param loopMode defines which loop mode you want to use (off by default)
  34677. * @param easingFunction defines the easing function to use (linear by default)
  34678. * @param onAnimationEnd defines the callback to call when animation end
  34679. * @returns the animatable created for this animation
  34680. */
  34681. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34682. /**
  34683. * Create and start an animation on a node and its descendants
  34684. * @param name defines the name of the global animation that will be run on all nodes
  34685. * @param node defines the root node where the animation will take place
  34686. * @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
  34687. * @param targetProperty defines property to animate
  34688. * @param framePerSecond defines the number of frame per second to use
  34689. * @param totalFrame defines the number of frames in total
  34690. * @param from defines the initial value
  34691. * @param to defines the final value
  34692. * @param loopMode defines which loop mode you want to use (off by default)
  34693. * @param easingFunction defines the easing function to use (linear by default)
  34694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34695. * @returns the list of animatables created for all nodes
  34696. * @example https://www.babylonjs-playground.com/#MH0VLI
  34697. */
  34698. 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[]>;
  34699. /**
  34700. * Creates a new animation, merges it with the existing animations and starts it
  34701. * @param name Name of the animation
  34702. * @param node Node which contains the scene that begins the animations
  34703. * @param targetProperty Specifies which property to animate
  34704. * @param framePerSecond The frames per second of the animation
  34705. * @param totalFrame The total number of frames
  34706. * @param from The frame at the beginning of the animation
  34707. * @param to The frame at the end of the animation
  34708. * @param loopMode Specifies the loop mode of the animation
  34709. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34710. * @param onAnimationEnd Callback to run once the animation is complete
  34711. * @returns Nullable animation
  34712. */
  34713. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34714. /**
  34715. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34716. * @param sourceAnimation defines the Animation containing keyframes to convert
  34717. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34718. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34719. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34720. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34721. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34722. */
  34723. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34724. /**
  34725. * Transition property of an host to the target Value
  34726. * @param property The property to transition
  34727. * @param targetValue The target Value of the property
  34728. * @param host The object where the property to animate belongs
  34729. * @param scene Scene used to run the animation
  34730. * @param frameRate Framerate (in frame/s) to use
  34731. * @param transition The transition type we want to use
  34732. * @param duration The duration of the animation, in milliseconds
  34733. * @param onAnimationEnd Callback trigger at the end of the animation
  34734. * @returns Nullable animation
  34735. */
  34736. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34737. /**
  34738. * Return the array of runtime animations currently using this animation
  34739. */
  34740. get runtimeAnimations(): RuntimeAnimation[];
  34741. /**
  34742. * Specifies if any of the runtime animations are currently running
  34743. */
  34744. get hasRunningRuntimeAnimations(): boolean;
  34745. /**
  34746. * Initializes the animation
  34747. * @param name Name of the animation
  34748. * @param targetProperty Property to animate
  34749. * @param framePerSecond The frames per second of the animation
  34750. * @param dataType The data type of the animation
  34751. * @param loopMode The loop mode of the animation
  34752. * @param enableBlending Specifies if blending should be enabled
  34753. */
  34754. constructor(
  34755. /**Name of the animation */
  34756. name: string,
  34757. /**Property to animate */
  34758. targetProperty: string,
  34759. /**The frames per second of the animation */
  34760. framePerSecond: number,
  34761. /**The data type of the animation */
  34762. dataType: number,
  34763. /**The loop mode of the animation */
  34764. loopMode?: number | undefined,
  34765. /**Specifies if blending should be enabled */
  34766. enableBlending?: boolean | undefined);
  34767. /**
  34768. * Converts the animation to a string
  34769. * @param fullDetails support for multiple levels of logging within scene loading
  34770. * @returns String form of the animation
  34771. */
  34772. toString(fullDetails?: boolean): string;
  34773. /**
  34774. * Add an event to this animation
  34775. * @param event Event to add
  34776. */
  34777. addEvent(event: AnimationEvent): void;
  34778. /**
  34779. * Remove all events found at the given frame
  34780. * @param frame The frame to remove events from
  34781. */
  34782. removeEvents(frame: number): void;
  34783. /**
  34784. * Retrieves all the events from the animation
  34785. * @returns Events from the animation
  34786. */
  34787. getEvents(): AnimationEvent[];
  34788. /**
  34789. * Creates an animation range
  34790. * @param name Name of the animation range
  34791. * @param from Starting frame of the animation range
  34792. * @param to Ending frame of the animation
  34793. */
  34794. createRange(name: string, from: number, to: number): void;
  34795. /**
  34796. * Deletes an animation range by name
  34797. * @param name Name of the animation range to delete
  34798. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34799. */
  34800. deleteRange(name: string, deleteFrames?: boolean): void;
  34801. /**
  34802. * Gets the animation range by name, or null if not defined
  34803. * @param name Name of the animation range
  34804. * @returns Nullable animation range
  34805. */
  34806. getRange(name: string): Nullable<AnimationRange>;
  34807. /**
  34808. * Gets the key frames from the animation
  34809. * @returns The key frames of the animation
  34810. */
  34811. getKeys(): Array<IAnimationKey>;
  34812. /**
  34813. * Gets the highest frame rate of the animation
  34814. * @returns Highest frame rate of the animation
  34815. */
  34816. getHighestFrame(): number;
  34817. /**
  34818. * Gets the easing function of the animation
  34819. * @returns Easing function of the animation
  34820. */
  34821. getEasingFunction(): IEasingFunction;
  34822. /**
  34823. * Sets the easing function of the animation
  34824. * @param easingFunction A custom mathematical formula for animation
  34825. */
  34826. setEasingFunction(easingFunction: EasingFunction): void;
  34827. /**
  34828. * Interpolates a scalar linearly
  34829. * @param startValue Start value of the animation curve
  34830. * @param endValue End value of the animation curve
  34831. * @param gradient Scalar amount to interpolate
  34832. * @returns Interpolated scalar value
  34833. */
  34834. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34835. /**
  34836. * Interpolates a scalar cubically
  34837. * @param startValue Start value of the animation curve
  34838. * @param outTangent End tangent of the animation
  34839. * @param endValue End value of the animation curve
  34840. * @param inTangent Start tangent of the animation curve
  34841. * @param gradient Scalar amount to interpolate
  34842. * @returns Interpolated scalar value
  34843. */
  34844. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34845. /**
  34846. * Interpolates a quaternion using a spherical linear interpolation
  34847. * @param startValue Start value of the animation curve
  34848. * @param endValue End value of the animation curve
  34849. * @param gradient Scalar amount to interpolate
  34850. * @returns Interpolated quaternion value
  34851. */
  34852. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34853. /**
  34854. * Interpolates a quaternion cubically
  34855. * @param startValue Start value of the animation curve
  34856. * @param outTangent End tangent of the animation curve
  34857. * @param endValue End value of the animation curve
  34858. * @param inTangent Start tangent of the animation curve
  34859. * @param gradient Scalar amount to interpolate
  34860. * @returns Interpolated quaternion value
  34861. */
  34862. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34863. /**
  34864. * Interpolates a Vector3 linearl
  34865. * @param startValue Start value of the animation curve
  34866. * @param endValue End value of the animation curve
  34867. * @param gradient Scalar amount to interpolate
  34868. * @returns Interpolated scalar value
  34869. */
  34870. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34871. /**
  34872. * Interpolates a Vector3 cubically
  34873. * @param startValue Start value of the animation curve
  34874. * @param outTangent End tangent of the animation
  34875. * @param endValue End value of the animation curve
  34876. * @param inTangent Start tangent of the animation curve
  34877. * @param gradient Scalar amount to interpolate
  34878. * @returns InterpolatedVector3 value
  34879. */
  34880. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34881. /**
  34882. * Interpolates a Vector2 linearly
  34883. * @param startValue Start value of the animation curve
  34884. * @param endValue End value of the animation curve
  34885. * @param gradient Scalar amount to interpolate
  34886. * @returns Interpolated Vector2 value
  34887. */
  34888. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34889. /**
  34890. * Interpolates a Vector2 cubically
  34891. * @param startValue Start value of the animation curve
  34892. * @param outTangent End tangent of the animation
  34893. * @param endValue End value of the animation curve
  34894. * @param inTangent Start tangent of the animation curve
  34895. * @param gradient Scalar amount to interpolate
  34896. * @returns Interpolated Vector2 value
  34897. */
  34898. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34899. /**
  34900. * Interpolates a size linearly
  34901. * @param startValue Start value of the animation curve
  34902. * @param endValue End value of the animation curve
  34903. * @param gradient Scalar amount to interpolate
  34904. * @returns Interpolated Size value
  34905. */
  34906. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34907. /**
  34908. * Interpolates a Color3 linearly
  34909. * @param startValue Start value of the animation curve
  34910. * @param endValue End value of the animation curve
  34911. * @param gradient Scalar amount to interpolate
  34912. * @returns Interpolated Color3 value
  34913. */
  34914. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34915. /**
  34916. * Interpolates a Color4 linearly
  34917. * @param startValue Start value of the animation curve
  34918. * @param endValue End value of the animation curve
  34919. * @param gradient Scalar amount to interpolate
  34920. * @returns Interpolated Color3 value
  34921. */
  34922. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34923. /**
  34924. * @hidden Internal use only
  34925. */
  34926. _getKeyValue(value: any): any;
  34927. /**
  34928. * @hidden Internal use only
  34929. */
  34930. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34931. /**
  34932. * Defines the function to use to interpolate matrices
  34933. * @param startValue defines the start matrix
  34934. * @param endValue defines the end matrix
  34935. * @param gradient defines the gradient between both matrices
  34936. * @param result defines an optional target matrix where to store the interpolation
  34937. * @returns the interpolated matrix
  34938. */
  34939. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34940. /**
  34941. * Makes a copy of the animation
  34942. * @returns Cloned animation
  34943. */
  34944. clone(): Animation;
  34945. /**
  34946. * Sets the key frames of the animation
  34947. * @param values The animation key frames to set
  34948. */
  34949. setKeys(values: Array<IAnimationKey>): void;
  34950. /**
  34951. * Serializes the animation to an object
  34952. * @returns Serialized object
  34953. */
  34954. serialize(): any;
  34955. /**
  34956. * Float animation type
  34957. */
  34958. static readonly ANIMATIONTYPE_FLOAT: number;
  34959. /**
  34960. * Vector3 animation type
  34961. */
  34962. static readonly ANIMATIONTYPE_VECTOR3: number;
  34963. /**
  34964. * Quaternion animation type
  34965. */
  34966. static readonly ANIMATIONTYPE_QUATERNION: number;
  34967. /**
  34968. * Matrix animation type
  34969. */
  34970. static readonly ANIMATIONTYPE_MATRIX: number;
  34971. /**
  34972. * Color3 animation type
  34973. */
  34974. static readonly ANIMATIONTYPE_COLOR3: number;
  34975. /**
  34976. * Color3 animation type
  34977. */
  34978. static readonly ANIMATIONTYPE_COLOR4: number;
  34979. /**
  34980. * Vector2 animation type
  34981. */
  34982. static readonly ANIMATIONTYPE_VECTOR2: number;
  34983. /**
  34984. * Size animation type
  34985. */
  34986. static readonly ANIMATIONTYPE_SIZE: number;
  34987. /**
  34988. * Relative Loop Mode
  34989. */
  34990. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34991. /**
  34992. * Cycle Loop Mode
  34993. */
  34994. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34995. /**
  34996. * Constant Loop Mode
  34997. */
  34998. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34999. /** @hidden */
  35000. static _UniversalLerp(left: any, right: any, amount: number): any;
  35001. /**
  35002. * Parses an animation object and creates an animation
  35003. * @param parsedAnimation Parsed animation object
  35004. * @returns Animation object
  35005. */
  35006. static Parse(parsedAnimation: any): Animation;
  35007. /**
  35008. * Appends the serialized animations from the source animations
  35009. * @param source Source containing the animations
  35010. * @param destination Target to store the animations
  35011. */
  35012. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35013. /**
  35014. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35015. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35016. * @param url defines the url to load from
  35017. * @returns a promise that will resolve to the new animation or an array of animations
  35018. */
  35019. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35020. /**
  35021. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35022. * @param snippetId defines the snippet to load
  35023. * @returns a promise that will resolve to the new animation or a new array of animations
  35024. */
  35025. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35026. }
  35027. }
  35028. declare module "babylonjs/Animations/animatable.interface" {
  35029. import { Nullable } from "babylonjs/types";
  35030. import { Animation } from "babylonjs/Animations/animation";
  35031. /**
  35032. * Interface containing an array of animations
  35033. */
  35034. export interface IAnimatable {
  35035. /**
  35036. * Array of animations
  35037. */
  35038. animations: Nullable<Array<Animation>>;
  35039. }
  35040. }
  35041. declare module "babylonjs/Misc/decorators" {
  35042. import { Nullable } from "babylonjs/types";
  35043. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35044. import { Scene } from "babylonjs/scene";
  35045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35046. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35047. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35049. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35050. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35051. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35052. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35053. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35054. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. /**
  35063. * Decorator used to define property that can be serialized as reference to a camera
  35064. * @param sourceName defines the name of the property to decorate
  35065. */
  35066. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35067. /**
  35068. * Class used to help serialization objects
  35069. */
  35070. export class SerializationHelper {
  35071. /** @hidden */
  35072. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35073. /** @hidden */
  35074. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35075. /** @hidden */
  35076. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35077. /** @hidden */
  35078. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35079. /**
  35080. * Appends the serialized animations from the source animations
  35081. * @param source Source containing the animations
  35082. * @param destination Target to store the animations
  35083. */
  35084. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35085. /**
  35086. * Static function used to serialized a specific entity
  35087. * @param entity defines the entity to serialize
  35088. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35089. * @returns a JSON compatible object representing the serialization of the entity
  35090. */
  35091. static Serialize<T>(entity: T, serializationObject?: any): any;
  35092. /**
  35093. * Creates a new entity from a serialization data object
  35094. * @param creationFunction defines a function used to instanciated the new entity
  35095. * @param source defines the source serialization data
  35096. * @param scene defines the hosting scene
  35097. * @param rootUrl defines the root url for resources
  35098. * @returns a new entity
  35099. */
  35100. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35101. /**
  35102. * Clones an object
  35103. * @param creationFunction defines the function used to instanciate the new object
  35104. * @param source defines the source object
  35105. * @returns the cloned object
  35106. */
  35107. static Clone<T>(creationFunction: () => T, source: T): T;
  35108. /**
  35109. * Instanciates a new object based on a source one (some data will be shared between both object)
  35110. * @param creationFunction defines the function used to instanciate the new object
  35111. * @param source defines the source object
  35112. * @returns the new object
  35113. */
  35114. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35115. }
  35116. }
  35117. declare module "babylonjs/Materials/Textures/baseTexture" {
  35118. import { Observable } from "babylonjs/Misc/observable";
  35119. import { Nullable } from "babylonjs/types";
  35120. import { Scene } from "babylonjs/scene";
  35121. import { Matrix } from "babylonjs/Maths/math.vector";
  35122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35124. import { ISize } from "babylonjs/Maths/math.size";
  35125. import "babylonjs/Misc/fileTools";
  35126. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35127. /**
  35128. * Base class of all the textures in babylon.
  35129. * It groups all the common properties the materials, post process, lights... might need
  35130. * in order to make a correct use of the texture.
  35131. */
  35132. export class BaseTexture implements IAnimatable {
  35133. /**
  35134. * Default anisotropic filtering level for the application.
  35135. * It is set to 4 as a good tradeoff between perf and quality.
  35136. */
  35137. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35138. /**
  35139. * Gets or sets the unique id of the texture
  35140. */
  35141. uniqueId: number;
  35142. /**
  35143. * Define the name of the texture.
  35144. */
  35145. name: string;
  35146. /**
  35147. * Gets or sets an object used to store user defined information.
  35148. */
  35149. metadata: any;
  35150. /**
  35151. * For internal use only. Please do not use.
  35152. */
  35153. reservedDataStore: any;
  35154. private _hasAlpha;
  35155. /**
  35156. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35157. */
  35158. set hasAlpha(value: boolean);
  35159. get hasAlpha(): boolean;
  35160. /**
  35161. * Defines if the alpha value should be determined via the rgb values.
  35162. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35163. */
  35164. getAlphaFromRGB: boolean;
  35165. /**
  35166. * Intensity or strength of the texture.
  35167. * It is commonly used by materials to fine tune the intensity of the texture
  35168. */
  35169. level: number;
  35170. /**
  35171. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35172. * This is part of the texture as textures usually maps to one uv set.
  35173. */
  35174. coordinatesIndex: number;
  35175. protected _coordinatesMode: number;
  35176. /**
  35177. * How a texture is mapped.
  35178. *
  35179. * | Value | Type | Description |
  35180. * | ----- | ----------------------------------- | ----------- |
  35181. * | 0 | EXPLICIT_MODE | |
  35182. * | 1 | SPHERICAL_MODE | |
  35183. * | 2 | PLANAR_MODE | |
  35184. * | 3 | CUBIC_MODE | |
  35185. * | 4 | PROJECTION_MODE | |
  35186. * | 5 | SKYBOX_MODE | |
  35187. * | 6 | INVCUBIC_MODE | |
  35188. * | 7 | EQUIRECTANGULAR_MODE | |
  35189. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35190. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35191. */
  35192. set coordinatesMode(value: number);
  35193. get coordinatesMode(): number;
  35194. private _wrapU;
  35195. /**
  35196. * | Value | Type | Description |
  35197. * | ----- | ------------------ | ----------- |
  35198. * | 0 | CLAMP_ADDRESSMODE | |
  35199. * | 1 | WRAP_ADDRESSMODE | |
  35200. * | 2 | MIRROR_ADDRESSMODE | |
  35201. */
  35202. get wrapU(): number;
  35203. set wrapU(value: number);
  35204. private _wrapV;
  35205. /**
  35206. * | Value | Type | Description |
  35207. * | ----- | ------------------ | ----------- |
  35208. * | 0 | CLAMP_ADDRESSMODE | |
  35209. * | 1 | WRAP_ADDRESSMODE | |
  35210. * | 2 | MIRROR_ADDRESSMODE | |
  35211. */
  35212. get wrapV(): number;
  35213. set wrapV(value: number);
  35214. /**
  35215. * | Value | Type | Description |
  35216. * | ----- | ------------------ | ----------- |
  35217. * | 0 | CLAMP_ADDRESSMODE | |
  35218. * | 1 | WRAP_ADDRESSMODE | |
  35219. * | 2 | MIRROR_ADDRESSMODE | |
  35220. */
  35221. wrapR: number;
  35222. /**
  35223. * With compliant hardware and browser (supporting anisotropic filtering)
  35224. * this defines the level of anisotropic filtering in the texture.
  35225. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35226. */
  35227. anisotropicFilteringLevel: number;
  35228. /**
  35229. * Define if the texture is a cube texture or if false a 2d texture.
  35230. */
  35231. get isCube(): boolean;
  35232. set isCube(value: boolean);
  35233. /**
  35234. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35235. */
  35236. get is3D(): boolean;
  35237. set is3D(value: boolean);
  35238. /**
  35239. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35240. */
  35241. get is2DArray(): boolean;
  35242. set is2DArray(value: boolean);
  35243. private _gammaSpace;
  35244. /**
  35245. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35246. * HDR texture are usually stored in linear space.
  35247. * This only impacts the PBR and Background materials
  35248. */
  35249. get gammaSpace(): boolean;
  35250. set gammaSpace(gamma: boolean);
  35251. /**
  35252. * Gets or sets whether or not the texture contains RGBD data.
  35253. */
  35254. get isRGBD(): boolean;
  35255. set isRGBD(value: boolean);
  35256. /**
  35257. * Is Z inverted in the texture (useful in a cube texture).
  35258. */
  35259. invertZ: boolean;
  35260. /**
  35261. * Are mip maps generated for this texture or not.
  35262. */
  35263. get noMipmap(): boolean;
  35264. /**
  35265. * @hidden
  35266. */
  35267. lodLevelInAlpha: boolean;
  35268. /**
  35269. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35270. */
  35271. get lodGenerationOffset(): number;
  35272. set lodGenerationOffset(value: number);
  35273. /**
  35274. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35275. */
  35276. get lodGenerationScale(): number;
  35277. set lodGenerationScale(value: number);
  35278. /**
  35279. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35280. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35281. * average roughness values.
  35282. */
  35283. get linearSpecularLOD(): boolean;
  35284. set linearSpecularLOD(value: boolean);
  35285. /**
  35286. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35287. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35288. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35289. */
  35290. get irradianceTexture(): Nullable<BaseTexture>;
  35291. set irradianceTexture(value: Nullable<BaseTexture>);
  35292. /**
  35293. * Define if the texture is a render target.
  35294. */
  35295. isRenderTarget: boolean;
  35296. /**
  35297. * Define the unique id of the texture in the scene.
  35298. */
  35299. get uid(): string;
  35300. /** @hidden */
  35301. _prefiltered: boolean;
  35302. /**
  35303. * Return a string representation of the texture.
  35304. * @returns the texture as a string
  35305. */
  35306. toString(): string;
  35307. /**
  35308. * Get the class name of the texture.
  35309. * @returns "BaseTexture"
  35310. */
  35311. getClassName(): string;
  35312. /**
  35313. * Define the list of animation attached to the texture.
  35314. */
  35315. animations: import("babylonjs/Animations/animation").Animation[];
  35316. /**
  35317. * An event triggered when the texture is disposed.
  35318. */
  35319. onDisposeObservable: Observable<BaseTexture>;
  35320. private _onDisposeObserver;
  35321. /**
  35322. * Callback triggered when the texture has been disposed.
  35323. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35324. */
  35325. set onDispose(callback: () => void);
  35326. /**
  35327. * Define the current state of the loading sequence when in delayed load mode.
  35328. */
  35329. delayLoadState: number;
  35330. protected _scene: Nullable<Scene>;
  35331. protected _engine: Nullable<ThinEngine>;
  35332. /** @hidden */
  35333. _texture: Nullable<InternalTexture>;
  35334. private _uid;
  35335. /**
  35336. * Define if the texture is preventinga material to render or not.
  35337. * If not and the texture is not ready, the engine will use a default black texture instead.
  35338. */
  35339. get isBlocking(): boolean;
  35340. /**
  35341. * Instantiates a new BaseTexture.
  35342. * Base class of all the textures in babylon.
  35343. * It groups all the common properties the materials, post process, lights... might need
  35344. * in order to make a correct use of the texture.
  35345. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35346. */
  35347. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35348. /**
  35349. * Get the scene the texture belongs to.
  35350. * @returns the scene or null if undefined
  35351. */
  35352. getScene(): Nullable<Scene>;
  35353. /** @hidden */
  35354. protected _getEngine(): Nullable<ThinEngine>;
  35355. /**
  35356. * Get the texture transform matrix used to offset tile the texture for istance.
  35357. * @returns the transformation matrix
  35358. */
  35359. getTextureMatrix(): Matrix;
  35360. /**
  35361. * Get the texture reflection matrix used to rotate/transform the reflection.
  35362. * @returns the reflection matrix
  35363. */
  35364. getReflectionTextureMatrix(): Matrix;
  35365. /**
  35366. * Get the underlying lower level texture from Babylon.
  35367. * @returns the insternal texture
  35368. */
  35369. getInternalTexture(): Nullable<InternalTexture>;
  35370. /**
  35371. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35372. * @returns true if ready or not blocking
  35373. */
  35374. isReadyOrNotBlocking(): boolean;
  35375. /**
  35376. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35377. * @returns true if fully ready
  35378. */
  35379. isReady(): boolean;
  35380. private _cachedSize;
  35381. /**
  35382. * Get the size of the texture.
  35383. * @returns the texture size.
  35384. */
  35385. getSize(): ISize;
  35386. /**
  35387. * Get the base size of the texture.
  35388. * It can be different from the size if the texture has been resized for POT for instance
  35389. * @returns the base size
  35390. */
  35391. getBaseSize(): ISize;
  35392. /**
  35393. * Update the sampling mode of the texture.
  35394. * Default is Trilinear mode.
  35395. *
  35396. * | Value | Type | Description |
  35397. * | ----- | ------------------ | ----------- |
  35398. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35399. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35400. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35401. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35402. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35403. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35404. * | 7 | NEAREST_LINEAR | |
  35405. * | 8 | NEAREST_NEAREST | |
  35406. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35407. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35408. * | 11 | LINEAR_LINEAR | |
  35409. * | 12 | LINEAR_NEAREST | |
  35410. *
  35411. * > _mag_: magnification filter (close to the viewer)
  35412. * > _min_: minification filter (far from the viewer)
  35413. * > _mip_: filter used between mip map levels
  35414. *@param samplingMode Define the new sampling mode of the texture
  35415. */
  35416. updateSamplingMode(samplingMode: number): void;
  35417. /**
  35418. * Scales the texture if is `canRescale()`
  35419. * @param ratio the resize factor we want to use to rescale
  35420. */
  35421. scale(ratio: number): void;
  35422. /**
  35423. * Get if the texture can rescale.
  35424. */
  35425. get canRescale(): boolean;
  35426. /** @hidden */
  35427. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35428. /** @hidden */
  35429. _rebuild(): void;
  35430. /**
  35431. * Triggers the load sequence in delayed load mode.
  35432. */
  35433. delayLoad(): void;
  35434. /**
  35435. * Clones the texture.
  35436. * @returns the cloned texture
  35437. */
  35438. clone(): Nullable<BaseTexture>;
  35439. /**
  35440. * Get the texture underlying type (INT, FLOAT...)
  35441. */
  35442. get textureType(): number;
  35443. /**
  35444. * Get the texture underlying format (RGB, RGBA...)
  35445. */
  35446. get textureFormat(): number;
  35447. /**
  35448. * Indicates that textures need to be re-calculated for all materials
  35449. */
  35450. protected _markAllSubMeshesAsTexturesDirty(): void;
  35451. /**
  35452. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35453. * This will returns an RGBA array buffer containing either in values (0-255) or
  35454. * float values (0-1) depending of the underlying buffer type.
  35455. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35456. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35457. * @param buffer defines a user defined buffer to fill with data (can be null)
  35458. * @returns The Array buffer containing the pixels data.
  35459. */
  35460. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35461. /**
  35462. * Release and destroy the underlying lower level texture aka internalTexture.
  35463. */
  35464. releaseInternalTexture(): void;
  35465. /** @hidden */
  35466. get _lodTextureHigh(): Nullable<BaseTexture>;
  35467. /** @hidden */
  35468. get _lodTextureMid(): Nullable<BaseTexture>;
  35469. /** @hidden */
  35470. get _lodTextureLow(): Nullable<BaseTexture>;
  35471. /**
  35472. * Dispose the texture and release its associated resources.
  35473. */
  35474. dispose(): void;
  35475. /**
  35476. * Serialize the texture into a JSON representation that can be parsed later on.
  35477. * @returns the JSON representation of the texture
  35478. */
  35479. serialize(): any;
  35480. /**
  35481. * Helper function to be called back once a list of texture contains only ready textures.
  35482. * @param textures Define the list of textures to wait for
  35483. * @param callback Define the callback triggered once the entire list will be ready
  35484. */
  35485. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35486. private static _isScene;
  35487. }
  35488. }
  35489. declare module "babylonjs/Materials/effect" {
  35490. import { Observable } from "babylonjs/Misc/observable";
  35491. import { Nullable } from "babylonjs/types";
  35492. import { IDisposable } from "babylonjs/scene";
  35493. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35495. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35496. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35497. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35498. import { Engine } from "babylonjs/Engines/engine";
  35499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35501. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35502. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35503. /**
  35504. * Options to be used when creating an effect.
  35505. */
  35506. export interface IEffectCreationOptions {
  35507. /**
  35508. * Atrributes that will be used in the shader.
  35509. */
  35510. attributes: string[];
  35511. /**
  35512. * Uniform varible names that will be set in the shader.
  35513. */
  35514. uniformsNames: string[];
  35515. /**
  35516. * Uniform buffer variable names that will be set in the shader.
  35517. */
  35518. uniformBuffersNames: string[];
  35519. /**
  35520. * Sampler texture variable names that will be set in the shader.
  35521. */
  35522. samplers: string[];
  35523. /**
  35524. * Define statements that will be set in the shader.
  35525. */
  35526. defines: any;
  35527. /**
  35528. * Possible fallbacks for this effect to improve performance when needed.
  35529. */
  35530. fallbacks: Nullable<IEffectFallbacks>;
  35531. /**
  35532. * Callback that will be called when the shader is compiled.
  35533. */
  35534. onCompiled: Nullable<(effect: Effect) => void>;
  35535. /**
  35536. * Callback that will be called if an error occurs during shader compilation.
  35537. */
  35538. onError: Nullable<(effect: Effect, errors: string) => void>;
  35539. /**
  35540. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35541. */
  35542. indexParameters?: any;
  35543. /**
  35544. * Max number of lights that can be used in the shader.
  35545. */
  35546. maxSimultaneousLights?: number;
  35547. /**
  35548. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35549. */
  35550. transformFeedbackVaryings?: Nullable<string[]>;
  35551. /**
  35552. * 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
  35553. */
  35554. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35555. /**
  35556. * Is this effect rendering to several color attachments ?
  35557. */
  35558. multiTarget?: boolean;
  35559. }
  35560. /**
  35561. * Effect containing vertex and fragment shader that can be executed on an object.
  35562. */
  35563. export class Effect implements IDisposable {
  35564. /**
  35565. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35566. */
  35567. static ShadersRepository: string;
  35568. /**
  35569. * Enable logging of the shader code when a compilation error occurs
  35570. */
  35571. static LogShaderCodeOnCompilationError: boolean;
  35572. /**
  35573. * Name of the effect.
  35574. */
  35575. name: any;
  35576. /**
  35577. * String container all the define statements that should be set on the shader.
  35578. */
  35579. defines: string;
  35580. /**
  35581. * Callback that will be called when the shader is compiled.
  35582. */
  35583. onCompiled: Nullable<(effect: Effect) => void>;
  35584. /**
  35585. * Callback that will be called if an error occurs during shader compilation.
  35586. */
  35587. onError: Nullable<(effect: Effect, errors: string) => void>;
  35588. /**
  35589. * Callback that will be called when effect is bound.
  35590. */
  35591. onBind: Nullable<(effect: Effect) => void>;
  35592. /**
  35593. * Unique ID of the effect.
  35594. */
  35595. uniqueId: number;
  35596. /**
  35597. * Observable that will be called when the shader is compiled.
  35598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35599. */
  35600. onCompileObservable: Observable<Effect>;
  35601. /**
  35602. * Observable that will be called if an error occurs during shader compilation.
  35603. */
  35604. onErrorObservable: Observable<Effect>;
  35605. /** @hidden */
  35606. _onBindObservable: Nullable<Observable<Effect>>;
  35607. /**
  35608. * @hidden
  35609. * Specifies if the effect was previously ready
  35610. */
  35611. _wasPreviouslyReady: boolean;
  35612. /**
  35613. * Observable that will be called when effect is bound.
  35614. */
  35615. get onBindObservable(): Observable<Effect>;
  35616. /** @hidden */
  35617. _bonesComputationForcedToCPU: boolean;
  35618. /** @hidden */
  35619. _multiTarget: boolean;
  35620. private static _uniqueIdSeed;
  35621. private _engine;
  35622. private _uniformBuffersNames;
  35623. private _uniformBuffersNamesList;
  35624. private _uniformsNames;
  35625. private _samplerList;
  35626. private _samplers;
  35627. private _isReady;
  35628. private _compilationError;
  35629. private _allFallbacksProcessed;
  35630. private _attributesNames;
  35631. private _attributes;
  35632. private _attributeLocationByName;
  35633. private _uniforms;
  35634. /**
  35635. * Key for the effect.
  35636. * @hidden
  35637. */
  35638. _key: string;
  35639. private _indexParameters;
  35640. private _fallbacks;
  35641. private _vertexSourceCode;
  35642. private _fragmentSourceCode;
  35643. private _vertexSourceCodeOverride;
  35644. private _fragmentSourceCodeOverride;
  35645. private _transformFeedbackVaryings;
  35646. /**
  35647. * Compiled shader to webGL program.
  35648. * @hidden
  35649. */
  35650. _pipelineContext: Nullable<IPipelineContext>;
  35651. private _valueCache;
  35652. private static _baseCache;
  35653. /**
  35654. * Instantiates an effect.
  35655. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35656. * @param baseName Name of the effect.
  35657. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35658. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35659. * @param samplers List of sampler variables that will be passed to the shader.
  35660. * @param engine Engine to be used to render the effect
  35661. * @param defines Define statements to be added to the shader.
  35662. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35663. * @param onCompiled Callback that will be called when the shader is compiled.
  35664. * @param onError Callback that will be called if an error occurs during shader compilation.
  35665. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35666. */
  35667. 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);
  35668. private _useFinalCode;
  35669. /**
  35670. * Unique key for this effect
  35671. */
  35672. get key(): string;
  35673. /**
  35674. * If the effect has been compiled and prepared.
  35675. * @returns if the effect is compiled and prepared.
  35676. */
  35677. isReady(): boolean;
  35678. private _isReadyInternal;
  35679. /**
  35680. * The engine the effect was initialized with.
  35681. * @returns the engine.
  35682. */
  35683. getEngine(): Engine;
  35684. /**
  35685. * The pipeline context for this effect
  35686. * @returns the associated pipeline context
  35687. */
  35688. getPipelineContext(): Nullable<IPipelineContext>;
  35689. /**
  35690. * The set of names of attribute variables for the shader.
  35691. * @returns An array of attribute names.
  35692. */
  35693. getAttributesNames(): string[];
  35694. /**
  35695. * Returns the attribute at the given index.
  35696. * @param index The index of the attribute.
  35697. * @returns The location of the attribute.
  35698. */
  35699. getAttributeLocation(index: number): number;
  35700. /**
  35701. * Returns the attribute based on the name of the variable.
  35702. * @param name of the attribute to look up.
  35703. * @returns the attribute location.
  35704. */
  35705. getAttributeLocationByName(name: string): number;
  35706. /**
  35707. * The number of attributes.
  35708. * @returns the numnber of attributes.
  35709. */
  35710. getAttributesCount(): number;
  35711. /**
  35712. * Gets the index of a uniform variable.
  35713. * @param uniformName of the uniform to look up.
  35714. * @returns the index.
  35715. */
  35716. getUniformIndex(uniformName: string): number;
  35717. /**
  35718. * Returns the attribute based on the name of the variable.
  35719. * @param uniformName of the uniform to look up.
  35720. * @returns the location of the uniform.
  35721. */
  35722. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35723. /**
  35724. * Returns an array of sampler variable names
  35725. * @returns The array of sampler variable names.
  35726. */
  35727. getSamplers(): string[];
  35728. /**
  35729. * Returns an array of uniform variable names
  35730. * @returns The array of uniform variable names.
  35731. */
  35732. getUniformNames(): string[];
  35733. /**
  35734. * Returns an array of uniform buffer variable names
  35735. * @returns The array of uniform buffer variable names.
  35736. */
  35737. getUniformBuffersNames(): string[];
  35738. /**
  35739. * Returns the index parameters used to create the effect
  35740. * @returns The index parameters object
  35741. */
  35742. getIndexParameters(): any;
  35743. /**
  35744. * The error from the last compilation.
  35745. * @returns the error string.
  35746. */
  35747. getCompilationError(): string;
  35748. /**
  35749. * Gets a boolean indicating that all fallbacks were used during compilation
  35750. * @returns true if all fallbacks were used
  35751. */
  35752. allFallbacksProcessed(): boolean;
  35753. /**
  35754. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35755. * @param func The callback to be used.
  35756. */
  35757. executeWhenCompiled(func: (effect: Effect) => void): void;
  35758. private _checkIsReady;
  35759. private _loadShader;
  35760. /**
  35761. * Gets the vertex shader source code of this effect
  35762. */
  35763. get vertexSourceCode(): string;
  35764. /**
  35765. * Gets the fragment shader source code of this effect
  35766. */
  35767. get fragmentSourceCode(): string;
  35768. /**
  35769. * Recompiles the webGL program
  35770. * @param vertexSourceCode The source code for the vertex shader.
  35771. * @param fragmentSourceCode The source code for the fragment shader.
  35772. * @param onCompiled Callback called when completed.
  35773. * @param onError Callback called on error.
  35774. * @hidden
  35775. */
  35776. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35777. /**
  35778. * Prepares the effect
  35779. * @hidden
  35780. */
  35781. _prepareEffect(): void;
  35782. private _getShaderCodeAndErrorLine;
  35783. private _processCompilationErrors;
  35784. /**
  35785. * Checks if the effect is supported. (Must be called after compilation)
  35786. */
  35787. get isSupported(): boolean;
  35788. /**
  35789. * Binds a texture to the engine to be used as output of the shader.
  35790. * @param channel Name of the output variable.
  35791. * @param texture Texture to bind.
  35792. * @hidden
  35793. */
  35794. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35795. /**
  35796. * Sets a texture on the engine to be used in the shader.
  35797. * @param channel Name of the sampler variable.
  35798. * @param texture Texture to set.
  35799. */
  35800. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35801. /**
  35802. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35803. * @param channel Name of the sampler variable.
  35804. * @param texture Texture to set.
  35805. */
  35806. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35807. /**
  35808. * Sets an array of textures on the engine to be used in the shader.
  35809. * @param channel Name of the variable.
  35810. * @param textures Textures to set.
  35811. */
  35812. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35813. /**
  35814. * 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)
  35815. * @param channel Name of the sampler variable.
  35816. * @param postProcess Post process to get the input texture from.
  35817. */
  35818. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35819. /**
  35820. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35821. * 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)
  35822. * @param channel Name of the sampler variable.
  35823. * @param postProcess Post process to get the output texture from.
  35824. */
  35825. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35826. /** @hidden */
  35827. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35828. /** @hidden */
  35829. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35830. /** @hidden */
  35831. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35832. /** @hidden */
  35833. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35834. /**
  35835. * Binds a buffer to a uniform.
  35836. * @param buffer Buffer to bind.
  35837. * @param name Name of the uniform variable to bind to.
  35838. */
  35839. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35840. /**
  35841. * Binds block to a uniform.
  35842. * @param blockName Name of the block to bind.
  35843. * @param index Index to bind.
  35844. */
  35845. bindUniformBlock(blockName: string, index: number): void;
  35846. /**
  35847. * Sets an interger value on a uniform variable.
  35848. * @param uniformName Name of the variable.
  35849. * @param value Value to be set.
  35850. * @returns this effect.
  35851. */
  35852. setInt(uniformName: string, value: number): Effect;
  35853. /**
  35854. * Sets an int array on a uniform variable.
  35855. * @param uniformName Name of the variable.
  35856. * @param array array to be set.
  35857. * @returns this effect.
  35858. */
  35859. setIntArray(uniformName: string, array: Int32Array): Effect;
  35860. /**
  35861. * 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)
  35862. * @param uniformName Name of the variable.
  35863. * @param array array to be set.
  35864. * @returns this effect.
  35865. */
  35866. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35867. /**
  35868. * 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)
  35869. * @param uniformName Name of the variable.
  35870. * @param array array to be set.
  35871. * @returns this effect.
  35872. */
  35873. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35874. /**
  35875. * 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)
  35876. * @param uniformName Name of the variable.
  35877. * @param array array to be set.
  35878. * @returns this effect.
  35879. */
  35880. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35881. /**
  35882. * Sets an float array on a uniform variable.
  35883. * @param uniformName Name of the variable.
  35884. * @param array array to be set.
  35885. * @returns this effect.
  35886. */
  35887. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35888. /**
  35889. * 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)
  35890. * @param uniformName Name of the variable.
  35891. * @param array array to be set.
  35892. * @returns this effect.
  35893. */
  35894. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35895. /**
  35896. * 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)
  35897. * @param uniformName Name of the variable.
  35898. * @param array array to be set.
  35899. * @returns this effect.
  35900. */
  35901. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35902. /**
  35903. * 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)
  35904. * @param uniformName Name of the variable.
  35905. * @param array array to be set.
  35906. * @returns this effect.
  35907. */
  35908. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35909. /**
  35910. * Sets an array on a uniform variable.
  35911. * @param uniformName Name of the variable.
  35912. * @param array array to be set.
  35913. * @returns this effect.
  35914. */
  35915. setArray(uniformName: string, array: number[]): Effect;
  35916. /**
  35917. * 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)
  35918. * @param uniformName Name of the variable.
  35919. * @param array array to be set.
  35920. * @returns this effect.
  35921. */
  35922. setArray2(uniformName: string, array: number[]): Effect;
  35923. /**
  35924. * 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)
  35925. * @param uniformName Name of the variable.
  35926. * @param array array to be set.
  35927. * @returns this effect.
  35928. */
  35929. setArray3(uniformName: string, array: number[]): Effect;
  35930. /**
  35931. * 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)
  35932. * @param uniformName Name of the variable.
  35933. * @param array array to be set.
  35934. * @returns this effect.
  35935. */
  35936. setArray4(uniformName: string, array: number[]): Effect;
  35937. /**
  35938. * Sets matrices on a uniform variable.
  35939. * @param uniformName Name of the variable.
  35940. * @param matrices matrices to be set.
  35941. * @returns this effect.
  35942. */
  35943. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35944. /**
  35945. * Sets matrix on a uniform variable.
  35946. * @param uniformName Name of the variable.
  35947. * @param matrix matrix to be set.
  35948. * @returns this effect.
  35949. */
  35950. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35951. /**
  35952. * 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)
  35953. * @param uniformName Name of the variable.
  35954. * @param matrix matrix to be set.
  35955. * @returns this effect.
  35956. */
  35957. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35958. /**
  35959. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35960. * @param uniformName Name of the variable.
  35961. * @param matrix matrix to be set.
  35962. * @returns this effect.
  35963. */
  35964. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35965. /**
  35966. * Sets a float on a uniform variable.
  35967. * @param uniformName Name of the variable.
  35968. * @param value value to be set.
  35969. * @returns this effect.
  35970. */
  35971. setFloat(uniformName: string, value: number): Effect;
  35972. /**
  35973. * Sets a boolean on a uniform variable.
  35974. * @param uniformName Name of the variable.
  35975. * @param bool value to be set.
  35976. * @returns this effect.
  35977. */
  35978. setBool(uniformName: string, bool: boolean): Effect;
  35979. /**
  35980. * Sets a Vector2 on a uniform variable.
  35981. * @param uniformName Name of the variable.
  35982. * @param vector2 vector2 to be set.
  35983. * @returns this effect.
  35984. */
  35985. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35986. /**
  35987. * Sets a float2 on a uniform variable.
  35988. * @param uniformName Name of the variable.
  35989. * @param x First float in float2.
  35990. * @param y Second float in float2.
  35991. * @returns this effect.
  35992. */
  35993. setFloat2(uniformName: string, x: number, y: number): Effect;
  35994. /**
  35995. * Sets a Vector3 on a uniform variable.
  35996. * @param uniformName Name of the variable.
  35997. * @param vector3 Value to be set.
  35998. * @returns this effect.
  35999. */
  36000. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36001. /**
  36002. * Sets a float3 on a uniform variable.
  36003. * @param uniformName Name of the variable.
  36004. * @param x First float in float3.
  36005. * @param y Second float in float3.
  36006. * @param z Third float in float3.
  36007. * @returns this effect.
  36008. */
  36009. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36010. /**
  36011. * Sets a Vector4 on a uniform variable.
  36012. * @param uniformName Name of the variable.
  36013. * @param vector4 Value to be set.
  36014. * @returns this effect.
  36015. */
  36016. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36017. /**
  36018. * Sets a float4 on a uniform variable.
  36019. * @param uniformName Name of the variable.
  36020. * @param x First float in float4.
  36021. * @param y Second float in float4.
  36022. * @param z Third float in float4.
  36023. * @param w Fourth float in float4.
  36024. * @returns this effect.
  36025. */
  36026. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36027. /**
  36028. * Sets a Color3 on a uniform variable.
  36029. * @param uniformName Name of the variable.
  36030. * @param color3 Value to be set.
  36031. * @returns this effect.
  36032. */
  36033. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36034. /**
  36035. * Sets a Color4 on a uniform variable.
  36036. * @param uniformName Name of the variable.
  36037. * @param color3 Value to be set.
  36038. * @param alpha Alpha value to be set.
  36039. * @returns this effect.
  36040. */
  36041. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36042. /**
  36043. * Sets a Color4 on a uniform variable
  36044. * @param uniformName defines the name of the variable
  36045. * @param color4 defines the value to be set
  36046. * @returns this effect.
  36047. */
  36048. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36049. /** Release all associated resources */
  36050. dispose(): void;
  36051. /**
  36052. * This function will add a new shader to the shader store
  36053. * @param name the name of the shader
  36054. * @param pixelShader optional pixel shader content
  36055. * @param vertexShader optional vertex shader content
  36056. */
  36057. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36058. /**
  36059. * Store of each shader (The can be looked up using effect.key)
  36060. */
  36061. static ShadersStore: {
  36062. [key: string]: string;
  36063. };
  36064. /**
  36065. * Store of each included file for a shader (The can be looked up using effect.key)
  36066. */
  36067. static IncludesShadersStore: {
  36068. [key: string]: string;
  36069. };
  36070. /**
  36071. * Resets the cache of effects.
  36072. */
  36073. static ResetCache(): void;
  36074. }
  36075. }
  36076. declare module "babylonjs/Engines/engineCapabilities" {
  36077. /**
  36078. * Interface used to describe the capabilities of the engine relatively to the current browser
  36079. */
  36080. export interface EngineCapabilities {
  36081. /** Maximum textures units per fragment shader */
  36082. maxTexturesImageUnits: number;
  36083. /** Maximum texture units per vertex shader */
  36084. maxVertexTextureImageUnits: number;
  36085. /** Maximum textures units in the entire pipeline */
  36086. maxCombinedTexturesImageUnits: number;
  36087. /** Maximum texture size */
  36088. maxTextureSize: number;
  36089. /** Maximum texture samples */
  36090. maxSamples?: number;
  36091. /** Maximum cube texture size */
  36092. maxCubemapTextureSize: number;
  36093. /** Maximum render texture size */
  36094. maxRenderTextureSize: number;
  36095. /** Maximum number of vertex attributes */
  36096. maxVertexAttribs: number;
  36097. /** Maximum number of varyings */
  36098. maxVaryingVectors: number;
  36099. /** Maximum number of uniforms per vertex shader */
  36100. maxVertexUniformVectors: number;
  36101. /** Maximum number of uniforms per fragment shader */
  36102. maxFragmentUniformVectors: number;
  36103. /** Defines if standard derivates (dx/dy) are supported */
  36104. standardDerivatives: boolean;
  36105. /** Defines if s3tc texture compression is supported */
  36106. s3tc?: WEBGL_compressed_texture_s3tc;
  36107. /** Defines if pvrtc texture compression is supported */
  36108. pvrtc: any;
  36109. /** Defines if etc1 texture compression is supported */
  36110. etc1: any;
  36111. /** Defines if etc2 texture compression is supported */
  36112. etc2: any;
  36113. /** Defines if astc texture compression is supported */
  36114. astc: any;
  36115. /** Defines if bptc texture compression is supported */
  36116. bptc: any;
  36117. /** Defines if float textures are supported */
  36118. textureFloat: boolean;
  36119. /** Defines if vertex array objects are supported */
  36120. vertexArrayObject: boolean;
  36121. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36122. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36123. /** Gets the maximum level of anisotropy supported */
  36124. maxAnisotropy: number;
  36125. /** Defines if instancing is supported */
  36126. instancedArrays: boolean;
  36127. /** Defines if 32 bits indices are supported */
  36128. uintIndices: boolean;
  36129. /** Defines if high precision shaders are supported */
  36130. highPrecisionShaderSupported: boolean;
  36131. /** Defines if depth reading in the fragment shader is supported */
  36132. fragmentDepthSupported: boolean;
  36133. /** Defines if float texture linear filtering is supported*/
  36134. textureFloatLinearFiltering: boolean;
  36135. /** Defines if rendering to float textures is supported */
  36136. textureFloatRender: boolean;
  36137. /** Defines if half float textures are supported*/
  36138. textureHalfFloat: boolean;
  36139. /** Defines if half float texture linear filtering is supported*/
  36140. textureHalfFloatLinearFiltering: boolean;
  36141. /** Defines if rendering to half float textures is supported */
  36142. textureHalfFloatRender: boolean;
  36143. /** Defines if textureLOD shader command is supported */
  36144. textureLOD: boolean;
  36145. /** Defines if draw buffers extension is supported */
  36146. drawBuffersExtension: boolean;
  36147. /** Defines if depth textures are supported */
  36148. depthTextureExtension: boolean;
  36149. /** Defines if float color buffer are supported */
  36150. colorBufferFloat: boolean;
  36151. /** Gets disjoint timer query extension (null if not supported) */
  36152. timerQuery?: EXT_disjoint_timer_query;
  36153. /** Defines if timestamp can be used with timer query */
  36154. canUseTimestampForTimerQuery: boolean;
  36155. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36156. multiview?: any;
  36157. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36158. oculusMultiview?: any;
  36159. /** Function used to let the system compiles shaders in background */
  36160. parallelShaderCompile?: {
  36161. COMPLETION_STATUS_KHR: number;
  36162. };
  36163. /** Max number of texture samples for MSAA */
  36164. maxMSAASamples: number;
  36165. /** Defines if the blend min max extension is supported */
  36166. blendMinMax: boolean;
  36167. }
  36168. }
  36169. declare module "babylonjs/States/depthCullingState" {
  36170. import { Nullable } from "babylonjs/types";
  36171. /**
  36172. * @hidden
  36173. **/
  36174. export class DepthCullingState {
  36175. private _isDepthTestDirty;
  36176. private _isDepthMaskDirty;
  36177. private _isDepthFuncDirty;
  36178. private _isCullFaceDirty;
  36179. private _isCullDirty;
  36180. private _isZOffsetDirty;
  36181. private _isFrontFaceDirty;
  36182. private _depthTest;
  36183. private _depthMask;
  36184. private _depthFunc;
  36185. private _cull;
  36186. private _cullFace;
  36187. private _zOffset;
  36188. private _frontFace;
  36189. /**
  36190. * Initializes the state.
  36191. */
  36192. constructor();
  36193. get isDirty(): boolean;
  36194. get zOffset(): number;
  36195. set zOffset(value: number);
  36196. get cullFace(): Nullable<number>;
  36197. set cullFace(value: Nullable<number>);
  36198. get cull(): Nullable<boolean>;
  36199. set cull(value: Nullable<boolean>);
  36200. get depthFunc(): Nullable<number>;
  36201. set depthFunc(value: Nullable<number>);
  36202. get depthMask(): boolean;
  36203. set depthMask(value: boolean);
  36204. get depthTest(): boolean;
  36205. set depthTest(value: boolean);
  36206. get frontFace(): Nullable<number>;
  36207. set frontFace(value: Nullable<number>);
  36208. reset(): void;
  36209. apply(gl: WebGLRenderingContext): void;
  36210. }
  36211. }
  36212. declare module "babylonjs/States/stencilState" {
  36213. /**
  36214. * @hidden
  36215. **/
  36216. export class StencilState {
  36217. /** 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 */
  36218. static readonly ALWAYS: number;
  36219. /** Passed to stencilOperation to specify that stencil value must be kept */
  36220. static readonly KEEP: number;
  36221. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36222. static readonly REPLACE: number;
  36223. private _isStencilTestDirty;
  36224. private _isStencilMaskDirty;
  36225. private _isStencilFuncDirty;
  36226. private _isStencilOpDirty;
  36227. private _stencilTest;
  36228. private _stencilMask;
  36229. private _stencilFunc;
  36230. private _stencilFuncRef;
  36231. private _stencilFuncMask;
  36232. private _stencilOpStencilFail;
  36233. private _stencilOpDepthFail;
  36234. private _stencilOpStencilDepthPass;
  36235. get isDirty(): boolean;
  36236. get stencilFunc(): number;
  36237. set stencilFunc(value: number);
  36238. get stencilFuncRef(): number;
  36239. set stencilFuncRef(value: number);
  36240. get stencilFuncMask(): number;
  36241. set stencilFuncMask(value: number);
  36242. get stencilOpStencilFail(): number;
  36243. set stencilOpStencilFail(value: number);
  36244. get stencilOpDepthFail(): number;
  36245. set stencilOpDepthFail(value: number);
  36246. get stencilOpStencilDepthPass(): number;
  36247. set stencilOpStencilDepthPass(value: number);
  36248. get stencilMask(): number;
  36249. set stencilMask(value: number);
  36250. get stencilTest(): boolean;
  36251. set stencilTest(value: boolean);
  36252. constructor();
  36253. reset(): void;
  36254. apply(gl: WebGLRenderingContext): void;
  36255. }
  36256. }
  36257. declare module "babylonjs/States/alphaCullingState" {
  36258. /**
  36259. * @hidden
  36260. **/
  36261. export class AlphaState {
  36262. private _isAlphaBlendDirty;
  36263. private _isBlendFunctionParametersDirty;
  36264. private _isBlendEquationParametersDirty;
  36265. private _isBlendConstantsDirty;
  36266. private _alphaBlend;
  36267. private _blendFunctionParameters;
  36268. private _blendEquationParameters;
  36269. private _blendConstants;
  36270. /**
  36271. * Initializes the state.
  36272. */
  36273. constructor();
  36274. get isDirty(): boolean;
  36275. get alphaBlend(): boolean;
  36276. set alphaBlend(value: boolean);
  36277. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36278. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36279. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36280. reset(): void;
  36281. apply(gl: WebGLRenderingContext): void;
  36282. }
  36283. }
  36284. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36285. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36286. /** @hidden */
  36287. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36288. attributeProcessor(attribute: string): string;
  36289. varyingProcessor(varying: string, isFragment: boolean): string;
  36290. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36291. }
  36292. }
  36293. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36294. /**
  36295. * Interface for attribute information associated with buffer instanciation
  36296. */
  36297. export interface InstancingAttributeInfo {
  36298. /**
  36299. * Name of the GLSL attribute
  36300. * if attribute index is not specified, this is used to retrieve the index from the effect
  36301. */
  36302. attributeName: string;
  36303. /**
  36304. * Index/offset of the attribute in the vertex shader
  36305. * if not specified, this will be computes from the name.
  36306. */
  36307. index?: number;
  36308. /**
  36309. * size of the attribute, 1, 2, 3 or 4
  36310. */
  36311. attributeSize: number;
  36312. /**
  36313. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36314. */
  36315. offset: number;
  36316. /**
  36317. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36318. * default to 1
  36319. */
  36320. divisor?: number;
  36321. /**
  36322. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36323. * default is FLOAT
  36324. */
  36325. attributeType?: number;
  36326. /**
  36327. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36328. */
  36329. normalized?: boolean;
  36330. }
  36331. }
  36332. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36334. import { Nullable } from "babylonjs/types";
  36335. module "babylonjs/Engines/thinEngine" {
  36336. interface ThinEngine {
  36337. /**
  36338. * Update a video texture
  36339. * @param texture defines the texture to update
  36340. * @param video defines the video element to use
  36341. * @param invertY defines if data must be stored with Y axis inverted
  36342. */
  36343. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36344. }
  36345. }
  36346. }
  36347. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36349. import { Nullable } from "babylonjs/types";
  36350. module "babylonjs/Engines/thinEngine" {
  36351. interface ThinEngine {
  36352. /**
  36353. * Creates a dynamic texture
  36354. * @param width defines the width of the texture
  36355. * @param height defines the height of the texture
  36356. * @param generateMipMaps defines if the engine should generate the mip levels
  36357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36358. * @returns the dynamic texture inside an InternalTexture
  36359. */
  36360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36361. /**
  36362. * Update the content of a dynamic texture
  36363. * @param texture defines the texture to update
  36364. * @param canvas defines the canvas containing the source
  36365. * @param invertY defines if data must be stored with Y axis inverted
  36366. * @param premulAlpha defines if alpha is stored as premultiplied
  36367. * @param format defines the format of the data
  36368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36369. */
  36370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36371. }
  36372. }
  36373. }
  36374. declare module "babylonjs/Materials/Textures/videoTexture" {
  36375. import { Observable } from "babylonjs/Misc/observable";
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Scene } from "babylonjs/scene";
  36378. import { Texture } from "babylonjs/Materials/Textures/texture";
  36379. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36380. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36381. /**
  36382. * Settings for finer control over video usage
  36383. */
  36384. export interface VideoTextureSettings {
  36385. /**
  36386. * Applies `autoplay` to video, if specified
  36387. */
  36388. autoPlay?: boolean;
  36389. /**
  36390. * Applies `loop` to video, if specified
  36391. */
  36392. loop?: boolean;
  36393. /**
  36394. * Automatically updates internal texture from video at every frame in the render loop
  36395. */
  36396. autoUpdateTexture: boolean;
  36397. /**
  36398. * Image src displayed during the video loading or until the user interacts with the video.
  36399. */
  36400. poster?: string;
  36401. }
  36402. /**
  36403. * If you want to display a video in your scene, this is the special texture for that.
  36404. * This special texture works similar to other textures, with the exception of a few parameters.
  36405. * @see https://doc.babylonjs.com/how_to/video_texture
  36406. */
  36407. export class VideoTexture extends Texture {
  36408. /**
  36409. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36410. */
  36411. readonly autoUpdateTexture: boolean;
  36412. /**
  36413. * The video instance used by the texture internally
  36414. */
  36415. readonly video: HTMLVideoElement;
  36416. private _onUserActionRequestedObservable;
  36417. /**
  36418. * Event triggerd when a dom action is required by the user to play the video.
  36419. * This happens due to recent changes in browser policies preventing video to auto start.
  36420. */
  36421. get onUserActionRequestedObservable(): Observable<Texture>;
  36422. private _generateMipMaps;
  36423. private _stillImageCaptured;
  36424. private _displayingPosterTexture;
  36425. private _settings;
  36426. private _createInternalTextureOnEvent;
  36427. private _frameId;
  36428. private _currentSrc;
  36429. /**
  36430. * Creates a video texture.
  36431. * If you want to display a video in your scene, this is the special texture for that.
  36432. * This special texture works similar to other textures, with the exception of a few parameters.
  36433. * @see https://doc.babylonjs.com/how_to/video_texture
  36434. * @param name optional name, will detect from video source, if not defined
  36435. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36436. * @param scene is obviously the current scene.
  36437. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36438. * @param invertY is false by default but can be used to invert video on Y axis
  36439. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36440. * @param settings allows finer control over video usage
  36441. */
  36442. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36443. private _getName;
  36444. private _getVideo;
  36445. private _createInternalTexture;
  36446. private reset;
  36447. /**
  36448. * @hidden Internal method to initiate `update`.
  36449. */
  36450. _rebuild(): void;
  36451. /**
  36452. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36453. */
  36454. update(): void;
  36455. /**
  36456. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36457. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36458. */
  36459. updateTexture(isVisible: boolean): void;
  36460. protected _updateInternalTexture: () => void;
  36461. /**
  36462. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36463. * @param url New url.
  36464. */
  36465. updateURL(url: string): void;
  36466. /**
  36467. * Clones the texture.
  36468. * @returns the cloned texture
  36469. */
  36470. clone(): VideoTexture;
  36471. /**
  36472. * Dispose the texture and release its associated resources.
  36473. */
  36474. dispose(): void;
  36475. /**
  36476. * Creates a video texture straight from a stream.
  36477. * @param scene Define the scene the texture should be created in
  36478. * @param stream Define the stream the texture should be created from
  36479. * @returns The created video texture as a promise
  36480. */
  36481. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36482. /**
  36483. * Creates a video texture straight from your WebCam video feed.
  36484. * @param scene Define the scene the texture should be created in
  36485. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36486. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36487. * @returns The created video texture as a promise
  36488. */
  36489. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36490. minWidth: number;
  36491. maxWidth: number;
  36492. minHeight: number;
  36493. maxHeight: number;
  36494. deviceId: string;
  36495. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36496. /**
  36497. * Creates a video texture straight from your WebCam video feed.
  36498. * @param scene Define the scene the texture should be created in
  36499. * @param onReady Define a callback to triggered once the texture will be ready
  36500. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36501. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36502. */
  36503. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36504. minWidth: number;
  36505. maxWidth: number;
  36506. minHeight: number;
  36507. maxHeight: number;
  36508. deviceId: string;
  36509. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36510. }
  36511. }
  36512. declare module "babylonjs/Engines/thinEngine" {
  36513. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36514. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36515. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36516. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36517. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36518. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36519. import { Observable } from "babylonjs/Misc/observable";
  36520. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36521. import { StencilState } from "babylonjs/States/stencilState";
  36522. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36524. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36526. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36527. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36528. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36529. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36530. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36532. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36533. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36534. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36535. import { WebRequest } from "babylonjs/Misc/webRequest";
  36536. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36537. /**
  36538. * Defines the interface used by objects working like Scene
  36539. * @hidden
  36540. */
  36541. export interface ISceneLike {
  36542. _addPendingData(data: any): void;
  36543. _removePendingData(data: any): void;
  36544. offlineProvider: IOfflineProvider;
  36545. }
  36546. /**
  36547. * Information about the current host
  36548. */
  36549. export interface HostInformation {
  36550. /**
  36551. * Defines if the current host is a mobile
  36552. */
  36553. isMobile: boolean;
  36554. }
  36555. /** Interface defining initialization parameters for Engine class */
  36556. export interface EngineOptions extends WebGLContextAttributes {
  36557. /**
  36558. * Defines if the engine should no exceed a specified device ratio
  36559. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36560. */
  36561. limitDeviceRatio?: number;
  36562. /**
  36563. * Defines if webvr should be enabled automatically
  36564. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36565. */
  36566. autoEnableWebVR?: boolean;
  36567. /**
  36568. * Defines if webgl2 should be turned off even if supported
  36569. * @see https://doc.babylonjs.com/features/webgl2
  36570. */
  36571. disableWebGL2Support?: boolean;
  36572. /**
  36573. * Defines if webaudio should be initialized as well
  36574. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36575. */
  36576. audioEngine?: boolean;
  36577. /**
  36578. * Defines if animations should run using a deterministic lock step
  36579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36580. */
  36581. deterministicLockstep?: boolean;
  36582. /** Defines the maximum steps to use with deterministic lock step mode */
  36583. lockstepMaxSteps?: number;
  36584. /** Defines the seconds between each deterministic lock step */
  36585. timeStep?: number;
  36586. /**
  36587. * Defines that engine should ignore context lost events
  36588. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36589. */
  36590. doNotHandleContextLost?: boolean;
  36591. /**
  36592. * Defines that engine should ignore modifying touch action attribute and style
  36593. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36594. */
  36595. doNotHandleTouchAction?: boolean;
  36596. /**
  36597. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36598. */
  36599. useHighPrecisionFloats?: boolean;
  36600. /**
  36601. * Make the canvas XR Compatible for XR sessions
  36602. */
  36603. xrCompatible?: boolean;
  36604. /**
  36605. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36606. */
  36607. useHighPrecisionMatrix?: boolean;
  36608. }
  36609. /**
  36610. * The base engine class (root of all engines)
  36611. */
  36612. export class ThinEngine {
  36613. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36614. static ExceptionList: ({
  36615. key: string;
  36616. capture: string;
  36617. captureConstraint: number;
  36618. targets: string[];
  36619. } | {
  36620. key: string;
  36621. capture: null;
  36622. captureConstraint: null;
  36623. targets: string[];
  36624. })[];
  36625. /** @hidden */
  36626. static _TextureLoaders: IInternalTextureLoader[];
  36627. /**
  36628. * Returns the current npm package of the sdk
  36629. */
  36630. static get NpmPackage(): string;
  36631. /**
  36632. * Returns the current version of the framework
  36633. */
  36634. static get Version(): string;
  36635. /**
  36636. * Returns a string describing the current engine
  36637. */
  36638. get description(): string;
  36639. /**
  36640. * Gets or sets the epsilon value used by collision engine
  36641. */
  36642. static CollisionsEpsilon: number;
  36643. /**
  36644. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36645. */
  36646. static get ShadersRepository(): string;
  36647. static set ShadersRepository(value: string);
  36648. /** @hidden */
  36649. _shaderProcessor: IShaderProcessor;
  36650. /**
  36651. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36652. */
  36653. forcePOTTextures: boolean;
  36654. /**
  36655. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36656. */
  36657. isFullscreen: boolean;
  36658. /**
  36659. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36660. */
  36661. cullBackFaces: boolean;
  36662. /**
  36663. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36664. */
  36665. renderEvenInBackground: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating that cache can be kept between frames
  36668. */
  36669. preventCacheWipeBetweenFrames: boolean;
  36670. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36671. validateShaderPrograms: boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36674. * This can provide greater z depth for distant objects.
  36675. */
  36676. useReverseDepthBuffer: boolean;
  36677. /**
  36678. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36679. */
  36680. disableUniformBuffers: boolean;
  36681. /** @hidden */
  36682. _uniformBuffers: UniformBuffer[];
  36683. /**
  36684. * Gets a boolean indicating that the engine supports uniform buffers
  36685. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36686. */
  36687. get supportsUniformBuffers(): boolean;
  36688. /** @hidden */
  36689. _gl: WebGLRenderingContext;
  36690. /** @hidden */
  36691. _webGLVersion: number;
  36692. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36693. protected _windowIsBackground: boolean;
  36694. protected _creationOptions: EngineOptions;
  36695. protected _highPrecisionShadersAllowed: boolean;
  36696. /** @hidden */
  36697. get _shouldUseHighPrecisionShader(): boolean;
  36698. /**
  36699. * Gets a boolean indicating that only power of 2 textures are supported
  36700. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36701. */
  36702. get needPOTTextures(): boolean;
  36703. /** @hidden */
  36704. _badOS: boolean;
  36705. /** @hidden */
  36706. _badDesktopOS: boolean;
  36707. private _hardwareScalingLevel;
  36708. /** @hidden */
  36709. _caps: EngineCapabilities;
  36710. private _isStencilEnable;
  36711. private _glVersion;
  36712. private _glRenderer;
  36713. private _glVendor;
  36714. /** @hidden */
  36715. _videoTextureSupported: boolean;
  36716. protected _renderingQueueLaunched: boolean;
  36717. protected _activeRenderLoops: (() => void)[];
  36718. /**
  36719. * Observable signaled when a context lost event is raised
  36720. */
  36721. onContextLostObservable: Observable<ThinEngine>;
  36722. /**
  36723. * Observable signaled when a context restored event is raised
  36724. */
  36725. onContextRestoredObservable: Observable<ThinEngine>;
  36726. private _onContextLost;
  36727. private _onContextRestored;
  36728. protected _contextWasLost: boolean;
  36729. /** @hidden */
  36730. _doNotHandleContextLost: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36733. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36734. */
  36735. get doNotHandleContextLost(): boolean;
  36736. set doNotHandleContextLost(value: boolean);
  36737. /**
  36738. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36739. */
  36740. disableVertexArrayObjects: boolean;
  36741. /** @hidden */
  36742. protected _colorWrite: boolean;
  36743. /** @hidden */
  36744. protected _colorWriteChanged: boolean;
  36745. /** @hidden */
  36746. protected _depthCullingState: DepthCullingState;
  36747. /** @hidden */
  36748. protected _stencilState: StencilState;
  36749. /** @hidden */
  36750. _alphaState: AlphaState;
  36751. /** @hidden */
  36752. _alphaMode: number;
  36753. /** @hidden */
  36754. _alphaEquation: number;
  36755. /** @hidden */
  36756. _internalTexturesCache: InternalTexture[];
  36757. /** @hidden */
  36758. protected _activeChannel: number;
  36759. private _currentTextureChannel;
  36760. /** @hidden */
  36761. protected _boundTexturesCache: {
  36762. [key: string]: Nullable<InternalTexture>;
  36763. };
  36764. /** @hidden */
  36765. protected _currentEffect: Nullable<Effect>;
  36766. /** @hidden */
  36767. protected _currentProgram: Nullable<WebGLProgram>;
  36768. private _compiledEffects;
  36769. private _vertexAttribArraysEnabled;
  36770. /** @hidden */
  36771. protected _cachedViewport: Nullable<IViewportLike>;
  36772. private _cachedVertexArrayObject;
  36773. /** @hidden */
  36774. protected _cachedVertexBuffers: any;
  36775. /** @hidden */
  36776. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36777. /** @hidden */
  36778. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36779. /** @hidden */
  36780. _currentRenderTarget: Nullable<InternalTexture>;
  36781. private _uintIndicesCurrentlySet;
  36782. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36783. /** @hidden */
  36784. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36785. /** @hidden */
  36786. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36787. private _currentBufferPointers;
  36788. private _currentInstanceLocations;
  36789. private _currentInstanceBuffers;
  36790. private _textureUnits;
  36791. /** @hidden */
  36792. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36793. /** @hidden */
  36794. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36795. /** @hidden */
  36796. _boundRenderFunction: any;
  36797. private _vaoRecordInProgress;
  36798. private _mustWipeVertexAttributes;
  36799. private _emptyTexture;
  36800. private _emptyCubeTexture;
  36801. private _emptyTexture3D;
  36802. private _emptyTexture2DArray;
  36803. /** @hidden */
  36804. _frameHandler: number;
  36805. private _nextFreeTextureSlots;
  36806. private _maxSimultaneousTextures;
  36807. private _activeRequests;
  36808. /** @hidden */
  36809. _transformTextureUrl: Nullable<(url: string) => string>;
  36810. /**
  36811. * Gets information about the current host
  36812. */
  36813. hostInformation: HostInformation;
  36814. protected get _supportsHardwareTextureRescaling(): boolean;
  36815. private _framebufferDimensionsObject;
  36816. /**
  36817. * sets the object from which width and height will be taken from when getting render width and height
  36818. * Will fallback to the gl object
  36819. * @param dimensions the framebuffer width and height that will be used.
  36820. */
  36821. set framebufferDimensionsObject(dimensions: Nullable<{
  36822. framebufferWidth: number;
  36823. framebufferHeight: number;
  36824. }>);
  36825. /**
  36826. * Gets the current viewport
  36827. */
  36828. get currentViewport(): Nullable<IViewportLike>;
  36829. /**
  36830. * Gets the default empty texture
  36831. */
  36832. get emptyTexture(): InternalTexture;
  36833. /**
  36834. * Gets the default empty 3D texture
  36835. */
  36836. get emptyTexture3D(): InternalTexture;
  36837. /**
  36838. * Gets the default empty 2D array texture
  36839. */
  36840. get emptyTexture2DArray(): InternalTexture;
  36841. /**
  36842. * Gets the default empty cube texture
  36843. */
  36844. get emptyCubeTexture(): InternalTexture;
  36845. /**
  36846. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36847. */
  36848. readonly premultipliedAlpha: boolean;
  36849. /**
  36850. * Observable event triggered before each texture is initialized
  36851. */
  36852. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36853. /**
  36854. * Creates a new engine
  36855. * @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
  36856. * @param antialias defines enable antialiasing (default: false)
  36857. * @param options defines further options to be sent to the getContext() function
  36858. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36859. */
  36860. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36861. private _rebuildInternalTextures;
  36862. private _rebuildEffects;
  36863. /**
  36864. * Gets a boolean indicating if all created effects are ready
  36865. * @returns true if all effects are ready
  36866. */
  36867. areAllEffectsReady(): boolean;
  36868. protected _rebuildBuffers(): void;
  36869. protected _initGLContext(): void;
  36870. /**
  36871. * Gets version of the current webGL context
  36872. */
  36873. get webGLVersion(): number;
  36874. /**
  36875. * Gets a string identifying the name of the class
  36876. * @returns "Engine" string
  36877. */
  36878. getClassName(): string;
  36879. /**
  36880. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36881. */
  36882. get isStencilEnable(): boolean;
  36883. /** @hidden */
  36884. _prepareWorkingCanvas(): void;
  36885. /**
  36886. * Reset the texture cache to empty state
  36887. */
  36888. resetTextureCache(): void;
  36889. /**
  36890. * Gets an object containing information about the current webGL context
  36891. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36892. */
  36893. getGlInfo(): {
  36894. vendor: string;
  36895. renderer: string;
  36896. version: string;
  36897. };
  36898. /**
  36899. * Defines the hardware scaling level.
  36900. * By default the hardware scaling level is computed from the window device ratio.
  36901. * 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.
  36902. * @param level defines the level to use
  36903. */
  36904. setHardwareScalingLevel(level: number): void;
  36905. /**
  36906. * Gets the current hardware scaling level.
  36907. * By default the hardware scaling level is computed from the window device ratio.
  36908. * 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.
  36909. * @returns a number indicating the current hardware scaling level
  36910. */
  36911. getHardwareScalingLevel(): number;
  36912. /**
  36913. * Gets the list of loaded textures
  36914. * @returns an array containing all loaded textures
  36915. */
  36916. getLoadedTexturesCache(): InternalTexture[];
  36917. /**
  36918. * Gets the object containing all engine capabilities
  36919. * @returns the EngineCapabilities object
  36920. */
  36921. getCaps(): EngineCapabilities;
  36922. /**
  36923. * stop executing a render loop function and remove it from the execution array
  36924. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36925. */
  36926. stopRenderLoop(renderFunction?: () => void): void;
  36927. /** @hidden */
  36928. _renderLoop(): void;
  36929. /**
  36930. * Gets the HTML canvas attached with the current webGL context
  36931. * @returns a HTML canvas
  36932. */
  36933. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36934. /**
  36935. * Gets host window
  36936. * @returns the host window object
  36937. */
  36938. getHostWindow(): Nullable<Window>;
  36939. /**
  36940. * Gets the current render width
  36941. * @param useScreen defines if screen size must be used (or the current render target if any)
  36942. * @returns a number defining the current render width
  36943. */
  36944. getRenderWidth(useScreen?: boolean): number;
  36945. /**
  36946. * Gets the current render height
  36947. * @param useScreen defines if screen size must be used (or the current render target if any)
  36948. * @returns a number defining the current render height
  36949. */
  36950. getRenderHeight(useScreen?: boolean): number;
  36951. /**
  36952. * Can be used to override the current requestAnimationFrame requester.
  36953. * @hidden
  36954. */
  36955. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36956. /**
  36957. * Register and execute a render loop. The engine can have more than one render function
  36958. * @param renderFunction defines the function to continuously execute
  36959. */
  36960. runRenderLoop(renderFunction: () => void): void;
  36961. /**
  36962. * Clear the current render buffer or the current render target (if any is set up)
  36963. * @param color defines the color to use
  36964. * @param backBuffer defines if the back buffer must be cleared
  36965. * @param depth defines if the depth buffer must be cleared
  36966. * @param stencil defines if the stencil buffer must be cleared
  36967. */
  36968. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36969. private _viewportCached;
  36970. /** @hidden */
  36971. _viewport(x: number, y: number, width: number, height: number): void;
  36972. /**
  36973. * Set the WebGL's viewport
  36974. * @param viewport defines the viewport element to be used
  36975. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36976. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36977. */
  36978. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36979. /**
  36980. * Begin a new frame
  36981. */
  36982. beginFrame(): void;
  36983. /**
  36984. * Enf the current frame
  36985. */
  36986. endFrame(): void;
  36987. /**
  36988. * Resize the view according to the canvas' size
  36989. */
  36990. resize(): void;
  36991. /**
  36992. * Force a specific size of the canvas
  36993. * @param width defines the new canvas' width
  36994. * @param height defines the new canvas' height
  36995. * @returns true if the size was changed
  36996. */
  36997. setSize(width: number, height: number): boolean;
  36998. /**
  36999. * Binds the frame buffer to the specified texture.
  37000. * @param texture The texture to render to or null for the default canvas
  37001. * @param faceIndex The face of the texture to render to in case of cube texture
  37002. * @param requiredWidth The width of the target to render to
  37003. * @param requiredHeight The height of the target to render to
  37004. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37005. * @param lodLevel defines the lod level to bind to the frame buffer
  37006. * @param layer defines the 2d array index to bind to frame buffer to
  37007. */
  37008. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37009. /** @hidden */
  37010. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37011. /**
  37012. * Unbind the current render target texture from the webGL context
  37013. * @param texture defines the render target texture to unbind
  37014. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37015. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37016. */
  37017. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37018. /**
  37019. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37020. */
  37021. flushFramebuffer(): void;
  37022. /**
  37023. * Unbind the current render target and bind the default framebuffer
  37024. */
  37025. restoreDefaultFramebuffer(): void;
  37026. /** @hidden */
  37027. protected _resetVertexBufferBinding(): void;
  37028. /**
  37029. * Creates a vertex buffer
  37030. * @param data the data for the vertex buffer
  37031. * @returns the new WebGL static buffer
  37032. */
  37033. createVertexBuffer(data: DataArray): DataBuffer;
  37034. private _createVertexBuffer;
  37035. /**
  37036. * Creates a dynamic vertex buffer
  37037. * @param data the data for the dynamic vertex buffer
  37038. * @returns the new WebGL dynamic buffer
  37039. */
  37040. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37041. protected _resetIndexBufferBinding(): void;
  37042. /**
  37043. * Creates a new index buffer
  37044. * @param indices defines the content of the index buffer
  37045. * @param updatable defines if the index buffer must be updatable
  37046. * @returns a new webGL buffer
  37047. */
  37048. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37049. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37050. /**
  37051. * Bind a webGL buffer to the webGL context
  37052. * @param buffer defines the buffer to bind
  37053. */
  37054. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37055. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37056. private bindBuffer;
  37057. /**
  37058. * update the bound buffer with the given data
  37059. * @param data defines the data to update
  37060. */
  37061. updateArrayBuffer(data: Float32Array): void;
  37062. private _vertexAttribPointer;
  37063. /** @hidden */
  37064. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37065. private _bindVertexBuffersAttributes;
  37066. /**
  37067. * Records a vertex array object
  37068. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37069. * @param vertexBuffers defines the list of vertex buffers to store
  37070. * @param indexBuffer defines the index buffer to store
  37071. * @param effect defines the effect to store
  37072. * @returns the new vertex array object
  37073. */
  37074. recordVertexArrayObject(vertexBuffers: {
  37075. [key: string]: VertexBuffer;
  37076. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37077. /**
  37078. * Bind a specific vertex array object
  37079. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37080. * @param vertexArrayObject defines the vertex array object to bind
  37081. * @param indexBuffer defines the index buffer to bind
  37082. */
  37083. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37084. /**
  37085. * Bind webGl buffers directly to the webGL context
  37086. * @param vertexBuffer defines the vertex buffer to bind
  37087. * @param indexBuffer defines the index buffer to bind
  37088. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37089. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37090. * @param effect defines the effect associated with the vertex buffer
  37091. */
  37092. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37093. private _unbindVertexArrayObject;
  37094. /**
  37095. * Bind a list of vertex buffers to the webGL context
  37096. * @param vertexBuffers defines the list of vertex buffers to bind
  37097. * @param indexBuffer defines the index buffer to bind
  37098. * @param effect defines the effect associated with the vertex buffers
  37099. */
  37100. bindBuffers(vertexBuffers: {
  37101. [key: string]: Nullable<VertexBuffer>;
  37102. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37103. /**
  37104. * Unbind all instance attributes
  37105. */
  37106. unbindInstanceAttributes(): void;
  37107. /**
  37108. * Release and free the memory of a vertex array object
  37109. * @param vao defines the vertex array object to delete
  37110. */
  37111. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37112. /** @hidden */
  37113. _releaseBuffer(buffer: DataBuffer): boolean;
  37114. protected _deleteBuffer(buffer: DataBuffer): void;
  37115. /**
  37116. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37117. * @param instancesBuffer defines the webGL buffer to update and bind
  37118. * @param data defines the data to store in the buffer
  37119. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37120. */
  37121. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37122. /**
  37123. * Bind the content of a webGL buffer used with instantiation
  37124. * @param instancesBuffer defines the webGL buffer to bind
  37125. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37126. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37127. */
  37128. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37129. /**
  37130. * Disable the instance attribute corresponding to the name in parameter
  37131. * @param name defines the name of the attribute to disable
  37132. */
  37133. disableInstanceAttributeByName(name: string): void;
  37134. /**
  37135. * Disable the instance attribute corresponding to the location in parameter
  37136. * @param attributeLocation defines the attribute location of the attribute to disable
  37137. */
  37138. disableInstanceAttribute(attributeLocation: number): void;
  37139. /**
  37140. * Disable the attribute corresponding to the location in parameter
  37141. * @param attributeLocation defines the attribute location of the attribute to disable
  37142. */
  37143. disableAttributeByIndex(attributeLocation: number): void;
  37144. /**
  37145. * Send a draw order
  37146. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37147. * @param indexStart defines the starting index
  37148. * @param indexCount defines the number of index to draw
  37149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37150. */
  37151. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37152. /**
  37153. * Draw a list of points
  37154. * @param verticesStart defines the index of first vertex to draw
  37155. * @param verticesCount defines the count of vertices to draw
  37156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37157. */
  37158. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37159. /**
  37160. * Draw a list of unindexed primitives
  37161. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37162. * @param verticesStart defines the index of first vertex to draw
  37163. * @param verticesCount defines the count of vertices to draw
  37164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37165. */
  37166. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37167. /**
  37168. * Draw a list of indexed primitives
  37169. * @param fillMode defines the primitive to use
  37170. * @param indexStart defines the starting index
  37171. * @param indexCount defines the number of index to draw
  37172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37173. */
  37174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37175. /**
  37176. * Draw a list of unindexed primitives
  37177. * @param fillMode defines the primitive to use
  37178. * @param verticesStart defines the index of first vertex to draw
  37179. * @param verticesCount defines the count of vertices to draw
  37180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37181. */
  37182. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37183. private _drawMode;
  37184. /** @hidden */
  37185. protected _reportDrawCall(): void;
  37186. /** @hidden */
  37187. _releaseEffect(effect: Effect): void;
  37188. /** @hidden */
  37189. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37190. /**
  37191. * Create a new effect (used to store vertex/fragment shaders)
  37192. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37193. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37194. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37195. * @param samplers defines an array of string used to represent textures
  37196. * @param defines defines the string containing the defines to use to compile the shaders
  37197. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37198. * @param onCompiled defines a function to call when the effect creation is successful
  37199. * @param onError defines a function to call when the effect creation has failed
  37200. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37201. * @returns the new Effect
  37202. */
  37203. 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;
  37204. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37205. private _compileShader;
  37206. private _compileRawShader;
  37207. /** @hidden */
  37208. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37209. /**
  37210. * Directly creates a webGL program
  37211. * @param pipelineContext defines the pipeline context to attach to
  37212. * @param vertexCode defines the vertex shader code to use
  37213. * @param fragmentCode defines the fragment shader code to use
  37214. * @param context defines the webGL context to use (if not set, the current one will be used)
  37215. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37216. * @returns the new webGL program
  37217. */
  37218. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37219. /**
  37220. * Creates a webGL program
  37221. * @param pipelineContext defines the pipeline context to attach to
  37222. * @param vertexCode defines the vertex shader code to use
  37223. * @param fragmentCode defines the fragment shader code to use
  37224. * @param defines defines the string containing the defines to use to compile the shaders
  37225. * @param context defines the webGL context to use (if not set, the current one will be used)
  37226. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37227. * @returns the new webGL program
  37228. */
  37229. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37230. /**
  37231. * Creates a new pipeline context
  37232. * @returns the new pipeline
  37233. */
  37234. createPipelineContext(): IPipelineContext;
  37235. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37236. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37237. /** @hidden */
  37238. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37239. /** @hidden */
  37240. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37241. /** @hidden */
  37242. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37243. /**
  37244. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37245. * @param pipelineContext defines the pipeline context to use
  37246. * @param uniformsNames defines the list of uniform names
  37247. * @returns an array of webGL uniform locations
  37248. */
  37249. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37250. /**
  37251. * Gets the lsit of active attributes for a given webGL program
  37252. * @param pipelineContext defines the pipeline context to use
  37253. * @param attributesNames defines the list of attribute names to get
  37254. * @returns an array of indices indicating the offset of each attribute
  37255. */
  37256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37257. /**
  37258. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37259. * @param effect defines the effect to activate
  37260. */
  37261. enableEffect(effect: Nullable<Effect>): void;
  37262. /**
  37263. * Set the value of an uniform to a number (int)
  37264. * @param uniform defines the webGL uniform location where to store the value
  37265. * @param value defines the int number to store
  37266. * @returns true if the value was set
  37267. */
  37268. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37269. /**
  37270. * Set the value of an uniform to an array of int32
  37271. * @param uniform defines the webGL uniform location where to store the value
  37272. * @param array defines the array of int32 to store
  37273. * @returns true if the value was set
  37274. */
  37275. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37276. /**
  37277. * Set the value of an uniform to an array of int32 (stored as vec2)
  37278. * @param uniform defines the webGL uniform location where to store the value
  37279. * @param array defines the array of int32 to store
  37280. * @returns true if the value was set
  37281. */
  37282. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37283. /**
  37284. * Set the value of an uniform to an array of int32 (stored as vec3)
  37285. * @param uniform defines the webGL uniform location where to store the value
  37286. * @param array defines the array of int32 to store
  37287. * @returns true if the value was set
  37288. */
  37289. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37290. /**
  37291. * Set the value of an uniform to an array of int32 (stored as vec4)
  37292. * @param uniform defines the webGL uniform location where to store the value
  37293. * @param array defines the array of int32 to store
  37294. * @returns true if the value was set
  37295. */
  37296. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37297. /**
  37298. * Set the value of an uniform to an array of number
  37299. * @param uniform defines the webGL uniform location where to store the value
  37300. * @param array defines the array of number to store
  37301. * @returns true if the value was set
  37302. */
  37303. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37304. /**
  37305. * Set the value of an uniform to an array of number (stored as vec2)
  37306. * @param uniform defines the webGL uniform location where to store the value
  37307. * @param array defines the array of number to store
  37308. * @returns true if the value was set
  37309. */
  37310. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37311. /**
  37312. * Set the value of an uniform to an array of number (stored as vec3)
  37313. * @param uniform defines the webGL uniform location where to store the value
  37314. * @param array defines the array of number to store
  37315. * @returns true if the value was set
  37316. */
  37317. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37318. /**
  37319. * Set the value of an uniform to an array of number (stored as vec4)
  37320. * @param uniform defines the webGL uniform location where to store the value
  37321. * @param array defines the array of number to store
  37322. * @returns true if the value was set
  37323. */
  37324. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37325. /**
  37326. * Set the value of an uniform to an array of float32 (stored as matrices)
  37327. * @param uniform defines the webGL uniform location where to store the value
  37328. * @param matrices defines the array of float32 to store
  37329. * @returns true if the value was set
  37330. */
  37331. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37332. /**
  37333. * Set the value of an uniform to a matrix (3x3)
  37334. * @param uniform defines the webGL uniform location where to store the value
  37335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37336. * @returns true if the value was set
  37337. */
  37338. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37339. /**
  37340. * Set the value of an uniform to a matrix (2x2)
  37341. * @param uniform defines the webGL uniform location where to store the value
  37342. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37343. * @returns true if the value was set
  37344. */
  37345. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37346. /**
  37347. * Set the value of an uniform to a number (float)
  37348. * @param uniform defines the webGL uniform location where to store the value
  37349. * @param value defines the float number to store
  37350. * @returns true if the value was transfered
  37351. */
  37352. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37353. /**
  37354. * Set the value of an uniform to a vec2
  37355. * @param uniform defines the webGL uniform location where to store the value
  37356. * @param x defines the 1st component of the value
  37357. * @param y defines the 2nd component of the value
  37358. * @returns true if the value was set
  37359. */
  37360. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37361. /**
  37362. * Set the value of an uniform to a vec3
  37363. * @param uniform defines the webGL uniform location where to store the value
  37364. * @param x defines the 1st component of the value
  37365. * @param y defines the 2nd component of the value
  37366. * @param z defines the 3rd component of the value
  37367. * @returns true if the value was set
  37368. */
  37369. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37370. /**
  37371. * Set the value of an uniform to a vec4
  37372. * @param uniform defines the webGL uniform location where to store the value
  37373. * @param x defines the 1st component of the value
  37374. * @param y defines the 2nd component of the value
  37375. * @param z defines the 3rd component of the value
  37376. * @param w defines the 4th component of the value
  37377. * @returns true if the value was set
  37378. */
  37379. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37380. /**
  37381. * Apply all cached states (depth, culling, stencil and alpha)
  37382. */
  37383. applyStates(): void;
  37384. /**
  37385. * Enable or disable color writing
  37386. * @param enable defines the state to set
  37387. */
  37388. setColorWrite(enable: boolean): void;
  37389. /**
  37390. * Gets a boolean indicating if color writing is enabled
  37391. * @returns the current color writing state
  37392. */
  37393. getColorWrite(): boolean;
  37394. /**
  37395. * Gets the depth culling state manager
  37396. */
  37397. get depthCullingState(): DepthCullingState;
  37398. /**
  37399. * Gets the alpha state manager
  37400. */
  37401. get alphaState(): AlphaState;
  37402. /**
  37403. * Gets the stencil state manager
  37404. */
  37405. get stencilState(): StencilState;
  37406. /**
  37407. * Clears the list of texture accessible through engine.
  37408. * This can help preventing texture load conflict due to name collision.
  37409. */
  37410. clearInternalTexturesCache(): void;
  37411. /**
  37412. * Force the entire cache to be cleared
  37413. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37414. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37415. */
  37416. wipeCaches(bruteForce?: boolean): void;
  37417. /** @hidden */
  37418. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37419. min: number;
  37420. mag: number;
  37421. };
  37422. /** @hidden */
  37423. _createTexture(): WebGLTexture;
  37424. /**
  37425. * Usually called from Texture.ts.
  37426. * Passed information to create a WebGLTexture
  37427. * @param url defines a value which contains one of the following:
  37428. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37429. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37430. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37432. * @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)
  37433. * @param scene needed for loading to the correct scene
  37434. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37435. * @param onLoad optional callback to be called upon successful completion
  37436. * @param onError optional callback to be called upon failure
  37437. * @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
  37438. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37439. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37440. * @param forcedExtension defines the extension to use to pick the right loader
  37441. * @param mimeType defines an optional mime type
  37442. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37443. */
  37444. 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;
  37445. /**
  37446. * Loads an image as an HTMLImageElement.
  37447. * @param input url string, ArrayBuffer, or Blob to load
  37448. * @param onLoad callback called when the image successfully loads
  37449. * @param onError callback called when the image fails to load
  37450. * @param offlineProvider offline provider for caching
  37451. * @param mimeType optional mime type
  37452. * @returns the HTMLImageElement of the loaded image
  37453. * @hidden
  37454. */
  37455. 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>;
  37456. /**
  37457. * @hidden
  37458. */
  37459. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37460. private _unpackFlipYCached;
  37461. /**
  37462. * In case you are sharing the context with other applications, it might
  37463. * be interested to not cache the unpack flip y state to ensure a consistent
  37464. * value would be set.
  37465. */
  37466. enableUnpackFlipYCached: boolean;
  37467. /** @hidden */
  37468. _unpackFlipY(value: boolean): void;
  37469. /** @hidden */
  37470. _getUnpackAlignement(): number;
  37471. private _getTextureTarget;
  37472. /**
  37473. * Update the sampling mode of a given texture
  37474. * @param samplingMode defines the required sampling mode
  37475. * @param texture defines the texture to update
  37476. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37477. */
  37478. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37479. /**
  37480. * Update the sampling mode of a given texture
  37481. * @param texture defines the texture to update
  37482. * @param wrapU defines the texture wrap mode of the u coordinates
  37483. * @param wrapV defines the texture wrap mode of the v coordinates
  37484. * @param wrapR defines the texture wrap mode of the r coordinates
  37485. */
  37486. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37487. /** @hidden */
  37488. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37489. width: number;
  37490. height: number;
  37491. layers?: number;
  37492. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37493. /** @hidden */
  37494. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37495. /** @hidden */
  37496. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37497. /**
  37498. * Update a portion of an internal texture
  37499. * @param texture defines the texture to update
  37500. * @param imageData defines the data to store into the texture
  37501. * @param xOffset defines the x coordinates of the update rectangle
  37502. * @param yOffset defines the y coordinates of the update rectangle
  37503. * @param width defines the width of the update rectangle
  37504. * @param height defines the height of the update rectangle
  37505. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37506. * @param lod defines the lod level to update (0 by default)
  37507. */
  37508. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37509. /** @hidden */
  37510. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37511. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37512. private _prepareWebGLTexture;
  37513. /** @hidden */
  37514. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37515. private _getDepthStencilBuffer;
  37516. /** @hidden */
  37517. _releaseFramebufferObjects(texture: InternalTexture): void;
  37518. /** @hidden */
  37519. _releaseTexture(texture: InternalTexture): void;
  37520. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37521. protected _setProgram(program: WebGLProgram): void;
  37522. protected _boundUniforms: {
  37523. [key: number]: WebGLUniformLocation;
  37524. };
  37525. /**
  37526. * Binds an effect to the webGL context
  37527. * @param effect defines the effect to bind
  37528. */
  37529. bindSamplers(effect: Effect): void;
  37530. private _activateCurrentTexture;
  37531. /** @hidden */
  37532. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37533. /** @hidden */
  37534. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37535. /**
  37536. * Unbind all textures from the webGL context
  37537. */
  37538. unbindAllTextures(): void;
  37539. /**
  37540. * Sets a texture to the according uniform.
  37541. * @param channel The texture channel
  37542. * @param uniform The uniform to set
  37543. * @param texture The texture to apply
  37544. */
  37545. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37546. private _bindSamplerUniformToChannel;
  37547. private _getTextureWrapMode;
  37548. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37549. /**
  37550. * Sets an array of texture to the webGL context
  37551. * @param channel defines the channel where the texture array must be set
  37552. * @param uniform defines the associated uniform location
  37553. * @param textures defines the array of textures to bind
  37554. */
  37555. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37556. /** @hidden */
  37557. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37558. private _setTextureParameterFloat;
  37559. private _setTextureParameterInteger;
  37560. /**
  37561. * Unbind all vertex attributes from the webGL context
  37562. */
  37563. unbindAllAttributes(): void;
  37564. /**
  37565. * 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
  37566. */
  37567. releaseEffects(): void;
  37568. /**
  37569. * Dispose and release all associated resources
  37570. */
  37571. dispose(): void;
  37572. /**
  37573. * Attach a new callback raised when context lost event is fired
  37574. * @param callback defines the callback to call
  37575. */
  37576. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37577. /**
  37578. * Attach a new callback raised when context restored event is fired
  37579. * @param callback defines the callback to call
  37580. */
  37581. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37582. /**
  37583. * Get the current error code of the webGL context
  37584. * @returns the error code
  37585. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37586. */
  37587. getError(): number;
  37588. private _canRenderToFloatFramebuffer;
  37589. private _canRenderToHalfFloatFramebuffer;
  37590. private _canRenderToFramebuffer;
  37591. /** @hidden */
  37592. _getWebGLTextureType(type: number): number;
  37593. /** @hidden */
  37594. _getInternalFormat(format: number): number;
  37595. /** @hidden */
  37596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37597. /** @hidden */
  37598. _getRGBAMultiSampleBufferFormat(type: number): number;
  37599. /** @hidden */
  37600. _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;
  37601. /**
  37602. * Loads a file from a url
  37603. * @param url url to load
  37604. * @param onSuccess callback called when the file successfully loads
  37605. * @param onProgress callback called while file is loading (if the server supports this mode)
  37606. * @param offlineProvider defines the offline provider for caching
  37607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37608. * @param onError callback called when the file fails to load
  37609. * @returns a file request object
  37610. * @hidden
  37611. */
  37612. 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;
  37613. /**
  37614. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37615. * @param x defines the x coordinate of the rectangle where pixels must be read
  37616. * @param y defines the y coordinate of the rectangle where pixels must be read
  37617. * @param width defines the width of the rectangle where pixels must be read
  37618. * @param height defines the height of the rectangle where pixels must be read
  37619. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37620. * @returns a Uint8Array containing RGBA colors
  37621. */
  37622. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37623. private static _isSupported;
  37624. /**
  37625. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37626. * @returns true if the engine can be created
  37627. * @ignorenaming
  37628. */
  37629. static isSupported(): boolean;
  37630. /**
  37631. * Find the next highest power of two.
  37632. * @param x Number to start search from.
  37633. * @return Next highest power of two.
  37634. */
  37635. static CeilingPOT(x: number): number;
  37636. /**
  37637. * Find the next lowest power of two.
  37638. * @param x Number to start search from.
  37639. * @return Next lowest power of two.
  37640. */
  37641. static FloorPOT(x: number): number;
  37642. /**
  37643. * Find the nearest power of two.
  37644. * @param x Number to start search from.
  37645. * @return Next nearest power of two.
  37646. */
  37647. static NearestPOT(x: number): number;
  37648. /**
  37649. * Get the closest exponent of two
  37650. * @param value defines the value to approximate
  37651. * @param max defines the maximum value to return
  37652. * @param mode defines how to define the closest value
  37653. * @returns closest exponent of two of the given value
  37654. */
  37655. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37656. /**
  37657. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37658. * @param func - the function to be called
  37659. * @param requester - the object that will request the next frame. Falls back to window.
  37660. * @returns frame number
  37661. */
  37662. static QueueNewFrame(func: () => void, requester?: any): number;
  37663. /**
  37664. * Gets host document
  37665. * @returns the host document object
  37666. */
  37667. getHostDocument(): Nullable<Document>;
  37668. }
  37669. }
  37670. declare module "babylonjs/Maths/sphericalPolynomial" {
  37671. import { Vector3 } from "babylonjs/Maths/math.vector";
  37672. import { Color3 } from "babylonjs/Maths/math.color";
  37673. /**
  37674. * Class representing spherical harmonics coefficients to the 3rd degree
  37675. */
  37676. export class SphericalHarmonics {
  37677. /**
  37678. * Defines whether or not the harmonics have been prescaled for rendering.
  37679. */
  37680. preScaled: boolean;
  37681. /**
  37682. * The l0,0 coefficients of the spherical harmonics
  37683. */
  37684. l00: Vector3;
  37685. /**
  37686. * The l1,-1 coefficients of the spherical harmonics
  37687. */
  37688. l1_1: Vector3;
  37689. /**
  37690. * The l1,0 coefficients of the spherical harmonics
  37691. */
  37692. l10: Vector3;
  37693. /**
  37694. * The l1,1 coefficients of the spherical harmonics
  37695. */
  37696. l11: Vector3;
  37697. /**
  37698. * The l2,-2 coefficients of the spherical harmonics
  37699. */
  37700. l2_2: Vector3;
  37701. /**
  37702. * The l2,-1 coefficients of the spherical harmonics
  37703. */
  37704. l2_1: Vector3;
  37705. /**
  37706. * The l2,0 coefficients of the spherical harmonics
  37707. */
  37708. l20: Vector3;
  37709. /**
  37710. * The l2,1 coefficients of the spherical harmonics
  37711. */
  37712. l21: Vector3;
  37713. /**
  37714. * The l2,2 coefficients of the spherical harmonics
  37715. */
  37716. l22: Vector3;
  37717. /**
  37718. * Adds a light to the spherical harmonics
  37719. * @param direction the direction of the light
  37720. * @param color the color of the light
  37721. * @param deltaSolidAngle the delta solid angle of the light
  37722. */
  37723. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37724. /**
  37725. * Scales the spherical harmonics by the given amount
  37726. * @param scale the amount to scale
  37727. */
  37728. scaleInPlace(scale: number): void;
  37729. /**
  37730. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37731. *
  37732. * ```
  37733. * E_lm = A_l * L_lm
  37734. * ```
  37735. *
  37736. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37737. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37738. * the scaling factors are given in equation 9.
  37739. */
  37740. convertIncidentRadianceToIrradiance(): void;
  37741. /**
  37742. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37743. *
  37744. * ```
  37745. * L = (1/pi) * E * rho
  37746. * ```
  37747. *
  37748. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37749. */
  37750. convertIrradianceToLambertianRadiance(): void;
  37751. /**
  37752. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37753. * required operations at run time.
  37754. *
  37755. * This is simply done by scaling back the SH with Ylm constants parameter.
  37756. * The trigonometric part being applied by the shader at run time.
  37757. */
  37758. preScaleForRendering(): void;
  37759. /**
  37760. * Constructs a spherical harmonics from an array.
  37761. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37762. * @returns the spherical harmonics
  37763. */
  37764. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37765. /**
  37766. * Gets the spherical harmonics from polynomial
  37767. * @param polynomial the spherical polynomial
  37768. * @returns the spherical harmonics
  37769. */
  37770. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37771. }
  37772. /**
  37773. * Class representing spherical polynomial coefficients to the 3rd degree
  37774. */
  37775. export class SphericalPolynomial {
  37776. private _harmonics;
  37777. /**
  37778. * The spherical harmonics used to create the polynomials.
  37779. */
  37780. get preScaledHarmonics(): SphericalHarmonics;
  37781. /**
  37782. * The x coefficients of the spherical polynomial
  37783. */
  37784. x: Vector3;
  37785. /**
  37786. * The y coefficients of the spherical polynomial
  37787. */
  37788. y: Vector3;
  37789. /**
  37790. * The z coefficients of the spherical polynomial
  37791. */
  37792. z: Vector3;
  37793. /**
  37794. * The xx coefficients of the spherical polynomial
  37795. */
  37796. xx: Vector3;
  37797. /**
  37798. * The yy coefficients of the spherical polynomial
  37799. */
  37800. yy: Vector3;
  37801. /**
  37802. * The zz coefficients of the spherical polynomial
  37803. */
  37804. zz: Vector3;
  37805. /**
  37806. * The xy coefficients of the spherical polynomial
  37807. */
  37808. xy: Vector3;
  37809. /**
  37810. * The yz coefficients of the spherical polynomial
  37811. */
  37812. yz: Vector3;
  37813. /**
  37814. * The zx coefficients of the spherical polynomial
  37815. */
  37816. zx: Vector3;
  37817. /**
  37818. * Adds an ambient color to the spherical polynomial
  37819. * @param color the color to add
  37820. */
  37821. addAmbient(color: Color3): void;
  37822. /**
  37823. * Scales the spherical polynomial by the given amount
  37824. * @param scale the amount to scale
  37825. */
  37826. scaleInPlace(scale: number): void;
  37827. /**
  37828. * Gets the spherical polynomial from harmonics
  37829. * @param harmonics the spherical harmonics
  37830. * @returns the spherical polynomial
  37831. */
  37832. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37833. /**
  37834. * Constructs a spherical polynomial from an array.
  37835. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37836. * @returns the spherical polynomial
  37837. */
  37838. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37839. }
  37840. }
  37841. declare module "babylonjs/Materials/Textures/internalTexture" {
  37842. import { Observable } from "babylonjs/Misc/observable";
  37843. import { Nullable, int } from "babylonjs/types";
  37844. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37846. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37847. /**
  37848. * Defines the source of the internal texture
  37849. */
  37850. export enum InternalTextureSource {
  37851. /**
  37852. * The source of the texture data is unknown
  37853. */
  37854. Unknown = 0,
  37855. /**
  37856. * Texture data comes from an URL
  37857. */
  37858. Url = 1,
  37859. /**
  37860. * Texture data is only used for temporary storage
  37861. */
  37862. Temp = 2,
  37863. /**
  37864. * Texture data comes from raw data (ArrayBuffer)
  37865. */
  37866. Raw = 3,
  37867. /**
  37868. * Texture content is dynamic (video or dynamic texture)
  37869. */
  37870. Dynamic = 4,
  37871. /**
  37872. * Texture content is generated by rendering to it
  37873. */
  37874. RenderTarget = 5,
  37875. /**
  37876. * Texture content is part of a multi render target process
  37877. */
  37878. MultiRenderTarget = 6,
  37879. /**
  37880. * Texture data comes from a cube data file
  37881. */
  37882. Cube = 7,
  37883. /**
  37884. * Texture data comes from a raw cube data
  37885. */
  37886. CubeRaw = 8,
  37887. /**
  37888. * Texture data come from a prefiltered cube data file
  37889. */
  37890. CubePrefiltered = 9,
  37891. /**
  37892. * Texture content is raw 3D data
  37893. */
  37894. Raw3D = 10,
  37895. /**
  37896. * Texture content is raw 2D array data
  37897. */
  37898. Raw2DArray = 11,
  37899. /**
  37900. * Texture content is a depth texture
  37901. */
  37902. Depth = 12,
  37903. /**
  37904. * Texture data comes from a raw cube data encoded with RGBD
  37905. */
  37906. CubeRawRGBD = 13
  37907. }
  37908. /**
  37909. * Class used to store data associated with WebGL texture data for the engine
  37910. * This class should not be used directly
  37911. */
  37912. export class InternalTexture {
  37913. /** @hidden */
  37914. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37915. /**
  37916. * Defines if the texture is ready
  37917. */
  37918. isReady: boolean;
  37919. /**
  37920. * Defines if the texture is a cube texture
  37921. */
  37922. isCube: boolean;
  37923. /**
  37924. * Defines if the texture contains 3D data
  37925. */
  37926. is3D: boolean;
  37927. /**
  37928. * Defines if the texture contains 2D array data
  37929. */
  37930. is2DArray: boolean;
  37931. /**
  37932. * Defines if the texture contains multiview data
  37933. */
  37934. isMultiview: boolean;
  37935. /**
  37936. * Gets the URL used to load this texture
  37937. */
  37938. url: string;
  37939. /**
  37940. * Gets the sampling mode of the texture
  37941. */
  37942. samplingMode: number;
  37943. /**
  37944. * Gets a boolean indicating if the texture needs mipmaps generation
  37945. */
  37946. generateMipMaps: boolean;
  37947. /**
  37948. * Gets the number of samples used by the texture (WebGL2+ only)
  37949. */
  37950. samples: number;
  37951. /**
  37952. * Gets the type of the texture (int, float...)
  37953. */
  37954. type: number;
  37955. /**
  37956. * Gets the format of the texture (RGB, RGBA...)
  37957. */
  37958. format: number;
  37959. /**
  37960. * Observable called when the texture is loaded
  37961. */
  37962. onLoadedObservable: Observable<InternalTexture>;
  37963. /**
  37964. * Gets the width of the texture
  37965. */
  37966. width: number;
  37967. /**
  37968. * Gets the height of the texture
  37969. */
  37970. height: number;
  37971. /**
  37972. * Gets the depth of the texture
  37973. */
  37974. depth: number;
  37975. /**
  37976. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37977. */
  37978. baseWidth: number;
  37979. /**
  37980. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37981. */
  37982. baseHeight: number;
  37983. /**
  37984. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37985. */
  37986. baseDepth: number;
  37987. /**
  37988. * Gets a boolean indicating if the texture is inverted on Y axis
  37989. */
  37990. invertY: boolean;
  37991. /** @hidden */
  37992. _invertVScale: boolean;
  37993. /** @hidden */
  37994. _associatedChannel: number;
  37995. /** @hidden */
  37996. _source: InternalTextureSource;
  37997. /** @hidden */
  37998. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37999. /** @hidden */
  38000. _bufferView: Nullable<ArrayBufferView>;
  38001. /** @hidden */
  38002. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38003. /** @hidden */
  38004. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38005. /** @hidden */
  38006. _size: number;
  38007. /** @hidden */
  38008. _extension: string;
  38009. /** @hidden */
  38010. _files: Nullable<string[]>;
  38011. /** @hidden */
  38012. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38013. /** @hidden */
  38014. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38015. /** @hidden */
  38016. _framebuffer: Nullable<WebGLFramebuffer>;
  38017. /** @hidden */
  38018. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38019. /** @hidden */
  38020. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38021. /** @hidden */
  38022. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38023. /** @hidden */
  38024. _attachments: Nullable<number[]>;
  38025. /** @hidden */
  38026. _textureArray: Nullable<InternalTexture[]>;
  38027. /** @hidden */
  38028. _cachedCoordinatesMode: Nullable<number>;
  38029. /** @hidden */
  38030. _cachedWrapU: Nullable<number>;
  38031. /** @hidden */
  38032. _cachedWrapV: Nullable<number>;
  38033. /** @hidden */
  38034. _cachedWrapR: Nullable<number>;
  38035. /** @hidden */
  38036. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38037. /** @hidden */
  38038. _isDisabled: boolean;
  38039. /** @hidden */
  38040. _compression: Nullable<string>;
  38041. /** @hidden */
  38042. _generateStencilBuffer: boolean;
  38043. /** @hidden */
  38044. _generateDepthBuffer: boolean;
  38045. /** @hidden */
  38046. _comparisonFunction: number;
  38047. /** @hidden */
  38048. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38049. /** @hidden */
  38050. _lodGenerationScale: number;
  38051. /** @hidden */
  38052. _lodGenerationOffset: number;
  38053. /** @hidden */
  38054. _depthStencilTexture: Nullable<InternalTexture>;
  38055. /** @hidden */
  38056. _colorTextureArray: Nullable<WebGLTexture>;
  38057. /** @hidden */
  38058. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38059. /** @hidden */
  38060. _lodTextureHigh: Nullable<BaseTexture>;
  38061. /** @hidden */
  38062. _lodTextureMid: Nullable<BaseTexture>;
  38063. /** @hidden */
  38064. _lodTextureLow: Nullable<BaseTexture>;
  38065. /** @hidden */
  38066. _isRGBD: boolean;
  38067. /** @hidden */
  38068. _linearSpecularLOD: boolean;
  38069. /** @hidden */
  38070. _irradianceTexture: Nullable<BaseTexture>;
  38071. /** @hidden */
  38072. _webGLTexture: Nullable<WebGLTexture>;
  38073. /** @hidden */
  38074. _references: number;
  38075. /** @hidden */
  38076. _gammaSpace: Nullable<boolean>;
  38077. private _engine;
  38078. /**
  38079. * Gets the Engine the texture belongs to.
  38080. * @returns The babylon engine
  38081. */
  38082. getEngine(): ThinEngine;
  38083. /**
  38084. * Gets the data source type of the texture
  38085. */
  38086. get source(): InternalTextureSource;
  38087. /**
  38088. * Creates a new InternalTexture
  38089. * @param engine defines the engine to use
  38090. * @param source defines the type of data that will be used
  38091. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38092. */
  38093. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38094. /**
  38095. * Increments the number of references (ie. the number of Texture that point to it)
  38096. */
  38097. incrementReferences(): void;
  38098. /**
  38099. * Change the size of the texture (not the size of the content)
  38100. * @param width defines the new width
  38101. * @param height defines the new height
  38102. * @param depth defines the new depth (1 by default)
  38103. */
  38104. updateSize(width: int, height: int, depth?: int): void;
  38105. /** @hidden */
  38106. _rebuild(): void;
  38107. /** @hidden */
  38108. _swapAndDie(target: InternalTexture): void;
  38109. /**
  38110. * Dispose the current allocated resources
  38111. */
  38112. dispose(): void;
  38113. }
  38114. }
  38115. declare module "babylonjs/Audio/analyser" {
  38116. import { Scene } from "babylonjs/scene";
  38117. /**
  38118. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38120. */
  38121. export class Analyser {
  38122. /**
  38123. * Gets or sets the smoothing
  38124. * @ignorenaming
  38125. */
  38126. SMOOTHING: number;
  38127. /**
  38128. * Gets or sets the FFT table size
  38129. * @ignorenaming
  38130. */
  38131. FFT_SIZE: number;
  38132. /**
  38133. * Gets or sets the bar graph amplitude
  38134. * @ignorenaming
  38135. */
  38136. BARGRAPHAMPLITUDE: number;
  38137. /**
  38138. * Gets or sets the position of the debug canvas
  38139. * @ignorenaming
  38140. */
  38141. DEBUGCANVASPOS: {
  38142. x: number;
  38143. y: number;
  38144. };
  38145. /**
  38146. * Gets or sets the debug canvas size
  38147. * @ignorenaming
  38148. */
  38149. DEBUGCANVASSIZE: {
  38150. width: number;
  38151. height: number;
  38152. };
  38153. private _byteFreqs;
  38154. private _byteTime;
  38155. private _floatFreqs;
  38156. private _webAudioAnalyser;
  38157. private _debugCanvas;
  38158. private _debugCanvasContext;
  38159. private _scene;
  38160. private _registerFunc;
  38161. private _audioEngine;
  38162. /**
  38163. * Creates a new analyser
  38164. * @param scene defines hosting scene
  38165. */
  38166. constructor(scene: Scene);
  38167. /**
  38168. * Get the number of data values you will have to play with for the visualization
  38169. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38170. * @returns a number
  38171. */
  38172. getFrequencyBinCount(): number;
  38173. /**
  38174. * Gets the current frequency data as a byte array
  38175. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38176. * @returns a Uint8Array
  38177. */
  38178. getByteFrequencyData(): Uint8Array;
  38179. /**
  38180. * Gets the current waveform as a byte array
  38181. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38182. * @returns a Uint8Array
  38183. */
  38184. getByteTimeDomainData(): Uint8Array;
  38185. /**
  38186. * Gets the current frequency data as a float array
  38187. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38188. * @returns a Float32Array
  38189. */
  38190. getFloatFrequencyData(): Float32Array;
  38191. /**
  38192. * Renders the debug canvas
  38193. */
  38194. drawDebugCanvas(): void;
  38195. /**
  38196. * Stops rendering the debug canvas and removes it
  38197. */
  38198. stopDebugCanvas(): void;
  38199. /**
  38200. * Connects two audio nodes
  38201. * @param inputAudioNode defines first node to connect
  38202. * @param outputAudioNode defines second node to connect
  38203. */
  38204. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38205. /**
  38206. * Releases all associated resources
  38207. */
  38208. dispose(): void;
  38209. }
  38210. }
  38211. declare module "babylonjs/Audio/audioEngine" {
  38212. import { IDisposable } from "babylonjs/scene";
  38213. import { Analyser } from "babylonjs/Audio/analyser";
  38214. import { Nullable } from "babylonjs/types";
  38215. import { Observable } from "babylonjs/Misc/observable";
  38216. /**
  38217. * This represents an audio engine and it is responsible
  38218. * to play, synchronize and analyse sounds throughout the application.
  38219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38220. */
  38221. export interface IAudioEngine extends IDisposable {
  38222. /**
  38223. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38224. */
  38225. readonly canUseWebAudio: boolean;
  38226. /**
  38227. * Gets the current AudioContext if available.
  38228. */
  38229. readonly audioContext: Nullable<AudioContext>;
  38230. /**
  38231. * The master gain node defines the global audio volume of your audio engine.
  38232. */
  38233. readonly masterGain: GainNode;
  38234. /**
  38235. * Gets whether or not mp3 are supported by your browser.
  38236. */
  38237. readonly isMP3supported: boolean;
  38238. /**
  38239. * Gets whether or not ogg are supported by your browser.
  38240. */
  38241. readonly isOGGsupported: boolean;
  38242. /**
  38243. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38244. * @ignoreNaming
  38245. */
  38246. WarnedWebAudioUnsupported: boolean;
  38247. /**
  38248. * Defines if the audio engine relies on a custom unlocked button.
  38249. * In this case, the embedded button will not be displayed.
  38250. */
  38251. useCustomUnlockedButton: boolean;
  38252. /**
  38253. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38254. */
  38255. readonly unlocked: boolean;
  38256. /**
  38257. * Event raised when audio has been unlocked on the browser.
  38258. */
  38259. onAudioUnlockedObservable: Observable<AudioEngine>;
  38260. /**
  38261. * Event raised when audio has been locked on the browser.
  38262. */
  38263. onAudioLockedObservable: Observable<AudioEngine>;
  38264. /**
  38265. * Flags the audio engine in Locked state.
  38266. * This happens due to new browser policies preventing audio to autoplay.
  38267. */
  38268. lock(): void;
  38269. /**
  38270. * Unlocks the audio engine once a user action has been done on the dom.
  38271. * This is helpful to resume play once browser policies have been satisfied.
  38272. */
  38273. unlock(): void;
  38274. /**
  38275. * Gets the global volume sets on the master gain.
  38276. * @returns the global volume if set or -1 otherwise
  38277. */
  38278. getGlobalVolume(): number;
  38279. /**
  38280. * Sets the global volume of your experience (sets on the master gain).
  38281. * @param newVolume Defines the new global volume of the application
  38282. */
  38283. setGlobalVolume(newVolume: number): void;
  38284. /**
  38285. * Connect the audio engine to an audio analyser allowing some amazing
  38286. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38287. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38288. * @param analyser The analyser to connect to the engine
  38289. */
  38290. connectToAnalyser(analyser: Analyser): void;
  38291. }
  38292. /**
  38293. * This represents the default audio engine used in babylon.
  38294. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38296. */
  38297. export class AudioEngine implements IAudioEngine {
  38298. private _audioContext;
  38299. private _audioContextInitialized;
  38300. private _muteButton;
  38301. private _hostElement;
  38302. /**
  38303. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38304. */
  38305. canUseWebAudio: boolean;
  38306. /**
  38307. * The master gain node defines the global audio volume of your audio engine.
  38308. */
  38309. masterGain: GainNode;
  38310. /**
  38311. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38312. * @ignoreNaming
  38313. */
  38314. WarnedWebAudioUnsupported: boolean;
  38315. /**
  38316. * Gets whether or not mp3 are supported by your browser.
  38317. */
  38318. isMP3supported: boolean;
  38319. /**
  38320. * Gets whether or not ogg are supported by your browser.
  38321. */
  38322. isOGGsupported: boolean;
  38323. /**
  38324. * Gets whether audio has been unlocked on the device.
  38325. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38326. * a user interaction has happened.
  38327. */
  38328. unlocked: boolean;
  38329. /**
  38330. * Defines if the audio engine relies on a custom unlocked button.
  38331. * In this case, the embedded button will not be displayed.
  38332. */
  38333. useCustomUnlockedButton: boolean;
  38334. /**
  38335. * Event raised when audio has been unlocked on the browser.
  38336. */
  38337. onAudioUnlockedObservable: Observable<AudioEngine>;
  38338. /**
  38339. * Event raised when audio has been locked on the browser.
  38340. */
  38341. onAudioLockedObservable: Observable<AudioEngine>;
  38342. /**
  38343. * Gets the current AudioContext if available.
  38344. */
  38345. get audioContext(): Nullable<AudioContext>;
  38346. private _connectedAnalyser;
  38347. /**
  38348. * Instantiates a new audio engine.
  38349. *
  38350. * There should be only one per page as some browsers restrict the number
  38351. * of audio contexts you can create.
  38352. * @param hostElement defines the host element where to display the mute icon if necessary
  38353. */
  38354. constructor(hostElement?: Nullable<HTMLElement>);
  38355. /**
  38356. * Flags the audio engine in Locked state.
  38357. * This happens due to new browser policies preventing audio to autoplay.
  38358. */
  38359. lock(): void;
  38360. /**
  38361. * Unlocks the audio engine once a user action has been done on the dom.
  38362. * This is helpful to resume play once browser policies have been satisfied.
  38363. */
  38364. unlock(): void;
  38365. private _resumeAudioContext;
  38366. private _initializeAudioContext;
  38367. private _tryToRun;
  38368. private _triggerRunningState;
  38369. private _triggerSuspendedState;
  38370. private _displayMuteButton;
  38371. private _moveButtonToTopLeft;
  38372. private _onResize;
  38373. private _hideMuteButton;
  38374. /**
  38375. * Destroy and release the resources associated with the audio ccontext.
  38376. */
  38377. dispose(): void;
  38378. /**
  38379. * Gets the global volume sets on the master gain.
  38380. * @returns the global volume if set or -1 otherwise
  38381. */
  38382. getGlobalVolume(): number;
  38383. /**
  38384. * Sets the global volume of your experience (sets on the master gain).
  38385. * @param newVolume Defines the new global volume of the application
  38386. */
  38387. setGlobalVolume(newVolume: number): void;
  38388. /**
  38389. * Connect the audio engine to an audio analyser allowing some amazing
  38390. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38391. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38392. * @param analyser The analyser to connect to the engine
  38393. */
  38394. connectToAnalyser(analyser: Analyser): void;
  38395. }
  38396. }
  38397. declare module "babylonjs/Loading/loadingScreen" {
  38398. /**
  38399. * Interface used to present a loading screen while loading a scene
  38400. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38401. */
  38402. export interface ILoadingScreen {
  38403. /**
  38404. * Function called to display the loading screen
  38405. */
  38406. displayLoadingUI: () => void;
  38407. /**
  38408. * Function called to hide the loading screen
  38409. */
  38410. hideLoadingUI: () => void;
  38411. /**
  38412. * Gets or sets the color to use for the background
  38413. */
  38414. loadingUIBackgroundColor: string;
  38415. /**
  38416. * Gets or sets the text to display while loading
  38417. */
  38418. loadingUIText: string;
  38419. }
  38420. /**
  38421. * Class used for the default loading screen
  38422. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38423. */
  38424. export class DefaultLoadingScreen implements ILoadingScreen {
  38425. private _renderingCanvas;
  38426. private _loadingText;
  38427. private _loadingDivBackgroundColor;
  38428. private _loadingDiv;
  38429. private _loadingTextDiv;
  38430. /** Gets or sets the logo url to use for the default loading screen */
  38431. static DefaultLogoUrl: string;
  38432. /** Gets or sets the spinner url to use for the default loading screen */
  38433. static DefaultSpinnerUrl: string;
  38434. /**
  38435. * Creates a new default loading screen
  38436. * @param _renderingCanvas defines the canvas used to render the scene
  38437. * @param _loadingText defines the default text to display
  38438. * @param _loadingDivBackgroundColor defines the default background color
  38439. */
  38440. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38441. /**
  38442. * Function called to display the loading screen
  38443. */
  38444. displayLoadingUI(): void;
  38445. /**
  38446. * Function called to hide the loading screen
  38447. */
  38448. hideLoadingUI(): void;
  38449. /**
  38450. * Gets or sets the text to display while loading
  38451. */
  38452. set loadingUIText(text: string);
  38453. get loadingUIText(): string;
  38454. /**
  38455. * Gets or sets the color to use for the background
  38456. */
  38457. get loadingUIBackgroundColor(): string;
  38458. set loadingUIBackgroundColor(color: string);
  38459. private _resizeLoadingUI;
  38460. }
  38461. }
  38462. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38463. /**
  38464. * Interface for any object that can request an animation frame
  38465. */
  38466. export interface ICustomAnimationFrameRequester {
  38467. /**
  38468. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38469. */
  38470. renderFunction?: Function;
  38471. /**
  38472. * Called to request the next frame to render to
  38473. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38474. */
  38475. requestAnimationFrame: Function;
  38476. /**
  38477. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38478. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38479. */
  38480. requestID?: number;
  38481. }
  38482. }
  38483. declare module "babylonjs/Misc/performanceMonitor" {
  38484. /**
  38485. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38486. */
  38487. export class PerformanceMonitor {
  38488. private _enabled;
  38489. private _rollingFrameTime;
  38490. private _lastFrameTimeMs;
  38491. /**
  38492. * constructor
  38493. * @param frameSampleSize The number of samples required to saturate the sliding window
  38494. */
  38495. constructor(frameSampleSize?: number);
  38496. /**
  38497. * Samples current frame
  38498. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38499. */
  38500. sampleFrame(timeMs?: number): void;
  38501. /**
  38502. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38503. */
  38504. get averageFrameTime(): number;
  38505. /**
  38506. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38507. */
  38508. get averageFrameTimeVariance(): number;
  38509. /**
  38510. * Returns the frame time of the most recent frame
  38511. */
  38512. get instantaneousFrameTime(): number;
  38513. /**
  38514. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38515. */
  38516. get averageFPS(): number;
  38517. /**
  38518. * Returns the average framerate in frames per second using the most recent frame time
  38519. */
  38520. get instantaneousFPS(): number;
  38521. /**
  38522. * Returns true if enough samples have been taken to completely fill the sliding window
  38523. */
  38524. get isSaturated(): boolean;
  38525. /**
  38526. * Enables contributions to the sliding window sample set
  38527. */
  38528. enable(): void;
  38529. /**
  38530. * Disables contributions to the sliding window sample set
  38531. * Samples will not be interpolated over the disabled period
  38532. */
  38533. disable(): void;
  38534. /**
  38535. * Returns true if sampling is enabled
  38536. */
  38537. get isEnabled(): boolean;
  38538. /**
  38539. * Resets performance monitor
  38540. */
  38541. reset(): void;
  38542. }
  38543. /**
  38544. * RollingAverage
  38545. *
  38546. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38547. */
  38548. export class RollingAverage {
  38549. /**
  38550. * Current average
  38551. */
  38552. average: number;
  38553. /**
  38554. * Current variance
  38555. */
  38556. variance: number;
  38557. protected _samples: Array<number>;
  38558. protected _sampleCount: number;
  38559. protected _pos: number;
  38560. protected _m2: number;
  38561. /**
  38562. * constructor
  38563. * @param length The number of samples required to saturate the sliding window
  38564. */
  38565. constructor(length: number);
  38566. /**
  38567. * Adds a sample to the sample set
  38568. * @param v The sample value
  38569. */
  38570. add(v: number): void;
  38571. /**
  38572. * Returns previously added values or null if outside of history or outside the sliding window domain
  38573. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38574. * @return Value previously recorded with add() or null if outside of range
  38575. */
  38576. history(i: number): number;
  38577. /**
  38578. * Returns true if enough samples have been taken to completely fill the sliding window
  38579. * @return true if sample-set saturated
  38580. */
  38581. isSaturated(): boolean;
  38582. /**
  38583. * Resets the rolling average (equivalent to 0 samples taken so far)
  38584. */
  38585. reset(): void;
  38586. /**
  38587. * Wraps a value around the sample range boundaries
  38588. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38589. * @return Wrapped position in sample range
  38590. */
  38591. protected _wrapPosition(i: number): number;
  38592. }
  38593. }
  38594. declare module "babylonjs/Misc/perfCounter" {
  38595. /**
  38596. * This class is used to track a performance counter which is number based.
  38597. * The user has access to many properties which give statistics of different nature.
  38598. *
  38599. * The implementer can track two kinds of Performance Counter: time and count.
  38600. * 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.
  38601. * 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.
  38602. */
  38603. export class PerfCounter {
  38604. /**
  38605. * Gets or sets a global boolean to turn on and off all the counters
  38606. */
  38607. static Enabled: boolean;
  38608. /**
  38609. * Returns the smallest value ever
  38610. */
  38611. get min(): number;
  38612. /**
  38613. * Returns the biggest value ever
  38614. */
  38615. get max(): number;
  38616. /**
  38617. * Returns the average value since the performance counter is running
  38618. */
  38619. get average(): number;
  38620. /**
  38621. * Returns the average value of the last second the counter was monitored
  38622. */
  38623. get lastSecAverage(): number;
  38624. /**
  38625. * Returns the current value
  38626. */
  38627. get current(): number;
  38628. /**
  38629. * Gets the accumulated total
  38630. */
  38631. get total(): number;
  38632. /**
  38633. * Gets the total value count
  38634. */
  38635. get count(): number;
  38636. /**
  38637. * Creates a new counter
  38638. */
  38639. constructor();
  38640. /**
  38641. * Call this method to start monitoring a new frame.
  38642. * 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.
  38643. */
  38644. fetchNewFrame(): void;
  38645. /**
  38646. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38647. * @param newCount the count value to add to the monitored count
  38648. * @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.
  38649. */
  38650. addCount(newCount: number, fetchResult: boolean): void;
  38651. /**
  38652. * Start monitoring this performance counter
  38653. */
  38654. beginMonitoring(): void;
  38655. /**
  38656. * Compute the time lapsed since the previous beginMonitoring() call.
  38657. * @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
  38658. */
  38659. endMonitoring(newFrame?: boolean): void;
  38660. private _fetchResult;
  38661. private _startMonitoringTime;
  38662. private _min;
  38663. private _max;
  38664. private _average;
  38665. private _current;
  38666. private _totalValueCount;
  38667. private _totalAccumulated;
  38668. private _lastSecAverage;
  38669. private _lastSecAccumulated;
  38670. private _lastSecTime;
  38671. private _lastSecValueCount;
  38672. }
  38673. }
  38674. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38676. import { Nullable } from "babylonjs/types";
  38677. module "babylonjs/Engines/thinEngine" {
  38678. interface ThinEngine {
  38679. /** @hidden */
  38680. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38681. }
  38682. }
  38683. }
  38684. declare module "babylonjs/Engines/engine" {
  38685. import { Observable } from "babylonjs/Misc/observable";
  38686. import { Nullable } from "babylonjs/types";
  38687. import { Scene } from "babylonjs/scene";
  38688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38689. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38690. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38691. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38692. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38693. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38694. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38695. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38696. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38698. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38699. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38700. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38701. import "babylonjs/Engines/Extensions/engine.alpha";
  38702. import "babylonjs/Engines/Extensions/engine.readTexture";
  38703. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38704. import { Material } from "babylonjs/Materials/material";
  38705. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38706. /**
  38707. * Defines the interface used by display changed events
  38708. */
  38709. export interface IDisplayChangedEventArgs {
  38710. /** Gets the vrDisplay object (if any) */
  38711. vrDisplay: Nullable<any>;
  38712. /** Gets a boolean indicating if webVR is supported */
  38713. vrSupported: boolean;
  38714. }
  38715. /**
  38716. * Defines the interface used by objects containing a viewport (like a camera)
  38717. */
  38718. interface IViewportOwnerLike {
  38719. /**
  38720. * Gets or sets the viewport
  38721. */
  38722. viewport: IViewportLike;
  38723. }
  38724. /**
  38725. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38726. */
  38727. export class Engine extends ThinEngine {
  38728. /** Defines that alpha blending is disabled */
  38729. static readonly ALPHA_DISABLE: number;
  38730. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38731. static readonly ALPHA_ADD: number;
  38732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38733. static readonly ALPHA_COMBINE: number;
  38734. /** Defines that alpha blending to DEST - SRC * DEST */
  38735. static readonly ALPHA_SUBTRACT: number;
  38736. /** Defines that alpha blending to SRC * DEST */
  38737. static readonly ALPHA_MULTIPLY: number;
  38738. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38739. static readonly ALPHA_MAXIMIZED: number;
  38740. /** Defines that alpha blending to SRC + DEST */
  38741. static readonly ALPHA_ONEONE: number;
  38742. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38743. static readonly ALPHA_PREMULTIPLIED: number;
  38744. /**
  38745. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38746. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38747. */
  38748. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38749. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38750. static readonly ALPHA_INTERPOLATE: number;
  38751. /**
  38752. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38753. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38754. */
  38755. static readonly ALPHA_SCREENMODE: number;
  38756. /** Defines that the ressource is not delayed*/
  38757. static readonly DELAYLOADSTATE_NONE: number;
  38758. /** Defines that the ressource was successfully delay loaded */
  38759. static readonly DELAYLOADSTATE_LOADED: number;
  38760. /** Defines that the ressource is currently delay loading */
  38761. static readonly DELAYLOADSTATE_LOADING: number;
  38762. /** Defines that the ressource is delayed and has not started loading */
  38763. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38765. static readonly NEVER: number;
  38766. /** 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 */
  38767. static readonly ALWAYS: number;
  38768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38769. static readonly LESS: number;
  38770. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38771. static readonly EQUAL: number;
  38772. /** 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 */
  38773. static readonly LEQUAL: number;
  38774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38775. static readonly GREATER: number;
  38776. /** 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 */
  38777. static readonly GEQUAL: number;
  38778. /** 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 */
  38779. static readonly NOTEQUAL: number;
  38780. /** Passed to stencilOperation to specify that stencil value must be kept */
  38781. static readonly KEEP: number;
  38782. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38783. static readonly REPLACE: number;
  38784. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38785. static readonly INCR: number;
  38786. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38787. static readonly DECR: number;
  38788. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38789. static readonly INVERT: number;
  38790. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38791. static readonly INCR_WRAP: number;
  38792. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38793. static readonly DECR_WRAP: number;
  38794. /** Texture is not repeating outside of 0..1 UVs */
  38795. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38796. /** Texture is repeating outside of 0..1 UVs */
  38797. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38798. /** Texture is repeating and mirrored */
  38799. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38800. /** ALPHA */
  38801. static readonly TEXTUREFORMAT_ALPHA: number;
  38802. /** LUMINANCE */
  38803. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38804. /** LUMINANCE_ALPHA */
  38805. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38806. /** RGB */
  38807. static readonly TEXTUREFORMAT_RGB: number;
  38808. /** RGBA */
  38809. static readonly TEXTUREFORMAT_RGBA: number;
  38810. /** RED */
  38811. static readonly TEXTUREFORMAT_RED: number;
  38812. /** RED (2nd reference) */
  38813. static readonly TEXTUREFORMAT_R: number;
  38814. /** RG */
  38815. static readonly TEXTUREFORMAT_RG: number;
  38816. /** RED_INTEGER */
  38817. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38818. /** RED_INTEGER (2nd reference) */
  38819. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38820. /** RG_INTEGER */
  38821. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38822. /** RGB_INTEGER */
  38823. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38824. /** RGBA_INTEGER */
  38825. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38826. /** UNSIGNED_BYTE */
  38827. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38828. /** UNSIGNED_BYTE (2nd reference) */
  38829. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38830. /** FLOAT */
  38831. static readonly TEXTURETYPE_FLOAT: number;
  38832. /** HALF_FLOAT */
  38833. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38834. /** BYTE */
  38835. static readonly TEXTURETYPE_BYTE: number;
  38836. /** SHORT */
  38837. static readonly TEXTURETYPE_SHORT: number;
  38838. /** UNSIGNED_SHORT */
  38839. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38840. /** INT */
  38841. static readonly TEXTURETYPE_INT: number;
  38842. /** UNSIGNED_INT */
  38843. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38844. /** UNSIGNED_SHORT_4_4_4_4 */
  38845. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38846. /** UNSIGNED_SHORT_5_5_5_1 */
  38847. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38848. /** UNSIGNED_SHORT_5_6_5 */
  38849. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38850. /** UNSIGNED_INT_2_10_10_10_REV */
  38851. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38852. /** UNSIGNED_INT_24_8 */
  38853. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38854. /** UNSIGNED_INT_10F_11F_11F_REV */
  38855. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38856. /** UNSIGNED_INT_5_9_9_9_REV */
  38857. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38858. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38859. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38860. /** nearest is mag = nearest and min = nearest and mip = linear */
  38861. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38863. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38864. /** Trilinear is mag = linear and min = linear and mip = linear */
  38865. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38866. /** nearest is mag = nearest and min = nearest and mip = linear */
  38867. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38869. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38870. /** Trilinear is mag = linear and min = linear and mip = linear */
  38871. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38872. /** mag = nearest and min = nearest and mip = nearest */
  38873. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38874. /** mag = nearest and min = linear and mip = nearest */
  38875. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38876. /** mag = nearest and min = linear and mip = linear */
  38877. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38878. /** mag = nearest and min = linear and mip = none */
  38879. static readonly TEXTURE_NEAREST_LINEAR: number;
  38880. /** mag = nearest and min = nearest and mip = none */
  38881. static readonly TEXTURE_NEAREST_NEAREST: number;
  38882. /** mag = linear and min = nearest and mip = nearest */
  38883. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38884. /** mag = linear and min = nearest and mip = linear */
  38885. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38886. /** mag = linear and min = linear and mip = none */
  38887. static readonly TEXTURE_LINEAR_LINEAR: number;
  38888. /** mag = linear and min = nearest and mip = none */
  38889. static readonly TEXTURE_LINEAR_NEAREST: number;
  38890. /** Explicit coordinates mode */
  38891. static readonly TEXTURE_EXPLICIT_MODE: number;
  38892. /** Spherical coordinates mode */
  38893. static readonly TEXTURE_SPHERICAL_MODE: number;
  38894. /** Planar coordinates mode */
  38895. static readonly TEXTURE_PLANAR_MODE: number;
  38896. /** Cubic coordinates mode */
  38897. static readonly TEXTURE_CUBIC_MODE: number;
  38898. /** Projection coordinates mode */
  38899. static readonly TEXTURE_PROJECTION_MODE: number;
  38900. /** Skybox coordinates mode */
  38901. static readonly TEXTURE_SKYBOX_MODE: number;
  38902. /** Inverse Cubic coordinates mode */
  38903. static readonly TEXTURE_INVCUBIC_MODE: number;
  38904. /** Equirectangular coordinates mode */
  38905. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38906. /** Equirectangular Fixed coordinates mode */
  38907. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38908. /** Equirectangular Fixed Mirrored coordinates mode */
  38909. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38910. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38911. static readonly SCALEMODE_FLOOR: number;
  38912. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38913. static readonly SCALEMODE_NEAREST: number;
  38914. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38915. static readonly SCALEMODE_CEILING: number;
  38916. /**
  38917. * Returns the current npm package of the sdk
  38918. */
  38919. static get NpmPackage(): string;
  38920. /**
  38921. * Returns the current version of the framework
  38922. */
  38923. static get Version(): string;
  38924. /** Gets the list of created engines */
  38925. static get Instances(): Engine[];
  38926. /**
  38927. * Gets the latest created engine
  38928. */
  38929. static get LastCreatedEngine(): Nullable<Engine>;
  38930. /**
  38931. * Gets the latest created scene
  38932. */
  38933. static get LastCreatedScene(): Nullable<Scene>;
  38934. /**
  38935. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38936. * @param flag defines which part of the materials must be marked as dirty
  38937. * @param predicate defines a predicate used to filter which materials should be affected
  38938. */
  38939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38940. /**
  38941. * Method called to create the default loading screen.
  38942. * This can be overriden in your own app.
  38943. * @param canvas The rendering canvas element
  38944. * @returns The loading screen
  38945. */
  38946. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38947. /**
  38948. * Method called to create the default rescale post process on each engine.
  38949. */
  38950. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38951. /**
  38952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38953. **/
  38954. enableOfflineSupport: boolean;
  38955. /**
  38956. * 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)
  38957. **/
  38958. disableManifestCheck: boolean;
  38959. /**
  38960. * Gets the list of created scenes
  38961. */
  38962. scenes: Scene[];
  38963. /**
  38964. * Event raised when a new scene is created
  38965. */
  38966. onNewSceneAddedObservable: Observable<Scene>;
  38967. /**
  38968. * Gets the list of created postprocesses
  38969. */
  38970. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38971. /**
  38972. * Gets a boolean indicating if the pointer is currently locked
  38973. */
  38974. isPointerLock: boolean;
  38975. /**
  38976. * Observable event triggered each time the rendering canvas is resized
  38977. */
  38978. onResizeObservable: Observable<Engine>;
  38979. /**
  38980. * Observable event triggered each time the canvas loses focus
  38981. */
  38982. onCanvasBlurObservable: Observable<Engine>;
  38983. /**
  38984. * Observable event triggered each time the canvas gains focus
  38985. */
  38986. onCanvasFocusObservable: Observable<Engine>;
  38987. /**
  38988. * Observable event triggered each time the canvas receives pointerout event
  38989. */
  38990. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38991. /**
  38992. * Observable raised when the engine begins a new frame
  38993. */
  38994. onBeginFrameObservable: Observable<Engine>;
  38995. /**
  38996. * If set, will be used to request the next animation frame for the render loop
  38997. */
  38998. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38999. /**
  39000. * Observable raised when the engine ends the current frame
  39001. */
  39002. onEndFrameObservable: Observable<Engine>;
  39003. /**
  39004. * Observable raised when the engine is about to compile a shader
  39005. */
  39006. onBeforeShaderCompilationObservable: Observable<Engine>;
  39007. /**
  39008. * Observable raised when the engine has jsut compiled a shader
  39009. */
  39010. onAfterShaderCompilationObservable: Observable<Engine>;
  39011. /**
  39012. * Gets the audio engine
  39013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39014. * @ignorenaming
  39015. */
  39016. static audioEngine: IAudioEngine;
  39017. /**
  39018. * Default AudioEngine factory responsible of creating the Audio Engine.
  39019. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39020. */
  39021. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39022. /**
  39023. * Default offline support factory responsible of creating a tool used to store data locally.
  39024. * By default, this will create a Database object if the workload has been embedded.
  39025. */
  39026. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39027. private _loadingScreen;
  39028. private _pointerLockRequested;
  39029. private _rescalePostProcess;
  39030. private _deterministicLockstep;
  39031. private _lockstepMaxSteps;
  39032. private _timeStep;
  39033. protected get _supportsHardwareTextureRescaling(): boolean;
  39034. private _fps;
  39035. private _deltaTime;
  39036. /** @hidden */
  39037. _drawCalls: PerfCounter;
  39038. /** 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 */
  39039. canvasTabIndex: number;
  39040. /**
  39041. * Turn this value on if you want to pause FPS computation when in background
  39042. */
  39043. disablePerformanceMonitorInBackground: boolean;
  39044. private _performanceMonitor;
  39045. /**
  39046. * Gets the performance monitor attached to this engine
  39047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39048. */
  39049. get performanceMonitor(): PerformanceMonitor;
  39050. private _onFocus;
  39051. private _onBlur;
  39052. private _onCanvasPointerOut;
  39053. private _onCanvasBlur;
  39054. private _onCanvasFocus;
  39055. private _onFullscreenChange;
  39056. private _onPointerLockChange;
  39057. /**
  39058. * Gets the HTML element used to attach event listeners
  39059. * @returns a HTML element
  39060. */
  39061. getInputElement(): Nullable<HTMLElement>;
  39062. /**
  39063. * Creates a new engine
  39064. * @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
  39065. * @param antialias defines enable antialiasing (default: false)
  39066. * @param options defines further options to be sent to the getContext() function
  39067. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39068. */
  39069. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39070. /**
  39071. * Gets current aspect ratio
  39072. * @param viewportOwner defines the camera to use to get the aspect ratio
  39073. * @param useScreen defines if screen size must be used (or the current render target if any)
  39074. * @returns a number defining the aspect ratio
  39075. */
  39076. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39077. /**
  39078. * Gets current screen aspect ratio
  39079. * @returns a number defining the aspect ratio
  39080. */
  39081. getScreenAspectRatio(): number;
  39082. /**
  39083. * Gets the client rect of the HTML canvas attached with the current webGL context
  39084. * @returns a client rectanglee
  39085. */
  39086. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39087. /**
  39088. * Gets the client rect of the HTML element used for events
  39089. * @returns a client rectanglee
  39090. */
  39091. getInputElementClientRect(): Nullable<ClientRect>;
  39092. /**
  39093. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39095. * @returns true if engine is in deterministic lock step mode
  39096. */
  39097. isDeterministicLockStep(): boolean;
  39098. /**
  39099. * Gets the max steps when engine is running in deterministic lock step
  39100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39101. * @returns the max steps
  39102. */
  39103. getLockstepMaxSteps(): number;
  39104. /**
  39105. * Returns the time in ms between steps when using deterministic lock step.
  39106. * @returns time step in (ms)
  39107. */
  39108. getTimeStep(): number;
  39109. /**
  39110. * Force the mipmap generation for the given render target texture
  39111. * @param texture defines the render target texture to use
  39112. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39113. */
  39114. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39115. /** States */
  39116. /**
  39117. * Set various states to the webGL context
  39118. * @param culling defines backface culling state
  39119. * @param zOffset defines the value to apply to zOffset (0 by default)
  39120. * @param force defines if states must be applied even if cache is up to date
  39121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39122. */
  39123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39124. /**
  39125. * Set the z offset to apply to current rendering
  39126. * @param value defines the offset to apply
  39127. */
  39128. setZOffset(value: number): void;
  39129. /**
  39130. * Gets the current value of the zOffset
  39131. * @returns the current zOffset state
  39132. */
  39133. getZOffset(): number;
  39134. /**
  39135. * Enable or disable depth buffering
  39136. * @param enable defines the state to set
  39137. */
  39138. setDepthBuffer(enable: boolean): void;
  39139. /**
  39140. * Gets a boolean indicating if depth writing is enabled
  39141. * @returns the current depth writing state
  39142. */
  39143. getDepthWrite(): boolean;
  39144. /**
  39145. * Enable or disable depth writing
  39146. * @param enable defines the state to set
  39147. */
  39148. setDepthWrite(enable: boolean): void;
  39149. /**
  39150. * Gets a boolean indicating if stencil buffer is enabled
  39151. * @returns the current stencil buffer state
  39152. */
  39153. getStencilBuffer(): boolean;
  39154. /**
  39155. * Enable or disable the stencil buffer
  39156. * @param enable defines if the stencil buffer must be enabled or disabled
  39157. */
  39158. setStencilBuffer(enable: boolean): void;
  39159. /**
  39160. * Gets the current stencil mask
  39161. * @returns a number defining the new stencil mask to use
  39162. */
  39163. getStencilMask(): number;
  39164. /**
  39165. * Sets the current stencil mask
  39166. * @param mask defines the new stencil mask to use
  39167. */
  39168. setStencilMask(mask: number): void;
  39169. /**
  39170. * Gets the current stencil function
  39171. * @returns a number defining the stencil function to use
  39172. */
  39173. getStencilFunction(): number;
  39174. /**
  39175. * Gets the current stencil reference value
  39176. * @returns a number defining the stencil reference value to use
  39177. */
  39178. getStencilFunctionReference(): number;
  39179. /**
  39180. * Gets the current stencil mask
  39181. * @returns a number defining the stencil mask to use
  39182. */
  39183. getStencilFunctionMask(): number;
  39184. /**
  39185. * Sets the current stencil function
  39186. * @param stencilFunc defines the new stencil function to use
  39187. */
  39188. setStencilFunction(stencilFunc: number): void;
  39189. /**
  39190. * Sets the current stencil reference
  39191. * @param reference defines the new stencil reference to use
  39192. */
  39193. setStencilFunctionReference(reference: number): void;
  39194. /**
  39195. * Sets the current stencil mask
  39196. * @param mask defines the new stencil mask to use
  39197. */
  39198. setStencilFunctionMask(mask: number): void;
  39199. /**
  39200. * Gets the current stencil operation when stencil fails
  39201. * @returns a number defining stencil operation to use when stencil fails
  39202. */
  39203. getStencilOperationFail(): number;
  39204. /**
  39205. * Gets the current stencil operation when depth fails
  39206. * @returns a number defining stencil operation to use when depth fails
  39207. */
  39208. getStencilOperationDepthFail(): number;
  39209. /**
  39210. * Gets the current stencil operation when stencil passes
  39211. * @returns a number defining stencil operation to use when stencil passes
  39212. */
  39213. getStencilOperationPass(): number;
  39214. /**
  39215. * Sets the stencil operation to use when stencil fails
  39216. * @param operation defines the stencil operation to use when stencil fails
  39217. */
  39218. setStencilOperationFail(operation: number): void;
  39219. /**
  39220. * Sets the stencil operation to use when depth fails
  39221. * @param operation defines the stencil operation to use when depth fails
  39222. */
  39223. setStencilOperationDepthFail(operation: number): void;
  39224. /**
  39225. * Sets the stencil operation to use when stencil passes
  39226. * @param operation defines the stencil operation to use when stencil passes
  39227. */
  39228. setStencilOperationPass(operation: number): void;
  39229. /**
  39230. * Sets a boolean indicating if the dithering state is enabled or disabled
  39231. * @param value defines the dithering state
  39232. */
  39233. setDitheringState(value: boolean): void;
  39234. /**
  39235. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39236. * @param value defines the rasterizer state
  39237. */
  39238. setRasterizerState(value: boolean): void;
  39239. /**
  39240. * Gets the current depth function
  39241. * @returns a number defining the depth function
  39242. */
  39243. getDepthFunction(): Nullable<number>;
  39244. /**
  39245. * Sets the current depth function
  39246. * @param depthFunc defines the function to use
  39247. */
  39248. setDepthFunction(depthFunc: number): void;
  39249. /**
  39250. * Sets the current depth function to GREATER
  39251. */
  39252. setDepthFunctionToGreater(): void;
  39253. /**
  39254. * Sets the current depth function to GEQUAL
  39255. */
  39256. setDepthFunctionToGreaterOrEqual(): void;
  39257. /**
  39258. * Sets the current depth function to LESS
  39259. */
  39260. setDepthFunctionToLess(): void;
  39261. /**
  39262. * Sets the current depth function to LEQUAL
  39263. */
  39264. setDepthFunctionToLessOrEqual(): void;
  39265. private _cachedStencilBuffer;
  39266. private _cachedStencilFunction;
  39267. private _cachedStencilMask;
  39268. private _cachedStencilOperationPass;
  39269. private _cachedStencilOperationFail;
  39270. private _cachedStencilOperationDepthFail;
  39271. private _cachedStencilReference;
  39272. /**
  39273. * Caches the the state of the stencil buffer
  39274. */
  39275. cacheStencilState(): void;
  39276. /**
  39277. * Restores the state of the stencil buffer
  39278. */
  39279. restoreStencilState(): void;
  39280. /**
  39281. * Directly set the WebGL Viewport
  39282. * @param x defines the x coordinate of the viewport (in screen space)
  39283. * @param y defines the y coordinate of the viewport (in screen space)
  39284. * @param width defines the width of the viewport (in screen space)
  39285. * @param height defines the height of the viewport (in screen space)
  39286. * @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
  39287. */
  39288. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39289. /**
  39290. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39291. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39292. * @param y defines the y-coordinate of the corner of the clear rectangle
  39293. * @param width defines the width of the clear rectangle
  39294. * @param height defines the height of the clear rectangle
  39295. * @param clearColor defines the clear color
  39296. */
  39297. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39298. /**
  39299. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39300. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39301. * @param y defines the y-coordinate of the corner of the clear rectangle
  39302. * @param width defines the width of the clear rectangle
  39303. * @param height defines the height of the clear rectangle
  39304. */
  39305. enableScissor(x: number, y: number, width: number, height: number): void;
  39306. /**
  39307. * Disable previously set scissor test rectangle
  39308. */
  39309. disableScissor(): void;
  39310. protected _reportDrawCall(): void;
  39311. /**
  39312. * Initializes a webVR display and starts listening to display change events
  39313. * The onVRDisplayChangedObservable will be notified upon these changes
  39314. * @returns The onVRDisplayChangedObservable
  39315. */
  39316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39317. /** @hidden */
  39318. _prepareVRComponent(): void;
  39319. /** @hidden */
  39320. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39321. /** @hidden */
  39322. _submitVRFrame(): void;
  39323. /**
  39324. * Call this function to leave webVR mode
  39325. * Will do nothing if webVR is not supported or if there is no webVR device
  39326. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39327. */
  39328. disableVR(): void;
  39329. /**
  39330. * Gets a boolean indicating that the system is in VR mode and is presenting
  39331. * @returns true if VR mode is engaged
  39332. */
  39333. isVRPresenting(): boolean;
  39334. /** @hidden */
  39335. _requestVRFrame(): void;
  39336. /** @hidden */
  39337. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39338. /**
  39339. * Gets the source code of the vertex shader associated with a specific webGL program
  39340. * @param program defines the program to use
  39341. * @returns a string containing the source code of the vertex shader associated with the program
  39342. */
  39343. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39344. /**
  39345. * Gets the source code of the fragment shader associated with a specific webGL program
  39346. * @param program defines the program to use
  39347. * @returns a string containing the source code of the fragment shader associated with the program
  39348. */
  39349. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39350. /**
  39351. * Sets a depth stencil texture from a render target to the according uniform.
  39352. * @param channel The texture channel
  39353. * @param uniform The uniform to set
  39354. * @param texture The render target texture containing the depth stencil texture to apply
  39355. */
  39356. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39357. /**
  39358. * Sets a texture to the webGL context from a postprocess
  39359. * @param channel defines the channel to use
  39360. * @param postProcess defines the source postprocess
  39361. */
  39362. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39363. /**
  39364. * Binds the output of the passed in post process to the texture channel specified
  39365. * @param channel The channel the texture should be bound to
  39366. * @param postProcess The post process which's output should be bound
  39367. */
  39368. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39369. protected _rebuildBuffers(): void;
  39370. /** @hidden */
  39371. _renderFrame(): void;
  39372. _renderLoop(): void;
  39373. /** @hidden */
  39374. _renderViews(): boolean;
  39375. /**
  39376. * Toggle full screen mode
  39377. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39378. */
  39379. switchFullscreen(requestPointerLock: boolean): void;
  39380. /**
  39381. * Enters full screen mode
  39382. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39383. */
  39384. enterFullscreen(requestPointerLock: boolean): void;
  39385. /**
  39386. * Exits full screen mode
  39387. */
  39388. exitFullscreen(): void;
  39389. /**
  39390. * Enters Pointerlock mode
  39391. */
  39392. enterPointerlock(): void;
  39393. /**
  39394. * Exits Pointerlock mode
  39395. */
  39396. exitPointerlock(): void;
  39397. /**
  39398. * Begin a new frame
  39399. */
  39400. beginFrame(): void;
  39401. /**
  39402. * Enf the current frame
  39403. */
  39404. endFrame(): void;
  39405. resize(): void;
  39406. /**
  39407. * Force a specific size of the canvas
  39408. * @param width defines the new canvas' width
  39409. * @param height defines the new canvas' height
  39410. * @returns true if the size was changed
  39411. */
  39412. setSize(width: number, height: number): boolean;
  39413. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39415. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39416. _releaseTexture(texture: InternalTexture): void;
  39417. /**
  39418. * @hidden
  39419. * Rescales a texture
  39420. * @param source input texutre
  39421. * @param destination destination texture
  39422. * @param scene scene to use to render the resize
  39423. * @param internalFormat format to use when resizing
  39424. * @param onComplete callback to be called when resize has completed
  39425. */
  39426. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39427. /**
  39428. * Gets the current framerate
  39429. * @returns a number representing the framerate
  39430. */
  39431. getFps(): number;
  39432. /**
  39433. * Gets the time spent between current and previous frame
  39434. * @returns a number representing the delta time in ms
  39435. */
  39436. getDeltaTime(): number;
  39437. private _measureFps;
  39438. /** @hidden */
  39439. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39440. /**
  39441. * Updates the sample count of a render target texture
  39442. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39443. * @param texture defines the texture to update
  39444. * @param samples defines the sample count to set
  39445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39446. */
  39447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39448. /**
  39449. * Updates a depth texture Comparison Mode and Function.
  39450. * If the comparison Function is equal to 0, the mode will be set to none.
  39451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39452. * @param texture The texture to set the comparison function for
  39453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39454. */
  39455. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39456. /**
  39457. * Creates a webGL buffer to use with instanciation
  39458. * @param capacity defines the size of the buffer
  39459. * @returns the webGL buffer
  39460. */
  39461. createInstancesBuffer(capacity: number): DataBuffer;
  39462. /**
  39463. * Delete a webGL buffer used with instanciation
  39464. * @param buffer defines the webGL buffer to delete
  39465. */
  39466. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39467. private _clientWaitAsync;
  39468. /** @hidden */
  39469. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39470. dispose(): void;
  39471. private _disableTouchAction;
  39472. /**
  39473. * Display the loading screen
  39474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39475. */
  39476. displayLoadingUI(): void;
  39477. /**
  39478. * Hide the loading screen
  39479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39480. */
  39481. hideLoadingUI(): void;
  39482. /**
  39483. * Gets the current loading screen object
  39484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39485. */
  39486. get loadingScreen(): ILoadingScreen;
  39487. /**
  39488. * Sets the current loading screen object
  39489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39490. */
  39491. set loadingScreen(loadingScreen: ILoadingScreen);
  39492. /**
  39493. * Sets the current loading screen text
  39494. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39495. */
  39496. set loadingUIText(text: string);
  39497. /**
  39498. * Sets the current loading screen background color
  39499. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39500. */
  39501. set loadingUIBackgroundColor(color: string);
  39502. /** Pointerlock and fullscreen */
  39503. /**
  39504. * Ask the browser to promote the current element to pointerlock mode
  39505. * @param element defines the DOM element to promote
  39506. */
  39507. static _RequestPointerlock(element: HTMLElement): void;
  39508. /**
  39509. * Asks the browser to exit pointerlock mode
  39510. */
  39511. static _ExitPointerlock(): void;
  39512. /**
  39513. * Ask the browser to promote the current element to fullscreen rendering mode
  39514. * @param element defines the DOM element to promote
  39515. */
  39516. static _RequestFullscreen(element: HTMLElement): void;
  39517. /**
  39518. * Asks the browser to exit fullscreen mode
  39519. */
  39520. static _ExitFullscreen(): void;
  39521. }
  39522. }
  39523. declare module "babylonjs/Engines/engineStore" {
  39524. import { Nullable } from "babylonjs/types";
  39525. import { Engine } from "babylonjs/Engines/engine";
  39526. import { Scene } from "babylonjs/scene";
  39527. /**
  39528. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39529. * during the life time of the application.
  39530. */
  39531. export class EngineStore {
  39532. /** Gets the list of created engines */
  39533. static Instances: import("babylonjs/Engines/engine").Engine[];
  39534. /** @hidden */
  39535. static _LastCreatedScene: Nullable<Scene>;
  39536. /**
  39537. * Gets the latest created engine
  39538. */
  39539. static get LastCreatedEngine(): Nullable<Engine>;
  39540. /**
  39541. * Gets the latest created scene
  39542. */
  39543. static get LastCreatedScene(): Nullable<Scene>;
  39544. /**
  39545. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39546. * @ignorenaming
  39547. */
  39548. static UseFallbackTexture: boolean;
  39549. /**
  39550. * Texture content used if a texture cannot loaded
  39551. * @ignorenaming
  39552. */
  39553. static FallbackTexture: string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Misc/promise" {
  39557. /**
  39558. * Helper class that provides a small promise polyfill
  39559. */
  39560. export class PromisePolyfill {
  39561. /**
  39562. * Static function used to check if the polyfill is required
  39563. * If this is the case then the function will inject the polyfill to window.Promise
  39564. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39565. */
  39566. static Apply(force?: boolean): void;
  39567. }
  39568. }
  39569. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39570. /**
  39571. * Interface for screenshot methods with describe argument called `size` as object with options
  39572. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39573. */
  39574. export interface IScreenshotSize {
  39575. /**
  39576. * number in pixels for canvas height
  39577. */
  39578. height?: number;
  39579. /**
  39580. * multiplier allowing render at a higher or lower resolution
  39581. * If value is defined then height and width will be ignored and taken from camera
  39582. */
  39583. precision?: number;
  39584. /**
  39585. * number in pixels for canvas width
  39586. */
  39587. width?: number;
  39588. }
  39589. }
  39590. declare module "babylonjs/Misc/tools" {
  39591. import { Nullable, float } from "babylonjs/types";
  39592. import { DomManagement } from "babylonjs/Misc/domManagement";
  39593. import { WebRequest } from "babylonjs/Misc/webRequest";
  39594. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39595. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39596. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39597. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39598. import { Camera } from "babylonjs/Cameras/camera";
  39599. import { Engine } from "babylonjs/Engines/engine";
  39600. interface IColor4Like {
  39601. r: float;
  39602. g: float;
  39603. b: float;
  39604. a: float;
  39605. }
  39606. /**
  39607. * Class containing a set of static utilities functions
  39608. */
  39609. export class Tools {
  39610. /**
  39611. * Gets or sets the base URL to use to load assets
  39612. */
  39613. static get BaseUrl(): string;
  39614. static set BaseUrl(value: string);
  39615. /**
  39616. * Enable/Disable Custom HTTP Request Headers globally.
  39617. * default = false
  39618. * @see CustomRequestHeaders
  39619. */
  39620. static UseCustomRequestHeaders: boolean;
  39621. /**
  39622. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39623. * i.e. when loading files, where the server/service expects an Authorization header
  39624. */
  39625. static CustomRequestHeaders: {
  39626. [key: string]: string;
  39627. };
  39628. /**
  39629. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39630. */
  39631. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39632. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39633. /**
  39634. * Default behaviour for cors in the application.
  39635. * It can be a string if the expected behavior is identical in the entire app.
  39636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39637. */
  39638. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39639. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39640. /**
  39641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39642. * @ignorenaming
  39643. */
  39644. static get UseFallbackTexture(): boolean;
  39645. static set UseFallbackTexture(value: boolean);
  39646. /**
  39647. * Use this object to register external classes like custom textures or material
  39648. * to allow the laoders to instantiate them
  39649. */
  39650. static get RegisteredExternalClasses(): {
  39651. [key: string]: Object;
  39652. };
  39653. static set RegisteredExternalClasses(classes: {
  39654. [key: string]: Object;
  39655. });
  39656. /**
  39657. * Texture content used if a texture cannot loaded
  39658. * @ignorenaming
  39659. */
  39660. static get fallbackTexture(): string;
  39661. static set fallbackTexture(value: string);
  39662. /**
  39663. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39664. * @param u defines the coordinate on X axis
  39665. * @param v defines the coordinate on Y axis
  39666. * @param width defines the width of the source data
  39667. * @param height defines the height of the source data
  39668. * @param pixels defines the source byte array
  39669. * @param color defines the output color
  39670. */
  39671. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39672. /**
  39673. * Interpolates between a and b via alpha
  39674. * @param a The lower value (returned when alpha = 0)
  39675. * @param b The upper value (returned when alpha = 1)
  39676. * @param alpha The interpolation-factor
  39677. * @return The mixed value
  39678. */
  39679. static Mix(a: number, b: number, alpha: number): number;
  39680. /**
  39681. * Tries to instantiate a new object from a given class name
  39682. * @param className defines the class name to instantiate
  39683. * @returns the new object or null if the system was not able to do the instantiation
  39684. */
  39685. static Instantiate(className: string): any;
  39686. /**
  39687. * Provides a slice function that will work even on IE
  39688. * @param data defines the array to slice
  39689. * @param start defines the start of the data (optional)
  39690. * @param end defines the end of the data (optional)
  39691. * @returns the new sliced array
  39692. */
  39693. static Slice<T>(data: T, start?: number, end?: number): T;
  39694. /**
  39695. * Polyfill for setImmediate
  39696. * @param action defines the action to execute after the current execution block
  39697. */
  39698. static SetImmediate(action: () => void): void;
  39699. /**
  39700. * Function indicating if a number is an exponent of 2
  39701. * @param value defines the value to test
  39702. * @returns true if the value is an exponent of 2
  39703. */
  39704. static IsExponentOfTwo(value: number): boolean;
  39705. private static _tmpFloatArray;
  39706. /**
  39707. * Returns the nearest 32-bit single precision float representation of a Number
  39708. * @param value A Number. If the parameter is of a different type, it will get converted
  39709. * to a number or to NaN if it cannot be converted
  39710. * @returns number
  39711. */
  39712. static FloatRound(value: number): number;
  39713. /**
  39714. * Extracts the filename from a path
  39715. * @param path defines the path to use
  39716. * @returns the filename
  39717. */
  39718. static GetFilename(path: string): string;
  39719. /**
  39720. * Extracts the "folder" part of a path (everything before the filename).
  39721. * @param uri The URI to extract the info from
  39722. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39723. * @returns The "folder" part of the path
  39724. */
  39725. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39726. /**
  39727. * Extracts text content from a DOM element hierarchy
  39728. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39729. */
  39730. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39731. /**
  39732. * Convert an angle in radians to degrees
  39733. * @param angle defines the angle to convert
  39734. * @returns the angle in degrees
  39735. */
  39736. static ToDegrees(angle: number): number;
  39737. /**
  39738. * Convert an angle in degrees to radians
  39739. * @param angle defines the angle to convert
  39740. * @returns the angle in radians
  39741. */
  39742. static ToRadians(angle: number): number;
  39743. /**
  39744. * Returns an array if obj is not an array
  39745. * @param obj defines the object to evaluate as an array
  39746. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39747. * @returns either obj directly if obj is an array or a new array containing obj
  39748. */
  39749. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39750. /**
  39751. * Gets the pointer prefix to use
  39752. * @param engine defines the engine we are finding the prefix for
  39753. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39754. */
  39755. static GetPointerPrefix(engine: Engine): string;
  39756. /**
  39757. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39758. * @param url define the url we are trying
  39759. * @param element define the dom element where to configure the cors policy
  39760. */
  39761. static SetCorsBehavior(url: string | string[], element: {
  39762. crossOrigin: string | null;
  39763. }): void;
  39764. /**
  39765. * Removes unwanted characters from an url
  39766. * @param url defines the url to clean
  39767. * @returns the cleaned url
  39768. */
  39769. static CleanUrl(url: string): string;
  39770. /**
  39771. * Gets or sets a function used to pre-process url before using them to load assets
  39772. */
  39773. static get PreprocessUrl(): (url: string) => string;
  39774. static set PreprocessUrl(processor: (url: string) => string);
  39775. /**
  39776. * Loads an image as an HTMLImageElement.
  39777. * @param input url string, ArrayBuffer, or Blob to load
  39778. * @param onLoad callback called when the image successfully loads
  39779. * @param onError callback called when the image fails to load
  39780. * @param offlineProvider offline provider for caching
  39781. * @param mimeType optional mime type
  39782. * @returns the HTMLImageElement of the loaded image
  39783. */
  39784. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39785. /**
  39786. * Loads a file from a url
  39787. * @param url url string, ArrayBuffer, or Blob to load
  39788. * @param onSuccess callback called when the file successfully loads
  39789. * @param onProgress callback called while file is loading (if the server supports this mode)
  39790. * @param offlineProvider defines the offline provider for caching
  39791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39792. * @param onError callback called when the file fails to load
  39793. * @returns a file request object
  39794. */
  39795. 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;
  39796. /**
  39797. * Loads a file from a url
  39798. * @param url the file url to load
  39799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39800. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39801. */
  39802. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39803. /**
  39804. * Load a script (identified by an url). When the url returns, the
  39805. * content of this file is added into a new script element, attached to the DOM (body element)
  39806. * @param scriptUrl defines the url of the script to laod
  39807. * @param onSuccess defines the callback called when the script is loaded
  39808. * @param onError defines the callback to call if an error occurs
  39809. * @param scriptId defines the id of the script element
  39810. */
  39811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39812. /**
  39813. * Load an asynchronous script (identified by an url). When the url returns, the
  39814. * content of this file is added into a new script element, attached to the DOM (body element)
  39815. * @param scriptUrl defines the url of the script to laod
  39816. * @param scriptId defines the id of the script element
  39817. * @returns a promise request object
  39818. */
  39819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39820. /**
  39821. * Loads a file from a blob
  39822. * @param fileToLoad defines the blob to use
  39823. * @param callback defines the callback to call when data is loaded
  39824. * @param progressCallback defines the callback to call during loading process
  39825. * @returns a file request object
  39826. */
  39827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39828. /**
  39829. * Reads a file from a File object
  39830. * @param file defines the file to load
  39831. * @param onSuccess defines the callback to call when data is loaded
  39832. * @param onProgress defines the callback to call during loading process
  39833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39834. * @param onError defines the callback to call when an error occurs
  39835. * @returns a file request object
  39836. */
  39837. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39838. /**
  39839. * Creates a data url from a given string content
  39840. * @param content defines the content to convert
  39841. * @returns the new data url link
  39842. */
  39843. static FileAsURL(content: string): string;
  39844. /**
  39845. * Format the given number to a specific decimal format
  39846. * @param value defines the number to format
  39847. * @param decimals defines the number of decimals to use
  39848. * @returns the formatted string
  39849. */
  39850. static Format(value: number, decimals?: number): string;
  39851. /**
  39852. * Tries to copy an object by duplicating every property
  39853. * @param source defines the source object
  39854. * @param destination defines the target object
  39855. * @param doNotCopyList defines a list of properties to avoid
  39856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39857. */
  39858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39859. /**
  39860. * Gets a boolean indicating if the given object has no own property
  39861. * @param obj defines the object to test
  39862. * @returns true if object has no own property
  39863. */
  39864. static IsEmpty(obj: any): boolean;
  39865. /**
  39866. * Function used to register events at window level
  39867. * @param windowElement defines the Window object to use
  39868. * @param events defines the events to register
  39869. */
  39870. static RegisterTopRootEvents(windowElement: Window, events: {
  39871. name: string;
  39872. handler: Nullable<(e: FocusEvent) => any>;
  39873. }[]): void;
  39874. /**
  39875. * Function used to unregister events from window level
  39876. * @param windowElement defines the Window object to use
  39877. * @param events defines the events to unregister
  39878. */
  39879. static UnregisterTopRootEvents(windowElement: Window, events: {
  39880. name: string;
  39881. handler: Nullable<(e: FocusEvent) => any>;
  39882. }[]): void;
  39883. /**
  39884. * @ignore
  39885. */
  39886. static _ScreenshotCanvas: HTMLCanvasElement;
  39887. /**
  39888. * Dumps the current bound framebuffer
  39889. * @param width defines the rendering width
  39890. * @param height defines the rendering height
  39891. * @param engine defines the hosting engine
  39892. * @param successCallback defines the callback triggered once the data are available
  39893. * @param mimeType defines the mime type of the result
  39894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39895. */
  39896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39897. /**
  39898. * Converts the canvas data to blob.
  39899. * This acts as a polyfill for browsers not supporting the to blob function.
  39900. * @param canvas Defines the canvas to extract the data from
  39901. * @param successCallback Defines the callback triggered once the data are available
  39902. * @param mimeType Defines the mime type of the result
  39903. */
  39904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39905. /**
  39906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39907. * @param successCallback defines the callback triggered once the data are available
  39908. * @param mimeType defines the mime type of the result
  39909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39910. */
  39911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39912. /**
  39913. * Downloads a blob in the browser
  39914. * @param blob defines the blob to download
  39915. * @param fileName defines the name of the downloaded file
  39916. */
  39917. static Download(blob: Blob, fileName: string): void;
  39918. /**
  39919. * Captures a screenshot of the current rendering
  39920. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39921. * @param engine defines the rendering engine
  39922. * @param camera defines the source camera
  39923. * @param size This parameter can be set to a single number or to an object with the
  39924. * following (optional) properties: precision, width, height. If a single number is passed,
  39925. * it will be used for both width and height. If an object is passed, the screenshot size
  39926. * will be derived from the parameters. The precision property is a multiplier allowing
  39927. * rendering at a higher or lower resolution
  39928. * @param successCallback defines the callback receives a single parameter which contains the
  39929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39930. * src parameter of an <img> to display it
  39931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39932. * Check your browser for supported MIME types
  39933. */
  39934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39935. /**
  39936. * Captures a screenshot of the current rendering
  39937. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39938. * @param engine defines the rendering engine
  39939. * @param camera defines the source camera
  39940. * @param size This parameter can be set to a single number or to an object with the
  39941. * following (optional) properties: precision, width, height. If a single number is passed,
  39942. * it will be used for both width and height. If an object is passed, the screenshot size
  39943. * will be derived from the parameters. The precision property is a multiplier allowing
  39944. * rendering at a higher or lower resolution
  39945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39946. * Check your browser for supported MIME types
  39947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39948. * to the src parameter of an <img> to display it
  39949. */
  39950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39951. /**
  39952. * Generates an image screenshot from the specified camera.
  39953. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39954. * @param engine The engine to use for rendering
  39955. * @param camera The camera to use for rendering
  39956. * @param size This parameter can be set to a single number or to an object with the
  39957. * following (optional) properties: precision, width, height. If a single number is passed,
  39958. * it will be used for both width and height. If an object is passed, the screenshot size
  39959. * will be derived from the parameters. The precision property is a multiplier allowing
  39960. * rendering at a higher or lower resolution
  39961. * @param successCallback The callback receives a single parameter which contains the
  39962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39963. * src parameter of an <img> to display it
  39964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39965. * Check your browser for supported MIME types
  39966. * @param samples Texture samples (default: 1)
  39967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39968. * @param fileName A name for for the downloaded file.
  39969. */
  39970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39971. /**
  39972. * Generates an image screenshot from the specified camera.
  39973. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39974. * @param engine The engine to use for rendering
  39975. * @param camera The camera to use for rendering
  39976. * @param size This parameter can be set to a single number or to an object with the
  39977. * following (optional) properties: precision, width, height. If a single number is passed,
  39978. * it will be used for both width and height. If an object is passed, the screenshot size
  39979. * will be derived from the parameters. The precision property is a multiplier allowing
  39980. * rendering at a higher or lower resolution
  39981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39982. * Check your browser for supported MIME types
  39983. * @param samples Texture samples (default: 1)
  39984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39985. * @param fileName A name for for the downloaded file.
  39986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39987. * to the src parameter of an <img> to display it
  39988. */
  39989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39990. /**
  39991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39992. * Be aware Math.random() could cause collisions, but:
  39993. * "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"
  39994. * @returns a pseudo random id
  39995. */
  39996. static RandomId(): string;
  39997. /**
  39998. * Test if the given uri is a base64 string
  39999. * @param uri The uri to test
  40000. * @return True if the uri is a base64 string or false otherwise
  40001. */
  40002. static IsBase64(uri: string): boolean;
  40003. /**
  40004. * Decode the given base64 uri.
  40005. * @param uri The uri to decode
  40006. * @return The decoded base64 data.
  40007. */
  40008. static DecodeBase64(uri: string): ArrayBuffer;
  40009. /**
  40010. * Gets the absolute url.
  40011. * @param url the input url
  40012. * @return the absolute url
  40013. */
  40014. static GetAbsoluteUrl(url: string): string;
  40015. /**
  40016. * No log
  40017. */
  40018. static readonly NoneLogLevel: number;
  40019. /**
  40020. * Only message logs
  40021. */
  40022. static readonly MessageLogLevel: number;
  40023. /**
  40024. * Only warning logs
  40025. */
  40026. static readonly WarningLogLevel: number;
  40027. /**
  40028. * Only error logs
  40029. */
  40030. static readonly ErrorLogLevel: number;
  40031. /**
  40032. * All logs
  40033. */
  40034. static readonly AllLogLevel: number;
  40035. /**
  40036. * Gets a value indicating the number of loading errors
  40037. * @ignorenaming
  40038. */
  40039. static get errorsCount(): number;
  40040. /**
  40041. * Callback called when a new log is added
  40042. */
  40043. static OnNewCacheEntry: (entry: string) => void;
  40044. /**
  40045. * Log a message to the console
  40046. * @param message defines the message to log
  40047. */
  40048. static Log(message: string): void;
  40049. /**
  40050. * Write a warning message to the console
  40051. * @param message defines the message to log
  40052. */
  40053. static Warn(message: string): void;
  40054. /**
  40055. * Write an error message to the console
  40056. * @param message defines the message to log
  40057. */
  40058. static Error(message: string): void;
  40059. /**
  40060. * Gets current log cache (list of logs)
  40061. */
  40062. static get LogCache(): string;
  40063. /**
  40064. * Clears the log cache
  40065. */
  40066. static ClearLogCache(): void;
  40067. /**
  40068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40069. */
  40070. static set LogLevels(level: number);
  40071. /**
  40072. * Checks if the window object exists
  40073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40074. */
  40075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40076. /**
  40077. * No performance log
  40078. */
  40079. static readonly PerformanceNoneLogLevel: number;
  40080. /**
  40081. * Use user marks to log performance
  40082. */
  40083. static readonly PerformanceUserMarkLogLevel: number;
  40084. /**
  40085. * Log performance to the console
  40086. */
  40087. static readonly PerformanceConsoleLogLevel: number;
  40088. private static _performance;
  40089. /**
  40090. * Sets the current performance log level
  40091. */
  40092. static set PerformanceLogLevel(level: number);
  40093. private static _StartPerformanceCounterDisabled;
  40094. private static _EndPerformanceCounterDisabled;
  40095. private static _StartUserMark;
  40096. private static _EndUserMark;
  40097. private static _StartPerformanceConsole;
  40098. private static _EndPerformanceConsole;
  40099. /**
  40100. * Starts a performance counter
  40101. */
  40102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40103. /**
  40104. * Ends a specific performance coutner
  40105. */
  40106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40107. /**
  40108. * Gets either window.performance.now() if supported or Date.now() else
  40109. */
  40110. static get Now(): number;
  40111. /**
  40112. * This method will return the name of the class used to create the instance of the given object.
  40113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40114. * @param object the object to get the class name from
  40115. * @param isType defines if the object is actually a type
  40116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40117. */
  40118. static GetClassName(object: any, isType?: boolean): string;
  40119. /**
  40120. * Gets the first element of an array satisfying a given predicate
  40121. * @param array defines the array to browse
  40122. * @param predicate defines the predicate to use
  40123. * @returns null if not found or the element
  40124. */
  40125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40126. /**
  40127. * This method will return the name of the full name of the class, including its owning module (if any).
  40128. * 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).
  40129. * @param object the object to get the class name from
  40130. * @param isType defines if the object is actually a type
  40131. * @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.
  40132. * @ignorenaming
  40133. */
  40134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40135. /**
  40136. * Returns a promise that resolves after the given amount of time.
  40137. * @param delay Number of milliseconds to delay
  40138. * @returns Promise that resolves after the given amount of time
  40139. */
  40140. static DelayAsync(delay: number): Promise<void>;
  40141. /**
  40142. * Utility function to detect if the current user agent is Safari
  40143. * @returns whether or not the current user agent is safari
  40144. */
  40145. static IsSafari(): boolean;
  40146. }
  40147. /**
  40148. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40149. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40150. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40151. * @param name The name of the class, case should be preserved
  40152. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40153. */
  40154. export function className(name: string, module?: string): (target: Object) => void;
  40155. /**
  40156. * An implementation of a loop for asynchronous functions.
  40157. */
  40158. export class AsyncLoop {
  40159. /**
  40160. * Defines the number of iterations for the loop
  40161. */
  40162. iterations: number;
  40163. /**
  40164. * Defines the current index of the loop.
  40165. */
  40166. index: number;
  40167. private _done;
  40168. private _fn;
  40169. private _successCallback;
  40170. /**
  40171. * Constructor.
  40172. * @param iterations the number of iterations.
  40173. * @param func the function to run each iteration
  40174. * @param successCallback the callback that will be called upon succesful execution
  40175. * @param offset starting offset.
  40176. */
  40177. constructor(
  40178. /**
  40179. * Defines the number of iterations for the loop
  40180. */
  40181. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40182. /**
  40183. * Execute the next iteration. Must be called after the last iteration was finished.
  40184. */
  40185. executeNext(): void;
  40186. /**
  40187. * Break the loop and run the success callback.
  40188. */
  40189. breakLoop(): void;
  40190. /**
  40191. * Create and run an async loop.
  40192. * @param iterations the number of iterations.
  40193. * @param fn the function to run each iteration
  40194. * @param successCallback the callback that will be called upon succesful execution
  40195. * @param offset starting offset.
  40196. * @returns the created async loop object
  40197. */
  40198. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40199. /**
  40200. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40201. * @param iterations total number of iterations
  40202. * @param syncedIterations number of synchronous iterations in each async iteration.
  40203. * @param fn the function to call each iteration.
  40204. * @param callback a success call back that will be called when iterating stops.
  40205. * @param breakFunction a break condition (optional)
  40206. * @param timeout timeout settings for the setTimeout function. default - 0.
  40207. * @returns the created async loop object
  40208. */
  40209. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40210. }
  40211. }
  40212. declare module "babylonjs/Misc/stringDictionary" {
  40213. import { Nullable } from "babylonjs/types";
  40214. /**
  40215. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40216. * The underlying implementation relies on an associative array to ensure the best performances.
  40217. * The value can be anything including 'null' but except 'undefined'
  40218. */
  40219. export class StringDictionary<T> {
  40220. /**
  40221. * This will clear this dictionary and copy the content from the 'source' one.
  40222. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40223. * @param source the dictionary to take the content from and copy to this dictionary
  40224. */
  40225. copyFrom(source: StringDictionary<T>): void;
  40226. /**
  40227. * Get a value based from its key
  40228. * @param key the given key to get the matching value from
  40229. * @return the value if found, otherwise undefined is returned
  40230. */
  40231. get(key: string): T | undefined;
  40232. /**
  40233. * Get a value from its key or add it if it doesn't exist.
  40234. * This method will ensure you that a given key/data will be present in the dictionary.
  40235. * @param key the given key to get the matching value from
  40236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40237. * The factory will only be invoked if there's no data for the given key.
  40238. * @return the value corresponding to the key.
  40239. */
  40240. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40241. /**
  40242. * Get a value from its key if present in the dictionary otherwise add it
  40243. * @param key the key to get the value from
  40244. * @param val if there's no such key/value pair in the dictionary add it with this value
  40245. * @return the value corresponding to the key
  40246. */
  40247. getOrAdd(key: string, val: T): T;
  40248. /**
  40249. * Check if there's a given key in the dictionary
  40250. * @param key the key to check for
  40251. * @return true if the key is present, false otherwise
  40252. */
  40253. contains(key: string): boolean;
  40254. /**
  40255. * Add a new key and its corresponding value
  40256. * @param key the key to add
  40257. * @param value the value corresponding to the key
  40258. * @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
  40259. */
  40260. add(key: string, value: T): boolean;
  40261. /**
  40262. * Update a specific value associated to a key
  40263. * @param key defines the key to use
  40264. * @param value defines the value to store
  40265. * @returns true if the value was updated (or false if the key was not found)
  40266. */
  40267. set(key: string, value: T): boolean;
  40268. /**
  40269. * Get the element of the given key and remove it from the dictionary
  40270. * @param key defines the key to search
  40271. * @returns the value associated with the key or null if not found
  40272. */
  40273. getAndRemove(key: string): Nullable<T>;
  40274. /**
  40275. * Remove a key/value from the dictionary.
  40276. * @param key the key to remove
  40277. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40278. */
  40279. remove(key: string): boolean;
  40280. /**
  40281. * Clear the whole content of the dictionary
  40282. */
  40283. clear(): void;
  40284. /**
  40285. * Gets the current count
  40286. */
  40287. get count(): number;
  40288. /**
  40289. * Execute a callback on each key/val of the dictionary.
  40290. * Note that you can remove any element in this dictionary in the callback implementation
  40291. * @param callback the callback to execute on a given key/value pair
  40292. */
  40293. forEach(callback: (key: string, val: T) => void): void;
  40294. /**
  40295. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40296. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40297. * Note that you can remove any element in this dictionary in the callback implementation
  40298. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40299. * @returns the first item
  40300. */
  40301. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40302. private _count;
  40303. private _data;
  40304. }
  40305. }
  40306. declare module "babylonjs/Collisions/collisionCoordinator" {
  40307. import { Nullable } from "babylonjs/types";
  40308. import { Scene } from "babylonjs/scene";
  40309. import { Vector3 } from "babylonjs/Maths/math.vector";
  40310. import { Collider } from "babylonjs/Collisions/collider";
  40311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40312. /** @hidden */
  40313. export interface ICollisionCoordinator {
  40314. createCollider(): Collider;
  40315. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40316. init(scene: Scene): void;
  40317. }
  40318. /** @hidden */
  40319. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40320. private _scene;
  40321. private _scaledPosition;
  40322. private _scaledVelocity;
  40323. private _finalPosition;
  40324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40325. createCollider(): Collider;
  40326. init(scene: Scene): void;
  40327. private _collideWithWorld;
  40328. }
  40329. }
  40330. declare module "babylonjs/Inputs/scene.inputManager" {
  40331. import { Nullable } from "babylonjs/types";
  40332. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40333. import { Vector2 } from "babylonjs/Maths/math.vector";
  40334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40335. import { Scene } from "babylonjs/scene";
  40336. /**
  40337. * Class used to manage all inputs for the scene.
  40338. */
  40339. export class InputManager {
  40340. /** The distance in pixel that you have to move to prevent some events */
  40341. static DragMovementThreshold: number;
  40342. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40343. static LongPressDelay: number;
  40344. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40345. static DoubleClickDelay: number;
  40346. /** If you need to check double click without raising a single click at first click, enable this flag */
  40347. static ExclusiveDoubleClickMode: boolean;
  40348. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  40349. private _alreadyAttached;
  40350. private _wheelEventName;
  40351. private _onPointerMove;
  40352. private _onPointerDown;
  40353. private _onPointerUp;
  40354. private _initClickEvent;
  40355. private _initActionManager;
  40356. private _delayedSimpleClick;
  40357. private _delayedSimpleClickTimeout;
  40358. private _previousDelayedSimpleClickTimeout;
  40359. private _meshPickProceed;
  40360. private _previousButtonPressed;
  40361. private _currentPickResult;
  40362. private _previousPickResult;
  40363. private _totalPointersPressed;
  40364. private _doubleClickOccured;
  40365. private _pointerOverMesh;
  40366. private _pickedDownMesh;
  40367. private _pickedUpMesh;
  40368. private _pointerX;
  40369. private _pointerY;
  40370. private _unTranslatedPointerX;
  40371. private _unTranslatedPointerY;
  40372. private _startingPointerPosition;
  40373. private _previousStartingPointerPosition;
  40374. private _startingPointerTime;
  40375. private _previousStartingPointerTime;
  40376. private _pointerCaptures;
  40377. private _meshUnderPointerId;
  40378. private _onKeyDown;
  40379. private _onKeyUp;
  40380. private _onCanvasFocusObserver;
  40381. private _onCanvasBlurObserver;
  40382. private _scene;
  40383. /**
  40384. * Creates a new InputManager
  40385. * @param scene defines the hosting scene
  40386. */
  40387. constructor(scene: Scene);
  40388. /**
  40389. * Gets the mesh that is currently under the pointer
  40390. */
  40391. get meshUnderPointer(): Nullable<AbstractMesh>;
  40392. /**
  40393. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40394. * @param pointerId the pointer id to use
  40395. * @returns The mesh under this pointer id or null if not found
  40396. */
  40397. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40398. /**
  40399. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40400. */
  40401. get unTranslatedPointer(): Vector2;
  40402. /**
  40403. * Gets or sets the current on-screen X position of the pointer
  40404. */
  40405. get pointerX(): number;
  40406. set pointerX(value: number);
  40407. /**
  40408. * Gets or sets the current on-screen Y position of the pointer
  40409. */
  40410. get pointerY(): number;
  40411. set pointerY(value: number);
  40412. private _updatePointerPosition;
  40413. private _processPointerMove;
  40414. private _setRayOnPointerInfo;
  40415. private _checkPrePointerObservable;
  40416. /**
  40417. * Use this method to simulate a pointer move on a mesh
  40418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40421. */
  40422. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40423. /**
  40424. * Use this method to simulate a pointer down on a mesh
  40425. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40426. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40427. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40428. */
  40429. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40430. private _processPointerDown;
  40431. /** @hidden */
  40432. _isPointerSwiping(): boolean;
  40433. /**
  40434. * Use this method to simulate a pointer up on a mesh
  40435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40438. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40439. */
  40440. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40441. private _processPointerUp;
  40442. /**
  40443. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40444. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40445. * @returns true if the pointer was captured
  40446. */
  40447. isPointerCaptured(pointerId?: number): boolean;
  40448. /**
  40449. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40450. * @param attachUp defines if you want to attach events to pointerup
  40451. * @param attachDown defines if you want to attach events to pointerdown
  40452. * @param attachMove defines if you want to attach events to pointermove
  40453. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40454. */
  40455. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40456. /**
  40457. * Detaches all event handlers
  40458. */
  40459. detachControl(): void;
  40460. /**
  40461. * Force the value of meshUnderPointer
  40462. * @param mesh defines the mesh to use
  40463. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40464. */
  40465. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40466. /**
  40467. * Gets the mesh under the pointer
  40468. * @returns a Mesh or null if no mesh is under the pointer
  40469. */
  40470. getPointerOverMesh(): Nullable<AbstractMesh>;
  40471. }
  40472. }
  40473. declare module "babylonjs/Animations/animationGroup" {
  40474. import { Animatable } from "babylonjs/Animations/animatable";
  40475. import { Animation } from "babylonjs/Animations/animation";
  40476. import { Scene, IDisposable } from "babylonjs/scene";
  40477. import { Observable } from "babylonjs/Misc/observable";
  40478. import { Nullable } from "babylonjs/types";
  40479. import "babylonjs/Animations/animatable";
  40480. /**
  40481. * This class defines the direct association between an animation and a target
  40482. */
  40483. export class TargetedAnimation {
  40484. /**
  40485. * Animation to perform
  40486. */
  40487. animation: Animation;
  40488. /**
  40489. * Target to animate
  40490. */
  40491. target: any;
  40492. /**
  40493. * Returns the string "TargetedAnimation"
  40494. * @returns "TargetedAnimation"
  40495. */
  40496. getClassName(): string;
  40497. /**
  40498. * Serialize the object
  40499. * @returns the JSON object representing the current entity
  40500. */
  40501. serialize(): any;
  40502. }
  40503. /**
  40504. * Use this class to create coordinated animations on multiple targets
  40505. */
  40506. export class AnimationGroup implements IDisposable {
  40507. /** The name of the animation group */
  40508. name: string;
  40509. private _scene;
  40510. private _targetedAnimations;
  40511. private _animatables;
  40512. private _from;
  40513. private _to;
  40514. private _isStarted;
  40515. private _isPaused;
  40516. private _speedRatio;
  40517. private _loopAnimation;
  40518. private _isAdditive;
  40519. /**
  40520. * Gets or sets the unique id of the node
  40521. */
  40522. uniqueId: number;
  40523. /**
  40524. * This observable will notify when one animation have ended
  40525. */
  40526. onAnimationEndObservable: Observable<TargetedAnimation>;
  40527. /**
  40528. * Observer raised when one animation loops
  40529. */
  40530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40531. /**
  40532. * Observer raised when all animations have looped
  40533. */
  40534. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40535. /**
  40536. * This observable will notify when all animations have ended.
  40537. */
  40538. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40539. /**
  40540. * This observable will notify when all animations have paused.
  40541. */
  40542. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40543. /**
  40544. * This observable will notify when all animations are playing.
  40545. */
  40546. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40547. /**
  40548. * Gets the first frame
  40549. */
  40550. get from(): number;
  40551. /**
  40552. * Gets the last frame
  40553. */
  40554. get to(): number;
  40555. /**
  40556. * Define if the animations are started
  40557. */
  40558. get isStarted(): boolean;
  40559. /**
  40560. * Gets a value indicating that the current group is playing
  40561. */
  40562. get isPlaying(): boolean;
  40563. /**
  40564. * Gets or sets the speed ratio to use for all animations
  40565. */
  40566. get speedRatio(): number;
  40567. /**
  40568. * Gets or sets the speed ratio to use for all animations
  40569. */
  40570. set speedRatio(value: number);
  40571. /**
  40572. * Gets or sets if all animations should loop or not
  40573. */
  40574. get loopAnimation(): boolean;
  40575. set loopAnimation(value: boolean);
  40576. /**
  40577. * Gets or sets if all animations should be evaluated additively
  40578. */
  40579. get isAdditive(): boolean;
  40580. set isAdditive(value: boolean);
  40581. /**
  40582. * Gets the targeted animations for this animation group
  40583. */
  40584. get targetedAnimations(): Array<TargetedAnimation>;
  40585. /**
  40586. * returning the list of animatables controlled by this animation group.
  40587. */
  40588. get animatables(): Array<Animatable>;
  40589. /**
  40590. * Gets the list of target animations
  40591. */
  40592. get children(): TargetedAnimation[];
  40593. /**
  40594. * Instantiates a new Animation Group.
  40595. * This helps managing several animations at once.
  40596. * @see https://doc.babylonjs.com/how_to/group
  40597. * @param name Defines the name of the group
  40598. * @param scene Defines the scene the group belongs to
  40599. */
  40600. constructor(
  40601. /** The name of the animation group */
  40602. name: string, scene?: Nullable<Scene>);
  40603. /**
  40604. * Add an animation (with its target) in the group
  40605. * @param animation defines the animation we want to add
  40606. * @param target defines the target of the animation
  40607. * @returns the TargetedAnimation object
  40608. */
  40609. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40610. /**
  40611. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40612. * It can add constant keys at begin or end
  40613. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40614. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40615. * @returns the animation group
  40616. */
  40617. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40618. private _animationLoopCount;
  40619. private _animationLoopFlags;
  40620. private _processLoop;
  40621. /**
  40622. * Start all animations on given targets
  40623. * @param loop defines if animations must loop
  40624. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40625. * @param from defines the from key (optional)
  40626. * @param to defines the to key (optional)
  40627. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40628. * @returns the current animation group
  40629. */
  40630. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40631. /**
  40632. * Pause all animations
  40633. * @returns the animation group
  40634. */
  40635. pause(): AnimationGroup;
  40636. /**
  40637. * Play all animations to initial state
  40638. * This function will start() the animations if they were not started or will restart() them if they were paused
  40639. * @param loop defines if animations must loop
  40640. * @returns the animation group
  40641. */
  40642. play(loop?: boolean): AnimationGroup;
  40643. /**
  40644. * Reset all animations to initial state
  40645. * @returns the animation group
  40646. */
  40647. reset(): AnimationGroup;
  40648. /**
  40649. * Restart animations from key 0
  40650. * @returns the animation group
  40651. */
  40652. restart(): AnimationGroup;
  40653. /**
  40654. * Stop all animations
  40655. * @returns the animation group
  40656. */
  40657. stop(): AnimationGroup;
  40658. /**
  40659. * Set animation weight for all animatables
  40660. * @param weight defines the weight to use
  40661. * @return the animationGroup
  40662. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40663. */
  40664. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40665. /**
  40666. * Synchronize and normalize all animatables with a source animatable
  40667. * @param root defines the root animatable to synchronize with
  40668. * @return the animationGroup
  40669. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40670. */
  40671. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40672. /**
  40673. * Goes to a specific frame in this animation group
  40674. * @param frame the frame number to go to
  40675. * @return the animationGroup
  40676. */
  40677. goToFrame(frame: number): AnimationGroup;
  40678. /**
  40679. * Dispose all associated resources
  40680. */
  40681. dispose(): void;
  40682. private _checkAnimationGroupEnded;
  40683. /**
  40684. * Clone the current animation group and returns a copy
  40685. * @param newName defines the name of the new group
  40686. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40687. * @returns the new aniamtion group
  40688. */
  40689. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40690. /**
  40691. * Serializes the animationGroup to an object
  40692. * @returns Serialized object
  40693. */
  40694. serialize(): any;
  40695. /**
  40696. * Returns a new AnimationGroup object parsed from the source provided.
  40697. * @param parsedAnimationGroup defines the source
  40698. * @param scene defines the scene that will receive the animationGroup
  40699. * @returns a new AnimationGroup
  40700. */
  40701. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40702. /**
  40703. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40704. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40705. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40706. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40707. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40708. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40709. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40710. */
  40711. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40712. /**
  40713. * Returns the string "AnimationGroup"
  40714. * @returns "AnimationGroup"
  40715. */
  40716. getClassName(): string;
  40717. /**
  40718. * Creates a detailled string about the object
  40719. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40720. * @returns a string representing the object
  40721. */
  40722. toString(fullDetails?: boolean): string;
  40723. }
  40724. }
  40725. declare module "babylonjs/scene" {
  40726. import { Nullable } from "babylonjs/types";
  40727. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40728. import { Observable } from "babylonjs/Misc/observable";
  40729. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40730. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40731. import { Geometry } from "babylonjs/Meshes/geometry";
  40732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40735. import { Mesh } from "babylonjs/Meshes/mesh";
  40736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40737. import { Bone } from "babylonjs/Bones/bone";
  40738. import { Skeleton } from "babylonjs/Bones/skeleton";
  40739. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40740. import { Camera } from "babylonjs/Cameras/camera";
  40741. import { AbstractScene } from "babylonjs/abstractScene";
  40742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40744. import { Material } from "babylonjs/Materials/material";
  40745. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40746. import { Effect } from "babylonjs/Materials/effect";
  40747. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40748. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40749. import { Light } from "babylonjs/Lights/light";
  40750. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40751. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40752. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40753. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40754. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40756. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40757. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40758. import { Engine } from "babylonjs/Engines/engine";
  40759. import { Node } from "babylonjs/node";
  40760. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40761. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40762. import { WebRequest } from "babylonjs/Misc/webRequest";
  40763. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40764. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40765. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40766. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40767. import { Plane } from "babylonjs/Maths/math.plane";
  40768. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40769. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40770. import { Ray } from "babylonjs/Culling/ray";
  40771. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40772. import { Animation } from "babylonjs/Animations/animation";
  40773. import { Animatable } from "babylonjs/Animations/animatable";
  40774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40775. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40776. import { Collider } from "babylonjs/Collisions/collider";
  40777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40778. /**
  40779. * Define an interface for all classes that will hold resources
  40780. */
  40781. export interface IDisposable {
  40782. /**
  40783. * Releases all held resources
  40784. */
  40785. dispose(): void;
  40786. }
  40787. /** Interface defining initialization parameters for Scene class */
  40788. export interface SceneOptions {
  40789. /**
  40790. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40791. * It will improve performance when the number of geometries becomes important.
  40792. */
  40793. useGeometryUniqueIdsMap?: boolean;
  40794. /**
  40795. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40796. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40797. */
  40798. useMaterialMeshMap?: boolean;
  40799. /**
  40800. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40801. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40802. */
  40803. useClonedMeshMap?: boolean;
  40804. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40805. virtual?: boolean;
  40806. }
  40807. /**
  40808. * Represents a scene to be rendered by the engine.
  40809. * @see https://doc.babylonjs.com/features/scene
  40810. */
  40811. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40812. /** The fog is deactivated */
  40813. static readonly FOGMODE_NONE: number;
  40814. /** The fog density is following an exponential function */
  40815. static readonly FOGMODE_EXP: number;
  40816. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40817. static readonly FOGMODE_EXP2: number;
  40818. /** The fog density is following a linear function. */
  40819. static readonly FOGMODE_LINEAR: number;
  40820. /**
  40821. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40822. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40823. */
  40824. static MinDeltaTime: number;
  40825. /**
  40826. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40827. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40828. */
  40829. static MaxDeltaTime: number;
  40830. /**
  40831. * Factory used to create the default material.
  40832. * @param name The name of the material to create
  40833. * @param scene The scene to create the material for
  40834. * @returns The default material
  40835. */
  40836. static DefaultMaterialFactory(scene: Scene): Material;
  40837. /**
  40838. * Factory used to create the a collision coordinator.
  40839. * @returns The collision coordinator
  40840. */
  40841. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40842. /** @hidden */
  40843. _inputManager: InputManager;
  40844. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40845. cameraToUseForPointers: Nullable<Camera>;
  40846. /** @hidden */
  40847. readonly _isScene: boolean;
  40848. /** @hidden */
  40849. _blockEntityCollection: boolean;
  40850. /**
  40851. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40852. */
  40853. autoClear: boolean;
  40854. /**
  40855. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40856. */
  40857. autoClearDepthAndStencil: boolean;
  40858. /**
  40859. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40860. */
  40861. clearColor: Color4;
  40862. /**
  40863. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40864. */
  40865. ambientColor: Color3;
  40866. /**
  40867. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40868. * It should only be one of the following (if not the default embedded one):
  40869. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40870. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40871. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40872. * The material properties need to be setup according to the type of texture in use.
  40873. */
  40874. environmentBRDFTexture: BaseTexture;
  40875. /**
  40876. * Texture used in all pbr material as the reflection texture.
  40877. * As in the majority of the scene they are the same (exception for multi room and so on),
  40878. * this is easier to reference from here than from all the materials.
  40879. */
  40880. get environmentTexture(): Nullable<BaseTexture>;
  40881. /**
  40882. * Texture used in all pbr material as the reflection texture.
  40883. * As in the majority of the scene they are the same (exception for multi room and so on),
  40884. * this is easier to set here than in all the materials.
  40885. */
  40886. set environmentTexture(value: Nullable<BaseTexture>);
  40887. /** @hidden */
  40888. protected _environmentIntensity: number;
  40889. /**
  40890. * Intensity of the environment in all pbr material.
  40891. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40892. * As in the majority of the scene they are the same (exception for multi room and so on),
  40893. * this is easier to reference from here than from all the materials.
  40894. */
  40895. get environmentIntensity(): number;
  40896. /**
  40897. * Intensity of the environment in all pbr material.
  40898. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40899. * As in the majority of the scene they are the same (exception for multi room and so on),
  40900. * this is easier to set here than in all the materials.
  40901. */
  40902. set environmentIntensity(value: number);
  40903. /** @hidden */
  40904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40905. /**
  40906. * Default image processing configuration used either in the rendering
  40907. * Forward main pass or through the imageProcessingPostProcess if present.
  40908. * As in the majority of the scene they are the same (exception for multi camera),
  40909. * this is easier to reference from here than from all the materials and post process.
  40910. *
  40911. * No setter as we it is a shared configuration, you can set the values instead.
  40912. */
  40913. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40914. private _forceWireframe;
  40915. /**
  40916. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40917. */
  40918. set forceWireframe(value: boolean);
  40919. get forceWireframe(): boolean;
  40920. private _skipFrustumClipping;
  40921. /**
  40922. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40923. */
  40924. set skipFrustumClipping(value: boolean);
  40925. get skipFrustumClipping(): boolean;
  40926. private _forcePointsCloud;
  40927. /**
  40928. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40929. */
  40930. set forcePointsCloud(value: boolean);
  40931. get forcePointsCloud(): boolean;
  40932. /**
  40933. * Gets or sets the active clipplane 1
  40934. */
  40935. clipPlane: Nullable<Plane>;
  40936. /**
  40937. * Gets or sets the active clipplane 2
  40938. */
  40939. clipPlane2: Nullable<Plane>;
  40940. /**
  40941. * Gets or sets the active clipplane 3
  40942. */
  40943. clipPlane3: Nullable<Plane>;
  40944. /**
  40945. * Gets or sets the active clipplane 4
  40946. */
  40947. clipPlane4: Nullable<Plane>;
  40948. /**
  40949. * Gets or sets the active clipplane 5
  40950. */
  40951. clipPlane5: Nullable<Plane>;
  40952. /**
  40953. * Gets or sets the active clipplane 6
  40954. */
  40955. clipPlane6: Nullable<Plane>;
  40956. /**
  40957. * Gets or sets a boolean indicating if animations are enabled
  40958. */
  40959. animationsEnabled: boolean;
  40960. private _animationPropertiesOverride;
  40961. /**
  40962. * Gets or sets the animation properties override
  40963. */
  40964. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40965. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40966. /**
  40967. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40968. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40969. */
  40970. useConstantAnimationDeltaTime: boolean;
  40971. /**
  40972. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40973. * Please note that it requires to run a ray cast through the scene on every frame
  40974. */
  40975. constantlyUpdateMeshUnderPointer: boolean;
  40976. /**
  40977. * Defines the HTML cursor to use when hovering over interactive elements
  40978. */
  40979. hoverCursor: string;
  40980. /**
  40981. * Defines the HTML default cursor to use (empty by default)
  40982. */
  40983. defaultCursor: string;
  40984. /**
  40985. * Defines whether cursors are handled by the scene.
  40986. */
  40987. doNotHandleCursors: boolean;
  40988. /**
  40989. * This is used to call preventDefault() on pointer down
  40990. * in order to block unwanted artifacts like system double clicks
  40991. */
  40992. preventDefaultOnPointerDown: boolean;
  40993. /**
  40994. * This is used to call preventDefault() on pointer up
  40995. * in order to block unwanted artifacts like system double clicks
  40996. */
  40997. preventDefaultOnPointerUp: boolean;
  40998. /**
  40999. * Gets or sets user defined metadata
  41000. */
  41001. metadata: any;
  41002. /**
  41003. * For internal use only. Please do not use.
  41004. */
  41005. reservedDataStore: any;
  41006. /**
  41007. * Gets the name of the plugin used to load this scene (null by default)
  41008. */
  41009. loadingPluginName: string;
  41010. /**
  41011. * Use this array to add regular expressions used to disable offline support for specific urls
  41012. */
  41013. disableOfflineSupportExceptionRules: RegExp[];
  41014. /**
  41015. * An event triggered when the scene is disposed.
  41016. */
  41017. onDisposeObservable: Observable<Scene>;
  41018. private _onDisposeObserver;
  41019. /** Sets a function to be executed when this scene is disposed. */
  41020. set onDispose(callback: () => void);
  41021. /**
  41022. * An event triggered before rendering the scene (right after animations and physics)
  41023. */
  41024. onBeforeRenderObservable: Observable<Scene>;
  41025. private _onBeforeRenderObserver;
  41026. /** Sets a function to be executed before rendering this scene */
  41027. set beforeRender(callback: Nullable<() => void>);
  41028. /**
  41029. * An event triggered after rendering the scene
  41030. */
  41031. onAfterRenderObservable: Observable<Scene>;
  41032. /**
  41033. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41034. */
  41035. onAfterRenderCameraObservable: Observable<Camera>;
  41036. private _onAfterRenderObserver;
  41037. /** Sets a function to be executed after rendering this scene */
  41038. set afterRender(callback: Nullable<() => void>);
  41039. /**
  41040. * An event triggered before animating the scene
  41041. */
  41042. onBeforeAnimationsObservable: Observable<Scene>;
  41043. /**
  41044. * An event triggered after animations processing
  41045. */
  41046. onAfterAnimationsObservable: Observable<Scene>;
  41047. /**
  41048. * An event triggered before draw calls are ready to be sent
  41049. */
  41050. onBeforeDrawPhaseObservable: Observable<Scene>;
  41051. /**
  41052. * An event triggered after draw calls have been sent
  41053. */
  41054. onAfterDrawPhaseObservable: Observable<Scene>;
  41055. /**
  41056. * An event triggered when the scene is ready
  41057. */
  41058. onReadyObservable: Observable<Scene>;
  41059. /**
  41060. * An event triggered before rendering a camera
  41061. */
  41062. onBeforeCameraRenderObservable: Observable<Camera>;
  41063. private _onBeforeCameraRenderObserver;
  41064. /** Sets a function to be executed before rendering a camera*/
  41065. set beforeCameraRender(callback: () => void);
  41066. /**
  41067. * An event triggered after rendering a camera
  41068. */
  41069. onAfterCameraRenderObservable: Observable<Camera>;
  41070. private _onAfterCameraRenderObserver;
  41071. /** Sets a function to be executed after rendering a camera*/
  41072. set afterCameraRender(callback: () => void);
  41073. /**
  41074. * An event triggered when active meshes evaluation is about to start
  41075. */
  41076. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41077. /**
  41078. * An event triggered when active meshes evaluation is done
  41079. */
  41080. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41081. /**
  41082. * An event triggered when particles rendering is about to start
  41083. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41084. */
  41085. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41086. /**
  41087. * An event triggered when particles rendering is done
  41088. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41089. */
  41090. onAfterParticlesRenderingObservable: Observable<Scene>;
  41091. /**
  41092. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41093. */
  41094. onDataLoadedObservable: Observable<Scene>;
  41095. /**
  41096. * An event triggered when a camera is created
  41097. */
  41098. onNewCameraAddedObservable: Observable<Camera>;
  41099. /**
  41100. * An event triggered when a camera is removed
  41101. */
  41102. onCameraRemovedObservable: Observable<Camera>;
  41103. /**
  41104. * An event triggered when a light is created
  41105. */
  41106. onNewLightAddedObservable: Observable<Light>;
  41107. /**
  41108. * An event triggered when a light is removed
  41109. */
  41110. onLightRemovedObservable: Observable<Light>;
  41111. /**
  41112. * An event triggered when a geometry is created
  41113. */
  41114. onNewGeometryAddedObservable: Observable<Geometry>;
  41115. /**
  41116. * An event triggered when a geometry is removed
  41117. */
  41118. onGeometryRemovedObservable: Observable<Geometry>;
  41119. /**
  41120. * An event triggered when a transform node is created
  41121. */
  41122. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41123. /**
  41124. * An event triggered when a transform node is removed
  41125. */
  41126. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41127. /**
  41128. * An event triggered when a mesh is created
  41129. */
  41130. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41131. /**
  41132. * An event triggered when a mesh is removed
  41133. */
  41134. onMeshRemovedObservable: Observable<AbstractMesh>;
  41135. /**
  41136. * An event triggered when a skeleton is created
  41137. */
  41138. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41139. /**
  41140. * An event triggered when a skeleton is removed
  41141. */
  41142. onSkeletonRemovedObservable: Observable<Skeleton>;
  41143. /**
  41144. * An event triggered when a material is created
  41145. */
  41146. onNewMaterialAddedObservable: Observable<Material>;
  41147. /**
  41148. * An event triggered when a material is removed
  41149. */
  41150. onMaterialRemovedObservable: Observable<Material>;
  41151. /**
  41152. * An event triggered when a texture is created
  41153. */
  41154. onNewTextureAddedObservable: Observable<BaseTexture>;
  41155. /**
  41156. * An event triggered when a texture is removed
  41157. */
  41158. onTextureRemovedObservable: Observable<BaseTexture>;
  41159. /**
  41160. * An event triggered when render targets are about to be rendered
  41161. * Can happen multiple times per frame.
  41162. */
  41163. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41164. /**
  41165. * An event triggered when render targets were rendered.
  41166. * Can happen multiple times per frame.
  41167. */
  41168. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41169. /**
  41170. * An event triggered before calculating deterministic simulation step
  41171. */
  41172. onBeforeStepObservable: Observable<Scene>;
  41173. /**
  41174. * An event triggered after calculating deterministic simulation step
  41175. */
  41176. onAfterStepObservable: Observable<Scene>;
  41177. /**
  41178. * An event triggered when the activeCamera property is updated
  41179. */
  41180. onActiveCameraChanged: Observable<Scene>;
  41181. /**
  41182. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41183. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41184. * 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)
  41185. */
  41186. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41187. /**
  41188. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41189. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41190. * 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)
  41191. */
  41192. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41193. /**
  41194. * This Observable will when a mesh has been imported into the scene.
  41195. */
  41196. onMeshImportedObservable: Observable<AbstractMesh>;
  41197. /**
  41198. * This Observable will when an animation file has been imported into the scene.
  41199. */
  41200. onAnimationFileImportedObservable: Observable<Scene>;
  41201. /**
  41202. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41203. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41204. */
  41205. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41206. /** @hidden */
  41207. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41208. /**
  41209. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41210. */
  41211. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41212. /**
  41213. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41214. */
  41215. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41216. /**
  41217. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41218. */
  41219. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41220. /** Callback called when a pointer move is detected */
  41221. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41222. /** Callback called when a pointer down is detected */
  41223. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41224. /** Callback called when a pointer up is detected */
  41225. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41226. /** Callback called when a pointer pick is detected */
  41227. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41228. /**
  41229. * 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).
  41230. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41231. */
  41232. onPrePointerObservable: Observable<PointerInfoPre>;
  41233. /**
  41234. * Observable event triggered each time an input event is received from the rendering canvas
  41235. */
  41236. onPointerObservable: Observable<PointerInfo>;
  41237. /**
  41238. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41239. */
  41240. get unTranslatedPointer(): Vector2;
  41241. /**
  41242. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41243. */
  41244. static get DragMovementThreshold(): number;
  41245. static set DragMovementThreshold(value: number);
  41246. /**
  41247. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41248. */
  41249. static get LongPressDelay(): number;
  41250. static set LongPressDelay(value: number);
  41251. /**
  41252. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41253. */
  41254. static get DoubleClickDelay(): number;
  41255. static set DoubleClickDelay(value: number);
  41256. /** If you need to check double click without raising a single click at first click, enable this flag */
  41257. static get ExclusiveDoubleClickMode(): boolean;
  41258. static set ExclusiveDoubleClickMode(value: boolean);
  41259. /** @hidden */
  41260. _mirroredCameraPosition: Nullable<Vector3>;
  41261. /**
  41262. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41263. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41264. */
  41265. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41266. /**
  41267. * Observable event triggered each time an keyboard event is received from the hosting window
  41268. */
  41269. onKeyboardObservable: Observable<KeyboardInfo>;
  41270. private _useRightHandedSystem;
  41271. /**
  41272. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41273. */
  41274. set useRightHandedSystem(value: boolean);
  41275. get useRightHandedSystem(): boolean;
  41276. private _timeAccumulator;
  41277. private _currentStepId;
  41278. private _currentInternalStep;
  41279. /**
  41280. * Sets the step Id used by deterministic lock step
  41281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41282. * @param newStepId defines the step Id
  41283. */
  41284. setStepId(newStepId: number): void;
  41285. /**
  41286. * Gets the step Id used by deterministic lock step
  41287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41288. * @returns the step Id
  41289. */
  41290. getStepId(): number;
  41291. /**
  41292. * Gets the internal step used by deterministic lock step
  41293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41294. * @returns the internal step
  41295. */
  41296. getInternalStep(): number;
  41297. private _fogEnabled;
  41298. /**
  41299. * Gets or sets a boolean indicating if fog is enabled on this scene
  41300. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41301. * (Default is true)
  41302. */
  41303. set fogEnabled(value: boolean);
  41304. get fogEnabled(): boolean;
  41305. private _fogMode;
  41306. /**
  41307. * Gets or sets the fog mode to use
  41308. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41309. * | mode | value |
  41310. * | --- | --- |
  41311. * | FOGMODE_NONE | 0 |
  41312. * | FOGMODE_EXP | 1 |
  41313. * | FOGMODE_EXP2 | 2 |
  41314. * | FOGMODE_LINEAR | 3 |
  41315. */
  41316. set fogMode(value: number);
  41317. get fogMode(): number;
  41318. /**
  41319. * Gets or sets the fog color to use
  41320. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41321. * (Default is Color3(0.2, 0.2, 0.3))
  41322. */
  41323. fogColor: Color3;
  41324. /**
  41325. * Gets or sets the fog density to use
  41326. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41327. * (Default is 0.1)
  41328. */
  41329. fogDensity: number;
  41330. /**
  41331. * Gets or sets the fog start distance to use
  41332. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41333. * (Default is 0)
  41334. */
  41335. fogStart: number;
  41336. /**
  41337. * Gets or sets the fog end distance to use
  41338. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41339. * (Default is 1000)
  41340. */
  41341. fogEnd: number;
  41342. /**
  41343. * Flag indicating that the frame buffer binding is handled by another component
  41344. */
  41345. prePass: boolean;
  41346. private _shadowsEnabled;
  41347. /**
  41348. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41349. */
  41350. set shadowsEnabled(value: boolean);
  41351. get shadowsEnabled(): boolean;
  41352. private _lightsEnabled;
  41353. /**
  41354. * Gets or sets a boolean indicating if lights are enabled on this scene
  41355. */
  41356. set lightsEnabled(value: boolean);
  41357. get lightsEnabled(): boolean;
  41358. /** All of the active cameras added to this scene. */
  41359. activeCameras: Camera[];
  41360. /** @hidden */
  41361. _activeCamera: Nullable<Camera>;
  41362. /** Gets or sets the current active camera */
  41363. get activeCamera(): Nullable<Camera>;
  41364. set activeCamera(value: Nullable<Camera>);
  41365. private _defaultMaterial;
  41366. /** The default material used on meshes when no material is affected */
  41367. get defaultMaterial(): Material;
  41368. /** The default material used on meshes when no material is affected */
  41369. set defaultMaterial(value: Material);
  41370. private _texturesEnabled;
  41371. /**
  41372. * Gets or sets a boolean indicating if textures are enabled on this scene
  41373. */
  41374. set texturesEnabled(value: boolean);
  41375. get texturesEnabled(): boolean;
  41376. /**
  41377. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41378. */
  41379. physicsEnabled: boolean;
  41380. /**
  41381. * Gets or sets a boolean indicating if particles are enabled on this scene
  41382. */
  41383. particlesEnabled: boolean;
  41384. /**
  41385. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41386. */
  41387. spritesEnabled: boolean;
  41388. private _skeletonsEnabled;
  41389. /**
  41390. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41391. */
  41392. set skeletonsEnabled(value: boolean);
  41393. get skeletonsEnabled(): boolean;
  41394. /**
  41395. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41396. */
  41397. lensFlaresEnabled: boolean;
  41398. /**
  41399. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41400. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41401. */
  41402. collisionsEnabled: boolean;
  41403. private _collisionCoordinator;
  41404. /** @hidden */
  41405. get collisionCoordinator(): ICollisionCoordinator;
  41406. /**
  41407. * Defines the gravity applied to this scene (used only for collisions)
  41408. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41409. */
  41410. gravity: Vector3;
  41411. /**
  41412. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41413. */
  41414. postProcessesEnabled: boolean;
  41415. /**
  41416. * Gets the current postprocess manager
  41417. */
  41418. postProcessManager: PostProcessManager;
  41419. /**
  41420. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41421. */
  41422. renderTargetsEnabled: boolean;
  41423. /**
  41424. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41425. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41426. */
  41427. dumpNextRenderTargets: boolean;
  41428. /**
  41429. * The list of user defined render targets added to the scene
  41430. */
  41431. customRenderTargets: RenderTargetTexture[];
  41432. /**
  41433. * Defines if texture loading must be delayed
  41434. * If true, textures will only be loaded when they need to be rendered
  41435. */
  41436. useDelayedTextureLoading: boolean;
  41437. /**
  41438. * Gets the list of meshes imported to the scene through SceneLoader
  41439. */
  41440. importedMeshesFiles: String[];
  41441. /**
  41442. * Gets or sets a boolean indicating if probes are enabled on this scene
  41443. */
  41444. probesEnabled: boolean;
  41445. /**
  41446. * Gets or sets the current offline provider to use to store scene data
  41447. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41448. */
  41449. offlineProvider: IOfflineProvider;
  41450. /**
  41451. * Gets or sets the action manager associated with the scene
  41452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41453. */
  41454. actionManager: AbstractActionManager;
  41455. private _meshesForIntersections;
  41456. /**
  41457. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41458. */
  41459. proceduralTexturesEnabled: boolean;
  41460. private _engine;
  41461. private _totalVertices;
  41462. /** @hidden */
  41463. _activeIndices: PerfCounter;
  41464. /** @hidden */
  41465. _activeParticles: PerfCounter;
  41466. /** @hidden */
  41467. _activeBones: PerfCounter;
  41468. private _animationRatio;
  41469. /** @hidden */
  41470. _animationTimeLast: number;
  41471. /** @hidden */
  41472. _animationTime: number;
  41473. /**
  41474. * Gets or sets a general scale for animation speed
  41475. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41476. */
  41477. animationTimeScale: number;
  41478. /** @hidden */
  41479. _cachedMaterial: Nullable<Material>;
  41480. /** @hidden */
  41481. _cachedEffect: Nullable<Effect>;
  41482. /** @hidden */
  41483. _cachedVisibility: Nullable<number>;
  41484. private _renderId;
  41485. private _frameId;
  41486. private _executeWhenReadyTimeoutId;
  41487. private _intermediateRendering;
  41488. private _viewUpdateFlag;
  41489. private _projectionUpdateFlag;
  41490. /** @hidden */
  41491. _toBeDisposed: Nullable<IDisposable>[];
  41492. private _activeRequests;
  41493. /** @hidden */
  41494. _pendingData: any[];
  41495. private _isDisposed;
  41496. /**
  41497. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41498. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41499. */
  41500. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41501. private _activeMeshes;
  41502. private _processedMaterials;
  41503. private _renderTargets;
  41504. /** @hidden */
  41505. _activeParticleSystems: SmartArray<IParticleSystem>;
  41506. private _activeSkeletons;
  41507. private _softwareSkinnedMeshes;
  41508. private _renderingManager;
  41509. /** @hidden */
  41510. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41511. private _transformMatrix;
  41512. private _sceneUbo;
  41513. /** @hidden */
  41514. _viewMatrix: Matrix;
  41515. private _projectionMatrix;
  41516. /** @hidden */
  41517. _forcedViewPosition: Nullable<Vector3>;
  41518. /** @hidden */
  41519. _frustumPlanes: Plane[];
  41520. /**
  41521. * Gets the list of frustum planes (built from the active camera)
  41522. */
  41523. get frustumPlanes(): Plane[];
  41524. /**
  41525. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41526. * This is useful if there are more lights that the maximum simulteanous authorized
  41527. */
  41528. requireLightSorting: boolean;
  41529. /** @hidden */
  41530. readonly useMaterialMeshMap: boolean;
  41531. /** @hidden */
  41532. readonly useClonedMeshMap: boolean;
  41533. private _externalData;
  41534. private _uid;
  41535. /**
  41536. * @hidden
  41537. * Backing store of defined scene components.
  41538. */
  41539. _components: ISceneComponent[];
  41540. /**
  41541. * @hidden
  41542. * Backing store of defined scene components.
  41543. */
  41544. _serializableComponents: ISceneSerializableComponent[];
  41545. /**
  41546. * List of components to register on the next registration step.
  41547. */
  41548. private _transientComponents;
  41549. /**
  41550. * Registers the transient components if needed.
  41551. */
  41552. private _registerTransientComponents;
  41553. /**
  41554. * @hidden
  41555. * Add a component to the scene.
  41556. * Note that the ccomponent could be registered on th next frame if this is called after
  41557. * the register component stage.
  41558. * @param component Defines the component to add to the scene
  41559. */
  41560. _addComponent(component: ISceneComponent): void;
  41561. /**
  41562. * @hidden
  41563. * Gets a component from the scene.
  41564. * @param name defines the name of the component to retrieve
  41565. * @returns the component or null if not present
  41566. */
  41567. _getComponent(name: string): Nullable<ISceneComponent>;
  41568. /**
  41569. * @hidden
  41570. * Defines the actions happening before camera updates.
  41571. */
  41572. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41573. /**
  41574. * @hidden
  41575. * Defines the actions happening before clear the canvas.
  41576. */
  41577. _beforeClearStage: Stage<SimpleStageAction>;
  41578. /**
  41579. * @hidden
  41580. * Defines the actions when collecting render targets for the frame.
  41581. */
  41582. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41583. /**
  41584. * @hidden
  41585. * Defines the actions happening for one camera in the frame.
  41586. */
  41587. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41588. /**
  41589. * @hidden
  41590. * Defines the actions happening during the per mesh ready checks.
  41591. */
  41592. _isReadyForMeshStage: Stage<MeshStageAction>;
  41593. /**
  41594. * @hidden
  41595. * Defines the actions happening before evaluate active mesh checks.
  41596. */
  41597. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41598. /**
  41599. * @hidden
  41600. * Defines the actions happening during the evaluate sub mesh checks.
  41601. */
  41602. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41603. /**
  41604. * @hidden
  41605. * Defines the actions happening during the active mesh stage.
  41606. */
  41607. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41608. /**
  41609. * @hidden
  41610. * Defines the actions happening during the per camera render target step.
  41611. */
  41612. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41613. /**
  41614. * @hidden
  41615. * Defines the actions happening just before the active camera is drawing.
  41616. */
  41617. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41618. /**
  41619. * @hidden
  41620. * Defines the actions happening just before a render target is drawing.
  41621. */
  41622. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41623. /**
  41624. * @hidden
  41625. * Defines the actions happening just before a rendering group is drawing.
  41626. */
  41627. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41628. /**
  41629. * @hidden
  41630. * Defines the actions happening just before a mesh is drawing.
  41631. */
  41632. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41633. /**
  41634. * @hidden
  41635. * Defines the actions happening just after a mesh has been drawn.
  41636. */
  41637. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41638. /**
  41639. * @hidden
  41640. * Defines the actions happening just after a rendering group has been drawn.
  41641. */
  41642. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41643. /**
  41644. * @hidden
  41645. * Defines the actions happening just after the active camera has been drawn.
  41646. */
  41647. _afterCameraDrawStage: Stage<CameraStageAction>;
  41648. /**
  41649. * @hidden
  41650. * Defines the actions happening just after a render target has been drawn.
  41651. */
  41652. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41653. /**
  41654. * @hidden
  41655. * Defines the actions happening just after rendering all cameras and computing intersections.
  41656. */
  41657. _afterRenderStage: Stage<SimpleStageAction>;
  41658. /**
  41659. * @hidden
  41660. * Defines the actions happening when a pointer move event happens.
  41661. */
  41662. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41663. /**
  41664. * @hidden
  41665. * Defines the actions happening when a pointer down event happens.
  41666. */
  41667. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41668. /**
  41669. * @hidden
  41670. * Defines the actions happening when a pointer up event happens.
  41671. */
  41672. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41673. /**
  41674. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41675. */
  41676. private geometriesByUniqueId;
  41677. /**
  41678. * Creates a new Scene
  41679. * @param engine defines the engine to use to render this scene
  41680. * @param options defines the scene options
  41681. */
  41682. constructor(engine: Engine, options?: SceneOptions);
  41683. /**
  41684. * Gets a string identifying the name of the class
  41685. * @returns "Scene" string
  41686. */
  41687. getClassName(): string;
  41688. private _defaultMeshCandidates;
  41689. /**
  41690. * @hidden
  41691. */
  41692. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41693. private _defaultSubMeshCandidates;
  41694. /**
  41695. * @hidden
  41696. */
  41697. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41698. /**
  41699. * Sets the default candidate providers for the scene.
  41700. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41701. * and getCollidingSubMeshCandidates to their default function
  41702. */
  41703. setDefaultCandidateProviders(): void;
  41704. /**
  41705. * Gets the mesh that is currently under the pointer
  41706. */
  41707. get meshUnderPointer(): Nullable<AbstractMesh>;
  41708. /**
  41709. * Gets or sets the current on-screen X position of the pointer
  41710. */
  41711. get pointerX(): number;
  41712. set pointerX(value: number);
  41713. /**
  41714. * Gets or sets the current on-screen Y position of the pointer
  41715. */
  41716. get pointerY(): number;
  41717. set pointerY(value: number);
  41718. /**
  41719. * Gets the cached material (ie. the latest rendered one)
  41720. * @returns the cached material
  41721. */
  41722. getCachedMaterial(): Nullable<Material>;
  41723. /**
  41724. * Gets the cached effect (ie. the latest rendered one)
  41725. * @returns the cached effect
  41726. */
  41727. getCachedEffect(): Nullable<Effect>;
  41728. /**
  41729. * Gets the cached visibility state (ie. the latest rendered one)
  41730. * @returns the cached visibility state
  41731. */
  41732. getCachedVisibility(): Nullable<number>;
  41733. /**
  41734. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41735. * @param material defines the current material
  41736. * @param effect defines the current effect
  41737. * @param visibility defines the current visibility state
  41738. * @returns true if one parameter is not cached
  41739. */
  41740. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41741. /**
  41742. * Gets the engine associated with the scene
  41743. * @returns an Engine
  41744. */
  41745. getEngine(): Engine;
  41746. /**
  41747. * Gets the total number of vertices rendered per frame
  41748. * @returns the total number of vertices rendered per frame
  41749. */
  41750. getTotalVertices(): number;
  41751. /**
  41752. * Gets the performance counter for total vertices
  41753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41754. */
  41755. get totalVerticesPerfCounter(): PerfCounter;
  41756. /**
  41757. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41758. * @returns the total number of active indices rendered per frame
  41759. */
  41760. getActiveIndices(): number;
  41761. /**
  41762. * Gets the performance counter for active indices
  41763. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41764. */
  41765. get totalActiveIndicesPerfCounter(): PerfCounter;
  41766. /**
  41767. * Gets the total number of active particles rendered per frame
  41768. * @returns the total number of active particles rendered per frame
  41769. */
  41770. getActiveParticles(): number;
  41771. /**
  41772. * Gets the performance counter for active particles
  41773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41774. */
  41775. get activeParticlesPerfCounter(): PerfCounter;
  41776. /**
  41777. * Gets the total number of active bones rendered per frame
  41778. * @returns the total number of active bones rendered per frame
  41779. */
  41780. getActiveBones(): number;
  41781. /**
  41782. * Gets the performance counter for active bones
  41783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41784. */
  41785. get activeBonesPerfCounter(): PerfCounter;
  41786. /**
  41787. * Gets the array of active meshes
  41788. * @returns an array of AbstractMesh
  41789. */
  41790. getActiveMeshes(): SmartArray<AbstractMesh>;
  41791. /**
  41792. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41793. * @returns a number
  41794. */
  41795. getAnimationRatio(): number;
  41796. /**
  41797. * Gets an unique Id for the current render phase
  41798. * @returns a number
  41799. */
  41800. getRenderId(): number;
  41801. /**
  41802. * Gets an unique Id for the current frame
  41803. * @returns a number
  41804. */
  41805. getFrameId(): number;
  41806. /** Call this function if you want to manually increment the render Id*/
  41807. incrementRenderId(): void;
  41808. private _createUbo;
  41809. /**
  41810. * Use this method to simulate a pointer move on a mesh
  41811. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41812. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41813. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41814. * @returns the current scene
  41815. */
  41816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41817. /**
  41818. * Use this method to simulate a pointer down on a mesh
  41819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41822. * @returns the current scene
  41823. */
  41824. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41825. /**
  41826. * Use this method to simulate a pointer up on a mesh
  41827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41830. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41831. * @returns the current scene
  41832. */
  41833. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41834. /**
  41835. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41836. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41837. * @returns true if the pointer was captured
  41838. */
  41839. isPointerCaptured(pointerId?: number): boolean;
  41840. /**
  41841. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41842. * @param attachUp defines if you want to attach events to pointerup
  41843. * @param attachDown defines if you want to attach events to pointerdown
  41844. * @param attachMove defines if you want to attach events to pointermove
  41845. */
  41846. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41847. /** Detaches all event handlers*/
  41848. detachControl(): void;
  41849. /**
  41850. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41851. * Delay loaded resources are not taking in account
  41852. * @return true if all required resources are ready
  41853. */
  41854. isReady(): boolean;
  41855. /** Resets all cached information relative to material (including effect and visibility) */
  41856. resetCachedMaterial(): void;
  41857. /**
  41858. * Registers a function to be called before every frame render
  41859. * @param func defines the function to register
  41860. */
  41861. registerBeforeRender(func: () => void): void;
  41862. /**
  41863. * Unregisters a function called before every frame render
  41864. * @param func defines the function to unregister
  41865. */
  41866. unregisterBeforeRender(func: () => void): void;
  41867. /**
  41868. * Registers a function to be called after every frame render
  41869. * @param func defines the function to register
  41870. */
  41871. registerAfterRender(func: () => void): void;
  41872. /**
  41873. * Unregisters a function called after every frame render
  41874. * @param func defines the function to unregister
  41875. */
  41876. unregisterAfterRender(func: () => void): void;
  41877. private _executeOnceBeforeRender;
  41878. /**
  41879. * The provided function will run before render once and will be disposed afterwards.
  41880. * A timeout delay can be provided so that the function will be executed in N ms.
  41881. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41882. * @param func The function to be executed.
  41883. * @param timeout optional delay in ms
  41884. */
  41885. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41886. /** @hidden */
  41887. _addPendingData(data: any): void;
  41888. /** @hidden */
  41889. _removePendingData(data: any): void;
  41890. /**
  41891. * Returns the number of items waiting to be loaded
  41892. * @returns the number of items waiting to be loaded
  41893. */
  41894. getWaitingItemsCount(): number;
  41895. /**
  41896. * Returns a boolean indicating if the scene is still loading data
  41897. */
  41898. get isLoading(): boolean;
  41899. /**
  41900. * Registers a function to be executed when the scene is ready
  41901. * @param {Function} func - the function to be executed
  41902. */
  41903. executeWhenReady(func: () => void): void;
  41904. /**
  41905. * Returns a promise that resolves when the scene is ready
  41906. * @returns A promise that resolves when the scene is ready
  41907. */
  41908. whenReadyAsync(): Promise<void>;
  41909. /** @hidden */
  41910. _checkIsReady(): void;
  41911. /**
  41912. * Gets all animatable attached to the scene
  41913. */
  41914. get animatables(): Animatable[];
  41915. /**
  41916. * Resets the last animation time frame.
  41917. * Useful to override when animations start running when loading a scene for the first time.
  41918. */
  41919. resetLastAnimationTimeFrame(): void;
  41920. /**
  41921. * Gets the current view matrix
  41922. * @returns a Matrix
  41923. */
  41924. getViewMatrix(): Matrix;
  41925. /**
  41926. * Gets the current projection matrix
  41927. * @returns a Matrix
  41928. */
  41929. getProjectionMatrix(): Matrix;
  41930. /**
  41931. * Gets the current transform matrix
  41932. * @returns a Matrix made of View * Projection
  41933. */
  41934. getTransformMatrix(): Matrix;
  41935. /**
  41936. * Sets the current transform matrix
  41937. * @param viewL defines the View matrix to use
  41938. * @param projectionL defines the Projection matrix to use
  41939. * @param viewR defines the right View matrix to use (if provided)
  41940. * @param projectionR defines the right Projection matrix to use (if provided)
  41941. */
  41942. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41943. /**
  41944. * Gets the uniform buffer used to store scene data
  41945. * @returns a UniformBuffer
  41946. */
  41947. getSceneUniformBuffer(): UniformBuffer;
  41948. /**
  41949. * Gets an unique (relatively to the current scene) Id
  41950. * @returns an unique number for the scene
  41951. */
  41952. getUniqueId(): number;
  41953. /**
  41954. * Add a mesh to the list of scene's meshes
  41955. * @param newMesh defines the mesh to add
  41956. * @param recursive if all child meshes should also be added to the scene
  41957. */
  41958. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41959. /**
  41960. * Remove a mesh for the list of scene's meshes
  41961. * @param toRemove defines the mesh to remove
  41962. * @param recursive if all child meshes should also be removed from the scene
  41963. * @returns the index where the mesh was in the mesh list
  41964. */
  41965. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41966. /**
  41967. * Add a transform node to the list of scene's transform nodes
  41968. * @param newTransformNode defines the transform node to add
  41969. */
  41970. addTransformNode(newTransformNode: TransformNode): void;
  41971. /**
  41972. * Remove a transform node for the list of scene's transform nodes
  41973. * @param toRemove defines the transform node to remove
  41974. * @returns the index where the transform node was in the transform node list
  41975. */
  41976. removeTransformNode(toRemove: TransformNode): number;
  41977. /**
  41978. * Remove a skeleton for the list of scene's skeletons
  41979. * @param toRemove defines the skeleton to remove
  41980. * @returns the index where the skeleton was in the skeleton list
  41981. */
  41982. removeSkeleton(toRemove: Skeleton): number;
  41983. /**
  41984. * Remove a morph target for the list of scene's morph targets
  41985. * @param toRemove defines the morph target to remove
  41986. * @returns the index where the morph target was in the morph target list
  41987. */
  41988. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41989. /**
  41990. * Remove a light for the list of scene's lights
  41991. * @param toRemove defines the light to remove
  41992. * @returns the index where the light was in the light list
  41993. */
  41994. removeLight(toRemove: Light): number;
  41995. /**
  41996. * Remove a camera for the list of scene's cameras
  41997. * @param toRemove defines the camera to remove
  41998. * @returns the index where the camera was in the camera list
  41999. */
  42000. removeCamera(toRemove: Camera): number;
  42001. /**
  42002. * Remove a particle system for the list of scene's particle systems
  42003. * @param toRemove defines the particle system to remove
  42004. * @returns the index where the particle system was in the particle system list
  42005. */
  42006. removeParticleSystem(toRemove: IParticleSystem): number;
  42007. /**
  42008. * Remove a animation for the list of scene's animations
  42009. * @param toRemove defines the animation to remove
  42010. * @returns the index where the animation was in the animation list
  42011. */
  42012. removeAnimation(toRemove: Animation): number;
  42013. /**
  42014. * Will stop the animation of the given target
  42015. * @param target - the target
  42016. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42017. * @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)
  42018. */
  42019. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42020. /**
  42021. * Removes the given animation group from this scene.
  42022. * @param toRemove The animation group to remove
  42023. * @returns The index of the removed animation group
  42024. */
  42025. removeAnimationGroup(toRemove: AnimationGroup): number;
  42026. /**
  42027. * Removes the given multi-material from this scene.
  42028. * @param toRemove The multi-material to remove
  42029. * @returns The index of the removed multi-material
  42030. */
  42031. removeMultiMaterial(toRemove: MultiMaterial): number;
  42032. /**
  42033. * Removes the given material from this scene.
  42034. * @param toRemove The material to remove
  42035. * @returns The index of the removed material
  42036. */
  42037. removeMaterial(toRemove: Material): number;
  42038. /**
  42039. * Removes the given action manager from this scene.
  42040. * @param toRemove The action manager to remove
  42041. * @returns The index of the removed action manager
  42042. */
  42043. removeActionManager(toRemove: AbstractActionManager): number;
  42044. /**
  42045. * Removes the given texture from this scene.
  42046. * @param toRemove The texture to remove
  42047. * @returns The index of the removed texture
  42048. */
  42049. removeTexture(toRemove: BaseTexture): number;
  42050. /**
  42051. * Adds the given light to this scene
  42052. * @param newLight The light to add
  42053. */
  42054. addLight(newLight: Light): void;
  42055. /**
  42056. * Sorts the list list based on light priorities
  42057. */
  42058. sortLightsByPriority(): void;
  42059. /**
  42060. * Adds the given camera to this scene
  42061. * @param newCamera The camera to add
  42062. */
  42063. addCamera(newCamera: Camera): void;
  42064. /**
  42065. * Adds the given skeleton to this scene
  42066. * @param newSkeleton The skeleton to add
  42067. */
  42068. addSkeleton(newSkeleton: Skeleton): void;
  42069. /**
  42070. * Adds the given particle system to this scene
  42071. * @param newParticleSystem The particle system to add
  42072. */
  42073. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42074. /**
  42075. * Adds the given animation to this scene
  42076. * @param newAnimation The animation to add
  42077. */
  42078. addAnimation(newAnimation: Animation): void;
  42079. /**
  42080. * Adds the given animation group to this scene.
  42081. * @param newAnimationGroup The animation group to add
  42082. */
  42083. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42084. /**
  42085. * Adds the given multi-material to this scene
  42086. * @param newMultiMaterial The multi-material to add
  42087. */
  42088. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42089. /**
  42090. * Adds the given material to this scene
  42091. * @param newMaterial The material to add
  42092. */
  42093. addMaterial(newMaterial: Material): void;
  42094. /**
  42095. * Adds the given morph target to this scene
  42096. * @param newMorphTargetManager The morph target to add
  42097. */
  42098. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42099. /**
  42100. * Adds the given geometry to this scene
  42101. * @param newGeometry The geometry to add
  42102. */
  42103. addGeometry(newGeometry: Geometry): void;
  42104. /**
  42105. * Adds the given action manager to this scene
  42106. * @param newActionManager The action manager to add
  42107. */
  42108. addActionManager(newActionManager: AbstractActionManager): void;
  42109. /**
  42110. * Adds the given texture to this scene.
  42111. * @param newTexture The texture to add
  42112. */
  42113. addTexture(newTexture: BaseTexture): void;
  42114. /**
  42115. * Switch active camera
  42116. * @param newCamera defines the new active camera
  42117. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42118. */
  42119. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42120. /**
  42121. * sets the active camera of the scene using its ID
  42122. * @param id defines the camera's ID
  42123. * @return the new active camera or null if none found.
  42124. */
  42125. setActiveCameraByID(id: string): Nullable<Camera>;
  42126. /**
  42127. * sets the active camera of the scene using its name
  42128. * @param name defines the camera's name
  42129. * @returns the new active camera or null if none found.
  42130. */
  42131. setActiveCameraByName(name: string): Nullable<Camera>;
  42132. /**
  42133. * get an animation group using its name
  42134. * @param name defines the material's name
  42135. * @return the animation group or null if none found.
  42136. */
  42137. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42138. /**
  42139. * Get a material using its unique id
  42140. * @param uniqueId defines the material's unique id
  42141. * @return the material or null if none found.
  42142. */
  42143. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42144. /**
  42145. * get a material using its id
  42146. * @param id defines the material's ID
  42147. * @return the material or null if none found.
  42148. */
  42149. getMaterialByID(id: string): Nullable<Material>;
  42150. /**
  42151. * Gets a the last added material using a given id
  42152. * @param id defines the material's ID
  42153. * @return the last material with the given id or null if none found.
  42154. */
  42155. getLastMaterialByID(id: string): Nullable<Material>;
  42156. /**
  42157. * Gets a material using its name
  42158. * @param name defines the material's name
  42159. * @return the material or null if none found.
  42160. */
  42161. getMaterialByName(name: string): Nullable<Material>;
  42162. /**
  42163. * Get a texture using its unique id
  42164. * @param uniqueId defines the texture's unique id
  42165. * @return the texture or null if none found.
  42166. */
  42167. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42168. /**
  42169. * Gets a camera using its id
  42170. * @param id defines the id to look for
  42171. * @returns the camera or null if not found
  42172. */
  42173. getCameraByID(id: string): Nullable<Camera>;
  42174. /**
  42175. * Gets a camera using its unique id
  42176. * @param uniqueId defines the unique id to look for
  42177. * @returns the camera or null if not found
  42178. */
  42179. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42180. /**
  42181. * Gets a camera using its name
  42182. * @param name defines the camera's name
  42183. * @return the camera or null if none found.
  42184. */
  42185. getCameraByName(name: string): Nullable<Camera>;
  42186. /**
  42187. * Gets a bone using its id
  42188. * @param id defines the bone's id
  42189. * @return the bone or null if not found
  42190. */
  42191. getBoneByID(id: string): Nullable<Bone>;
  42192. /**
  42193. * Gets a bone using its id
  42194. * @param name defines the bone's name
  42195. * @return the bone or null if not found
  42196. */
  42197. getBoneByName(name: string): Nullable<Bone>;
  42198. /**
  42199. * Gets a light node using its name
  42200. * @param name defines the the light's name
  42201. * @return the light or null if none found.
  42202. */
  42203. getLightByName(name: string): Nullable<Light>;
  42204. /**
  42205. * Gets a light node using its id
  42206. * @param id defines the light's id
  42207. * @return the light or null if none found.
  42208. */
  42209. getLightByID(id: string): Nullable<Light>;
  42210. /**
  42211. * Gets a light node using its scene-generated unique ID
  42212. * @param uniqueId defines the light's unique id
  42213. * @return the light or null if none found.
  42214. */
  42215. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42216. /**
  42217. * Gets a particle system by id
  42218. * @param id defines the particle system id
  42219. * @return the corresponding system or null if none found
  42220. */
  42221. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42222. /**
  42223. * Gets a geometry using its ID
  42224. * @param id defines the geometry's id
  42225. * @return the geometry or null if none found.
  42226. */
  42227. getGeometryByID(id: string): Nullable<Geometry>;
  42228. private _getGeometryByUniqueID;
  42229. /**
  42230. * Add a new geometry to this scene
  42231. * @param geometry defines the geometry to be added to the scene.
  42232. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42233. * @return a boolean defining if the geometry was added or not
  42234. */
  42235. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42236. /**
  42237. * Removes an existing geometry
  42238. * @param geometry defines the geometry to be removed from the scene
  42239. * @return a boolean defining if the geometry was removed or not
  42240. */
  42241. removeGeometry(geometry: Geometry): boolean;
  42242. /**
  42243. * Gets the list of geometries attached to the scene
  42244. * @returns an array of Geometry
  42245. */
  42246. getGeometries(): Geometry[];
  42247. /**
  42248. * Gets the first added mesh found of a given ID
  42249. * @param id defines the id to search for
  42250. * @return the mesh found or null if not found at all
  42251. */
  42252. getMeshByID(id: string): Nullable<AbstractMesh>;
  42253. /**
  42254. * Gets a list of meshes using their id
  42255. * @param id defines the id to search for
  42256. * @returns a list of meshes
  42257. */
  42258. getMeshesByID(id: string): Array<AbstractMesh>;
  42259. /**
  42260. * Gets the first added transform node found of a given ID
  42261. * @param id defines the id to search for
  42262. * @return the found transform node or null if not found at all.
  42263. */
  42264. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42265. /**
  42266. * Gets a transform node with its auto-generated unique id
  42267. * @param uniqueId efines the unique id to search for
  42268. * @return the found transform node or null if not found at all.
  42269. */
  42270. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42271. /**
  42272. * Gets a list of transform nodes using their id
  42273. * @param id defines the id to search for
  42274. * @returns a list of transform nodes
  42275. */
  42276. getTransformNodesByID(id: string): Array<TransformNode>;
  42277. /**
  42278. * Gets a mesh with its auto-generated unique id
  42279. * @param uniqueId defines the unique id to search for
  42280. * @return the found mesh or null if not found at all.
  42281. */
  42282. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42283. /**
  42284. * Gets a the last added mesh using a given id
  42285. * @param id defines the id to search for
  42286. * @return the found mesh or null if not found at all.
  42287. */
  42288. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42289. /**
  42290. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42291. * @param id defines the id to search for
  42292. * @return the found node or null if not found at all
  42293. */
  42294. getLastEntryByID(id: string): Nullable<Node>;
  42295. /**
  42296. * Gets a node (Mesh, Camera, Light) using a given id
  42297. * @param id defines the id to search for
  42298. * @return the found node or null if not found at all
  42299. */
  42300. getNodeByID(id: string): Nullable<Node>;
  42301. /**
  42302. * Gets a node (Mesh, Camera, Light) using a given name
  42303. * @param name defines the name to search for
  42304. * @return the found node or null if not found at all.
  42305. */
  42306. getNodeByName(name: string): Nullable<Node>;
  42307. /**
  42308. * Gets a mesh using a given name
  42309. * @param name defines the name to search for
  42310. * @return the found mesh or null if not found at all.
  42311. */
  42312. getMeshByName(name: string): Nullable<AbstractMesh>;
  42313. /**
  42314. * Gets a transform node using a given name
  42315. * @param name defines the name to search for
  42316. * @return the found transform node or null if not found at all.
  42317. */
  42318. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42319. /**
  42320. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42321. * @param id defines the id to search for
  42322. * @return the found skeleton or null if not found at all.
  42323. */
  42324. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42325. /**
  42326. * Gets a skeleton using a given auto generated unique id
  42327. * @param uniqueId defines the unique id to search for
  42328. * @return the found skeleton or null if not found at all.
  42329. */
  42330. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42331. /**
  42332. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42333. * @param id defines the id to search for
  42334. * @return the found skeleton or null if not found at all.
  42335. */
  42336. getSkeletonById(id: string): Nullable<Skeleton>;
  42337. /**
  42338. * Gets a skeleton using a given name
  42339. * @param name defines the name to search for
  42340. * @return the found skeleton or null if not found at all.
  42341. */
  42342. getSkeletonByName(name: string): Nullable<Skeleton>;
  42343. /**
  42344. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42345. * @param id defines the id to search for
  42346. * @return the found morph target manager or null if not found at all.
  42347. */
  42348. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42349. /**
  42350. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42351. * @param id defines the id to search for
  42352. * @return the found morph target or null if not found at all.
  42353. */
  42354. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42355. /**
  42356. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42357. * @param name defines the name to search for
  42358. * @return the found morph target or null if not found at all.
  42359. */
  42360. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42361. /**
  42362. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42363. * @param name defines the name to search for
  42364. * @return the found post process or null if not found at all.
  42365. */
  42366. getPostProcessByName(name: string): Nullable<PostProcess>;
  42367. /**
  42368. * Gets a boolean indicating if the given mesh is active
  42369. * @param mesh defines the mesh to look for
  42370. * @returns true if the mesh is in the active list
  42371. */
  42372. isActiveMesh(mesh: AbstractMesh): boolean;
  42373. /**
  42374. * Return a unique id as a string which can serve as an identifier for the scene
  42375. */
  42376. get uid(): string;
  42377. /**
  42378. * Add an externaly attached data from its key.
  42379. * This method call will fail and return false, if such key already exists.
  42380. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42381. * @param key the unique key that identifies the data
  42382. * @param data the data object to associate to the key for this Engine instance
  42383. * @return true if no such key were already present and the data was added successfully, false otherwise
  42384. */
  42385. addExternalData<T>(key: string, data: T): boolean;
  42386. /**
  42387. * Get an externaly attached data from its key
  42388. * @param key the unique key that identifies the data
  42389. * @return the associated data, if present (can be null), or undefined if not present
  42390. */
  42391. getExternalData<T>(key: string): Nullable<T>;
  42392. /**
  42393. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42394. * @param key the unique key that identifies the data
  42395. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42396. * @return the associated data, can be null if the factory returned null.
  42397. */
  42398. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42399. /**
  42400. * Remove an externaly attached data from the Engine instance
  42401. * @param key the unique key that identifies the data
  42402. * @return true if the data was successfully removed, false if it doesn't exist
  42403. */
  42404. removeExternalData(key: string): boolean;
  42405. private _evaluateSubMesh;
  42406. /**
  42407. * Clear the processed materials smart array preventing retention point in material dispose.
  42408. */
  42409. freeProcessedMaterials(): void;
  42410. private _preventFreeActiveMeshesAndRenderingGroups;
  42411. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42412. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42413. * when disposing several meshes in a row or a hierarchy of meshes.
  42414. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42415. */
  42416. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42417. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42418. /**
  42419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42420. */
  42421. freeActiveMeshes(): void;
  42422. /**
  42423. * Clear the info related to rendering groups preventing retention points during dispose.
  42424. */
  42425. freeRenderingGroups(): void;
  42426. /** @hidden */
  42427. _isInIntermediateRendering(): boolean;
  42428. /**
  42429. * Lambda returning the list of potentially active meshes.
  42430. */
  42431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42432. /**
  42433. * Lambda returning the list of potentially active sub meshes.
  42434. */
  42435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42436. /**
  42437. * Lambda returning the list of potentially intersecting sub meshes.
  42438. */
  42439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42440. /**
  42441. * Lambda returning the list of potentially colliding sub meshes.
  42442. */
  42443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42444. private _activeMeshesFrozen;
  42445. private _skipEvaluateActiveMeshesCompletely;
  42446. /**
  42447. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42448. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42449. * @returns the current scene
  42450. */
  42451. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42452. /**
  42453. * Use this function to restart evaluating active meshes on every frame
  42454. * @returns the current scene
  42455. */
  42456. unfreezeActiveMeshes(): Scene;
  42457. private _evaluateActiveMeshes;
  42458. private _activeMesh;
  42459. /**
  42460. * Update the transform matrix to update from the current active camera
  42461. * @param force defines a boolean used to force the update even if cache is up to date
  42462. */
  42463. updateTransformMatrix(force?: boolean): void;
  42464. private _bindFrameBuffer;
  42465. /** @hidden */
  42466. _allowPostProcessClearColor: boolean;
  42467. /** @hidden */
  42468. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42469. private _processSubCameras;
  42470. private _checkIntersections;
  42471. /** @hidden */
  42472. _advancePhysicsEngineStep(step: number): void;
  42473. /**
  42474. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42475. */
  42476. getDeterministicFrameTime: () => number;
  42477. /** @hidden */
  42478. _animate(): void;
  42479. /** Execute all animations (for a frame) */
  42480. animate(): void;
  42481. /**
  42482. * Render the scene
  42483. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42484. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42485. */
  42486. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42487. /**
  42488. * Freeze all materials
  42489. * A frozen material will not be updatable but should be faster to render
  42490. */
  42491. freezeMaterials(): void;
  42492. /**
  42493. * Unfreeze all materials
  42494. * A frozen material will not be updatable but should be faster to render
  42495. */
  42496. unfreezeMaterials(): void;
  42497. /**
  42498. * Releases all held ressources
  42499. */
  42500. dispose(): void;
  42501. /**
  42502. * Gets if the scene is already disposed
  42503. */
  42504. get isDisposed(): boolean;
  42505. /**
  42506. * Call this function to reduce memory footprint of the scene.
  42507. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42508. */
  42509. clearCachedVertexData(): void;
  42510. /**
  42511. * This function will remove the local cached buffer data from texture.
  42512. * It will save memory but will prevent the texture from being rebuilt
  42513. */
  42514. cleanCachedTextureBuffer(): void;
  42515. /**
  42516. * Get the world extend vectors with an optional filter
  42517. *
  42518. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42519. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42520. */
  42521. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42522. min: Vector3;
  42523. max: Vector3;
  42524. };
  42525. /**
  42526. * Creates a ray that can be used to pick in the scene
  42527. * @param x defines the x coordinate of the origin (on-screen)
  42528. * @param y defines the y coordinate of the origin (on-screen)
  42529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42530. * @param camera defines the camera to use for the picking
  42531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42532. * @returns a Ray
  42533. */
  42534. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42535. /**
  42536. * Creates a ray that can be used to pick in the scene
  42537. * @param x defines the x coordinate of the origin (on-screen)
  42538. * @param y defines the y coordinate of the origin (on-screen)
  42539. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42540. * @param result defines the ray where to store the picking ray
  42541. * @param camera defines the camera to use for the picking
  42542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42543. * @returns the current scene
  42544. */
  42545. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42546. /**
  42547. * Creates a ray that can be used to pick in the scene
  42548. * @param x defines the x coordinate of the origin (on-screen)
  42549. * @param y defines the y coordinate of the origin (on-screen)
  42550. * @param camera defines the camera to use for the picking
  42551. * @returns a Ray
  42552. */
  42553. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42554. /**
  42555. * Creates a ray that can be used to pick in the scene
  42556. * @param x defines the x coordinate of the origin (on-screen)
  42557. * @param y defines the y coordinate of the origin (on-screen)
  42558. * @param result defines the ray where to store the picking ray
  42559. * @param camera defines the camera to use for the picking
  42560. * @returns the current scene
  42561. */
  42562. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42563. /** Launch a ray to try to pick a mesh in the scene
  42564. * @param x position on screen
  42565. * @param y position on screen
  42566. * @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
  42567. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42568. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42570. * @returns a PickingInfo
  42571. */
  42572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42573. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42574. * @param x position on screen
  42575. * @param y position on screen
  42576. * @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
  42577. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42578. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42579. * @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)
  42580. */
  42581. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42582. /** Use the given ray to pick a mesh in the scene
  42583. * @param ray The ray to use to pick meshes
  42584. * @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
  42585. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42587. * @returns a PickingInfo
  42588. */
  42589. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42590. /**
  42591. * Launch a ray to try to pick a mesh in the scene
  42592. * @param x X position on screen
  42593. * @param y Y position on screen
  42594. * @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
  42595. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42596. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42597. * @returns an array of PickingInfo
  42598. */
  42599. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42600. /**
  42601. * Launch a ray to try to pick a mesh in the scene
  42602. * @param ray Ray to use
  42603. * @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
  42604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42605. * @returns an array of PickingInfo
  42606. */
  42607. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42608. /**
  42609. * Force the value of meshUnderPointer
  42610. * @param mesh defines the mesh to use
  42611. * @param pointerId optional pointer id when using more than one pointer
  42612. */
  42613. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42614. /**
  42615. * Gets the mesh under the pointer
  42616. * @returns a Mesh or null if no mesh is under the pointer
  42617. */
  42618. getPointerOverMesh(): Nullable<AbstractMesh>;
  42619. /** @hidden */
  42620. _rebuildGeometries(): void;
  42621. /** @hidden */
  42622. _rebuildTextures(): void;
  42623. private _getByTags;
  42624. /**
  42625. * Get a list of meshes by tags
  42626. * @param tagsQuery defines the tags query to use
  42627. * @param forEach defines a predicate used to filter results
  42628. * @returns an array of Mesh
  42629. */
  42630. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42631. /**
  42632. * Get a list of cameras by tags
  42633. * @param tagsQuery defines the tags query to use
  42634. * @param forEach defines a predicate used to filter results
  42635. * @returns an array of Camera
  42636. */
  42637. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42638. /**
  42639. * Get a list of lights by tags
  42640. * @param tagsQuery defines the tags query to use
  42641. * @param forEach defines a predicate used to filter results
  42642. * @returns an array of Light
  42643. */
  42644. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42645. /**
  42646. * Get a list of materials by tags
  42647. * @param tagsQuery defines the tags query to use
  42648. * @param forEach defines a predicate used to filter results
  42649. * @returns an array of Material
  42650. */
  42651. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42652. /**
  42653. * Get a list of transform nodes by tags
  42654. * @param tagsQuery defines the tags query to use
  42655. * @param forEach defines a predicate used to filter results
  42656. * @returns an array of TransformNode
  42657. */
  42658. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42659. /**
  42660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42661. * This allowed control for front to back rendering or reversly depending of the special needs.
  42662. *
  42663. * @param renderingGroupId The rendering group id corresponding to its index
  42664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42667. */
  42668. 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;
  42669. /**
  42670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42671. *
  42672. * @param renderingGroupId The rendering group id corresponding to its index
  42673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42674. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42675. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42676. */
  42677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42678. /**
  42679. * Gets the current auto clear configuration for one rendering group of the rendering
  42680. * manager.
  42681. * @param index the rendering group index to get the information for
  42682. * @returns The auto clear setup for the requested rendering group
  42683. */
  42684. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42685. private _blockMaterialDirtyMechanism;
  42686. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42687. get blockMaterialDirtyMechanism(): boolean;
  42688. set blockMaterialDirtyMechanism(value: boolean);
  42689. /**
  42690. * Will flag all materials as dirty to trigger new shader compilation
  42691. * @param flag defines the flag used to specify which material part must be marked as dirty
  42692. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42693. */
  42694. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42695. /** @hidden */
  42696. _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;
  42697. /** @hidden */
  42698. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42699. /** @hidden */
  42700. _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;
  42701. /** @hidden */
  42702. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42703. /** @hidden */
  42704. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42705. /** @hidden */
  42706. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42707. }
  42708. }
  42709. declare module "babylonjs/assetContainer" {
  42710. import { AbstractScene } from "babylonjs/abstractScene";
  42711. import { Scene } from "babylonjs/scene";
  42712. import { Mesh } from "babylonjs/Meshes/mesh";
  42713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42714. import { Skeleton } from "babylonjs/Bones/skeleton";
  42715. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42716. import { Animatable } from "babylonjs/Animations/animatable";
  42717. import { Nullable } from "babylonjs/types";
  42718. import { Node } from "babylonjs/node";
  42719. /**
  42720. * Set of assets to keep when moving a scene into an asset container.
  42721. */
  42722. export class KeepAssets extends AbstractScene {
  42723. }
  42724. /**
  42725. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42726. */
  42727. export class InstantiatedEntries {
  42728. /**
  42729. * List of new root nodes (eg. nodes with no parent)
  42730. */
  42731. rootNodes: TransformNode[];
  42732. /**
  42733. * List of new skeletons
  42734. */
  42735. skeletons: Skeleton[];
  42736. /**
  42737. * List of new animation groups
  42738. */
  42739. animationGroups: AnimationGroup[];
  42740. }
  42741. /**
  42742. * Container with a set of assets that can be added or removed from a scene.
  42743. */
  42744. export class AssetContainer extends AbstractScene {
  42745. private _wasAddedToScene;
  42746. /**
  42747. * The scene the AssetContainer belongs to.
  42748. */
  42749. scene: Scene;
  42750. /**
  42751. * Instantiates an AssetContainer.
  42752. * @param scene The scene the AssetContainer belongs to.
  42753. */
  42754. constructor(scene: Scene);
  42755. /**
  42756. * Instantiate or clone all meshes and add the new ones to the scene.
  42757. * Skeletons and animation groups will all be cloned
  42758. * @param nameFunction defines an optional function used to get new names for clones
  42759. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42760. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42761. */
  42762. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42763. /**
  42764. * Adds all the assets from the container to the scene.
  42765. */
  42766. addAllToScene(): void;
  42767. /**
  42768. * Removes all the assets in the container from the scene
  42769. */
  42770. removeAllFromScene(): void;
  42771. /**
  42772. * Disposes all the assets in the container
  42773. */
  42774. dispose(): void;
  42775. private _moveAssets;
  42776. /**
  42777. * Removes all the assets contained in the scene and adds them to the container.
  42778. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42779. */
  42780. moveAllFromScene(keepAssets?: KeepAssets): void;
  42781. /**
  42782. * 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.
  42783. * @returns the root mesh
  42784. */
  42785. createRootMesh(): Mesh;
  42786. /**
  42787. * Merge animations (direct and animation groups) from this asset container into a scene
  42788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42789. * @param animatables set of animatables to retarget to a node from the scene
  42790. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42791. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42792. */
  42793. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42794. }
  42795. }
  42796. declare module "babylonjs/abstractScene" {
  42797. import { Scene } from "babylonjs/scene";
  42798. import { Nullable } from "babylonjs/types";
  42799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42801. import { Geometry } from "babylonjs/Meshes/geometry";
  42802. import { Skeleton } from "babylonjs/Bones/skeleton";
  42803. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42804. import { AssetContainer } from "babylonjs/assetContainer";
  42805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42806. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42808. import { Material } from "babylonjs/Materials/material";
  42809. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42810. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42811. import { Camera } from "babylonjs/Cameras/camera";
  42812. import { Light } from "babylonjs/Lights/light";
  42813. import { Node } from "babylonjs/node";
  42814. import { Animation } from "babylonjs/Animations/animation";
  42815. /**
  42816. * Defines how the parser contract is defined.
  42817. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42818. */
  42819. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42820. /**
  42821. * Defines how the individual parser contract is defined.
  42822. * These parser can parse an individual asset
  42823. */
  42824. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42825. /**
  42826. * Base class of the scene acting as a container for the different elements composing a scene.
  42827. * This class is dynamically extended by the different components of the scene increasing
  42828. * flexibility and reducing coupling
  42829. */
  42830. export abstract class AbstractScene {
  42831. /**
  42832. * Stores the list of available parsers in the application.
  42833. */
  42834. private static _BabylonFileParsers;
  42835. /**
  42836. * Stores the list of available individual parsers in the application.
  42837. */
  42838. private static _IndividualBabylonFileParsers;
  42839. /**
  42840. * Adds a parser in the list of available ones
  42841. * @param name Defines the name of the parser
  42842. * @param parser Defines the parser to add
  42843. */
  42844. static AddParser(name: string, parser: BabylonFileParser): void;
  42845. /**
  42846. * Gets a general parser from the list of avaialble ones
  42847. * @param name Defines the name of the parser
  42848. * @returns the requested parser or null
  42849. */
  42850. static GetParser(name: string): Nullable<BabylonFileParser>;
  42851. /**
  42852. * Adds n individual parser in the list of available ones
  42853. * @param name Defines the name of the parser
  42854. * @param parser Defines the parser to add
  42855. */
  42856. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42857. /**
  42858. * Gets an individual parser from the list of avaialble ones
  42859. * @param name Defines the name of the parser
  42860. * @returns the requested parser or null
  42861. */
  42862. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42863. /**
  42864. * Parser json data and populate both a scene and its associated container object
  42865. * @param jsonData Defines the data to parse
  42866. * @param scene Defines the scene to parse the data for
  42867. * @param container Defines the container attached to the parsing sequence
  42868. * @param rootUrl Defines the root url of the data
  42869. */
  42870. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42871. /**
  42872. * Gets the list of root nodes (ie. nodes with no parent)
  42873. */
  42874. rootNodes: Node[];
  42875. /** All of the cameras added to this scene
  42876. * @see https://doc.babylonjs.com/babylon101/cameras
  42877. */
  42878. cameras: Camera[];
  42879. /**
  42880. * All of the lights added to this scene
  42881. * @see https://doc.babylonjs.com/babylon101/lights
  42882. */
  42883. lights: Light[];
  42884. /**
  42885. * All of the (abstract) meshes added to this scene
  42886. */
  42887. meshes: AbstractMesh[];
  42888. /**
  42889. * The list of skeletons added to the scene
  42890. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42891. */
  42892. skeletons: Skeleton[];
  42893. /**
  42894. * All of the particle systems added to this scene
  42895. * @see https://doc.babylonjs.com/babylon101/particles
  42896. */
  42897. particleSystems: IParticleSystem[];
  42898. /**
  42899. * Gets a list of Animations associated with the scene
  42900. */
  42901. animations: Animation[];
  42902. /**
  42903. * All of the animation groups added to this scene
  42904. * @see https://doc.babylonjs.com/how_to/group
  42905. */
  42906. animationGroups: AnimationGroup[];
  42907. /**
  42908. * All of the multi-materials added to this scene
  42909. * @see https://doc.babylonjs.com/how_to/multi_materials
  42910. */
  42911. multiMaterials: MultiMaterial[];
  42912. /**
  42913. * All of the materials added to this scene
  42914. * In the context of a Scene, it is not supposed to be modified manually.
  42915. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42916. * Note also that the order of the Material within the array is not significant and might change.
  42917. * @see https://doc.babylonjs.com/babylon101/materials
  42918. */
  42919. materials: Material[];
  42920. /**
  42921. * The list of morph target managers added to the scene
  42922. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42923. */
  42924. morphTargetManagers: MorphTargetManager[];
  42925. /**
  42926. * The list of geometries used in the scene.
  42927. */
  42928. geometries: Geometry[];
  42929. /**
  42930. * All of the tranform nodes added to this scene
  42931. * In the context of a Scene, it is not supposed to be modified manually.
  42932. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42933. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42934. * @see https://doc.babylonjs.com/how_to/transformnode
  42935. */
  42936. transformNodes: TransformNode[];
  42937. /**
  42938. * ActionManagers available on the scene.
  42939. */
  42940. actionManagers: AbstractActionManager[];
  42941. /**
  42942. * Textures to keep.
  42943. */
  42944. textures: BaseTexture[];
  42945. /** @hidden */
  42946. protected _environmentTexture: Nullable<BaseTexture>;
  42947. /**
  42948. * Texture used in all pbr material as the reflection texture.
  42949. * As in the majority of the scene they are the same (exception for multi room and so on),
  42950. * this is easier to reference from here than from all the materials.
  42951. */
  42952. get environmentTexture(): Nullable<BaseTexture>;
  42953. set environmentTexture(value: Nullable<BaseTexture>);
  42954. /**
  42955. * The list of postprocesses added to the scene
  42956. */
  42957. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42958. /**
  42959. * @returns all meshes, lights, cameras, transformNodes and bones
  42960. */
  42961. getNodes(): Array<Node>;
  42962. }
  42963. }
  42964. declare module "babylonjs/Audio/sound" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Vector3 } from "babylonjs/Maths/math.vector";
  42967. import { Nullable } from "babylonjs/types";
  42968. import { Scene } from "babylonjs/scene";
  42969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42970. /**
  42971. * Interface used to define options for Sound class
  42972. */
  42973. export interface ISoundOptions {
  42974. /**
  42975. * Does the sound autoplay once loaded.
  42976. */
  42977. autoplay?: boolean;
  42978. /**
  42979. * Does the sound loop after it finishes playing once.
  42980. */
  42981. loop?: boolean;
  42982. /**
  42983. * Sound's volume
  42984. */
  42985. volume?: number;
  42986. /**
  42987. * Is it a spatial sound?
  42988. */
  42989. spatialSound?: boolean;
  42990. /**
  42991. * Maximum distance to hear that sound
  42992. */
  42993. maxDistance?: number;
  42994. /**
  42995. * Uses user defined attenuation function
  42996. */
  42997. useCustomAttenuation?: boolean;
  42998. /**
  42999. * Define the roll off factor of spatial sounds.
  43000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43001. */
  43002. rolloffFactor?: number;
  43003. /**
  43004. * Define the reference distance the sound should be heard perfectly.
  43005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43006. */
  43007. refDistance?: number;
  43008. /**
  43009. * Define the distance attenuation model the sound will follow.
  43010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43011. */
  43012. distanceModel?: string;
  43013. /**
  43014. * Defines the playback speed (1 by default)
  43015. */
  43016. playbackRate?: number;
  43017. /**
  43018. * Defines if the sound is from a streaming source
  43019. */
  43020. streaming?: boolean;
  43021. /**
  43022. * Defines an optional length (in seconds) inside the sound file
  43023. */
  43024. length?: number;
  43025. /**
  43026. * Defines an optional offset (in seconds) inside the sound file
  43027. */
  43028. offset?: number;
  43029. /**
  43030. * If true, URLs will not be required to state the audio file codec to use.
  43031. */
  43032. skipCodecCheck?: boolean;
  43033. }
  43034. /**
  43035. * Defines a sound that can be played in the application.
  43036. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43038. */
  43039. export class Sound {
  43040. /**
  43041. * The name of the sound in the scene.
  43042. */
  43043. name: string;
  43044. /**
  43045. * Does the sound autoplay once loaded.
  43046. */
  43047. autoplay: boolean;
  43048. /**
  43049. * Does the sound loop after it finishes playing once.
  43050. */
  43051. loop: boolean;
  43052. /**
  43053. * Does the sound use a custom attenuation curve to simulate the falloff
  43054. * happening when the source gets further away from the camera.
  43055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43056. */
  43057. useCustomAttenuation: boolean;
  43058. /**
  43059. * The sound track id this sound belongs to.
  43060. */
  43061. soundTrackId: number;
  43062. /**
  43063. * Is this sound currently played.
  43064. */
  43065. isPlaying: boolean;
  43066. /**
  43067. * Is this sound currently paused.
  43068. */
  43069. isPaused: boolean;
  43070. /**
  43071. * Does this sound enables spatial sound.
  43072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43073. */
  43074. spatialSound: boolean;
  43075. /**
  43076. * Define the reference distance the sound should be heard perfectly.
  43077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43078. */
  43079. refDistance: number;
  43080. /**
  43081. * Define the roll off factor of spatial sounds.
  43082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43083. */
  43084. rolloffFactor: number;
  43085. /**
  43086. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43088. */
  43089. maxDistance: number;
  43090. /**
  43091. * Define the distance attenuation model the sound will follow.
  43092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43093. */
  43094. distanceModel: string;
  43095. /**
  43096. * @hidden
  43097. * Back Compat
  43098. **/
  43099. onended: () => any;
  43100. /**
  43101. * Gets or sets an object used to store user defined information for the sound.
  43102. */
  43103. metadata: any;
  43104. /**
  43105. * Observable event when the current playing sound finishes.
  43106. */
  43107. onEndedObservable: Observable<Sound>;
  43108. private _panningModel;
  43109. private _playbackRate;
  43110. private _streaming;
  43111. private _startTime;
  43112. private _startOffset;
  43113. private _position;
  43114. /** @hidden */
  43115. _positionInEmitterSpace: boolean;
  43116. private _localDirection;
  43117. private _volume;
  43118. private _isReadyToPlay;
  43119. private _isDirectional;
  43120. private _readyToPlayCallback;
  43121. private _audioBuffer;
  43122. private _soundSource;
  43123. private _streamingSource;
  43124. private _soundPanner;
  43125. private _soundGain;
  43126. private _inputAudioNode;
  43127. private _outputAudioNode;
  43128. private _coneInnerAngle;
  43129. private _coneOuterAngle;
  43130. private _coneOuterGain;
  43131. private _scene;
  43132. private _connectedTransformNode;
  43133. private _customAttenuationFunction;
  43134. private _registerFunc;
  43135. private _isOutputConnected;
  43136. private _htmlAudioElement;
  43137. private _urlType;
  43138. private _length?;
  43139. private _offset?;
  43140. /** @hidden */
  43141. static _SceneComponentInitialization: (scene: Scene) => void;
  43142. /**
  43143. * Create a sound and attach it to a scene
  43144. * @param name Name of your sound
  43145. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43146. * @param scene defines the scene the sound belongs to
  43147. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43148. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43149. */
  43150. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43151. /**
  43152. * Release the sound and its associated resources
  43153. */
  43154. dispose(): void;
  43155. /**
  43156. * Gets if the sounds is ready to be played or not.
  43157. * @returns true if ready, otherwise false
  43158. */
  43159. isReady(): boolean;
  43160. private _soundLoaded;
  43161. /**
  43162. * Sets the data of the sound from an audiobuffer
  43163. * @param audioBuffer The audioBuffer containing the data
  43164. */
  43165. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43166. /**
  43167. * Updates the current sounds options such as maxdistance, loop...
  43168. * @param options A JSON object containing values named as the object properties
  43169. */
  43170. updateOptions(options: ISoundOptions): void;
  43171. private _createSpatialParameters;
  43172. private _updateSpatialParameters;
  43173. /**
  43174. * Switch the panning model to HRTF:
  43175. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43177. */
  43178. switchPanningModelToHRTF(): void;
  43179. /**
  43180. * Switch the panning model to Equal Power:
  43181. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43183. */
  43184. switchPanningModelToEqualPower(): void;
  43185. private _switchPanningModel;
  43186. /**
  43187. * Connect this sound to a sound track audio node like gain...
  43188. * @param soundTrackAudioNode the sound track audio node to connect to
  43189. */
  43190. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43191. /**
  43192. * Transform this sound into a directional source
  43193. * @param coneInnerAngle Size of the inner cone in degree
  43194. * @param coneOuterAngle Size of the outer cone in degree
  43195. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43196. */
  43197. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43198. /**
  43199. * Gets or sets the inner angle for the directional cone.
  43200. */
  43201. get directionalConeInnerAngle(): number;
  43202. /**
  43203. * Gets or sets the inner angle for the directional cone.
  43204. */
  43205. set directionalConeInnerAngle(value: number);
  43206. /**
  43207. * Gets or sets the outer angle for the directional cone.
  43208. */
  43209. get directionalConeOuterAngle(): number;
  43210. /**
  43211. * Gets or sets the outer angle for the directional cone.
  43212. */
  43213. set directionalConeOuterAngle(value: number);
  43214. /**
  43215. * Sets the position of the emitter if spatial sound is enabled
  43216. * @param newPosition Defines the new posisiton
  43217. */
  43218. setPosition(newPosition: Vector3): void;
  43219. /**
  43220. * Sets the local direction of the emitter if spatial sound is enabled
  43221. * @param newLocalDirection Defines the new local direction
  43222. */
  43223. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43224. private _updateDirection;
  43225. /** @hidden */
  43226. updateDistanceFromListener(): void;
  43227. /**
  43228. * Sets a new custom attenuation function for the sound.
  43229. * @param callback Defines the function used for the attenuation
  43230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43231. */
  43232. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43233. /**
  43234. * Play the sound
  43235. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43236. * @param offset (optional) Start the sound at a specific time in seconds
  43237. * @param length (optional) Sound duration (in seconds)
  43238. */
  43239. play(time?: number, offset?: number, length?: number): void;
  43240. private _onended;
  43241. /**
  43242. * Stop the sound
  43243. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43244. */
  43245. stop(time?: number): void;
  43246. /**
  43247. * Put the sound in pause
  43248. */
  43249. pause(): void;
  43250. /**
  43251. * Sets a dedicated volume for this sounds
  43252. * @param newVolume Define the new volume of the sound
  43253. * @param time Define time for gradual change to new volume
  43254. */
  43255. setVolume(newVolume: number, time?: number): void;
  43256. /**
  43257. * Set the sound play back rate
  43258. * @param newPlaybackRate Define the playback rate the sound should be played at
  43259. */
  43260. setPlaybackRate(newPlaybackRate: number): void;
  43261. /**
  43262. * Gets the volume of the sound.
  43263. * @returns the volume of the sound
  43264. */
  43265. getVolume(): number;
  43266. /**
  43267. * Attach the sound to a dedicated mesh
  43268. * @param transformNode The transform node to connect the sound with
  43269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43270. */
  43271. attachToMesh(transformNode: TransformNode): void;
  43272. /**
  43273. * Detach the sound from the previously attached mesh
  43274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43275. */
  43276. detachFromMesh(): void;
  43277. private _onRegisterAfterWorldMatrixUpdate;
  43278. /**
  43279. * Clone the current sound in the scene.
  43280. * @returns the new sound clone
  43281. */
  43282. clone(): Nullable<Sound>;
  43283. /**
  43284. * Gets the current underlying audio buffer containing the data
  43285. * @returns the audio buffer
  43286. */
  43287. getAudioBuffer(): Nullable<AudioBuffer>;
  43288. /**
  43289. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43290. * @returns the source node
  43291. */
  43292. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43293. /**
  43294. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43295. * @returns the gain node
  43296. */
  43297. getSoundGain(): Nullable<GainNode>;
  43298. /**
  43299. * Serializes the Sound in a JSON representation
  43300. * @returns the JSON representation of the sound
  43301. */
  43302. serialize(): any;
  43303. /**
  43304. * Parse a JSON representation of a sound to innstantiate in a given scene
  43305. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43306. * @param scene Define the scene the new parsed sound should be created in
  43307. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43308. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43309. * @returns the newly parsed sound
  43310. */
  43311. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43312. }
  43313. }
  43314. declare module "babylonjs/Actions/directAudioActions" {
  43315. import { Action } from "babylonjs/Actions/action";
  43316. import { Condition } from "babylonjs/Actions/condition";
  43317. import { Sound } from "babylonjs/Audio/sound";
  43318. /**
  43319. * This defines an action helpful to play a defined sound on a triggered action.
  43320. */
  43321. export class PlaySoundAction extends Action {
  43322. private _sound;
  43323. /**
  43324. * Instantiate the action
  43325. * @param triggerOptions defines the trigger options
  43326. * @param sound defines the sound to play
  43327. * @param condition defines the trigger related conditions
  43328. */
  43329. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43330. /** @hidden */
  43331. _prepare(): void;
  43332. /**
  43333. * Execute the action and play the sound.
  43334. */
  43335. execute(): void;
  43336. /**
  43337. * Serializes the actions and its related information.
  43338. * @param parent defines the object to serialize in
  43339. * @returns the serialized object
  43340. */
  43341. serialize(parent: any): any;
  43342. }
  43343. /**
  43344. * This defines an action helpful to stop a defined sound on a triggered action.
  43345. */
  43346. export class StopSoundAction extends Action {
  43347. private _sound;
  43348. /**
  43349. * Instantiate the action
  43350. * @param triggerOptions defines the trigger options
  43351. * @param sound defines the sound to stop
  43352. * @param condition defines the trigger related conditions
  43353. */
  43354. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43355. /** @hidden */
  43356. _prepare(): void;
  43357. /**
  43358. * Execute the action and stop the sound.
  43359. */
  43360. execute(): void;
  43361. /**
  43362. * Serializes the actions and its related information.
  43363. * @param parent defines the object to serialize in
  43364. * @returns the serialized object
  43365. */
  43366. serialize(parent: any): any;
  43367. }
  43368. }
  43369. declare module "babylonjs/Actions/interpolateValueAction" {
  43370. import { Action } from "babylonjs/Actions/action";
  43371. import { Condition } from "babylonjs/Actions/condition";
  43372. import { Observable } from "babylonjs/Misc/observable";
  43373. /**
  43374. * This defines an action responsible to change the value of a property
  43375. * by interpolating between its current value and the newly set one once triggered.
  43376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43377. */
  43378. export class InterpolateValueAction extends Action {
  43379. /**
  43380. * Defines the path of the property where the value should be interpolated
  43381. */
  43382. propertyPath: string;
  43383. /**
  43384. * Defines the target value at the end of the interpolation.
  43385. */
  43386. value: any;
  43387. /**
  43388. * Defines the time it will take for the property to interpolate to the value.
  43389. */
  43390. duration: number;
  43391. /**
  43392. * Defines if the other scene animations should be stopped when the action has been triggered
  43393. */
  43394. stopOtherAnimations?: boolean;
  43395. /**
  43396. * Defines a callback raised once the interpolation animation has been done.
  43397. */
  43398. onInterpolationDone?: () => void;
  43399. /**
  43400. * Observable triggered once the interpolation animation has been done.
  43401. */
  43402. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43403. private _target;
  43404. private _effectiveTarget;
  43405. private _property;
  43406. /**
  43407. * Instantiate the action
  43408. * @param triggerOptions defines the trigger options
  43409. * @param target defines the object containing the value to interpolate
  43410. * @param propertyPath defines the path to the property in the target object
  43411. * @param value defines the target value at the end of the interpolation
  43412. * @param duration deines the time it will take for the property to interpolate to the value.
  43413. * @param condition defines the trigger related conditions
  43414. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43415. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43416. */
  43417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43418. /** @hidden */
  43419. _prepare(): void;
  43420. /**
  43421. * Execute the action starts the value interpolation.
  43422. */
  43423. execute(): void;
  43424. /**
  43425. * Serializes the actions and its related information.
  43426. * @param parent defines the object to serialize in
  43427. * @returns the serialized object
  43428. */
  43429. serialize(parent: any): any;
  43430. }
  43431. }
  43432. declare module "babylonjs/Actions/index" {
  43433. export * from "babylonjs/Actions/abstractActionManager";
  43434. export * from "babylonjs/Actions/action";
  43435. export * from "babylonjs/Actions/actionEvent";
  43436. export * from "babylonjs/Actions/actionManager";
  43437. export * from "babylonjs/Actions/condition";
  43438. export * from "babylonjs/Actions/directActions";
  43439. export * from "babylonjs/Actions/directAudioActions";
  43440. export * from "babylonjs/Actions/interpolateValueAction";
  43441. }
  43442. declare module "babylonjs/Animations/index" {
  43443. export * from "babylonjs/Animations/animatable";
  43444. export * from "babylonjs/Animations/animation";
  43445. export * from "babylonjs/Animations/animationGroup";
  43446. export * from "babylonjs/Animations/animationPropertiesOverride";
  43447. export * from "babylonjs/Animations/easing";
  43448. export * from "babylonjs/Animations/runtimeAnimation";
  43449. export * from "babylonjs/Animations/animationEvent";
  43450. export * from "babylonjs/Animations/animationGroup";
  43451. export * from "babylonjs/Animations/animationKey";
  43452. export * from "babylonjs/Animations/animationRange";
  43453. export * from "babylonjs/Animations/animatable.interface";
  43454. }
  43455. declare module "babylonjs/Audio/soundTrack" {
  43456. import { Sound } from "babylonjs/Audio/sound";
  43457. import { Analyser } from "babylonjs/Audio/analyser";
  43458. import { Scene } from "babylonjs/scene";
  43459. /**
  43460. * Options allowed during the creation of a sound track.
  43461. */
  43462. export interface ISoundTrackOptions {
  43463. /**
  43464. * The volume the sound track should take during creation
  43465. */
  43466. volume?: number;
  43467. /**
  43468. * Define if the sound track is the main sound track of the scene
  43469. */
  43470. mainTrack?: boolean;
  43471. }
  43472. /**
  43473. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43474. * It will be also used in a future release to apply effects on a specific track.
  43475. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43476. */
  43477. export class SoundTrack {
  43478. /**
  43479. * The unique identifier of the sound track in the scene.
  43480. */
  43481. id: number;
  43482. /**
  43483. * The list of sounds included in the sound track.
  43484. */
  43485. soundCollection: Array<Sound>;
  43486. private _outputAudioNode;
  43487. private _scene;
  43488. private _connectedAnalyser;
  43489. private _options;
  43490. private _isInitialized;
  43491. /**
  43492. * Creates a new sound track.
  43493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43494. * @param scene Define the scene the sound track belongs to
  43495. * @param options
  43496. */
  43497. constructor(scene: Scene, options?: ISoundTrackOptions);
  43498. private _initializeSoundTrackAudioGraph;
  43499. /**
  43500. * Release the sound track and its associated resources
  43501. */
  43502. dispose(): void;
  43503. /**
  43504. * Adds a sound to this sound track
  43505. * @param sound define the cound to add
  43506. * @ignoreNaming
  43507. */
  43508. AddSound(sound: Sound): void;
  43509. /**
  43510. * Removes a sound to this sound track
  43511. * @param sound define the cound to remove
  43512. * @ignoreNaming
  43513. */
  43514. RemoveSound(sound: Sound): void;
  43515. /**
  43516. * Set a global volume for the full sound track.
  43517. * @param newVolume Define the new volume of the sound track
  43518. */
  43519. setVolume(newVolume: number): void;
  43520. /**
  43521. * Switch the panning model to HRTF:
  43522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43523. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43524. */
  43525. switchPanningModelToHRTF(): void;
  43526. /**
  43527. * Switch the panning model to Equal Power:
  43528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43530. */
  43531. switchPanningModelToEqualPower(): void;
  43532. /**
  43533. * Connect the sound track to an audio analyser allowing some amazing
  43534. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43536. * @param analyser The analyser to connect to the engine
  43537. */
  43538. connectToAnalyser(analyser: Analyser): void;
  43539. }
  43540. }
  43541. declare module "babylonjs/Audio/audioSceneComponent" {
  43542. import { Sound } from "babylonjs/Audio/sound";
  43543. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Vector3 } from "babylonjs/Maths/math.vector";
  43546. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { AbstractScene } from "babylonjs/abstractScene";
  43549. import "babylonjs/Audio/audioEngine";
  43550. module "babylonjs/abstractScene" {
  43551. interface AbstractScene {
  43552. /**
  43553. * The list of sounds used in the scene.
  43554. */
  43555. sounds: Nullable<Array<Sound>>;
  43556. }
  43557. }
  43558. module "babylonjs/scene" {
  43559. interface Scene {
  43560. /**
  43561. * @hidden
  43562. * Backing field
  43563. */
  43564. _mainSoundTrack: SoundTrack;
  43565. /**
  43566. * The main sound track played by the scene.
  43567. * It cotains your primary collection of sounds.
  43568. */
  43569. mainSoundTrack: SoundTrack;
  43570. /**
  43571. * The list of sound tracks added to the scene
  43572. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43573. */
  43574. soundTracks: Nullable<Array<SoundTrack>>;
  43575. /**
  43576. * Gets a sound using a given name
  43577. * @param name defines the name to search for
  43578. * @return the found sound or null if not found at all.
  43579. */
  43580. getSoundByName(name: string): Nullable<Sound>;
  43581. /**
  43582. * Gets or sets if audio support is enabled
  43583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43584. */
  43585. audioEnabled: boolean;
  43586. /**
  43587. * Gets or sets if audio will be output to headphones
  43588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43589. */
  43590. headphone: boolean;
  43591. /**
  43592. * Gets or sets custom audio listener position provider
  43593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43594. */
  43595. audioListenerPositionProvider: Nullable<() => Vector3>;
  43596. /**
  43597. * Gets or sets a refresh rate when using 3D audio positioning
  43598. */
  43599. audioPositioningRefreshRate: number;
  43600. }
  43601. }
  43602. /**
  43603. * Defines the sound scene component responsible to manage any sounds
  43604. * in a given scene.
  43605. */
  43606. export class AudioSceneComponent implements ISceneSerializableComponent {
  43607. private static _CameraDirectionLH;
  43608. private static _CameraDirectionRH;
  43609. /**
  43610. * The component name helpfull to identify the component in the list of scene components.
  43611. */
  43612. readonly name: string;
  43613. /**
  43614. * The scene the component belongs to.
  43615. */
  43616. scene: Scene;
  43617. private _audioEnabled;
  43618. /**
  43619. * Gets whether audio is enabled or not.
  43620. * Please use related enable/disable method to switch state.
  43621. */
  43622. get audioEnabled(): boolean;
  43623. private _headphone;
  43624. /**
  43625. * Gets whether audio is outputing to headphone or not.
  43626. * Please use the according Switch methods to change output.
  43627. */
  43628. get headphone(): boolean;
  43629. /**
  43630. * Gets or sets a refresh rate when using 3D audio positioning
  43631. */
  43632. audioPositioningRefreshRate: number;
  43633. private _audioListenerPositionProvider;
  43634. /**
  43635. * Gets the current audio listener position provider
  43636. */
  43637. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43638. /**
  43639. * Sets a custom listener position for all sounds in the scene
  43640. * By default, this is the position of the first active camera
  43641. */
  43642. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43643. /**
  43644. * Creates a new instance of the component for the given scene
  43645. * @param scene Defines the scene to register the component in
  43646. */
  43647. constructor(scene: Scene);
  43648. /**
  43649. * Registers the component in a given scene
  43650. */
  43651. register(): void;
  43652. /**
  43653. * Rebuilds the elements related to this component in case of
  43654. * context lost for instance.
  43655. */
  43656. rebuild(): void;
  43657. /**
  43658. * Serializes the component data to the specified json object
  43659. * @param serializationObject The object to serialize to
  43660. */
  43661. serialize(serializationObject: any): void;
  43662. /**
  43663. * Adds all the elements from the container to the scene
  43664. * @param container the container holding the elements
  43665. */
  43666. addFromContainer(container: AbstractScene): void;
  43667. /**
  43668. * Removes all the elements in the container from the scene
  43669. * @param container contains the elements to remove
  43670. * @param dispose if the removed element should be disposed (default: false)
  43671. */
  43672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43673. /**
  43674. * Disposes the component and the associated ressources.
  43675. */
  43676. dispose(): void;
  43677. /**
  43678. * Disables audio in the associated scene.
  43679. */
  43680. disableAudio(): void;
  43681. /**
  43682. * Enables audio in the associated scene.
  43683. */
  43684. enableAudio(): void;
  43685. /**
  43686. * Switch audio to headphone output.
  43687. */
  43688. switchAudioModeForHeadphones(): void;
  43689. /**
  43690. * Switch audio to normal speakers.
  43691. */
  43692. switchAudioModeForNormalSpeakers(): void;
  43693. private _cachedCameraDirection;
  43694. private _cachedCameraPosition;
  43695. private _lastCheck;
  43696. private _afterRender;
  43697. }
  43698. }
  43699. declare module "babylonjs/Audio/weightedsound" {
  43700. import { Sound } from "babylonjs/Audio/sound";
  43701. /**
  43702. * Wraps one or more Sound objects and selects one with random weight for playback.
  43703. */
  43704. export class WeightedSound {
  43705. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43706. loop: boolean;
  43707. private _coneInnerAngle;
  43708. private _coneOuterAngle;
  43709. private _volume;
  43710. /** A Sound is currently playing. */
  43711. isPlaying: boolean;
  43712. /** A Sound is currently paused. */
  43713. isPaused: boolean;
  43714. private _sounds;
  43715. private _weights;
  43716. private _currentIndex?;
  43717. /**
  43718. * Creates a new WeightedSound from the list of sounds given.
  43719. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43720. * @param sounds Array of Sounds that will be selected from.
  43721. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43722. */
  43723. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43724. /**
  43725. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43726. */
  43727. get directionalConeInnerAngle(): number;
  43728. /**
  43729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43730. */
  43731. set directionalConeInnerAngle(value: number);
  43732. /**
  43733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43735. */
  43736. get directionalConeOuterAngle(): number;
  43737. /**
  43738. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43739. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43740. */
  43741. set directionalConeOuterAngle(value: number);
  43742. /**
  43743. * Playback volume.
  43744. */
  43745. get volume(): number;
  43746. /**
  43747. * Playback volume.
  43748. */
  43749. set volume(value: number);
  43750. private _onended;
  43751. /**
  43752. * Suspend playback
  43753. */
  43754. pause(): void;
  43755. /**
  43756. * Stop playback
  43757. */
  43758. stop(): void;
  43759. /**
  43760. * Start playback.
  43761. * @param startOffset Position the clip head at a specific time in seconds.
  43762. */
  43763. play(startOffset?: number): void;
  43764. }
  43765. }
  43766. declare module "babylonjs/Audio/index" {
  43767. export * from "babylonjs/Audio/analyser";
  43768. export * from "babylonjs/Audio/audioEngine";
  43769. export * from "babylonjs/Audio/audioSceneComponent";
  43770. export * from "babylonjs/Audio/sound";
  43771. export * from "babylonjs/Audio/soundTrack";
  43772. export * from "babylonjs/Audio/weightedsound";
  43773. }
  43774. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43775. import { Behavior } from "babylonjs/Behaviors/behavior";
  43776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43777. import { BackEase } from "babylonjs/Animations/easing";
  43778. /**
  43779. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43780. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43781. */
  43782. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43783. /**
  43784. * Gets the name of the behavior.
  43785. */
  43786. get name(): string;
  43787. /**
  43788. * The easing function used by animations
  43789. */
  43790. static EasingFunction: BackEase;
  43791. /**
  43792. * The easing mode used by animations
  43793. */
  43794. static EasingMode: number;
  43795. /**
  43796. * The duration of the animation, in milliseconds
  43797. */
  43798. transitionDuration: number;
  43799. /**
  43800. * Length of the distance animated by the transition when lower radius is reached
  43801. */
  43802. lowerRadiusTransitionRange: number;
  43803. /**
  43804. * Length of the distance animated by the transition when upper radius is reached
  43805. */
  43806. upperRadiusTransitionRange: number;
  43807. private _autoTransitionRange;
  43808. /**
  43809. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43810. */
  43811. get autoTransitionRange(): boolean;
  43812. /**
  43813. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43814. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43815. */
  43816. set autoTransitionRange(value: boolean);
  43817. private _attachedCamera;
  43818. private _onAfterCheckInputsObserver;
  43819. private _onMeshTargetChangedObserver;
  43820. /**
  43821. * Initializes the behavior.
  43822. */
  43823. init(): void;
  43824. /**
  43825. * Attaches the behavior to its arc rotate camera.
  43826. * @param camera Defines the camera to attach the behavior to
  43827. */
  43828. attach(camera: ArcRotateCamera): void;
  43829. /**
  43830. * Detaches the behavior from its current arc rotate camera.
  43831. */
  43832. detach(): void;
  43833. private _radiusIsAnimating;
  43834. private _radiusBounceTransition;
  43835. private _animatables;
  43836. private _cachedWheelPrecision;
  43837. /**
  43838. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43839. * @param radiusLimit The limit to check against.
  43840. * @return Bool to indicate if at limit.
  43841. */
  43842. private _isRadiusAtLimit;
  43843. /**
  43844. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43845. * @param radiusDelta The delta by which to animate to. Can be negative.
  43846. */
  43847. private _applyBoundRadiusAnimation;
  43848. /**
  43849. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43850. */
  43851. protected _clearAnimationLocks(): void;
  43852. /**
  43853. * Stops and removes all animations that have been applied to the camera
  43854. */
  43855. stopAllAnimations(): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43859. import { Behavior } from "babylonjs/Behaviors/behavior";
  43860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43861. import { ExponentialEase } from "babylonjs/Animations/easing";
  43862. import { Nullable } from "babylonjs/types";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { Vector3 } from "babylonjs/Maths/math.vector";
  43865. /**
  43866. * 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.
  43867. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43868. */
  43869. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43870. /**
  43871. * Gets the name of the behavior.
  43872. */
  43873. get name(): string;
  43874. private _mode;
  43875. private _radiusScale;
  43876. private _positionScale;
  43877. private _defaultElevation;
  43878. private _elevationReturnTime;
  43879. private _elevationReturnWaitTime;
  43880. private _zoomStopsAnimation;
  43881. private _framingTime;
  43882. /**
  43883. * The easing function used by animations
  43884. */
  43885. static EasingFunction: ExponentialEase;
  43886. /**
  43887. * The easing mode used by animations
  43888. */
  43889. static EasingMode: number;
  43890. /**
  43891. * Sets the current mode used by the behavior
  43892. */
  43893. set mode(mode: number);
  43894. /**
  43895. * Gets current mode used by the behavior.
  43896. */
  43897. get mode(): number;
  43898. /**
  43899. * Sets the scale applied to the radius (1 by default)
  43900. */
  43901. set radiusScale(radius: number);
  43902. /**
  43903. * Gets the scale applied to the radius
  43904. */
  43905. get radiusScale(): number;
  43906. /**
  43907. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43908. */
  43909. set positionScale(scale: number);
  43910. /**
  43911. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43912. */
  43913. get positionScale(): number;
  43914. /**
  43915. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43916. * behaviour is triggered, in radians.
  43917. */
  43918. set defaultElevation(elevation: number);
  43919. /**
  43920. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43921. * behaviour is triggered, in radians.
  43922. */
  43923. get defaultElevation(): number;
  43924. /**
  43925. * Sets the time (in milliseconds) taken to return to the default beta position.
  43926. * Negative value indicates camera should not return to default.
  43927. */
  43928. set elevationReturnTime(speed: number);
  43929. /**
  43930. * Gets the time (in milliseconds) taken to return to the default beta position.
  43931. * Negative value indicates camera should not return to default.
  43932. */
  43933. get elevationReturnTime(): number;
  43934. /**
  43935. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43936. */
  43937. set elevationReturnWaitTime(time: number);
  43938. /**
  43939. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43940. */
  43941. get elevationReturnWaitTime(): number;
  43942. /**
  43943. * Sets the flag that indicates if user zooming should stop animation.
  43944. */
  43945. set zoomStopsAnimation(flag: boolean);
  43946. /**
  43947. * Gets the flag that indicates if user zooming should stop animation.
  43948. */
  43949. get zoomStopsAnimation(): boolean;
  43950. /**
  43951. * Sets the transition time when framing the mesh, in milliseconds
  43952. */
  43953. set framingTime(time: number);
  43954. /**
  43955. * Gets the transition time when framing the mesh, in milliseconds
  43956. */
  43957. get framingTime(): number;
  43958. /**
  43959. * Define if the behavior should automatically change the configured
  43960. * camera limits and sensibilities.
  43961. */
  43962. autoCorrectCameraLimitsAndSensibility: boolean;
  43963. private _onPrePointerObservableObserver;
  43964. private _onAfterCheckInputsObserver;
  43965. private _onMeshTargetChangedObserver;
  43966. private _attachedCamera;
  43967. private _isPointerDown;
  43968. private _lastInteractionTime;
  43969. /**
  43970. * Initializes the behavior.
  43971. */
  43972. init(): void;
  43973. /**
  43974. * Attaches the behavior to its arc rotate camera.
  43975. * @param camera Defines the camera to attach the behavior to
  43976. */
  43977. attach(camera: ArcRotateCamera): void;
  43978. /**
  43979. * Detaches the behavior from its current arc rotate camera.
  43980. */
  43981. detach(): void;
  43982. private _animatables;
  43983. private _betaIsAnimating;
  43984. private _betaTransition;
  43985. private _radiusTransition;
  43986. private _vectorTransition;
  43987. /**
  43988. * Targets the given mesh and updates zoom level accordingly.
  43989. * @param mesh The mesh to target.
  43990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43992. */
  43993. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43994. /**
  43995. * Targets the given mesh with its children and updates zoom level accordingly.
  43996. * @param mesh The mesh to target.
  43997. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43998. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43999. */
  44000. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44001. /**
  44002. * Targets the given meshes with their children and updates zoom level accordingly.
  44003. * @param meshes The mesh to target.
  44004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44006. */
  44007. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44008. /**
  44009. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44010. * @param minimumWorld Determines the smaller position of the bounding box extend
  44011. * @param maximumWorld Determines the bigger position of the bounding box extend
  44012. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44013. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44014. */
  44015. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44016. /**
  44017. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44018. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44019. * frustum width.
  44020. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44021. * to fully enclose the mesh in the viewing frustum.
  44022. */
  44023. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44024. /**
  44025. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44026. * is automatically returned to its default position (expected to be above ground plane).
  44027. */
  44028. private _maintainCameraAboveGround;
  44029. /**
  44030. * Returns the frustum slope based on the canvas ratio and camera FOV
  44031. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44032. */
  44033. private _getFrustumSlope;
  44034. /**
  44035. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44036. */
  44037. private _clearAnimationLocks;
  44038. /**
  44039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44040. */
  44041. private _applyUserInteraction;
  44042. /**
  44043. * Stops and removes all animations that have been applied to the camera
  44044. */
  44045. stopAllAnimations(): void;
  44046. /**
  44047. * Gets a value indicating if the user is moving the camera
  44048. */
  44049. get isUserIsMoving(): boolean;
  44050. /**
  44051. * The camera can move all the way towards the mesh.
  44052. */
  44053. static IgnoreBoundsSizeMode: number;
  44054. /**
  44055. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44056. */
  44057. static FitFrustumSidesMode: number;
  44058. }
  44059. }
  44060. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44061. import { Nullable } from "babylonjs/types";
  44062. import { Camera } from "babylonjs/Cameras/camera";
  44063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44065. /**
  44066. * Base class for Camera Pointer Inputs.
  44067. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44068. * for example usage.
  44069. */
  44070. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44071. /**
  44072. * Defines the camera the input is attached to.
  44073. */
  44074. abstract camera: Camera;
  44075. /**
  44076. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44077. */
  44078. protected _altKey: boolean;
  44079. protected _ctrlKey: boolean;
  44080. protected _metaKey: boolean;
  44081. protected _shiftKey: boolean;
  44082. /**
  44083. * Which mouse buttons were pressed at time of last mouse event.
  44084. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44085. */
  44086. protected _buttonsPressed: number;
  44087. /**
  44088. * Defines the buttons associated with the input to handle camera move.
  44089. */
  44090. buttons: number[];
  44091. /**
  44092. * Attach the input controls to a specific dom element to get the input from.
  44093. * @param element Defines the element the controls should be listened from
  44094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44095. */
  44096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44097. /**
  44098. * Detach the current controls from the specified dom element.
  44099. * @param element Defines the element to stop listening the inputs from
  44100. */
  44101. detachControl(element: Nullable<HTMLElement>): void;
  44102. /**
  44103. * Gets the class name of the current input.
  44104. * @returns the class name
  44105. */
  44106. getClassName(): string;
  44107. /**
  44108. * Get the friendly name associated with the input class.
  44109. * @returns the input friendly name
  44110. */
  44111. getSimpleName(): string;
  44112. /**
  44113. * Called on pointer POINTERDOUBLETAP event.
  44114. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44115. */
  44116. protected onDoubleTap(type: string): void;
  44117. /**
  44118. * Called on pointer POINTERMOVE event if only a single touch is active.
  44119. * Override this method to provide functionality.
  44120. */
  44121. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44122. /**
  44123. * Called on pointer POINTERMOVE event if multiple touches are active.
  44124. * Override this method to provide functionality.
  44125. */
  44126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44127. /**
  44128. * Called on JS contextmenu event.
  44129. * Override this method to provide functionality.
  44130. */
  44131. protected onContextMenu(evt: PointerEvent): void;
  44132. /**
  44133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44134. * press.
  44135. * Override this method to provide functionality.
  44136. */
  44137. protected onButtonDown(evt: PointerEvent): void;
  44138. /**
  44139. * Called each time a new POINTERUP event occurs. Ie, for each button
  44140. * release.
  44141. * Override this method to provide functionality.
  44142. */
  44143. protected onButtonUp(evt: PointerEvent): void;
  44144. /**
  44145. * Called when window becomes inactive.
  44146. * Override this method to provide functionality.
  44147. */
  44148. protected onLostFocus(): void;
  44149. private _pointerInput;
  44150. private _observer;
  44151. private _onLostFocus;
  44152. private pointA;
  44153. private pointB;
  44154. }
  44155. }
  44156. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44157. import { Nullable } from "babylonjs/types";
  44158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44159. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44160. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44161. /**
  44162. * Manage the pointers inputs to control an arc rotate camera.
  44163. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44164. */
  44165. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44166. /**
  44167. * Defines the camera the input is attached to.
  44168. */
  44169. camera: ArcRotateCamera;
  44170. /**
  44171. * Gets the class name of the current input.
  44172. * @returns the class name
  44173. */
  44174. getClassName(): string;
  44175. /**
  44176. * Defines the buttons associated with the input to handle camera move.
  44177. */
  44178. buttons: number[];
  44179. /**
  44180. * Defines the pointer angular sensibility along the X axis or how fast is
  44181. * the camera rotating.
  44182. */
  44183. angularSensibilityX: number;
  44184. /**
  44185. * Defines the pointer angular sensibility along the Y axis or how fast is
  44186. * the camera rotating.
  44187. */
  44188. angularSensibilityY: number;
  44189. /**
  44190. * Defines the pointer pinch precision or how fast is the camera zooming.
  44191. */
  44192. pinchPrecision: number;
  44193. /**
  44194. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44195. * from 0.
  44196. * It defines the percentage of current camera.radius to use as delta when
  44197. * pinch zoom is used.
  44198. */
  44199. pinchDeltaPercentage: number;
  44200. /**
  44201. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44202. * that any object in the plane at the camera's target point will scale
  44203. * perfectly with finger motion.
  44204. * Overrides pinchDeltaPercentage and pinchPrecision.
  44205. */
  44206. useNaturalPinchZoom: boolean;
  44207. /**
  44208. * Defines the pointer panning sensibility or how fast is the camera moving.
  44209. */
  44210. panningSensibility: number;
  44211. /**
  44212. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44213. */
  44214. multiTouchPanning: boolean;
  44215. /**
  44216. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44217. * zoom (pinch) through multitouch.
  44218. */
  44219. multiTouchPanAndZoom: boolean;
  44220. /**
  44221. * Revers pinch action direction.
  44222. */
  44223. pinchInwards: boolean;
  44224. private _isPanClick;
  44225. private _twoFingerActivityCount;
  44226. private _isPinching;
  44227. /**
  44228. * Called on pointer POINTERMOVE event if only a single touch is active.
  44229. */
  44230. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44231. /**
  44232. * Called on pointer POINTERDOUBLETAP event.
  44233. */
  44234. protected onDoubleTap(type: string): void;
  44235. /**
  44236. * Called on pointer POINTERMOVE event if multiple touches are active.
  44237. */
  44238. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44239. /**
  44240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44241. * press.
  44242. */
  44243. protected onButtonDown(evt: PointerEvent): void;
  44244. /**
  44245. * Called each time a new POINTERUP event occurs. Ie, for each button
  44246. * release.
  44247. */
  44248. protected onButtonUp(evt: PointerEvent): void;
  44249. /**
  44250. * Called when window becomes inactive.
  44251. */
  44252. protected onLostFocus(): void;
  44253. }
  44254. }
  44255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44256. import { Nullable } from "babylonjs/types";
  44257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44259. /**
  44260. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44262. */
  44263. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44264. /**
  44265. * Defines the camera the input is attached to.
  44266. */
  44267. camera: ArcRotateCamera;
  44268. /**
  44269. * Defines the list of key codes associated with the up action (increase alpha)
  44270. */
  44271. keysUp: number[];
  44272. /**
  44273. * Defines the list of key codes associated with the down action (decrease alpha)
  44274. */
  44275. keysDown: number[];
  44276. /**
  44277. * Defines the list of key codes associated with the left action (increase beta)
  44278. */
  44279. keysLeft: number[];
  44280. /**
  44281. * Defines the list of key codes associated with the right action (decrease beta)
  44282. */
  44283. keysRight: number[];
  44284. /**
  44285. * Defines the list of key codes associated with the reset action.
  44286. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44287. */
  44288. keysReset: number[];
  44289. /**
  44290. * Defines the panning sensibility of the inputs.
  44291. * (How fast is the camera panning)
  44292. */
  44293. panningSensibility: number;
  44294. /**
  44295. * Defines the zooming sensibility of the inputs.
  44296. * (How fast is the camera zooming)
  44297. */
  44298. zoomingSensibility: number;
  44299. /**
  44300. * Defines whether maintaining the alt key down switch the movement mode from
  44301. * orientation to zoom.
  44302. */
  44303. useAltToZoom: boolean;
  44304. /**
  44305. * Rotation speed of the camera
  44306. */
  44307. angularSpeed: number;
  44308. private _keys;
  44309. private _ctrlPressed;
  44310. private _altPressed;
  44311. private _onCanvasBlurObserver;
  44312. private _onKeyboardObserver;
  44313. private _engine;
  44314. private _scene;
  44315. /**
  44316. * Attach the input controls to a specific dom element to get the input from.
  44317. * @param element Defines the element the controls should be listened from
  44318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44319. */
  44320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44321. /**
  44322. * Detach the current controls from the specified dom element.
  44323. * @param element Defines the element to stop listening the inputs from
  44324. */
  44325. detachControl(element: Nullable<HTMLElement>): void;
  44326. /**
  44327. * Update the current camera state depending on the inputs that have been used this frame.
  44328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44329. */
  44330. checkInputs(): void;
  44331. /**
  44332. * Gets the class name of the current intput.
  44333. * @returns the class name
  44334. */
  44335. getClassName(): string;
  44336. /**
  44337. * Get the friendly name associated with the input class.
  44338. * @returns the input friendly name
  44339. */
  44340. getSimpleName(): string;
  44341. }
  44342. }
  44343. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44344. import { Nullable } from "babylonjs/types";
  44345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44347. /**
  44348. * Manage the mouse wheel inputs to control an arc rotate camera.
  44349. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44350. */
  44351. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44352. /**
  44353. * Defines the camera the input is attached to.
  44354. */
  44355. camera: ArcRotateCamera;
  44356. /**
  44357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44358. */
  44359. wheelPrecision: number;
  44360. /**
  44361. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44362. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44363. */
  44364. wheelDeltaPercentage: number;
  44365. private _wheel;
  44366. private _observer;
  44367. private computeDeltaFromMouseWheelLegacyEvent;
  44368. /**
  44369. * Attach the input controls to a specific dom element to get the input from.
  44370. * @param element Defines the element the controls should be listened from
  44371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44372. */
  44373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44374. /**
  44375. * Detach the current controls from the specified dom element.
  44376. * @param element Defines the element to stop listening the inputs from
  44377. */
  44378. detachControl(element: Nullable<HTMLElement>): void;
  44379. /**
  44380. * Gets the class name of the current intput.
  44381. * @returns the class name
  44382. */
  44383. getClassName(): string;
  44384. /**
  44385. * Get the friendly name associated with the input class.
  44386. * @returns the input friendly name
  44387. */
  44388. getSimpleName(): string;
  44389. }
  44390. }
  44391. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44393. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44394. /**
  44395. * Default Inputs manager for the ArcRotateCamera.
  44396. * It groups all the default supported inputs for ease of use.
  44397. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44398. */
  44399. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44400. /**
  44401. * Instantiates a new ArcRotateCameraInputsManager.
  44402. * @param camera Defines the camera the inputs belong to
  44403. */
  44404. constructor(camera: ArcRotateCamera);
  44405. /**
  44406. * Add mouse wheel input support to the input manager.
  44407. * @returns the current input manager
  44408. */
  44409. addMouseWheel(): ArcRotateCameraInputsManager;
  44410. /**
  44411. * Add pointers input support to the input manager.
  44412. * @returns the current input manager
  44413. */
  44414. addPointers(): ArcRotateCameraInputsManager;
  44415. /**
  44416. * Add keyboard input support to the input manager.
  44417. * @returns the current input manager
  44418. */
  44419. addKeyboard(): ArcRotateCameraInputsManager;
  44420. }
  44421. }
  44422. declare module "babylonjs/Cameras/arcRotateCamera" {
  44423. import { Observable } from "babylonjs/Misc/observable";
  44424. import { Nullable } from "babylonjs/types";
  44425. import { Scene } from "babylonjs/scene";
  44426. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44428. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44429. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44430. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44431. import { Camera } from "babylonjs/Cameras/camera";
  44432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44433. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44434. import { Collider } from "babylonjs/Collisions/collider";
  44435. /**
  44436. * This represents an orbital type of camera.
  44437. *
  44438. * 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.
  44439. * 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.
  44440. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44441. */
  44442. export class ArcRotateCamera extends TargetCamera {
  44443. /**
  44444. * Defines the rotation angle of the camera along the longitudinal axis.
  44445. */
  44446. alpha: number;
  44447. /**
  44448. * Defines the rotation angle of the camera along the latitudinal axis.
  44449. */
  44450. beta: number;
  44451. /**
  44452. * Defines the radius of the camera from it s target point.
  44453. */
  44454. radius: number;
  44455. protected _target: Vector3;
  44456. protected _targetHost: Nullable<AbstractMesh>;
  44457. /**
  44458. * Defines the target point of the camera.
  44459. * The camera looks towards it form the radius distance.
  44460. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44461. */
  44462. get target(): Vector3;
  44463. set target(value: Vector3);
  44464. /**
  44465. * Define the current local position of the camera in the scene
  44466. */
  44467. get position(): Vector3;
  44468. set position(newPosition: Vector3);
  44469. protected _upToYMatrix: Matrix;
  44470. protected _YToUpMatrix: Matrix;
  44471. /**
  44472. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44473. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44474. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44475. */
  44476. set upVector(vec: Vector3);
  44477. get upVector(): Vector3;
  44478. /**
  44479. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44480. */
  44481. setMatUp(): void;
  44482. /**
  44483. * Current inertia value on the longitudinal axis.
  44484. * The bigger this number the longer it will take for the camera to stop.
  44485. */
  44486. inertialAlphaOffset: number;
  44487. /**
  44488. * Current inertia value on the latitudinal axis.
  44489. * The bigger this number the longer it will take for the camera to stop.
  44490. */
  44491. inertialBetaOffset: number;
  44492. /**
  44493. * Current inertia value on the radius axis.
  44494. * The bigger this number the longer it will take for the camera to stop.
  44495. */
  44496. inertialRadiusOffset: number;
  44497. /**
  44498. * Minimum allowed angle on the longitudinal axis.
  44499. * This can help limiting how the Camera is able to move in the scene.
  44500. */
  44501. lowerAlphaLimit: Nullable<number>;
  44502. /**
  44503. * Maximum allowed angle on the longitudinal axis.
  44504. * This can help limiting how the Camera is able to move in the scene.
  44505. */
  44506. upperAlphaLimit: Nullable<number>;
  44507. /**
  44508. * Minimum allowed angle on the latitudinal axis.
  44509. * This can help limiting how the Camera is able to move in the scene.
  44510. */
  44511. lowerBetaLimit: number;
  44512. /**
  44513. * Maximum allowed angle on the latitudinal axis.
  44514. * This can help limiting how the Camera is able to move in the scene.
  44515. */
  44516. upperBetaLimit: number;
  44517. /**
  44518. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44519. * This can help limiting how the Camera is able to move in the scene.
  44520. */
  44521. lowerRadiusLimit: Nullable<number>;
  44522. /**
  44523. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44524. * This can help limiting how the Camera is able to move in the scene.
  44525. */
  44526. upperRadiusLimit: Nullable<number>;
  44527. /**
  44528. * Defines the current inertia value used during panning of the camera along the X axis.
  44529. */
  44530. inertialPanningX: number;
  44531. /**
  44532. * Defines the current inertia value used during panning of the camera along the Y axis.
  44533. */
  44534. inertialPanningY: number;
  44535. /**
  44536. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44537. * Basically if your fingers moves away from more than this distance you will be considered
  44538. * in pinch mode.
  44539. */
  44540. pinchToPanMaxDistance: number;
  44541. /**
  44542. * Defines the maximum distance the camera can pan.
  44543. * This could help keeping the cammera always in your scene.
  44544. */
  44545. panningDistanceLimit: Nullable<number>;
  44546. /**
  44547. * Defines the target of the camera before paning.
  44548. */
  44549. panningOriginTarget: Vector3;
  44550. /**
  44551. * Defines the value of the inertia used during panning.
  44552. * 0 would mean stop inertia and one would mean no decelleration at all.
  44553. */
  44554. panningInertia: number;
  44555. /**
  44556. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44557. */
  44558. get angularSensibilityX(): number;
  44559. set angularSensibilityX(value: number);
  44560. /**
  44561. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44562. */
  44563. get angularSensibilityY(): number;
  44564. set angularSensibilityY(value: number);
  44565. /**
  44566. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44567. */
  44568. get pinchPrecision(): number;
  44569. set pinchPrecision(value: number);
  44570. /**
  44571. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44572. * It will be used instead of pinchDeltaPrecision if different from 0.
  44573. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44574. */
  44575. get pinchDeltaPercentage(): number;
  44576. set pinchDeltaPercentage(value: number);
  44577. /**
  44578. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44579. * and pinch delta percentage.
  44580. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44581. * that any object in the plane at the camera's target point will scale
  44582. * perfectly with finger motion.
  44583. */
  44584. get useNaturalPinchZoom(): boolean;
  44585. set useNaturalPinchZoom(value: boolean);
  44586. /**
  44587. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44588. */
  44589. get panningSensibility(): number;
  44590. set panningSensibility(value: number);
  44591. /**
  44592. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44593. */
  44594. get keysUp(): number[];
  44595. set keysUp(value: number[]);
  44596. /**
  44597. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44598. */
  44599. get keysDown(): number[];
  44600. set keysDown(value: number[]);
  44601. /**
  44602. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44603. */
  44604. get keysLeft(): number[];
  44605. set keysLeft(value: number[]);
  44606. /**
  44607. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44608. */
  44609. get keysRight(): number[];
  44610. set keysRight(value: number[]);
  44611. /**
  44612. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44613. */
  44614. get wheelPrecision(): number;
  44615. set wheelPrecision(value: number);
  44616. /**
  44617. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44618. * It will be used instead of pinchDeltaPrecision if different from 0.
  44619. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44620. */
  44621. get wheelDeltaPercentage(): number;
  44622. set wheelDeltaPercentage(value: number);
  44623. /**
  44624. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44625. */
  44626. zoomOnFactor: number;
  44627. /**
  44628. * Defines a screen offset for the camera position.
  44629. */
  44630. targetScreenOffset: Vector2;
  44631. /**
  44632. * Allows the camera to be completely reversed.
  44633. * If false the camera can not arrive upside down.
  44634. */
  44635. allowUpsideDown: boolean;
  44636. /**
  44637. * Define if double tap/click is used to restore the previously saved state of the camera.
  44638. */
  44639. useInputToRestoreState: boolean;
  44640. /** @hidden */
  44641. _viewMatrix: Matrix;
  44642. /** @hidden */
  44643. _useCtrlForPanning: boolean;
  44644. /** @hidden */
  44645. _panningMouseButton: number;
  44646. /**
  44647. * Defines the input associated to the camera.
  44648. */
  44649. inputs: ArcRotateCameraInputsManager;
  44650. /** @hidden */
  44651. _reset: () => void;
  44652. /**
  44653. * Defines the allowed panning axis.
  44654. */
  44655. panningAxis: Vector3;
  44656. protected _localDirection: Vector3;
  44657. protected _transformedDirection: Vector3;
  44658. private _bouncingBehavior;
  44659. /**
  44660. * Gets the bouncing behavior of the camera if it has been enabled.
  44661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44662. */
  44663. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44664. /**
  44665. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44666. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44667. */
  44668. get useBouncingBehavior(): boolean;
  44669. set useBouncingBehavior(value: boolean);
  44670. private _framingBehavior;
  44671. /**
  44672. * Gets the framing behavior of the camera if it has been enabled.
  44673. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44674. */
  44675. get framingBehavior(): Nullable<FramingBehavior>;
  44676. /**
  44677. * Defines if the framing behavior of the camera is enabled on the camera.
  44678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44679. */
  44680. get useFramingBehavior(): boolean;
  44681. set useFramingBehavior(value: boolean);
  44682. private _autoRotationBehavior;
  44683. /**
  44684. * Gets the auto rotation behavior of the camera if it has been enabled.
  44685. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44686. */
  44687. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44688. /**
  44689. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44690. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44691. */
  44692. get useAutoRotationBehavior(): boolean;
  44693. set useAutoRotationBehavior(value: boolean);
  44694. /**
  44695. * Observable triggered when the mesh target has been changed on the camera.
  44696. */
  44697. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44698. /**
  44699. * Event raised when the camera is colliding with a mesh.
  44700. */
  44701. onCollide: (collidedMesh: AbstractMesh) => void;
  44702. /**
  44703. * Defines whether the camera should check collision with the objects oh the scene.
  44704. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44705. */
  44706. checkCollisions: boolean;
  44707. /**
  44708. * Defines the collision radius of the camera.
  44709. * This simulates a sphere around the camera.
  44710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44711. */
  44712. collisionRadius: Vector3;
  44713. protected _collider: Collider;
  44714. protected _previousPosition: Vector3;
  44715. protected _collisionVelocity: Vector3;
  44716. protected _newPosition: Vector3;
  44717. protected _previousAlpha: number;
  44718. protected _previousBeta: number;
  44719. protected _previousRadius: number;
  44720. protected _collisionTriggered: boolean;
  44721. protected _targetBoundingCenter: Nullable<Vector3>;
  44722. private _computationVector;
  44723. /**
  44724. * Instantiates a new ArcRotateCamera in a given scene
  44725. * @param name Defines the name of the camera
  44726. * @param alpha Defines the camera rotation along the logitudinal axis
  44727. * @param beta Defines the camera rotation along the latitudinal axis
  44728. * @param radius Defines the camera distance from its target
  44729. * @param target Defines the camera target
  44730. * @param scene Defines the scene the camera belongs to
  44731. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44732. */
  44733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44734. /** @hidden */
  44735. _initCache(): void;
  44736. /** @hidden */
  44737. _updateCache(ignoreParentClass?: boolean): void;
  44738. protected _getTargetPosition(): Vector3;
  44739. private _storedAlpha;
  44740. private _storedBeta;
  44741. private _storedRadius;
  44742. private _storedTarget;
  44743. private _storedTargetScreenOffset;
  44744. /**
  44745. * Stores the current state of the camera (alpha, beta, radius and target)
  44746. * @returns the camera itself
  44747. */
  44748. storeState(): Camera;
  44749. /**
  44750. * @hidden
  44751. * Restored camera state. You must call storeState() first
  44752. */
  44753. _restoreStateValues(): boolean;
  44754. /** @hidden */
  44755. _isSynchronizedViewMatrix(): boolean;
  44756. /**
  44757. * Attached controls to the current camera.
  44758. * @param element Defines the element the controls should be listened from
  44759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44761. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44762. */
  44763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44764. /**
  44765. * Detach the current controls from the camera.
  44766. * The camera will stop reacting to inputs.
  44767. * @param element Defines the element to stop listening the inputs from
  44768. */
  44769. detachControl(element: HTMLElement): void;
  44770. /** @hidden */
  44771. _checkInputs(): void;
  44772. protected _checkLimits(): void;
  44773. /**
  44774. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44775. */
  44776. rebuildAnglesAndRadius(): void;
  44777. /**
  44778. * Use a position to define the current camera related information like alpha, beta and radius
  44779. * @param position Defines the position to set the camera at
  44780. */
  44781. setPosition(position: Vector3): void;
  44782. /**
  44783. * Defines the target the camera should look at.
  44784. * This will automatically adapt alpha beta and radius to fit within the new target.
  44785. * @param target Defines the new target as a Vector or a mesh
  44786. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44787. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44788. */
  44789. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44790. /** @hidden */
  44791. _getViewMatrix(): Matrix;
  44792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44793. /**
  44794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44795. * @param meshes Defines the mesh to zoom on
  44796. * @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)
  44797. */
  44798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44799. /**
  44800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44801. * The target will be changed but the radius
  44802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44803. * @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)
  44804. */
  44805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44806. min: Vector3;
  44807. max: Vector3;
  44808. distance: number;
  44809. }, doNotUpdateMaxZ?: boolean): void;
  44810. /**
  44811. * @override
  44812. * Override Camera.createRigCamera
  44813. */
  44814. createRigCamera(name: string, cameraIndex: number): Camera;
  44815. /**
  44816. * @hidden
  44817. * @override
  44818. * Override Camera._updateRigCameras
  44819. */
  44820. _updateRigCameras(): void;
  44821. /**
  44822. * Destroy the camera and release the current resources hold by it.
  44823. */
  44824. dispose(): void;
  44825. /**
  44826. * Gets the current object class name.
  44827. * @return the class name
  44828. */
  44829. getClassName(): string;
  44830. }
  44831. }
  44832. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44833. import { Behavior } from "babylonjs/Behaviors/behavior";
  44834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44835. /**
  44836. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44837. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44838. */
  44839. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44840. /**
  44841. * Gets the name of the behavior.
  44842. */
  44843. get name(): string;
  44844. private _zoomStopsAnimation;
  44845. private _idleRotationSpeed;
  44846. private _idleRotationWaitTime;
  44847. private _idleRotationSpinupTime;
  44848. /**
  44849. * Sets the flag that indicates if user zooming should stop animation.
  44850. */
  44851. set zoomStopsAnimation(flag: boolean);
  44852. /**
  44853. * Gets the flag that indicates if user zooming should stop animation.
  44854. */
  44855. get zoomStopsAnimation(): boolean;
  44856. /**
  44857. * Sets the default speed at which the camera rotates around the model.
  44858. */
  44859. set idleRotationSpeed(speed: number);
  44860. /**
  44861. * Gets the default speed at which the camera rotates around the model.
  44862. */
  44863. get idleRotationSpeed(): number;
  44864. /**
  44865. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44866. */
  44867. set idleRotationWaitTime(time: number);
  44868. /**
  44869. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44870. */
  44871. get idleRotationWaitTime(): number;
  44872. /**
  44873. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44874. */
  44875. set idleRotationSpinupTime(time: number);
  44876. /**
  44877. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44878. */
  44879. get idleRotationSpinupTime(): number;
  44880. /**
  44881. * Gets a value indicating if the camera is currently rotating because of this behavior
  44882. */
  44883. get rotationInProgress(): boolean;
  44884. private _onPrePointerObservableObserver;
  44885. private _onAfterCheckInputsObserver;
  44886. private _attachedCamera;
  44887. private _isPointerDown;
  44888. private _lastFrameTime;
  44889. private _lastInteractionTime;
  44890. private _cameraRotationSpeed;
  44891. /**
  44892. * Initializes the behavior.
  44893. */
  44894. init(): void;
  44895. /**
  44896. * Attaches the behavior to its arc rotate camera.
  44897. * @param camera Defines the camera to attach the behavior to
  44898. */
  44899. attach(camera: ArcRotateCamera): void;
  44900. /**
  44901. * Detaches the behavior from its current arc rotate camera.
  44902. */
  44903. detach(): void;
  44904. /**
  44905. * Returns true if user is scrolling.
  44906. * @return true if user is scrolling.
  44907. */
  44908. private _userIsZooming;
  44909. private _lastFrameRadius;
  44910. private _shouldAnimationStopForInteraction;
  44911. /**
  44912. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44913. */
  44914. private _applyUserInteraction;
  44915. private _userIsMoving;
  44916. }
  44917. }
  44918. declare module "babylonjs/Behaviors/Cameras/index" {
  44919. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44920. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44921. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44922. }
  44923. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44924. import { Mesh } from "babylonjs/Meshes/mesh";
  44925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44926. import { Behavior } from "babylonjs/Behaviors/behavior";
  44927. /**
  44928. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44929. */
  44930. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44931. private ui;
  44932. /**
  44933. * The name of the behavior
  44934. */
  44935. name: string;
  44936. /**
  44937. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44938. */
  44939. distanceAwayFromFace: number;
  44940. /**
  44941. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44942. */
  44943. distanceAwayFromBottomOfFace: number;
  44944. private _faceVectors;
  44945. private _target;
  44946. private _scene;
  44947. private _onRenderObserver;
  44948. private _tmpMatrix;
  44949. private _tmpVector;
  44950. /**
  44951. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44952. * @param ui The transform node that should be attched to the mesh
  44953. */
  44954. constructor(ui: TransformNode);
  44955. /**
  44956. * Initializes the behavior
  44957. */
  44958. init(): void;
  44959. private _closestFace;
  44960. private _zeroVector;
  44961. private _lookAtTmpMatrix;
  44962. private _lookAtToRef;
  44963. /**
  44964. * Attaches the AttachToBoxBehavior to the passed in mesh
  44965. * @param target The mesh that the specified node will be attached to
  44966. */
  44967. attach(target: Mesh): void;
  44968. /**
  44969. * Detaches the behavior from the mesh
  44970. */
  44971. detach(): void;
  44972. }
  44973. }
  44974. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44975. import { Behavior } from "babylonjs/Behaviors/behavior";
  44976. import { Mesh } from "babylonjs/Meshes/mesh";
  44977. /**
  44978. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44979. */
  44980. export class FadeInOutBehavior implements Behavior<Mesh> {
  44981. /**
  44982. * Time in milliseconds to delay before fading in (Default: 0)
  44983. */
  44984. delay: number;
  44985. /**
  44986. * Time in milliseconds for the mesh to fade in (Default: 300)
  44987. */
  44988. fadeInTime: number;
  44989. private _millisecondsPerFrame;
  44990. private _hovered;
  44991. private _hoverValue;
  44992. private _ownerNode;
  44993. /**
  44994. * Instatiates the FadeInOutBehavior
  44995. */
  44996. constructor();
  44997. /**
  44998. * The name of the behavior
  44999. */
  45000. get name(): string;
  45001. /**
  45002. * Initializes the behavior
  45003. */
  45004. init(): void;
  45005. /**
  45006. * Attaches the fade behavior on the passed in mesh
  45007. * @param ownerNode The mesh that will be faded in/out once attached
  45008. */
  45009. attach(ownerNode: Mesh): void;
  45010. /**
  45011. * Detaches the behavior from the mesh
  45012. */
  45013. detach(): void;
  45014. /**
  45015. * Triggers the mesh to begin fading in or out
  45016. * @param value if the object should fade in or out (true to fade in)
  45017. */
  45018. fadeIn(value: boolean): void;
  45019. private _update;
  45020. private _setAllVisibility;
  45021. }
  45022. }
  45023. declare module "babylonjs/Misc/pivotTools" {
  45024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45025. /**
  45026. * Class containing a set of static utilities functions for managing Pivots
  45027. * @hidden
  45028. */
  45029. export class PivotTools {
  45030. private static _PivotCached;
  45031. private static _OldPivotPoint;
  45032. private static _PivotTranslation;
  45033. private static _PivotTmpVector;
  45034. private static _PivotPostMultiplyPivotMatrix;
  45035. /** @hidden */
  45036. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45037. /** @hidden */
  45038. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45039. }
  45040. }
  45041. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45042. import { Scene } from "babylonjs/scene";
  45043. import { Vector4 } from "babylonjs/Maths/math.vector";
  45044. import { Mesh } from "babylonjs/Meshes/mesh";
  45045. import { Nullable } from "babylonjs/types";
  45046. import { Plane } from "babylonjs/Maths/math.plane";
  45047. /**
  45048. * Class containing static functions to help procedurally build meshes
  45049. */
  45050. export class PlaneBuilder {
  45051. /**
  45052. * Creates a plane mesh
  45053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45059. * @param name defines the name of the mesh
  45060. * @param options defines the options used to create the mesh
  45061. * @param scene defines the hosting scene
  45062. * @returns the plane mesh
  45063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45064. */
  45065. static CreatePlane(name: string, options: {
  45066. size?: number;
  45067. width?: number;
  45068. height?: number;
  45069. sideOrientation?: number;
  45070. frontUVs?: Vector4;
  45071. backUVs?: Vector4;
  45072. updatable?: boolean;
  45073. sourcePlane?: Plane;
  45074. }, scene?: Nullable<Scene>): Mesh;
  45075. }
  45076. }
  45077. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45078. import { Behavior } from "babylonjs/Behaviors/behavior";
  45079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45080. import { Observable } from "babylonjs/Misc/observable";
  45081. import { Vector3 } from "babylonjs/Maths/math.vector";
  45082. import { Ray } from "babylonjs/Culling/ray";
  45083. import "babylonjs/Meshes/Builders/planeBuilder";
  45084. /**
  45085. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45086. */
  45087. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45088. private static _AnyMouseID;
  45089. /**
  45090. * Abstract mesh the behavior is set on
  45091. */
  45092. attachedNode: AbstractMesh;
  45093. private _dragPlane;
  45094. private _scene;
  45095. private _pointerObserver;
  45096. private _beforeRenderObserver;
  45097. private static _planeScene;
  45098. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45099. /**
  45100. * 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)
  45101. */
  45102. maxDragAngle: number;
  45103. /**
  45104. * @hidden
  45105. */
  45106. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45107. /**
  45108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45109. */
  45110. currentDraggingPointerID: number;
  45111. /**
  45112. * The last position where the pointer hit the drag plane in world space
  45113. */
  45114. lastDragPosition: Vector3;
  45115. /**
  45116. * If the behavior is currently in a dragging state
  45117. */
  45118. dragging: boolean;
  45119. /**
  45120. * 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)
  45121. */
  45122. dragDeltaRatio: number;
  45123. /**
  45124. * If the drag plane orientation should be updated during the dragging (Default: true)
  45125. */
  45126. updateDragPlane: boolean;
  45127. private _debugMode;
  45128. private _moving;
  45129. /**
  45130. * Fires each time the attached mesh is dragged with the pointer
  45131. * * delta between last drag position and current drag position in world space
  45132. * * dragDistance along the drag axis
  45133. * * dragPlaneNormal normal of the current drag plane used during the drag
  45134. * * dragPlanePoint in world space where the drag intersects the drag plane
  45135. */
  45136. onDragObservable: Observable<{
  45137. delta: Vector3;
  45138. dragPlanePoint: Vector3;
  45139. dragPlaneNormal: Vector3;
  45140. dragDistance: number;
  45141. pointerId: number;
  45142. }>;
  45143. /**
  45144. * Fires each time a drag begins (eg. mouse down on mesh)
  45145. */
  45146. onDragStartObservable: Observable<{
  45147. dragPlanePoint: Vector3;
  45148. pointerId: number;
  45149. }>;
  45150. /**
  45151. * Fires each time a drag ends (eg. mouse release after drag)
  45152. */
  45153. onDragEndObservable: Observable<{
  45154. dragPlanePoint: Vector3;
  45155. pointerId: number;
  45156. }>;
  45157. /**
  45158. * If the attached mesh should be moved when dragged
  45159. */
  45160. moveAttached: boolean;
  45161. /**
  45162. * If the drag behavior will react to drag events (Default: true)
  45163. */
  45164. enabled: boolean;
  45165. /**
  45166. * If pointer events should start and release the drag (Default: true)
  45167. */
  45168. startAndReleaseDragOnPointerEvents: boolean;
  45169. /**
  45170. * If camera controls should be detached during the drag
  45171. */
  45172. detachCameraControls: boolean;
  45173. /**
  45174. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45175. */
  45176. useObjectOrientationForDragging: boolean;
  45177. private _options;
  45178. /**
  45179. * Gets the options used by the behavior
  45180. */
  45181. get options(): {
  45182. dragAxis?: Vector3;
  45183. dragPlaneNormal?: Vector3;
  45184. };
  45185. /**
  45186. * Sets the options used by the behavior
  45187. */
  45188. set options(options: {
  45189. dragAxis?: Vector3;
  45190. dragPlaneNormal?: Vector3;
  45191. });
  45192. /**
  45193. * Creates a pointer drag behavior that can be attached to a mesh
  45194. * @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)
  45195. */
  45196. constructor(options?: {
  45197. dragAxis?: Vector3;
  45198. dragPlaneNormal?: Vector3;
  45199. });
  45200. /**
  45201. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45202. */
  45203. validateDrag: (targetPosition: Vector3) => boolean;
  45204. /**
  45205. * The name of the behavior
  45206. */
  45207. get name(): string;
  45208. /**
  45209. * Initializes the behavior
  45210. */
  45211. init(): void;
  45212. private _tmpVector;
  45213. private _alternatePickedPoint;
  45214. private _worldDragAxis;
  45215. private _targetPosition;
  45216. private _attachedElement;
  45217. /**
  45218. * Attaches the drag behavior the passed in mesh
  45219. * @param ownerNode The mesh that will be dragged around once attached
  45220. * @param predicate Predicate to use for pick filtering
  45221. */
  45222. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45223. /**
  45224. * Force relase the drag action by code.
  45225. */
  45226. releaseDrag(): void;
  45227. private _startDragRay;
  45228. private _lastPointerRay;
  45229. /**
  45230. * Simulates the start of a pointer drag event on the behavior
  45231. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45232. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45233. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45234. */
  45235. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45236. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45237. private _dragDelta;
  45238. protected _moveDrag(ray: Ray): void;
  45239. private _pickWithRayOnDragPlane;
  45240. private _pointA;
  45241. private _pointC;
  45242. private _localAxis;
  45243. private _lookAt;
  45244. private _updateDragPlanePosition;
  45245. /**
  45246. * Detaches the behavior from the mesh
  45247. */
  45248. detach(): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45252. import { Mesh } from "babylonjs/Meshes/mesh";
  45253. import { Behavior } from "babylonjs/Behaviors/behavior";
  45254. /**
  45255. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45256. */
  45257. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45258. private _dragBehaviorA;
  45259. private _dragBehaviorB;
  45260. private _startDistance;
  45261. private _initialScale;
  45262. private _targetScale;
  45263. private _ownerNode;
  45264. private _sceneRenderObserver;
  45265. /**
  45266. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45267. */
  45268. constructor();
  45269. /**
  45270. * The name of the behavior
  45271. */
  45272. get name(): string;
  45273. /**
  45274. * Initializes the behavior
  45275. */
  45276. init(): void;
  45277. private _getCurrentDistance;
  45278. /**
  45279. * Attaches the scale behavior the passed in mesh
  45280. * @param ownerNode The mesh that will be scaled around once attached
  45281. */
  45282. attach(ownerNode: Mesh): void;
  45283. /**
  45284. * Detaches the behavior from the mesh
  45285. */
  45286. detach(): void;
  45287. }
  45288. }
  45289. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45290. import { Behavior } from "babylonjs/Behaviors/behavior";
  45291. import { Mesh } from "babylonjs/Meshes/mesh";
  45292. import { Observable } from "babylonjs/Misc/observable";
  45293. /**
  45294. * 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
  45295. */
  45296. export class SixDofDragBehavior implements Behavior<Mesh> {
  45297. private static _virtualScene;
  45298. private _ownerNode;
  45299. private _sceneRenderObserver;
  45300. private _scene;
  45301. private _targetPosition;
  45302. private _virtualOriginMesh;
  45303. private _virtualDragMesh;
  45304. private _pointerObserver;
  45305. private _moving;
  45306. private _startingOrientation;
  45307. private _attachedElement;
  45308. /**
  45309. * 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)
  45310. */
  45311. private zDragFactor;
  45312. /**
  45313. * If the object should rotate to face the drag origin
  45314. */
  45315. rotateDraggedObject: boolean;
  45316. /**
  45317. * If the behavior is currently in a dragging state
  45318. */
  45319. dragging: boolean;
  45320. /**
  45321. * 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)
  45322. */
  45323. dragDeltaRatio: number;
  45324. /**
  45325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45326. */
  45327. currentDraggingPointerID: number;
  45328. /**
  45329. * If camera controls should be detached during the drag
  45330. */
  45331. detachCameraControls: boolean;
  45332. /**
  45333. * Fires each time a drag starts
  45334. */
  45335. onDragStartObservable: Observable<{}>;
  45336. /**
  45337. * Fires each time a drag ends (eg. mouse release after drag)
  45338. */
  45339. onDragEndObservable: Observable<{}>;
  45340. /**
  45341. * 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
  45342. */
  45343. constructor();
  45344. /**
  45345. * The name of the behavior
  45346. */
  45347. get name(): string;
  45348. /**
  45349. * Initializes the behavior
  45350. */
  45351. init(): void;
  45352. /**
  45353. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45354. */
  45355. private get _pointerCamera();
  45356. /**
  45357. * Attaches the scale behavior the passed in mesh
  45358. * @param ownerNode The mesh that will be scaled around once attached
  45359. */
  45360. attach(ownerNode: Mesh): void;
  45361. /**
  45362. * Detaches the behavior from the mesh
  45363. */
  45364. detach(): void;
  45365. }
  45366. }
  45367. declare module "babylonjs/Behaviors/Meshes/index" {
  45368. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45369. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45370. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45371. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45372. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45373. }
  45374. declare module "babylonjs/Behaviors/index" {
  45375. export * from "babylonjs/Behaviors/behavior";
  45376. export * from "babylonjs/Behaviors/Cameras/index";
  45377. export * from "babylonjs/Behaviors/Meshes/index";
  45378. }
  45379. declare module "babylonjs/Bones/boneIKController" {
  45380. import { Bone } from "babylonjs/Bones/bone";
  45381. import { Vector3 } from "babylonjs/Maths/math.vector";
  45382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45383. import { Nullable } from "babylonjs/types";
  45384. /**
  45385. * Class used to apply inverse kinematics to bones
  45386. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45387. */
  45388. export class BoneIKController {
  45389. private static _tmpVecs;
  45390. private static _tmpQuat;
  45391. private static _tmpMats;
  45392. /**
  45393. * Gets or sets the target mesh
  45394. */
  45395. targetMesh: AbstractMesh;
  45396. /** Gets or sets the mesh used as pole */
  45397. poleTargetMesh: AbstractMesh;
  45398. /**
  45399. * Gets or sets the bone used as pole
  45400. */
  45401. poleTargetBone: Nullable<Bone>;
  45402. /**
  45403. * Gets or sets the target position
  45404. */
  45405. targetPosition: Vector3;
  45406. /**
  45407. * Gets or sets the pole target position
  45408. */
  45409. poleTargetPosition: Vector3;
  45410. /**
  45411. * Gets or sets the pole target local offset
  45412. */
  45413. poleTargetLocalOffset: Vector3;
  45414. /**
  45415. * Gets or sets the pole angle
  45416. */
  45417. poleAngle: number;
  45418. /**
  45419. * Gets or sets the mesh associated with the controller
  45420. */
  45421. mesh: AbstractMesh;
  45422. /**
  45423. * 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)
  45424. */
  45425. slerpAmount: number;
  45426. private _bone1Quat;
  45427. private _bone1Mat;
  45428. private _bone2Ang;
  45429. private _bone1;
  45430. private _bone2;
  45431. private _bone1Length;
  45432. private _bone2Length;
  45433. private _maxAngle;
  45434. private _maxReach;
  45435. private _rightHandedSystem;
  45436. private _bendAxis;
  45437. private _slerping;
  45438. private _adjustRoll;
  45439. /**
  45440. * Gets or sets maximum allowed angle
  45441. */
  45442. get maxAngle(): number;
  45443. set maxAngle(value: number);
  45444. /**
  45445. * Creates a new BoneIKController
  45446. * @param mesh defines the mesh to control
  45447. * @param bone defines the bone to control
  45448. * @param options defines options to set up the controller
  45449. */
  45450. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45451. targetMesh?: AbstractMesh;
  45452. poleTargetMesh?: AbstractMesh;
  45453. poleTargetBone?: Bone;
  45454. poleTargetLocalOffset?: Vector3;
  45455. poleAngle?: number;
  45456. bendAxis?: Vector3;
  45457. maxAngle?: number;
  45458. slerpAmount?: number;
  45459. });
  45460. private _setMaxAngle;
  45461. /**
  45462. * Force the controller to update the bones
  45463. */
  45464. update(): void;
  45465. }
  45466. }
  45467. declare module "babylonjs/Bones/boneLookController" {
  45468. import { Vector3 } from "babylonjs/Maths/math.vector";
  45469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45470. import { Bone } from "babylonjs/Bones/bone";
  45471. import { Space } from "babylonjs/Maths/math.axis";
  45472. /**
  45473. * Class used to make a bone look toward a point in space
  45474. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45475. */
  45476. export class BoneLookController {
  45477. private static _tmpVecs;
  45478. private static _tmpQuat;
  45479. private static _tmpMats;
  45480. /**
  45481. * The target Vector3 that the bone will look at
  45482. */
  45483. target: Vector3;
  45484. /**
  45485. * The mesh that the bone is attached to
  45486. */
  45487. mesh: AbstractMesh;
  45488. /**
  45489. * The bone that will be looking to the target
  45490. */
  45491. bone: Bone;
  45492. /**
  45493. * The up axis of the coordinate system that is used when the bone is rotated
  45494. */
  45495. upAxis: Vector3;
  45496. /**
  45497. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45498. */
  45499. upAxisSpace: Space;
  45500. /**
  45501. * Used to make an adjustment to the yaw of the bone
  45502. */
  45503. adjustYaw: number;
  45504. /**
  45505. * Used to make an adjustment to the pitch of the bone
  45506. */
  45507. adjustPitch: number;
  45508. /**
  45509. * Used to make an adjustment to the roll of the bone
  45510. */
  45511. adjustRoll: number;
  45512. /**
  45513. * 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)
  45514. */
  45515. slerpAmount: number;
  45516. private _minYaw;
  45517. private _maxYaw;
  45518. private _minPitch;
  45519. private _maxPitch;
  45520. private _minYawSin;
  45521. private _minYawCos;
  45522. private _maxYawSin;
  45523. private _maxYawCos;
  45524. private _midYawConstraint;
  45525. private _minPitchTan;
  45526. private _maxPitchTan;
  45527. private _boneQuat;
  45528. private _slerping;
  45529. private _transformYawPitch;
  45530. private _transformYawPitchInv;
  45531. private _firstFrameSkipped;
  45532. private _yawRange;
  45533. private _fowardAxis;
  45534. /**
  45535. * Gets or sets the minimum yaw angle that the bone can look to
  45536. */
  45537. get minYaw(): number;
  45538. set minYaw(value: number);
  45539. /**
  45540. * Gets or sets the maximum yaw angle that the bone can look to
  45541. */
  45542. get maxYaw(): number;
  45543. set maxYaw(value: number);
  45544. /**
  45545. * Gets or sets the minimum pitch angle that the bone can look to
  45546. */
  45547. get minPitch(): number;
  45548. set minPitch(value: number);
  45549. /**
  45550. * Gets or sets the maximum pitch angle that the bone can look to
  45551. */
  45552. get maxPitch(): number;
  45553. set maxPitch(value: number);
  45554. /**
  45555. * Create a BoneLookController
  45556. * @param mesh the mesh that the bone belongs to
  45557. * @param bone the bone that will be looking to the target
  45558. * @param target the target Vector3 to look at
  45559. * @param options optional settings:
  45560. * * maxYaw: the maximum angle the bone will yaw to
  45561. * * minYaw: the minimum angle the bone will yaw to
  45562. * * maxPitch: the maximum angle the bone will pitch to
  45563. * * minPitch: the minimum angle the bone will yaw to
  45564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45565. * * upAxis: the up axis of the coordinate system
  45566. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45571. * * adjustRoll: used to make an adjustment to the roll of the bone
  45572. **/
  45573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45574. maxYaw?: number;
  45575. minYaw?: number;
  45576. maxPitch?: number;
  45577. minPitch?: number;
  45578. slerpAmount?: number;
  45579. upAxis?: Vector3;
  45580. upAxisSpace?: Space;
  45581. yawAxis?: Vector3;
  45582. pitchAxis?: Vector3;
  45583. adjustYaw?: number;
  45584. adjustPitch?: number;
  45585. adjustRoll?: number;
  45586. });
  45587. /**
  45588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45589. */
  45590. update(): void;
  45591. private _getAngleDiff;
  45592. private _getAngleBetween;
  45593. private _isAngleBetween;
  45594. }
  45595. }
  45596. declare module "babylonjs/Bones/index" {
  45597. export * from "babylonjs/Bones/bone";
  45598. export * from "babylonjs/Bones/boneIKController";
  45599. export * from "babylonjs/Bones/boneLookController";
  45600. export * from "babylonjs/Bones/skeleton";
  45601. }
  45602. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45603. import { Nullable } from "babylonjs/types";
  45604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45607. /**
  45608. * Manage the gamepad inputs to control an arc rotate camera.
  45609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45610. */
  45611. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45612. /**
  45613. * Defines the camera the input is attached to.
  45614. */
  45615. camera: ArcRotateCamera;
  45616. /**
  45617. * Defines the gamepad the input is gathering event from.
  45618. */
  45619. gamepad: Nullable<Gamepad>;
  45620. /**
  45621. * Defines the gamepad rotation sensiblity.
  45622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45623. */
  45624. gamepadRotationSensibility: number;
  45625. /**
  45626. * Defines the gamepad move sensiblity.
  45627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45628. */
  45629. gamepadMoveSensibility: number;
  45630. private _yAxisScale;
  45631. /**
  45632. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45633. */
  45634. get invertYAxis(): boolean;
  45635. set invertYAxis(value: boolean);
  45636. private _onGamepadConnectedObserver;
  45637. private _onGamepadDisconnectedObserver;
  45638. /**
  45639. * Attach the input controls to a specific dom element to get the input from.
  45640. * @param element Defines the element the controls should be listened from
  45641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45642. */
  45643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45644. /**
  45645. * Detach the current controls from the specified dom element.
  45646. * @param element Defines the element to stop listening the inputs from
  45647. */
  45648. detachControl(element: Nullable<HTMLElement>): void;
  45649. /**
  45650. * Update the current camera state depending on the inputs that have been used this frame.
  45651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45652. */
  45653. checkInputs(): void;
  45654. /**
  45655. * Gets the class name of the current intput.
  45656. * @returns the class name
  45657. */
  45658. getClassName(): string;
  45659. /**
  45660. * Get the friendly name associated with the input class.
  45661. * @returns the input friendly name
  45662. */
  45663. getSimpleName(): string;
  45664. }
  45665. }
  45666. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45667. import { Nullable } from "babylonjs/types";
  45668. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45669. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45670. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45671. interface ArcRotateCameraInputsManager {
  45672. /**
  45673. * Add orientation input support to the input manager.
  45674. * @returns the current input manager
  45675. */
  45676. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45677. }
  45678. }
  45679. /**
  45680. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45681. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45682. */
  45683. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45684. /**
  45685. * Defines the camera the input is attached to.
  45686. */
  45687. camera: ArcRotateCamera;
  45688. /**
  45689. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45690. */
  45691. alphaCorrection: number;
  45692. /**
  45693. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45694. */
  45695. gammaCorrection: number;
  45696. private _alpha;
  45697. private _gamma;
  45698. private _dirty;
  45699. private _deviceOrientationHandler;
  45700. /**
  45701. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45702. */
  45703. constructor();
  45704. /**
  45705. * Attach the input controls to a specific dom element to get the input from.
  45706. * @param element Defines the element the controls should be listened from
  45707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45708. */
  45709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45710. /** @hidden */
  45711. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45712. /**
  45713. * Update the current camera state depending on the inputs that have been used this frame.
  45714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45715. */
  45716. checkInputs(): void;
  45717. /**
  45718. * Detach the current controls from the specified dom element.
  45719. * @param element Defines the element to stop listening the inputs from
  45720. */
  45721. detachControl(element: Nullable<HTMLElement>): void;
  45722. /**
  45723. * Gets the class name of the current intput.
  45724. * @returns the class name
  45725. */
  45726. getClassName(): string;
  45727. /**
  45728. * Get the friendly name associated with the input class.
  45729. * @returns the input friendly name
  45730. */
  45731. getSimpleName(): string;
  45732. }
  45733. }
  45734. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45735. import { Nullable } from "babylonjs/types";
  45736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45737. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45738. /**
  45739. * Listen to mouse events to control the camera.
  45740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45741. */
  45742. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45743. /**
  45744. * Defines the camera the input is attached to.
  45745. */
  45746. camera: FlyCamera;
  45747. /**
  45748. * Defines if touch is enabled. (Default is true.)
  45749. */
  45750. touchEnabled: boolean;
  45751. /**
  45752. * Defines the buttons associated with the input to handle camera rotation.
  45753. */
  45754. buttons: number[];
  45755. /**
  45756. * Assign buttons for Yaw control.
  45757. */
  45758. buttonsYaw: number[];
  45759. /**
  45760. * Assign buttons for Pitch control.
  45761. */
  45762. buttonsPitch: number[];
  45763. /**
  45764. * Assign buttons for Roll control.
  45765. */
  45766. buttonsRoll: number[];
  45767. /**
  45768. * Detect if any button is being pressed while mouse is moved.
  45769. * -1 = Mouse locked.
  45770. * 0 = Left button.
  45771. * 1 = Middle Button.
  45772. * 2 = Right Button.
  45773. */
  45774. activeButton: number;
  45775. /**
  45776. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45777. * Higher values reduce its sensitivity.
  45778. */
  45779. angularSensibility: number;
  45780. private _mousemoveCallback;
  45781. private _observer;
  45782. private _rollObserver;
  45783. private previousPosition;
  45784. private noPreventDefault;
  45785. private element;
  45786. /**
  45787. * Listen to mouse events to control the camera.
  45788. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45790. */
  45791. constructor(touchEnabled?: boolean);
  45792. /**
  45793. * Attach the mouse control to the HTML DOM element.
  45794. * @param element Defines the element that listens to the input events.
  45795. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45796. */
  45797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45798. /**
  45799. * Detach the current controls from the specified dom element.
  45800. * @param element Defines the element to stop listening the inputs from
  45801. */
  45802. detachControl(element: Nullable<HTMLElement>): void;
  45803. /**
  45804. * Gets the class name of the current input.
  45805. * @returns the class name.
  45806. */
  45807. getClassName(): string;
  45808. /**
  45809. * Get the friendly name associated with the input class.
  45810. * @returns the input's friendly name.
  45811. */
  45812. getSimpleName(): string;
  45813. private _pointerInput;
  45814. private _onMouseMove;
  45815. /**
  45816. * Rotate camera by mouse offset.
  45817. */
  45818. private rotateCamera;
  45819. }
  45820. }
  45821. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45822. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45824. /**
  45825. * Default Inputs manager for the FlyCamera.
  45826. * It groups all the default supported inputs for ease of use.
  45827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45828. */
  45829. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45830. /**
  45831. * Instantiates a new FlyCameraInputsManager.
  45832. * @param camera Defines the camera the inputs belong to.
  45833. */
  45834. constructor(camera: FlyCamera);
  45835. /**
  45836. * Add keyboard input support to the input manager.
  45837. * @returns the new FlyCameraKeyboardMoveInput().
  45838. */
  45839. addKeyboard(): FlyCameraInputsManager;
  45840. /**
  45841. * Add mouse input support to the input manager.
  45842. * @param touchEnabled Enable touch screen support.
  45843. * @returns the new FlyCameraMouseInput().
  45844. */
  45845. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45846. }
  45847. }
  45848. declare module "babylonjs/Cameras/flyCamera" {
  45849. import { Scene } from "babylonjs/scene";
  45850. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45852. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45853. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45854. /**
  45855. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45856. * such as in a 3D Space Shooter or a Flight Simulator.
  45857. */
  45858. export class FlyCamera extends TargetCamera {
  45859. /**
  45860. * Define the collision ellipsoid of the camera.
  45861. * This is helpful for simulating a camera body, like a player's body.
  45862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45863. */
  45864. ellipsoid: Vector3;
  45865. /**
  45866. * Define an offset for the position of the ellipsoid around the camera.
  45867. * This can be helpful if the camera is attached away from the player's body center,
  45868. * such as at its head.
  45869. */
  45870. ellipsoidOffset: Vector3;
  45871. /**
  45872. * Enable or disable collisions of the camera with the rest of the scene objects.
  45873. */
  45874. checkCollisions: boolean;
  45875. /**
  45876. * Enable or disable gravity on the camera.
  45877. */
  45878. applyGravity: boolean;
  45879. /**
  45880. * Define the current direction the camera is moving to.
  45881. */
  45882. cameraDirection: Vector3;
  45883. /**
  45884. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45885. * This overrides and empties cameraRotation.
  45886. */
  45887. rotationQuaternion: Quaternion;
  45888. /**
  45889. * Track Roll to maintain the wanted Rolling when looking around.
  45890. */
  45891. _trackRoll: number;
  45892. /**
  45893. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45894. */
  45895. rollCorrect: number;
  45896. /**
  45897. * Mimic a banked turn, Rolling the camera when Yawing.
  45898. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45899. */
  45900. bankedTurn: boolean;
  45901. /**
  45902. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45903. */
  45904. bankedTurnLimit: number;
  45905. /**
  45906. * Value of 0 disables the banked Roll.
  45907. * Value of 1 is equal to the Yaw angle in radians.
  45908. */
  45909. bankedTurnMultiplier: number;
  45910. /**
  45911. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45912. */
  45913. inputs: FlyCameraInputsManager;
  45914. /**
  45915. * Gets the input sensibility for mouse input.
  45916. * Higher values reduce sensitivity.
  45917. */
  45918. get angularSensibility(): number;
  45919. /**
  45920. * Sets the input sensibility for a mouse input.
  45921. * Higher values reduce sensitivity.
  45922. */
  45923. set angularSensibility(value: number);
  45924. /**
  45925. * Get the keys for camera movement forward.
  45926. */
  45927. get keysForward(): number[];
  45928. /**
  45929. * Set the keys for camera movement forward.
  45930. */
  45931. set keysForward(value: number[]);
  45932. /**
  45933. * Get the keys for camera movement backward.
  45934. */
  45935. get keysBackward(): number[];
  45936. set keysBackward(value: number[]);
  45937. /**
  45938. * Get the keys for camera movement up.
  45939. */
  45940. get keysUp(): number[];
  45941. /**
  45942. * Set the keys for camera movement up.
  45943. */
  45944. set keysUp(value: number[]);
  45945. /**
  45946. * Get the keys for camera movement down.
  45947. */
  45948. get keysDown(): number[];
  45949. /**
  45950. * Set the keys for camera movement down.
  45951. */
  45952. set keysDown(value: number[]);
  45953. /**
  45954. * Get the keys for camera movement left.
  45955. */
  45956. get keysLeft(): number[];
  45957. /**
  45958. * Set the keys for camera movement left.
  45959. */
  45960. set keysLeft(value: number[]);
  45961. /**
  45962. * Set the keys for camera movement right.
  45963. */
  45964. get keysRight(): number[];
  45965. /**
  45966. * Set the keys for camera movement right.
  45967. */
  45968. set keysRight(value: number[]);
  45969. /**
  45970. * Event raised when the camera collides with a mesh in the scene.
  45971. */
  45972. onCollide: (collidedMesh: AbstractMesh) => void;
  45973. private _collider;
  45974. private _needMoveForGravity;
  45975. private _oldPosition;
  45976. private _diffPosition;
  45977. private _newPosition;
  45978. /** @hidden */
  45979. _localDirection: Vector3;
  45980. /** @hidden */
  45981. _transformedDirection: Vector3;
  45982. /**
  45983. * Instantiates a FlyCamera.
  45984. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45985. * such as in a 3D Space Shooter or a Flight Simulator.
  45986. * @param name Define the name of the camera in the scene.
  45987. * @param position Define the starting position of the camera in the scene.
  45988. * @param scene Define the scene the camera belongs to.
  45989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45990. */
  45991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45992. /**
  45993. * Attach a control to the HTML DOM element.
  45994. * @param element Defines the element that listens to the input events.
  45995. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45996. */
  45997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45998. /**
  45999. * Detach a control from the HTML DOM element.
  46000. * The camera will stop reacting to that input.
  46001. * @param element Defines the element that listens to the input events.
  46002. */
  46003. detachControl(element: HTMLElement): void;
  46004. private _collisionMask;
  46005. /**
  46006. * Get the mask that the camera ignores in collision events.
  46007. */
  46008. get collisionMask(): number;
  46009. /**
  46010. * Set the mask that the camera ignores in collision events.
  46011. */
  46012. set collisionMask(mask: number);
  46013. /** @hidden */
  46014. _collideWithWorld(displacement: Vector3): void;
  46015. /** @hidden */
  46016. private _onCollisionPositionChange;
  46017. /** @hidden */
  46018. _checkInputs(): void;
  46019. /** @hidden */
  46020. _decideIfNeedsToMove(): boolean;
  46021. /** @hidden */
  46022. _updatePosition(): void;
  46023. /**
  46024. * Restore the Roll to its target value at the rate specified.
  46025. * @param rate - Higher means slower restoring.
  46026. * @hidden
  46027. */
  46028. restoreRoll(rate: number): void;
  46029. /**
  46030. * Destroy the camera and release the current resources held by it.
  46031. */
  46032. dispose(): void;
  46033. /**
  46034. * Get the current object class name.
  46035. * @returns the class name.
  46036. */
  46037. getClassName(): string;
  46038. }
  46039. }
  46040. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46041. import { Nullable } from "babylonjs/types";
  46042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46043. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46044. /**
  46045. * Listen to keyboard events to control the camera.
  46046. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46047. */
  46048. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46049. /**
  46050. * Defines the camera the input is attached to.
  46051. */
  46052. camera: FlyCamera;
  46053. /**
  46054. * The list of keyboard keys used to control the forward move of the camera.
  46055. */
  46056. keysForward: number[];
  46057. /**
  46058. * The list of keyboard keys used to control the backward move of the camera.
  46059. */
  46060. keysBackward: number[];
  46061. /**
  46062. * The list of keyboard keys used to control the forward move of the camera.
  46063. */
  46064. keysUp: number[];
  46065. /**
  46066. * The list of keyboard keys used to control the backward move of the camera.
  46067. */
  46068. keysDown: number[];
  46069. /**
  46070. * The list of keyboard keys used to control the right strafe move of the camera.
  46071. */
  46072. keysRight: number[];
  46073. /**
  46074. * The list of keyboard keys used to control the left strafe move of the camera.
  46075. */
  46076. keysLeft: number[];
  46077. private _keys;
  46078. private _onCanvasBlurObserver;
  46079. private _onKeyboardObserver;
  46080. private _engine;
  46081. private _scene;
  46082. /**
  46083. * Attach the input controls to a specific dom element to get the input from.
  46084. * @param element Defines the element the controls should be listened from
  46085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46086. */
  46087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46088. /**
  46089. * Detach the current controls from the specified dom element.
  46090. * @param element Defines the element to stop listening the inputs from
  46091. */
  46092. detachControl(element: Nullable<HTMLElement>): void;
  46093. /**
  46094. * Gets the class name of the current intput.
  46095. * @returns the class name
  46096. */
  46097. getClassName(): string;
  46098. /** @hidden */
  46099. _onLostFocus(e: FocusEvent): void;
  46100. /**
  46101. * Get the friendly name associated with the input class.
  46102. * @returns the input friendly name
  46103. */
  46104. getSimpleName(): string;
  46105. /**
  46106. * Update the current camera state depending on the inputs that have been used this frame.
  46107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46108. */
  46109. checkInputs(): void;
  46110. }
  46111. }
  46112. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46113. import { Nullable } from "babylonjs/types";
  46114. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46116. /**
  46117. * Manage the mouse wheel inputs to control a follow camera.
  46118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46119. */
  46120. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46121. /**
  46122. * Defines the camera the input is attached to.
  46123. */
  46124. camera: FollowCamera;
  46125. /**
  46126. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46127. */
  46128. axisControlRadius: boolean;
  46129. /**
  46130. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46131. */
  46132. axisControlHeight: boolean;
  46133. /**
  46134. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46135. */
  46136. axisControlRotation: boolean;
  46137. /**
  46138. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46139. * relation to mouseWheel events.
  46140. */
  46141. wheelPrecision: number;
  46142. /**
  46143. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46144. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46145. */
  46146. wheelDeltaPercentage: number;
  46147. private _wheel;
  46148. private _observer;
  46149. /**
  46150. * Attach the input controls to a specific dom element to get the input from.
  46151. * @param element Defines the element the controls should be listened from
  46152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46153. */
  46154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46155. /**
  46156. * Detach the current controls from the specified dom element.
  46157. * @param element Defines the element to stop listening the inputs from
  46158. */
  46159. detachControl(element: Nullable<HTMLElement>): void;
  46160. /**
  46161. * Gets the class name of the current intput.
  46162. * @returns the class name
  46163. */
  46164. getClassName(): string;
  46165. /**
  46166. * Get the friendly name associated with the input class.
  46167. * @returns the input friendly name
  46168. */
  46169. getSimpleName(): string;
  46170. }
  46171. }
  46172. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46173. import { Nullable } from "babylonjs/types";
  46174. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46175. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46176. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46177. /**
  46178. * Manage the pointers inputs to control an follow camera.
  46179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46180. */
  46181. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46182. /**
  46183. * Defines the camera the input is attached to.
  46184. */
  46185. camera: FollowCamera;
  46186. /**
  46187. * Gets the class name of the current input.
  46188. * @returns the class name
  46189. */
  46190. getClassName(): string;
  46191. /**
  46192. * Defines the pointer angular sensibility along the X axis or how fast is
  46193. * the camera rotating.
  46194. * A negative number will reverse the axis direction.
  46195. */
  46196. angularSensibilityX: number;
  46197. /**
  46198. * Defines the pointer angular sensibility along the Y axis or how fast is
  46199. * the camera rotating.
  46200. * A negative number will reverse the axis direction.
  46201. */
  46202. angularSensibilityY: number;
  46203. /**
  46204. * Defines the pointer pinch precision or how fast is the camera zooming.
  46205. * A negative number will reverse the axis direction.
  46206. */
  46207. pinchPrecision: number;
  46208. /**
  46209. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46210. * from 0.
  46211. * It defines the percentage of current camera.radius to use as delta when
  46212. * pinch zoom is used.
  46213. */
  46214. pinchDeltaPercentage: number;
  46215. /**
  46216. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46217. */
  46218. axisXControlRadius: boolean;
  46219. /**
  46220. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46221. */
  46222. axisXControlHeight: boolean;
  46223. /**
  46224. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46225. */
  46226. axisXControlRotation: boolean;
  46227. /**
  46228. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46229. */
  46230. axisYControlRadius: boolean;
  46231. /**
  46232. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46233. */
  46234. axisYControlHeight: boolean;
  46235. /**
  46236. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46237. */
  46238. axisYControlRotation: boolean;
  46239. /**
  46240. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46241. */
  46242. axisPinchControlRadius: boolean;
  46243. /**
  46244. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46245. */
  46246. axisPinchControlHeight: boolean;
  46247. /**
  46248. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46249. */
  46250. axisPinchControlRotation: boolean;
  46251. /**
  46252. * Log error messages if basic misconfiguration has occurred.
  46253. */
  46254. warningEnable: boolean;
  46255. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46256. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46257. private _warningCounter;
  46258. private _warning;
  46259. }
  46260. }
  46261. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46262. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46263. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46264. /**
  46265. * Default Inputs manager for the FollowCamera.
  46266. * It groups all the default supported inputs for ease of use.
  46267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46268. */
  46269. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46270. /**
  46271. * Instantiates a new FollowCameraInputsManager.
  46272. * @param camera Defines the camera the inputs belong to
  46273. */
  46274. constructor(camera: FollowCamera);
  46275. /**
  46276. * Add keyboard input support to the input manager.
  46277. * @returns the current input manager
  46278. */
  46279. addKeyboard(): FollowCameraInputsManager;
  46280. /**
  46281. * Add mouse wheel input support to the input manager.
  46282. * @returns the current input manager
  46283. */
  46284. addMouseWheel(): FollowCameraInputsManager;
  46285. /**
  46286. * Add pointers input support to the input manager.
  46287. * @returns the current input manager
  46288. */
  46289. addPointers(): FollowCameraInputsManager;
  46290. /**
  46291. * Add orientation input support to the input manager.
  46292. * @returns the current input manager
  46293. */
  46294. addVRDeviceOrientation(): FollowCameraInputsManager;
  46295. }
  46296. }
  46297. declare module "babylonjs/Cameras/followCamera" {
  46298. import { Nullable } from "babylonjs/types";
  46299. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46300. import { Scene } from "babylonjs/scene";
  46301. import { Vector3 } from "babylonjs/Maths/math.vector";
  46302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46303. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46304. /**
  46305. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46306. * an arc rotate version arcFollowCamera are available.
  46307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46308. */
  46309. export class FollowCamera extends TargetCamera {
  46310. /**
  46311. * Distance the follow camera should follow an object at
  46312. */
  46313. radius: number;
  46314. /**
  46315. * Minimum allowed distance of the camera to the axis of rotation
  46316. * (The camera can not get closer).
  46317. * This can help limiting how the Camera is able to move in the scene.
  46318. */
  46319. lowerRadiusLimit: Nullable<number>;
  46320. /**
  46321. * Maximum allowed distance of the camera to the axis of rotation
  46322. * (The camera can not get further).
  46323. * This can help limiting how the Camera is able to move in the scene.
  46324. */
  46325. upperRadiusLimit: Nullable<number>;
  46326. /**
  46327. * Define a rotation offset between the camera and the object it follows
  46328. */
  46329. rotationOffset: number;
  46330. /**
  46331. * Minimum allowed angle to camera position relative to target object.
  46332. * This can help limiting how the Camera is able to move in the scene.
  46333. */
  46334. lowerRotationOffsetLimit: Nullable<number>;
  46335. /**
  46336. * Maximum allowed angle to camera position relative to target object.
  46337. * This can help limiting how the Camera is able to move in the scene.
  46338. */
  46339. upperRotationOffsetLimit: Nullable<number>;
  46340. /**
  46341. * Define a height offset between the camera and the object it follows.
  46342. * It can help following an object from the top (like a car chaing a plane)
  46343. */
  46344. heightOffset: number;
  46345. /**
  46346. * Minimum allowed height of camera position relative to target object.
  46347. * This can help limiting how the Camera is able to move in the scene.
  46348. */
  46349. lowerHeightOffsetLimit: Nullable<number>;
  46350. /**
  46351. * Maximum allowed height of camera position relative to target object.
  46352. * This can help limiting how the Camera is able to move in the scene.
  46353. */
  46354. upperHeightOffsetLimit: Nullable<number>;
  46355. /**
  46356. * Define how fast the camera can accelerate to follow it s target.
  46357. */
  46358. cameraAcceleration: number;
  46359. /**
  46360. * Define the speed limit of the camera following an object.
  46361. */
  46362. maxCameraSpeed: number;
  46363. /**
  46364. * Define the target of the camera.
  46365. */
  46366. lockedTarget: Nullable<AbstractMesh>;
  46367. /**
  46368. * Defines the input associated with the camera.
  46369. */
  46370. inputs: FollowCameraInputsManager;
  46371. /**
  46372. * Instantiates the follow camera.
  46373. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46374. * @param name Define the name of the camera in the scene
  46375. * @param position Define the position of the camera
  46376. * @param scene Define the scene the camera belong to
  46377. * @param lockedTarget Define the target of the camera
  46378. */
  46379. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46380. private _follow;
  46381. /**
  46382. * Attached controls to the current camera.
  46383. * @param element Defines the element the controls should be listened from
  46384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46385. */
  46386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46387. /**
  46388. * Detach the current controls from the camera.
  46389. * The camera will stop reacting to inputs.
  46390. * @param element Defines the element to stop listening the inputs from
  46391. */
  46392. detachControl(element: HTMLElement): void;
  46393. /** @hidden */
  46394. _checkInputs(): void;
  46395. private _checkLimits;
  46396. /**
  46397. * Gets the camera class name.
  46398. * @returns the class name
  46399. */
  46400. getClassName(): string;
  46401. }
  46402. /**
  46403. * Arc Rotate version of the follow camera.
  46404. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46405. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46406. */
  46407. export class ArcFollowCamera extends TargetCamera {
  46408. /** The longitudinal angle of the camera */
  46409. alpha: number;
  46410. /** The latitudinal angle of the camera */
  46411. beta: number;
  46412. /** The radius of the camera from its target */
  46413. radius: number;
  46414. private _cartesianCoordinates;
  46415. /** Define the camera target (the mesh it should follow) */
  46416. private _meshTarget;
  46417. /**
  46418. * Instantiates a new ArcFollowCamera
  46419. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46420. * @param name Define the name of the camera
  46421. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46422. * @param beta Define the rotation angle of the camera around the elevation axis
  46423. * @param radius Define the radius of the camera from its target point
  46424. * @param target Define the target of the camera
  46425. * @param scene Define the scene the camera belongs to
  46426. */
  46427. constructor(name: string,
  46428. /** The longitudinal angle of the camera */
  46429. alpha: number,
  46430. /** The latitudinal angle of the camera */
  46431. beta: number,
  46432. /** The radius of the camera from its target */
  46433. radius: number,
  46434. /** Define the camera target (the mesh it should follow) */
  46435. target: Nullable<AbstractMesh>, scene: Scene);
  46436. private _follow;
  46437. /** @hidden */
  46438. _checkInputs(): void;
  46439. /**
  46440. * Returns the class name of the object.
  46441. * It is mostly used internally for serialization purposes.
  46442. */
  46443. getClassName(): string;
  46444. }
  46445. }
  46446. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46448. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46449. import { Nullable } from "babylonjs/types";
  46450. /**
  46451. * Manage the keyboard inputs to control the movement of a follow camera.
  46452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46453. */
  46454. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46455. /**
  46456. * Defines the camera the input is attached to.
  46457. */
  46458. camera: FollowCamera;
  46459. /**
  46460. * Defines the list of key codes associated with the up action (increase heightOffset)
  46461. */
  46462. keysHeightOffsetIncr: number[];
  46463. /**
  46464. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46465. */
  46466. keysHeightOffsetDecr: number[];
  46467. /**
  46468. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46469. */
  46470. keysHeightOffsetModifierAlt: boolean;
  46471. /**
  46472. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46473. */
  46474. keysHeightOffsetModifierCtrl: boolean;
  46475. /**
  46476. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46477. */
  46478. keysHeightOffsetModifierShift: boolean;
  46479. /**
  46480. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46481. */
  46482. keysRotationOffsetIncr: number[];
  46483. /**
  46484. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46485. */
  46486. keysRotationOffsetDecr: number[];
  46487. /**
  46488. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46489. */
  46490. keysRotationOffsetModifierAlt: boolean;
  46491. /**
  46492. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46493. */
  46494. keysRotationOffsetModifierCtrl: boolean;
  46495. /**
  46496. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46497. */
  46498. keysRotationOffsetModifierShift: boolean;
  46499. /**
  46500. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46501. */
  46502. keysRadiusIncr: number[];
  46503. /**
  46504. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46505. */
  46506. keysRadiusDecr: number[];
  46507. /**
  46508. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46509. */
  46510. keysRadiusModifierAlt: boolean;
  46511. /**
  46512. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46513. */
  46514. keysRadiusModifierCtrl: boolean;
  46515. /**
  46516. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46517. */
  46518. keysRadiusModifierShift: boolean;
  46519. /**
  46520. * Defines the rate of change of heightOffset.
  46521. */
  46522. heightSensibility: number;
  46523. /**
  46524. * Defines the rate of change of rotationOffset.
  46525. */
  46526. rotationSensibility: number;
  46527. /**
  46528. * Defines the rate of change of radius.
  46529. */
  46530. radiusSensibility: number;
  46531. private _keys;
  46532. private _ctrlPressed;
  46533. private _altPressed;
  46534. private _shiftPressed;
  46535. private _onCanvasBlurObserver;
  46536. private _onKeyboardObserver;
  46537. private _engine;
  46538. private _scene;
  46539. /**
  46540. * Attach the input controls to a specific dom element to get the input from.
  46541. * @param element Defines the element the controls should be listened from
  46542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46543. */
  46544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46545. /**
  46546. * Detach the current controls from the specified dom element.
  46547. * @param element Defines the element to stop listening the inputs from
  46548. */
  46549. detachControl(element: Nullable<HTMLElement>): void;
  46550. /**
  46551. * Update the current camera state depending on the inputs that have been used this frame.
  46552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46553. */
  46554. checkInputs(): void;
  46555. /**
  46556. * Gets the class name of the current input.
  46557. * @returns the class name
  46558. */
  46559. getClassName(): string;
  46560. /**
  46561. * Get the friendly name associated with the input class.
  46562. * @returns the input friendly name
  46563. */
  46564. getSimpleName(): string;
  46565. /**
  46566. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46567. * allow modification of the heightOffset value.
  46568. */
  46569. private _modifierHeightOffset;
  46570. /**
  46571. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46572. * allow modification of the rotationOffset value.
  46573. */
  46574. private _modifierRotationOffset;
  46575. /**
  46576. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46577. * allow modification of the radius value.
  46578. */
  46579. private _modifierRadius;
  46580. }
  46581. }
  46582. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46583. import { Nullable } from "babylonjs/types";
  46584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46586. import { Observable } from "babylonjs/Misc/observable";
  46587. module "babylonjs/Cameras/freeCameraInputsManager" {
  46588. interface FreeCameraInputsManager {
  46589. /**
  46590. * @hidden
  46591. */
  46592. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46593. /**
  46594. * Add orientation input support to the input manager.
  46595. * @returns the current input manager
  46596. */
  46597. addDeviceOrientation(): FreeCameraInputsManager;
  46598. }
  46599. }
  46600. /**
  46601. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46602. * Screen rotation is taken into account.
  46603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46604. */
  46605. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46606. private _camera;
  46607. private _screenOrientationAngle;
  46608. private _constantTranform;
  46609. private _screenQuaternion;
  46610. private _alpha;
  46611. private _beta;
  46612. private _gamma;
  46613. /**
  46614. * Can be used to detect if a device orientation sensor is available on a device
  46615. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46616. * @returns a promise that will resolve on orientation change
  46617. */
  46618. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46619. /**
  46620. * @hidden
  46621. */
  46622. _onDeviceOrientationChangedObservable: Observable<void>;
  46623. /**
  46624. * Instantiates a new input
  46625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46626. */
  46627. constructor();
  46628. /**
  46629. * Define the camera controlled by the input.
  46630. */
  46631. get camera(): FreeCamera;
  46632. set camera(camera: FreeCamera);
  46633. /**
  46634. * Attach the input controls to a specific dom element to get the input from.
  46635. * @param element Defines the element the controls should be listened from
  46636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46637. */
  46638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46639. private _orientationChanged;
  46640. private _deviceOrientation;
  46641. /**
  46642. * Detach the current controls from the specified dom element.
  46643. * @param element Defines the element to stop listening the inputs from
  46644. */
  46645. detachControl(element: Nullable<HTMLElement>): void;
  46646. /**
  46647. * Update the current camera state depending on the inputs that have been used this frame.
  46648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46649. */
  46650. checkInputs(): void;
  46651. /**
  46652. * Gets the class name of the current intput.
  46653. * @returns the class name
  46654. */
  46655. getClassName(): string;
  46656. /**
  46657. * Get the friendly name associated with the input class.
  46658. * @returns the input friendly name
  46659. */
  46660. getSimpleName(): string;
  46661. }
  46662. }
  46663. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46664. import { Nullable } from "babylonjs/types";
  46665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46667. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46668. /**
  46669. * Manage the gamepad inputs to control a free camera.
  46670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46671. */
  46672. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46673. /**
  46674. * Define the camera the input is attached to.
  46675. */
  46676. camera: FreeCamera;
  46677. /**
  46678. * Define the Gamepad controlling the input
  46679. */
  46680. gamepad: Nullable<Gamepad>;
  46681. /**
  46682. * Defines the gamepad rotation sensiblity.
  46683. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46684. */
  46685. gamepadAngularSensibility: number;
  46686. /**
  46687. * Defines the gamepad move sensiblity.
  46688. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46689. */
  46690. gamepadMoveSensibility: number;
  46691. private _yAxisScale;
  46692. /**
  46693. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46694. */
  46695. get invertYAxis(): boolean;
  46696. set invertYAxis(value: boolean);
  46697. private _onGamepadConnectedObserver;
  46698. private _onGamepadDisconnectedObserver;
  46699. private _cameraTransform;
  46700. private _deltaTransform;
  46701. private _vector3;
  46702. private _vector2;
  46703. /**
  46704. * Attach the input controls to a specific dom element to get the input from.
  46705. * @param element Defines the element the controls should be listened from
  46706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46707. */
  46708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46709. /**
  46710. * Detach the current controls from the specified dom element.
  46711. * @param element Defines the element to stop listening the inputs from
  46712. */
  46713. detachControl(element: Nullable<HTMLElement>): void;
  46714. /**
  46715. * Update the current camera state depending on the inputs that have been used this frame.
  46716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46717. */
  46718. checkInputs(): void;
  46719. /**
  46720. * Gets the class name of the current intput.
  46721. * @returns the class name
  46722. */
  46723. getClassName(): string;
  46724. /**
  46725. * Get the friendly name associated with the input class.
  46726. * @returns the input friendly name
  46727. */
  46728. getSimpleName(): string;
  46729. }
  46730. }
  46731. declare module "babylonjs/Misc/virtualJoystick" {
  46732. import { Nullable } from "babylonjs/types";
  46733. import { Vector3 } from "babylonjs/Maths/math.vector";
  46734. /**
  46735. * Defines the potential axis of a Joystick
  46736. */
  46737. export enum JoystickAxis {
  46738. /** X axis */
  46739. X = 0,
  46740. /** Y axis */
  46741. Y = 1,
  46742. /** Z axis */
  46743. Z = 2
  46744. }
  46745. /**
  46746. * Represents the different customization options available
  46747. * for VirtualJoystick
  46748. */
  46749. interface VirtualJoystickCustomizations {
  46750. /**
  46751. * Size of the joystick's puck
  46752. */
  46753. puckSize: number;
  46754. /**
  46755. * Size of the joystick's container
  46756. */
  46757. containerSize: number;
  46758. /**
  46759. * Color of the joystick && puck
  46760. */
  46761. color: string;
  46762. /**
  46763. * Image URL for the joystick's puck
  46764. */
  46765. puckImage?: string;
  46766. /**
  46767. * Image URL for the joystick's container
  46768. */
  46769. containerImage?: string;
  46770. /**
  46771. * Defines the unmoving position of the joystick container
  46772. */
  46773. position?: {
  46774. x: number;
  46775. y: number;
  46776. };
  46777. /**
  46778. * Defines whether or not the joystick container is always visible
  46779. */
  46780. alwaysVisible: boolean;
  46781. /**
  46782. * Defines whether or not to limit the movement of the puck to the joystick's container
  46783. */
  46784. limitToContainer: boolean;
  46785. }
  46786. /**
  46787. * Class used to define virtual joystick (used in touch mode)
  46788. */
  46789. export class VirtualJoystick {
  46790. /**
  46791. * Gets or sets a boolean indicating that left and right values must be inverted
  46792. */
  46793. reverseLeftRight: boolean;
  46794. /**
  46795. * Gets or sets a boolean indicating that up and down values must be inverted
  46796. */
  46797. reverseUpDown: boolean;
  46798. /**
  46799. * Gets the offset value for the position (ie. the change of the position value)
  46800. */
  46801. deltaPosition: Vector3;
  46802. /**
  46803. * Gets a boolean indicating if the virtual joystick was pressed
  46804. */
  46805. pressed: boolean;
  46806. /**
  46807. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46808. */
  46809. static Canvas: Nullable<HTMLCanvasElement>;
  46810. /**
  46811. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46812. */
  46813. limitToContainer: boolean;
  46814. private static _globalJoystickIndex;
  46815. private static _alwaysVisibleSticks;
  46816. private static vjCanvasContext;
  46817. private static vjCanvasWidth;
  46818. private static vjCanvasHeight;
  46819. private static halfWidth;
  46820. private static _GetDefaultOptions;
  46821. private _action;
  46822. private _axisTargetedByLeftAndRight;
  46823. private _axisTargetedByUpAndDown;
  46824. private _joystickSensibility;
  46825. private _inversedSensibility;
  46826. private _joystickPointerID;
  46827. private _joystickColor;
  46828. private _joystickPointerPos;
  46829. private _joystickPreviousPointerPos;
  46830. private _joystickPointerStartPos;
  46831. private _deltaJoystickVector;
  46832. private _leftJoystick;
  46833. private _touches;
  46834. private _joystickPosition;
  46835. private _alwaysVisible;
  46836. private _puckImage;
  46837. private _containerImage;
  46838. private _joystickPuckSize;
  46839. private _joystickContainerSize;
  46840. private _clearPuckSize;
  46841. private _clearContainerSize;
  46842. private _clearPuckSizeOffset;
  46843. private _clearContainerSizeOffset;
  46844. private _onPointerDownHandlerRef;
  46845. private _onPointerMoveHandlerRef;
  46846. private _onPointerUpHandlerRef;
  46847. private _onResize;
  46848. /**
  46849. * Creates a new virtual joystick
  46850. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46851. * @param customizations Defines the options we want to customize the VirtualJoystick
  46852. */
  46853. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46854. /**
  46855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46856. * @param newJoystickSensibility defines the new sensibility
  46857. */
  46858. setJoystickSensibility(newJoystickSensibility: number): void;
  46859. private _onPointerDown;
  46860. private _onPointerMove;
  46861. private _onPointerUp;
  46862. /**
  46863. * Change the color of the virtual joystick
  46864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46865. */
  46866. setJoystickColor(newColor: string): void;
  46867. /**
  46868. * Size of the joystick's container
  46869. */
  46870. set containerSize(newSize: number);
  46871. get containerSize(): number;
  46872. /**
  46873. * Size of the joystick's puck
  46874. */
  46875. set puckSize(newSize: number);
  46876. get puckSize(): number;
  46877. /**
  46878. * Clears the set position of the joystick
  46879. */
  46880. clearPosition(): void;
  46881. /**
  46882. * Defines whether or not the joystick container is always visible
  46883. */
  46884. set alwaysVisible(value: boolean);
  46885. get alwaysVisible(): boolean;
  46886. /**
  46887. * Sets the constant position of the Joystick container
  46888. * @param x X axis coordinate
  46889. * @param y Y axis coordinate
  46890. */
  46891. setPosition(x: number, y: number): void;
  46892. /**
  46893. * Defines a callback to call when the joystick is touched
  46894. * @param action defines the callback
  46895. */
  46896. setActionOnTouch(action: () => any): void;
  46897. /**
  46898. * Defines which axis you'd like to control for left & right
  46899. * @param axis defines the axis to use
  46900. */
  46901. setAxisForLeftRight(axis: JoystickAxis): void;
  46902. /**
  46903. * Defines which axis you'd like to control for up & down
  46904. * @param axis defines the axis to use
  46905. */
  46906. setAxisForUpDown(axis: JoystickAxis): void;
  46907. /**
  46908. * Clears the canvas from the previous puck / container draw
  46909. */
  46910. private _clearPreviousDraw;
  46911. /**
  46912. * Loads `urlPath` to be used for the container's image
  46913. * @param urlPath defines the urlPath of an image to use
  46914. */
  46915. setContainerImage(urlPath: string): void;
  46916. /**
  46917. * Loads `urlPath` to be used for the puck's image
  46918. * @param urlPath defines the urlPath of an image to use
  46919. */
  46920. setPuckImage(urlPath: string): void;
  46921. /**
  46922. * Draws the Virtual Joystick's container
  46923. */
  46924. private _drawContainer;
  46925. /**
  46926. * Draws the Virtual Joystick's puck
  46927. */
  46928. private _drawPuck;
  46929. private _drawVirtualJoystick;
  46930. /**
  46931. * Release internal HTML canvas
  46932. */
  46933. releaseCanvas(): void;
  46934. }
  46935. }
  46936. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46937. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46938. import { Nullable } from "babylonjs/types";
  46939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46940. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46941. module "babylonjs/Cameras/freeCameraInputsManager" {
  46942. interface FreeCameraInputsManager {
  46943. /**
  46944. * Add virtual joystick input support to the input manager.
  46945. * @returns the current input manager
  46946. */
  46947. addVirtualJoystick(): FreeCameraInputsManager;
  46948. }
  46949. }
  46950. /**
  46951. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46952. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46953. */
  46954. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46955. /**
  46956. * Defines the camera the input is attached to.
  46957. */
  46958. camera: FreeCamera;
  46959. private _leftjoystick;
  46960. private _rightjoystick;
  46961. /**
  46962. * Gets the left stick of the virtual joystick.
  46963. * @returns The virtual Joystick
  46964. */
  46965. getLeftJoystick(): VirtualJoystick;
  46966. /**
  46967. * Gets the right stick of the virtual joystick.
  46968. * @returns The virtual Joystick
  46969. */
  46970. getRightJoystick(): VirtualJoystick;
  46971. /**
  46972. * Update the current camera state depending on the inputs that have been used this frame.
  46973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46974. */
  46975. checkInputs(): void;
  46976. /**
  46977. * Attach the input controls to a specific dom element to get the input from.
  46978. * @param element Defines the element the controls should be listened from
  46979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46980. */
  46981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46982. /**
  46983. * Detach the current controls from the specified dom element.
  46984. * @param element Defines the element to stop listening the inputs from
  46985. */
  46986. detachControl(element: Nullable<HTMLElement>): void;
  46987. /**
  46988. * Gets the class name of the current intput.
  46989. * @returns the class name
  46990. */
  46991. getClassName(): string;
  46992. /**
  46993. * Get the friendly name associated with the input class.
  46994. * @returns the input friendly name
  46995. */
  46996. getSimpleName(): string;
  46997. }
  46998. }
  46999. declare module "babylonjs/Cameras/Inputs/index" {
  47000. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47001. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47002. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47003. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47005. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47006. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47007. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47008. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47009. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47010. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47011. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47012. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47013. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47016. }
  47017. declare module "babylonjs/Cameras/touchCamera" {
  47018. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47019. import { Scene } from "babylonjs/scene";
  47020. import { Vector3 } from "babylonjs/Maths/math.vector";
  47021. /**
  47022. * This represents a FPS type of camera controlled by touch.
  47023. * This is like a universal camera minus the Gamepad controls.
  47024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47025. */
  47026. export class TouchCamera extends FreeCamera {
  47027. /**
  47028. * Defines the touch sensibility for rotation.
  47029. * The higher the faster.
  47030. */
  47031. get touchAngularSensibility(): number;
  47032. set touchAngularSensibility(value: number);
  47033. /**
  47034. * Defines the touch sensibility for move.
  47035. * The higher the faster.
  47036. */
  47037. get touchMoveSensibility(): number;
  47038. set touchMoveSensibility(value: number);
  47039. /**
  47040. * Instantiates a new touch camera.
  47041. * This represents a FPS type of camera controlled by touch.
  47042. * This is like a universal camera minus the Gamepad controls.
  47043. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47044. * @param name Define the name of the camera in the scene
  47045. * @param position Define the start position of the camera in the scene
  47046. * @param scene Define the scene the camera belongs to
  47047. */
  47048. constructor(name: string, position: Vector3, scene: Scene);
  47049. /**
  47050. * Gets the current object class name.
  47051. * @return the class name
  47052. */
  47053. getClassName(): string;
  47054. /** @hidden */
  47055. _setupInputs(): void;
  47056. }
  47057. }
  47058. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47059. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47060. import { Scene } from "babylonjs/scene";
  47061. import { Vector3 } from "babylonjs/Maths/math.vector";
  47062. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47063. import { Axis } from "babylonjs/Maths/math.axis";
  47064. /**
  47065. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47066. * being tilted forward or back and left or right.
  47067. */
  47068. export class DeviceOrientationCamera extends FreeCamera {
  47069. private _initialQuaternion;
  47070. private _quaternionCache;
  47071. private _tmpDragQuaternion;
  47072. private _disablePointerInputWhenUsingDeviceOrientation;
  47073. /**
  47074. * Creates a new device orientation camera
  47075. * @param name The name of the camera
  47076. * @param position The start position camera
  47077. * @param scene The scene the camera belongs to
  47078. */
  47079. constructor(name: string, position: Vector3, scene: Scene);
  47080. /**
  47081. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47082. */
  47083. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47084. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47085. private _dragFactor;
  47086. /**
  47087. * Enabled turning on the y axis when the orientation sensor is active
  47088. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47089. */
  47090. enableHorizontalDragging(dragFactor?: number): void;
  47091. /**
  47092. * Gets the current instance class name ("DeviceOrientationCamera").
  47093. * This helps avoiding instanceof at run time.
  47094. * @returns the class name
  47095. */
  47096. getClassName(): string;
  47097. /**
  47098. * @hidden
  47099. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47100. */
  47101. _checkInputs(): void;
  47102. /**
  47103. * Reset the camera to its default orientation on the specified axis only.
  47104. * @param axis The axis to reset
  47105. */
  47106. resetToCurrentRotation(axis?: Axis): void;
  47107. }
  47108. }
  47109. declare module "babylonjs/Gamepads/xboxGamepad" {
  47110. import { Observable } from "babylonjs/Misc/observable";
  47111. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47112. /**
  47113. * Defines supported buttons for XBox360 compatible gamepads
  47114. */
  47115. export enum Xbox360Button {
  47116. /** A */
  47117. A = 0,
  47118. /** B */
  47119. B = 1,
  47120. /** X */
  47121. X = 2,
  47122. /** Y */
  47123. Y = 3,
  47124. /** Left button */
  47125. LB = 4,
  47126. /** Right button */
  47127. RB = 5,
  47128. /** Back */
  47129. Back = 8,
  47130. /** Start */
  47131. Start = 9,
  47132. /** Left stick */
  47133. LeftStick = 10,
  47134. /** Right stick */
  47135. RightStick = 11
  47136. }
  47137. /** Defines values for XBox360 DPad */
  47138. export enum Xbox360Dpad {
  47139. /** Up */
  47140. Up = 12,
  47141. /** Down */
  47142. Down = 13,
  47143. /** Left */
  47144. Left = 14,
  47145. /** Right */
  47146. Right = 15
  47147. }
  47148. /**
  47149. * Defines a XBox360 gamepad
  47150. */
  47151. export class Xbox360Pad extends Gamepad {
  47152. private _leftTrigger;
  47153. private _rightTrigger;
  47154. private _onlefttriggerchanged;
  47155. private _onrighttriggerchanged;
  47156. private _onbuttondown;
  47157. private _onbuttonup;
  47158. private _ondpaddown;
  47159. private _ondpadup;
  47160. /** Observable raised when a button is pressed */
  47161. onButtonDownObservable: Observable<Xbox360Button>;
  47162. /** Observable raised when a button is released */
  47163. onButtonUpObservable: Observable<Xbox360Button>;
  47164. /** Observable raised when a pad is pressed */
  47165. onPadDownObservable: Observable<Xbox360Dpad>;
  47166. /** Observable raised when a pad is released */
  47167. onPadUpObservable: Observable<Xbox360Dpad>;
  47168. private _buttonA;
  47169. private _buttonB;
  47170. private _buttonX;
  47171. private _buttonY;
  47172. private _buttonBack;
  47173. private _buttonStart;
  47174. private _buttonLB;
  47175. private _buttonRB;
  47176. private _buttonLeftStick;
  47177. private _buttonRightStick;
  47178. private _dPadUp;
  47179. private _dPadDown;
  47180. private _dPadLeft;
  47181. private _dPadRight;
  47182. private _isXboxOnePad;
  47183. /**
  47184. * Creates a new XBox360 gamepad object
  47185. * @param id defines the id of this gamepad
  47186. * @param index defines its index
  47187. * @param gamepad defines the internal HTML gamepad object
  47188. * @param xboxOne defines if it is a XBox One gamepad
  47189. */
  47190. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47191. /**
  47192. * Defines the callback to call when left trigger is pressed
  47193. * @param callback defines the callback to use
  47194. */
  47195. onlefttriggerchanged(callback: (value: number) => void): void;
  47196. /**
  47197. * Defines the callback to call when right trigger is pressed
  47198. * @param callback defines the callback to use
  47199. */
  47200. onrighttriggerchanged(callback: (value: number) => void): void;
  47201. /**
  47202. * Gets the left trigger value
  47203. */
  47204. get leftTrigger(): number;
  47205. /**
  47206. * Sets the left trigger value
  47207. */
  47208. set leftTrigger(newValue: number);
  47209. /**
  47210. * Gets the right trigger value
  47211. */
  47212. get rightTrigger(): number;
  47213. /**
  47214. * Sets the right trigger value
  47215. */
  47216. set rightTrigger(newValue: number);
  47217. /**
  47218. * Defines the callback to call when a button is pressed
  47219. * @param callback defines the callback to use
  47220. */
  47221. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47222. /**
  47223. * Defines the callback to call when a button is released
  47224. * @param callback defines the callback to use
  47225. */
  47226. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47227. /**
  47228. * Defines the callback to call when a pad is pressed
  47229. * @param callback defines the callback to use
  47230. */
  47231. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47232. /**
  47233. * Defines the callback to call when a pad is released
  47234. * @param callback defines the callback to use
  47235. */
  47236. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47237. private _setButtonValue;
  47238. private _setDPadValue;
  47239. /**
  47240. * Gets the value of the `A` button
  47241. */
  47242. get buttonA(): number;
  47243. /**
  47244. * Sets the value of the `A` button
  47245. */
  47246. set buttonA(value: number);
  47247. /**
  47248. * Gets the value of the `B` button
  47249. */
  47250. get buttonB(): number;
  47251. /**
  47252. * Sets the value of the `B` button
  47253. */
  47254. set buttonB(value: number);
  47255. /**
  47256. * Gets the value of the `X` button
  47257. */
  47258. get buttonX(): number;
  47259. /**
  47260. * Sets the value of the `X` button
  47261. */
  47262. set buttonX(value: number);
  47263. /**
  47264. * Gets the value of the `Y` button
  47265. */
  47266. get buttonY(): number;
  47267. /**
  47268. * Sets the value of the `Y` button
  47269. */
  47270. set buttonY(value: number);
  47271. /**
  47272. * Gets the value of the `Start` button
  47273. */
  47274. get buttonStart(): number;
  47275. /**
  47276. * Sets the value of the `Start` button
  47277. */
  47278. set buttonStart(value: number);
  47279. /**
  47280. * Gets the value of the `Back` button
  47281. */
  47282. get buttonBack(): number;
  47283. /**
  47284. * Sets the value of the `Back` button
  47285. */
  47286. set buttonBack(value: number);
  47287. /**
  47288. * Gets the value of the `Left` button
  47289. */
  47290. get buttonLB(): number;
  47291. /**
  47292. * Sets the value of the `Left` button
  47293. */
  47294. set buttonLB(value: number);
  47295. /**
  47296. * Gets the value of the `Right` button
  47297. */
  47298. get buttonRB(): number;
  47299. /**
  47300. * Sets the value of the `Right` button
  47301. */
  47302. set buttonRB(value: number);
  47303. /**
  47304. * Gets the value of the Left joystick
  47305. */
  47306. get buttonLeftStick(): number;
  47307. /**
  47308. * Sets the value of the Left joystick
  47309. */
  47310. set buttonLeftStick(value: number);
  47311. /**
  47312. * Gets the value of the Right joystick
  47313. */
  47314. get buttonRightStick(): number;
  47315. /**
  47316. * Sets the value of the Right joystick
  47317. */
  47318. set buttonRightStick(value: number);
  47319. /**
  47320. * Gets the value of D-pad up
  47321. */
  47322. get dPadUp(): number;
  47323. /**
  47324. * Sets the value of D-pad up
  47325. */
  47326. set dPadUp(value: number);
  47327. /**
  47328. * Gets the value of D-pad down
  47329. */
  47330. get dPadDown(): number;
  47331. /**
  47332. * Sets the value of D-pad down
  47333. */
  47334. set dPadDown(value: number);
  47335. /**
  47336. * Gets the value of D-pad left
  47337. */
  47338. get dPadLeft(): number;
  47339. /**
  47340. * Sets the value of D-pad left
  47341. */
  47342. set dPadLeft(value: number);
  47343. /**
  47344. * Gets the value of D-pad right
  47345. */
  47346. get dPadRight(): number;
  47347. /**
  47348. * Sets the value of D-pad right
  47349. */
  47350. set dPadRight(value: number);
  47351. /**
  47352. * Force the gamepad to synchronize with device values
  47353. */
  47354. update(): void;
  47355. /**
  47356. * Disposes the gamepad
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47362. import { Observable } from "babylonjs/Misc/observable";
  47363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47364. /**
  47365. * Defines supported buttons for DualShock compatible gamepads
  47366. */
  47367. export enum DualShockButton {
  47368. /** Cross */
  47369. Cross = 0,
  47370. /** Circle */
  47371. Circle = 1,
  47372. /** Square */
  47373. Square = 2,
  47374. /** Triangle */
  47375. Triangle = 3,
  47376. /** L1 */
  47377. L1 = 4,
  47378. /** R1 */
  47379. R1 = 5,
  47380. /** Share */
  47381. Share = 8,
  47382. /** Options */
  47383. Options = 9,
  47384. /** Left stick */
  47385. LeftStick = 10,
  47386. /** Right stick */
  47387. RightStick = 11
  47388. }
  47389. /** Defines values for DualShock DPad */
  47390. export enum DualShockDpad {
  47391. /** Up */
  47392. Up = 12,
  47393. /** Down */
  47394. Down = 13,
  47395. /** Left */
  47396. Left = 14,
  47397. /** Right */
  47398. Right = 15
  47399. }
  47400. /**
  47401. * Defines a DualShock gamepad
  47402. */
  47403. export class DualShockPad extends Gamepad {
  47404. private _leftTrigger;
  47405. private _rightTrigger;
  47406. private _onlefttriggerchanged;
  47407. private _onrighttriggerchanged;
  47408. private _onbuttondown;
  47409. private _onbuttonup;
  47410. private _ondpaddown;
  47411. private _ondpadup;
  47412. /** Observable raised when a button is pressed */
  47413. onButtonDownObservable: Observable<DualShockButton>;
  47414. /** Observable raised when a button is released */
  47415. onButtonUpObservable: Observable<DualShockButton>;
  47416. /** Observable raised when a pad is pressed */
  47417. onPadDownObservable: Observable<DualShockDpad>;
  47418. /** Observable raised when a pad is released */
  47419. onPadUpObservable: Observable<DualShockDpad>;
  47420. private _buttonCross;
  47421. private _buttonCircle;
  47422. private _buttonSquare;
  47423. private _buttonTriangle;
  47424. private _buttonShare;
  47425. private _buttonOptions;
  47426. private _buttonL1;
  47427. private _buttonR1;
  47428. private _buttonLeftStick;
  47429. private _buttonRightStick;
  47430. private _dPadUp;
  47431. private _dPadDown;
  47432. private _dPadLeft;
  47433. private _dPadRight;
  47434. /**
  47435. * Creates a new DualShock gamepad object
  47436. * @param id defines the id of this gamepad
  47437. * @param index defines its index
  47438. * @param gamepad defines the internal HTML gamepad object
  47439. */
  47440. constructor(id: string, index: number, gamepad: any);
  47441. /**
  47442. * Defines the callback to call when left trigger is pressed
  47443. * @param callback defines the callback to use
  47444. */
  47445. onlefttriggerchanged(callback: (value: number) => void): void;
  47446. /**
  47447. * Defines the callback to call when right trigger is pressed
  47448. * @param callback defines the callback to use
  47449. */
  47450. onrighttriggerchanged(callback: (value: number) => void): void;
  47451. /**
  47452. * Gets the left trigger value
  47453. */
  47454. get leftTrigger(): number;
  47455. /**
  47456. * Sets the left trigger value
  47457. */
  47458. set leftTrigger(newValue: number);
  47459. /**
  47460. * Gets the right trigger value
  47461. */
  47462. get rightTrigger(): number;
  47463. /**
  47464. * Sets the right trigger value
  47465. */
  47466. set rightTrigger(newValue: number);
  47467. /**
  47468. * Defines the callback to call when a button is pressed
  47469. * @param callback defines the callback to use
  47470. */
  47471. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47472. /**
  47473. * Defines the callback to call when a button is released
  47474. * @param callback defines the callback to use
  47475. */
  47476. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47477. /**
  47478. * Defines the callback to call when a pad is pressed
  47479. * @param callback defines the callback to use
  47480. */
  47481. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47482. /**
  47483. * Defines the callback to call when a pad is released
  47484. * @param callback defines the callback to use
  47485. */
  47486. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47487. private _setButtonValue;
  47488. private _setDPadValue;
  47489. /**
  47490. * Gets the value of the `Cross` button
  47491. */
  47492. get buttonCross(): number;
  47493. /**
  47494. * Sets the value of the `Cross` button
  47495. */
  47496. set buttonCross(value: number);
  47497. /**
  47498. * Gets the value of the `Circle` button
  47499. */
  47500. get buttonCircle(): number;
  47501. /**
  47502. * Sets the value of the `Circle` button
  47503. */
  47504. set buttonCircle(value: number);
  47505. /**
  47506. * Gets the value of the `Square` button
  47507. */
  47508. get buttonSquare(): number;
  47509. /**
  47510. * Sets the value of the `Square` button
  47511. */
  47512. set buttonSquare(value: number);
  47513. /**
  47514. * Gets the value of the `Triangle` button
  47515. */
  47516. get buttonTriangle(): number;
  47517. /**
  47518. * Sets the value of the `Triangle` button
  47519. */
  47520. set buttonTriangle(value: number);
  47521. /**
  47522. * Gets the value of the `Options` button
  47523. */
  47524. get buttonOptions(): number;
  47525. /**
  47526. * Sets the value of the `Options` button
  47527. */
  47528. set buttonOptions(value: number);
  47529. /**
  47530. * Gets the value of the `Share` button
  47531. */
  47532. get buttonShare(): number;
  47533. /**
  47534. * Sets the value of the `Share` button
  47535. */
  47536. set buttonShare(value: number);
  47537. /**
  47538. * Gets the value of the `L1` button
  47539. */
  47540. get buttonL1(): number;
  47541. /**
  47542. * Sets the value of the `L1` button
  47543. */
  47544. set buttonL1(value: number);
  47545. /**
  47546. * Gets the value of the `R1` button
  47547. */
  47548. get buttonR1(): number;
  47549. /**
  47550. * Sets the value of the `R1` button
  47551. */
  47552. set buttonR1(value: number);
  47553. /**
  47554. * Gets the value of the Left joystick
  47555. */
  47556. get buttonLeftStick(): number;
  47557. /**
  47558. * Sets the value of the Left joystick
  47559. */
  47560. set buttonLeftStick(value: number);
  47561. /**
  47562. * Gets the value of the Right joystick
  47563. */
  47564. get buttonRightStick(): number;
  47565. /**
  47566. * Sets the value of the Right joystick
  47567. */
  47568. set buttonRightStick(value: number);
  47569. /**
  47570. * Gets the value of D-pad up
  47571. */
  47572. get dPadUp(): number;
  47573. /**
  47574. * Sets the value of D-pad up
  47575. */
  47576. set dPadUp(value: number);
  47577. /**
  47578. * Gets the value of D-pad down
  47579. */
  47580. get dPadDown(): number;
  47581. /**
  47582. * Sets the value of D-pad down
  47583. */
  47584. set dPadDown(value: number);
  47585. /**
  47586. * Gets the value of D-pad left
  47587. */
  47588. get dPadLeft(): number;
  47589. /**
  47590. * Sets the value of D-pad left
  47591. */
  47592. set dPadLeft(value: number);
  47593. /**
  47594. * Gets the value of D-pad right
  47595. */
  47596. get dPadRight(): number;
  47597. /**
  47598. * Sets the value of D-pad right
  47599. */
  47600. set dPadRight(value: number);
  47601. /**
  47602. * Force the gamepad to synchronize with device values
  47603. */
  47604. update(): void;
  47605. /**
  47606. * Disposes the gamepad
  47607. */
  47608. dispose(): void;
  47609. }
  47610. }
  47611. declare module "babylonjs/Gamepads/gamepadManager" {
  47612. import { Observable } from "babylonjs/Misc/observable";
  47613. import { Nullable } from "babylonjs/types";
  47614. import { Scene } from "babylonjs/scene";
  47615. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47616. /**
  47617. * Manager for handling gamepads
  47618. */
  47619. export class GamepadManager {
  47620. private _scene?;
  47621. private _babylonGamepads;
  47622. private _oneGamepadConnected;
  47623. /** @hidden */
  47624. _isMonitoring: boolean;
  47625. private _gamepadEventSupported;
  47626. private _gamepadSupport?;
  47627. /**
  47628. * observable to be triggered when the gamepad controller has been connected
  47629. */
  47630. onGamepadConnectedObservable: Observable<Gamepad>;
  47631. /**
  47632. * observable to be triggered when the gamepad controller has been disconnected
  47633. */
  47634. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47635. private _onGamepadConnectedEvent;
  47636. private _onGamepadDisconnectedEvent;
  47637. /**
  47638. * Initializes the gamepad manager
  47639. * @param _scene BabylonJS scene
  47640. */
  47641. constructor(_scene?: Scene | undefined);
  47642. /**
  47643. * The gamepads in the game pad manager
  47644. */
  47645. get gamepads(): Gamepad[];
  47646. /**
  47647. * Get the gamepad controllers based on type
  47648. * @param type The type of gamepad controller
  47649. * @returns Nullable gamepad
  47650. */
  47651. getGamepadByType(type?: number): Nullable<Gamepad>;
  47652. /**
  47653. * Disposes the gamepad manager
  47654. */
  47655. dispose(): void;
  47656. private _addNewGamepad;
  47657. private _startMonitoringGamepads;
  47658. private _stopMonitoringGamepads;
  47659. /** @hidden */
  47660. _checkGamepadsStatus(): void;
  47661. private _updateGamepadObjects;
  47662. }
  47663. }
  47664. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47665. import { Nullable } from "babylonjs/types";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { ISceneComponent } from "babylonjs/sceneComponent";
  47668. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47669. module "babylonjs/scene" {
  47670. interface Scene {
  47671. /** @hidden */
  47672. _gamepadManager: Nullable<GamepadManager>;
  47673. /**
  47674. * Gets the gamepad manager associated with the scene
  47675. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47676. */
  47677. gamepadManager: GamepadManager;
  47678. }
  47679. }
  47680. module "babylonjs/Cameras/freeCameraInputsManager" {
  47681. /**
  47682. * Interface representing a free camera inputs manager
  47683. */
  47684. interface FreeCameraInputsManager {
  47685. /**
  47686. * Adds gamepad input support to the FreeCameraInputsManager.
  47687. * @returns the FreeCameraInputsManager
  47688. */
  47689. addGamepad(): FreeCameraInputsManager;
  47690. }
  47691. }
  47692. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47693. /**
  47694. * Interface representing an arc rotate camera inputs manager
  47695. */
  47696. interface ArcRotateCameraInputsManager {
  47697. /**
  47698. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47699. * @returns the camera inputs manager
  47700. */
  47701. addGamepad(): ArcRotateCameraInputsManager;
  47702. }
  47703. }
  47704. /**
  47705. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47706. */
  47707. export class GamepadSystemSceneComponent implements ISceneComponent {
  47708. /**
  47709. * The component name helpfull to identify the component in the list of scene components.
  47710. */
  47711. readonly name: string;
  47712. /**
  47713. * The scene the component belongs to.
  47714. */
  47715. scene: Scene;
  47716. /**
  47717. * Creates a new instance of the component for the given scene
  47718. * @param scene Defines the scene to register the component in
  47719. */
  47720. constructor(scene: Scene);
  47721. /**
  47722. * Registers the component in a given scene
  47723. */
  47724. register(): void;
  47725. /**
  47726. * Rebuilds the elements related to this component in case of
  47727. * context lost for instance.
  47728. */
  47729. rebuild(): void;
  47730. /**
  47731. * Disposes the component and the associated ressources
  47732. */
  47733. dispose(): void;
  47734. private _beforeCameraUpdate;
  47735. }
  47736. }
  47737. declare module "babylonjs/Cameras/universalCamera" {
  47738. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47739. import { Scene } from "babylonjs/scene";
  47740. import { Vector3 } from "babylonjs/Maths/math.vector";
  47741. import "babylonjs/Gamepads/gamepadSceneComponent";
  47742. /**
  47743. * 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,
  47744. * which still works and will still be found in many Playgrounds.
  47745. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47746. */
  47747. export class UniversalCamera extends TouchCamera {
  47748. /**
  47749. * Defines the gamepad rotation sensiblity.
  47750. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47751. */
  47752. get gamepadAngularSensibility(): number;
  47753. set gamepadAngularSensibility(value: number);
  47754. /**
  47755. * Defines the gamepad move sensiblity.
  47756. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47757. */
  47758. get gamepadMoveSensibility(): number;
  47759. set gamepadMoveSensibility(value: number);
  47760. /**
  47761. * 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,
  47762. * which still works and will still be found in many Playgrounds.
  47763. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47764. * @param name Define the name of the camera in the scene
  47765. * @param position Define the start position of the camera in the scene
  47766. * @param scene Define the scene the camera belongs to
  47767. */
  47768. constructor(name: string, position: Vector3, scene: Scene);
  47769. /**
  47770. * Gets the current object class name.
  47771. * @return the class name
  47772. */
  47773. getClassName(): string;
  47774. }
  47775. }
  47776. declare module "babylonjs/Cameras/gamepadCamera" {
  47777. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47778. import { Scene } from "babylonjs/scene";
  47779. import { Vector3 } from "babylonjs/Maths/math.vector";
  47780. /**
  47781. * This represents a FPS type of camera. This is only here for back compat purpose.
  47782. * Please use the UniversalCamera instead as both are identical.
  47783. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47784. */
  47785. export class GamepadCamera extends UniversalCamera {
  47786. /**
  47787. * Instantiates a new Gamepad Camera
  47788. * This represents a FPS type of camera. This is only here for back compat purpose.
  47789. * Please use the UniversalCamera instead as both are identical.
  47790. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47791. * @param name Define the name of the camera in the scene
  47792. * @param position Define the start position of the camera in the scene
  47793. * @param scene Define the scene the camera belongs to
  47794. */
  47795. constructor(name: string, position: Vector3, scene: Scene);
  47796. /**
  47797. * Gets the current object class name.
  47798. * @return the class name
  47799. */
  47800. getClassName(): string;
  47801. }
  47802. }
  47803. declare module "babylonjs/Shaders/pass.fragment" {
  47804. /** @hidden */
  47805. export var passPixelShader: {
  47806. name: string;
  47807. shader: string;
  47808. };
  47809. }
  47810. declare module "babylonjs/Shaders/passCube.fragment" {
  47811. /** @hidden */
  47812. export var passCubePixelShader: {
  47813. name: string;
  47814. shader: string;
  47815. };
  47816. }
  47817. declare module "babylonjs/PostProcesses/passPostProcess" {
  47818. import { Nullable } from "babylonjs/types";
  47819. import { Camera } from "babylonjs/Cameras/camera";
  47820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47821. import { Engine } from "babylonjs/Engines/engine";
  47822. import "babylonjs/Shaders/pass.fragment";
  47823. import "babylonjs/Shaders/passCube.fragment";
  47824. import { Scene } from "babylonjs/scene";
  47825. /**
  47826. * PassPostProcess which produces an output the same as it's input
  47827. */
  47828. export class PassPostProcess extends PostProcess {
  47829. /**
  47830. * Gets a string identifying the name of the class
  47831. * @returns "PassPostProcess" string
  47832. */
  47833. getClassName(): string;
  47834. /**
  47835. * Creates the PassPostProcess
  47836. * @param name The name of the effect.
  47837. * @param options The required width/height ratio to downsize to before computing the render pass.
  47838. * @param camera The camera to apply the render pass to.
  47839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47840. * @param engine The engine which the post process will be applied. (default: current engine)
  47841. * @param reusable If the post process can be reused on the same frame. (default: false)
  47842. * @param textureType The type of texture to be used when performing the post processing.
  47843. * @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)
  47844. */
  47845. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47846. /** @hidden */
  47847. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47848. }
  47849. /**
  47850. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47851. */
  47852. export class PassCubePostProcess extends PostProcess {
  47853. private _face;
  47854. /**
  47855. * Gets or sets the cube face to display.
  47856. * * 0 is +X
  47857. * * 1 is -X
  47858. * * 2 is +Y
  47859. * * 3 is -Y
  47860. * * 4 is +Z
  47861. * * 5 is -Z
  47862. */
  47863. get face(): number;
  47864. set face(value: number);
  47865. /**
  47866. * Gets a string identifying the name of the class
  47867. * @returns "PassCubePostProcess" string
  47868. */
  47869. getClassName(): string;
  47870. /**
  47871. * Creates the PassCubePostProcess
  47872. * @param name The name of the effect.
  47873. * @param options The required width/height ratio to downsize to before computing the render pass.
  47874. * @param camera The camera to apply the render pass to.
  47875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47876. * @param engine The engine which the post process will be applied. (default: current engine)
  47877. * @param reusable If the post process can be reused on the same frame. (default: false)
  47878. * @param textureType The type of texture to be used when performing the post processing.
  47879. * @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)
  47880. */
  47881. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47882. /** @hidden */
  47883. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47884. }
  47885. }
  47886. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47887. /** @hidden */
  47888. export var anaglyphPixelShader: {
  47889. name: string;
  47890. shader: string;
  47891. };
  47892. }
  47893. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47894. import { Engine } from "babylonjs/Engines/engine";
  47895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47896. import { Camera } from "babylonjs/Cameras/camera";
  47897. import "babylonjs/Shaders/anaglyph.fragment";
  47898. /**
  47899. * Postprocess used to generate anaglyphic rendering
  47900. */
  47901. export class AnaglyphPostProcess extends PostProcess {
  47902. private _passedProcess;
  47903. /**
  47904. * Gets a string identifying the name of the class
  47905. * @returns "AnaglyphPostProcess" string
  47906. */
  47907. getClassName(): string;
  47908. /**
  47909. * Creates a new AnaglyphPostProcess
  47910. * @param name defines postprocess name
  47911. * @param options defines creation options or target ratio scale
  47912. * @param rigCameras defines cameras using this postprocess
  47913. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47914. * @param engine defines hosting engine
  47915. * @param reusable defines if the postprocess will be reused multiple times per frame
  47916. */
  47917. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47918. }
  47919. }
  47920. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47921. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47922. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47923. import { Scene } from "babylonjs/scene";
  47924. import { Vector3 } from "babylonjs/Maths/math.vector";
  47925. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47926. /**
  47927. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47928. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47929. */
  47930. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47931. /**
  47932. * Creates a new AnaglyphArcRotateCamera
  47933. * @param name defines camera name
  47934. * @param alpha defines alpha angle (in radians)
  47935. * @param beta defines beta angle (in radians)
  47936. * @param radius defines radius
  47937. * @param target defines camera target
  47938. * @param interaxialDistance defines distance between each color axis
  47939. * @param scene defines the hosting scene
  47940. */
  47941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47942. /**
  47943. * Gets camera class name
  47944. * @returns AnaglyphArcRotateCamera
  47945. */
  47946. getClassName(): string;
  47947. }
  47948. }
  47949. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47950. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47951. import { Scene } from "babylonjs/scene";
  47952. import { Vector3 } from "babylonjs/Maths/math.vector";
  47953. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47954. /**
  47955. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47956. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47957. */
  47958. export class AnaglyphFreeCamera extends FreeCamera {
  47959. /**
  47960. * Creates a new AnaglyphFreeCamera
  47961. * @param name defines camera name
  47962. * @param position defines initial position
  47963. * @param interaxialDistance defines distance between each color axis
  47964. * @param scene defines the hosting scene
  47965. */
  47966. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47967. /**
  47968. * Gets camera class name
  47969. * @returns AnaglyphFreeCamera
  47970. */
  47971. getClassName(): string;
  47972. }
  47973. }
  47974. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47975. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Vector3 } from "babylonjs/Maths/math.vector";
  47978. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47979. /**
  47980. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47982. */
  47983. export class AnaglyphGamepadCamera extends GamepadCamera {
  47984. /**
  47985. * Creates a new AnaglyphGamepadCamera
  47986. * @param name defines camera name
  47987. * @param position defines initial position
  47988. * @param interaxialDistance defines distance between each color axis
  47989. * @param scene defines the hosting scene
  47990. */
  47991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47992. /**
  47993. * Gets camera class name
  47994. * @returns AnaglyphGamepadCamera
  47995. */
  47996. getClassName(): string;
  47997. }
  47998. }
  47999. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48000. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48001. import { Scene } from "babylonjs/scene";
  48002. import { Vector3 } from "babylonjs/Maths/math.vector";
  48003. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48004. /**
  48005. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48006. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48007. */
  48008. export class AnaglyphUniversalCamera extends UniversalCamera {
  48009. /**
  48010. * Creates a new AnaglyphUniversalCamera
  48011. * @param name defines camera name
  48012. * @param position defines initial position
  48013. * @param interaxialDistance defines distance between each color axis
  48014. * @param scene defines the hosting scene
  48015. */
  48016. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48017. /**
  48018. * Gets camera class name
  48019. * @returns AnaglyphUniversalCamera
  48020. */
  48021. getClassName(): string;
  48022. }
  48023. }
  48024. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48025. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48026. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48027. import { Scene } from "babylonjs/scene";
  48028. import { Vector3 } from "babylonjs/Maths/math.vector";
  48029. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48030. /**
  48031. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48032. * @see https://doc.babylonjs.com/features/cameras
  48033. */
  48034. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48035. /**
  48036. * Creates a new StereoscopicArcRotateCamera
  48037. * @param name defines camera name
  48038. * @param alpha defines alpha angle (in radians)
  48039. * @param beta defines beta angle (in radians)
  48040. * @param radius defines radius
  48041. * @param target defines camera target
  48042. * @param interaxialDistance defines distance between each color axis
  48043. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48044. * @param scene defines the hosting scene
  48045. */
  48046. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48047. /**
  48048. * Gets camera class name
  48049. * @returns StereoscopicArcRotateCamera
  48050. */
  48051. getClassName(): string;
  48052. }
  48053. }
  48054. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48056. import { Scene } from "babylonjs/scene";
  48057. import { Vector3 } from "babylonjs/Maths/math.vector";
  48058. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48059. /**
  48060. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48061. * @see https://doc.babylonjs.com/features/cameras
  48062. */
  48063. export class StereoscopicFreeCamera extends FreeCamera {
  48064. /**
  48065. * Creates a new StereoscopicFreeCamera
  48066. * @param name defines camera name
  48067. * @param position defines initial position
  48068. * @param interaxialDistance defines distance between each color axis
  48069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48070. * @param scene defines the hosting scene
  48071. */
  48072. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48073. /**
  48074. * Gets camera class name
  48075. * @returns StereoscopicFreeCamera
  48076. */
  48077. getClassName(): string;
  48078. }
  48079. }
  48080. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48081. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48082. import { Scene } from "babylonjs/scene";
  48083. import { Vector3 } from "babylonjs/Maths/math.vector";
  48084. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48085. /**
  48086. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48087. * @see https://doc.babylonjs.com/features/cameras
  48088. */
  48089. export class StereoscopicGamepadCamera extends GamepadCamera {
  48090. /**
  48091. * Creates a new StereoscopicGamepadCamera
  48092. * @param name defines camera name
  48093. * @param position defines initial position
  48094. * @param interaxialDistance defines distance between each color axis
  48095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48096. * @param scene defines the hosting scene
  48097. */
  48098. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48099. /**
  48100. * Gets camera class name
  48101. * @returns StereoscopicGamepadCamera
  48102. */
  48103. getClassName(): string;
  48104. }
  48105. }
  48106. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48107. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48108. import { Scene } from "babylonjs/scene";
  48109. import { Vector3 } from "babylonjs/Maths/math.vector";
  48110. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48111. /**
  48112. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48113. * @see https://doc.babylonjs.com/features/cameras
  48114. */
  48115. export class StereoscopicUniversalCamera extends UniversalCamera {
  48116. /**
  48117. * Creates a new StereoscopicUniversalCamera
  48118. * @param name defines camera name
  48119. * @param position defines initial position
  48120. * @param interaxialDistance defines distance between each color axis
  48121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48122. * @param scene defines the hosting scene
  48123. */
  48124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48125. /**
  48126. * Gets camera class name
  48127. * @returns StereoscopicUniversalCamera
  48128. */
  48129. getClassName(): string;
  48130. }
  48131. }
  48132. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48133. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48134. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48135. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48136. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48137. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48141. }
  48142. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48143. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48144. import { Scene } from "babylonjs/scene";
  48145. import { Vector3 } from "babylonjs/Maths/math.vector";
  48146. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48147. /**
  48148. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48149. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48150. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48151. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48152. */
  48153. export class VirtualJoysticksCamera extends FreeCamera {
  48154. /**
  48155. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48156. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48157. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48158. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48159. * @param name Define the name of the camera in the scene
  48160. * @param position Define the start position of the camera in the scene
  48161. * @param scene Define the scene the camera belongs to
  48162. */
  48163. constructor(name: string, position: Vector3, scene: Scene);
  48164. /**
  48165. * Gets the current object class name.
  48166. * @return the class name
  48167. */
  48168. getClassName(): string;
  48169. }
  48170. }
  48171. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48172. import { Matrix } from "babylonjs/Maths/math.vector";
  48173. /**
  48174. * This represents all the required metrics to create a VR camera.
  48175. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48176. */
  48177. export class VRCameraMetrics {
  48178. /**
  48179. * Define the horizontal resolution off the screen.
  48180. */
  48181. hResolution: number;
  48182. /**
  48183. * Define the vertical resolution off the screen.
  48184. */
  48185. vResolution: number;
  48186. /**
  48187. * Define the horizontal screen size.
  48188. */
  48189. hScreenSize: number;
  48190. /**
  48191. * Define the vertical screen size.
  48192. */
  48193. vScreenSize: number;
  48194. /**
  48195. * Define the vertical screen center position.
  48196. */
  48197. vScreenCenter: number;
  48198. /**
  48199. * Define the distance of the eyes to the screen.
  48200. */
  48201. eyeToScreenDistance: number;
  48202. /**
  48203. * Define the distance between both lenses
  48204. */
  48205. lensSeparationDistance: number;
  48206. /**
  48207. * Define the distance between both viewer's eyes.
  48208. */
  48209. interpupillaryDistance: number;
  48210. /**
  48211. * Define the distortion factor of the VR postprocess.
  48212. * Please, touch with care.
  48213. */
  48214. distortionK: number[];
  48215. /**
  48216. * Define the chromatic aberration correction factors for the VR post process.
  48217. */
  48218. chromaAbCorrection: number[];
  48219. /**
  48220. * Define the scale factor of the post process.
  48221. * The smaller the better but the slower.
  48222. */
  48223. postProcessScaleFactor: number;
  48224. /**
  48225. * Define an offset for the lens center.
  48226. */
  48227. lensCenterOffset: number;
  48228. /**
  48229. * Define if the current vr camera should compensate the distortion of the lense or not.
  48230. */
  48231. compensateDistortion: boolean;
  48232. /**
  48233. * Defines if multiview should be enabled when rendering (Default: false)
  48234. */
  48235. multiviewEnabled: boolean;
  48236. /**
  48237. * Gets the rendering aspect ratio based on the provided resolutions.
  48238. */
  48239. get aspectRatio(): number;
  48240. /**
  48241. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48242. */
  48243. get aspectRatioFov(): number;
  48244. /**
  48245. * @hidden
  48246. */
  48247. get leftHMatrix(): Matrix;
  48248. /**
  48249. * @hidden
  48250. */
  48251. get rightHMatrix(): Matrix;
  48252. /**
  48253. * @hidden
  48254. */
  48255. get leftPreViewMatrix(): Matrix;
  48256. /**
  48257. * @hidden
  48258. */
  48259. get rightPreViewMatrix(): Matrix;
  48260. /**
  48261. * Get the default VRMetrics based on the most generic setup.
  48262. * @returns the default vr metrics
  48263. */
  48264. static GetDefault(): VRCameraMetrics;
  48265. }
  48266. }
  48267. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48268. /** @hidden */
  48269. export var vrDistortionCorrectionPixelShader: {
  48270. name: string;
  48271. shader: string;
  48272. };
  48273. }
  48274. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48275. import { Camera } from "babylonjs/Cameras/camera";
  48276. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48278. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48279. /**
  48280. * VRDistortionCorrectionPostProcess used for mobile VR
  48281. */
  48282. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48283. private _isRightEye;
  48284. private _distortionFactors;
  48285. private _postProcessScaleFactor;
  48286. private _lensCenterOffset;
  48287. private _scaleIn;
  48288. private _scaleFactor;
  48289. private _lensCenter;
  48290. /**
  48291. * Gets a string identifying the name of the class
  48292. * @returns "VRDistortionCorrectionPostProcess" string
  48293. */
  48294. getClassName(): string;
  48295. /**
  48296. * Initializes the VRDistortionCorrectionPostProcess
  48297. * @param name The name of the effect.
  48298. * @param camera The camera to apply the render pass to.
  48299. * @param isRightEye If this is for the right eye distortion
  48300. * @param vrMetrics All the required metrics for the VR camera
  48301. */
  48302. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48303. }
  48304. }
  48305. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48306. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48308. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Vector3 } from "babylonjs/Maths/math.vector";
  48311. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48312. import "babylonjs/Cameras/RigModes/vrRigMode";
  48313. /**
  48314. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48315. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48316. */
  48317. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48318. /**
  48319. * Creates a new VRDeviceOrientationArcRotateCamera
  48320. * @param name defines camera name
  48321. * @param alpha defines the camera rotation along the logitudinal axis
  48322. * @param beta defines the camera rotation along the latitudinal axis
  48323. * @param radius defines the camera distance from its target
  48324. * @param target defines the camera target
  48325. * @param scene defines the scene the camera belongs to
  48326. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48327. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48328. */
  48329. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48330. /**
  48331. * Gets camera class name
  48332. * @returns VRDeviceOrientationArcRotateCamera
  48333. */
  48334. getClassName(): string;
  48335. }
  48336. }
  48337. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48338. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48339. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48340. import { Scene } from "babylonjs/scene";
  48341. import { Vector3 } from "babylonjs/Maths/math.vector";
  48342. import "babylonjs/Cameras/RigModes/vrRigMode";
  48343. /**
  48344. * Camera used to simulate VR rendering (based on FreeCamera)
  48345. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48346. */
  48347. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48348. /**
  48349. * Creates a new VRDeviceOrientationFreeCamera
  48350. * @param name defines camera name
  48351. * @param position defines the start position of the camera
  48352. * @param scene defines the scene the camera belongs to
  48353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48355. */
  48356. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48357. /**
  48358. * Gets camera class name
  48359. * @returns VRDeviceOrientationFreeCamera
  48360. */
  48361. getClassName(): string;
  48362. }
  48363. }
  48364. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48365. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48366. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48367. import { Scene } from "babylonjs/scene";
  48368. import { Vector3 } from "babylonjs/Maths/math.vector";
  48369. import "babylonjs/Gamepads/gamepadSceneComponent";
  48370. /**
  48371. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48372. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48373. */
  48374. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48375. /**
  48376. * Creates a new VRDeviceOrientationGamepadCamera
  48377. * @param name defines camera name
  48378. * @param position defines the start position of the camera
  48379. * @param scene defines the scene the camera belongs to
  48380. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48381. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48382. */
  48383. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48384. /**
  48385. * Gets camera class name
  48386. * @returns VRDeviceOrientationGamepadCamera
  48387. */
  48388. getClassName(): string;
  48389. }
  48390. }
  48391. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48392. import { Scene } from "babylonjs/scene";
  48393. import { Texture } from "babylonjs/Materials/Textures/texture";
  48394. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48395. /**
  48396. * A class extending Texture allowing drawing on a texture
  48397. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48398. */
  48399. export class DynamicTexture extends Texture {
  48400. private _generateMipMaps;
  48401. private _canvas;
  48402. private _context;
  48403. /**
  48404. * Creates a DynamicTexture
  48405. * @param name defines the name of the texture
  48406. * @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
  48407. * @param scene defines the scene where you want the texture
  48408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48411. */
  48412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48413. /**
  48414. * Get the current class name of the texture useful for serialization or dynamic coding.
  48415. * @returns "DynamicTexture"
  48416. */
  48417. getClassName(): string;
  48418. /**
  48419. * Gets the current state of canRescale
  48420. */
  48421. get canRescale(): boolean;
  48422. private _recreate;
  48423. /**
  48424. * Scales the texture
  48425. * @param ratio the scale factor to apply to both width and height
  48426. */
  48427. scale(ratio: number): void;
  48428. /**
  48429. * Resizes the texture
  48430. * @param width the new width
  48431. * @param height the new height
  48432. */
  48433. scaleTo(width: number, height: number): void;
  48434. /**
  48435. * Gets the context of the canvas used by the texture
  48436. * @returns the canvas context of the dynamic texture
  48437. */
  48438. getContext(): CanvasRenderingContext2D;
  48439. /**
  48440. * Clears the texture
  48441. */
  48442. clear(): void;
  48443. /**
  48444. * Updates the texture
  48445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48447. */
  48448. update(invertY?: boolean, premulAlpha?: boolean): void;
  48449. /**
  48450. * Draws text onto the texture
  48451. * @param text defines the text to be drawn
  48452. * @param x defines the placement of the text from the left
  48453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48454. * @param font defines the font to be used with font-style, font-size, font-name
  48455. * @param color defines the color used for the text
  48456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48458. * @param update defines whether texture is immediately update (default is true)
  48459. */
  48460. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48461. /**
  48462. * Clones the texture
  48463. * @returns the clone of the texture.
  48464. */
  48465. clone(): DynamicTexture;
  48466. /**
  48467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48468. * @returns a serialized dynamic texture object
  48469. */
  48470. serialize(): any;
  48471. private _IsCanvasElement;
  48472. /** @hidden */
  48473. _rebuild(): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48477. import { Scene } from "babylonjs/scene";
  48478. import { Color3 } from "babylonjs/Maths/math.color";
  48479. import { Mesh } from "babylonjs/Meshes/mesh";
  48480. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48481. import { Nullable } from "babylonjs/types";
  48482. /**
  48483. * Class containing static functions to help procedurally build meshes
  48484. */
  48485. export class GroundBuilder {
  48486. /**
  48487. * Creates a ground mesh
  48488. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48489. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48491. * @param name defines the name of the mesh
  48492. * @param options defines the options used to create the mesh
  48493. * @param scene defines the hosting scene
  48494. * @returns the ground mesh
  48495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48496. */
  48497. static CreateGround(name: string, options: {
  48498. width?: number;
  48499. height?: number;
  48500. subdivisions?: number;
  48501. subdivisionsX?: number;
  48502. subdivisionsY?: number;
  48503. updatable?: boolean;
  48504. }, scene: any): Mesh;
  48505. /**
  48506. * Creates a tiled ground mesh
  48507. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48508. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48509. * * 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
  48510. * * 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
  48511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48512. * @param name defines the name of the mesh
  48513. * @param options defines the options used to create the mesh
  48514. * @param scene defines the hosting scene
  48515. * @returns the tiled ground mesh
  48516. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48517. */
  48518. static CreateTiledGround(name: string, options: {
  48519. xmin: number;
  48520. zmin: number;
  48521. xmax: number;
  48522. zmax: number;
  48523. subdivisions?: {
  48524. w: number;
  48525. h: number;
  48526. };
  48527. precision?: {
  48528. w: number;
  48529. h: number;
  48530. };
  48531. updatable?: boolean;
  48532. }, scene?: Nullable<Scene>): Mesh;
  48533. /**
  48534. * Creates a ground mesh from a height map
  48535. * * The parameter `url` sets the URL of the height map image resource.
  48536. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48537. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48538. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48539. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48540. * * 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.
  48541. * * 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).
  48542. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48544. * @param name defines the name of the mesh
  48545. * @param url defines the url to the height map
  48546. * @param options defines the options used to create the mesh
  48547. * @param scene defines the hosting scene
  48548. * @returns the ground mesh
  48549. * @see https://doc.babylonjs.com/babylon101/height_map
  48550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48551. */
  48552. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48553. width?: number;
  48554. height?: number;
  48555. subdivisions?: number;
  48556. minHeight?: number;
  48557. maxHeight?: number;
  48558. colorFilter?: Color3;
  48559. alphaFilter?: number;
  48560. updatable?: boolean;
  48561. onReady?: (mesh: GroundMesh) => void;
  48562. }, scene?: Nullable<Scene>): GroundMesh;
  48563. }
  48564. }
  48565. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48566. import { Vector4 } from "babylonjs/Maths/math.vector";
  48567. import { Mesh } from "babylonjs/Meshes/mesh";
  48568. /**
  48569. * Class containing static functions to help procedurally build meshes
  48570. */
  48571. export class TorusBuilder {
  48572. /**
  48573. * Creates a torus mesh
  48574. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48575. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48576. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48580. * @param name defines the name of the mesh
  48581. * @param options defines the options used to create the mesh
  48582. * @param scene defines the hosting scene
  48583. * @returns the torus mesh
  48584. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48585. */
  48586. static CreateTorus(name: string, options: {
  48587. diameter?: number;
  48588. thickness?: number;
  48589. tessellation?: number;
  48590. updatable?: boolean;
  48591. sideOrientation?: number;
  48592. frontUVs?: Vector4;
  48593. backUVs?: Vector4;
  48594. }, scene: any): Mesh;
  48595. }
  48596. }
  48597. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48598. import { Vector4 } from "babylonjs/Maths/math.vector";
  48599. import { Color4 } from "babylonjs/Maths/math.color";
  48600. import { Mesh } from "babylonjs/Meshes/mesh";
  48601. /**
  48602. * Class containing static functions to help procedurally build meshes
  48603. */
  48604. export class CylinderBuilder {
  48605. /**
  48606. * Creates a cylinder or a cone mesh
  48607. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48608. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48609. * * 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.
  48610. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48611. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48612. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48613. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48614. * * 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).
  48615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48616. * * 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).
  48617. * * 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
  48618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48619. * * 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
  48620. * * 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.
  48621. * * If `enclose` is false, a ring surface is one element.
  48622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48623. * * 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
  48624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48627. * @param name defines the name of the mesh
  48628. * @param options defines the options used to create the mesh
  48629. * @param scene defines the hosting scene
  48630. * @returns the cylinder mesh
  48631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48632. */
  48633. static CreateCylinder(name: string, options: {
  48634. height?: number;
  48635. diameterTop?: number;
  48636. diameterBottom?: number;
  48637. diameter?: number;
  48638. tessellation?: number;
  48639. subdivisions?: number;
  48640. arc?: number;
  48641. faceColors?: Color4[];
  48642. faceUV?: Vector4[];
  48643. updatable?: boolean;
  48644. hasRings?: boolean;
  48645. enclose?: boolean;
  48646. cap?: number;
  48647. sideOrientation?: number;
  48648. frontUVs?: Vector4;
  48649. backUVs?: Vector4;
  48650. }, scene: any): Mesh;
  48651. }
  48652. }
  48653. declare module "babylonjs/XR/webXRTypes" {
  48654. import { Nullable } from "babylonjs/types";
  48655. import { IDisposable } from "babylonjs/scene";
  48656. /**
  48657. * States of the webXR experience
  48658. */
  48659. export enum WebXRState {
  48660. /**
  48661. * Transitioning to being in XR mode
  48662. */
  48663. ENTERING_XR = 0,
  48664. /**
  48665. * Transitioning to non XR mode
  48666. */
  48667. EXITING_XR = 1,
  48668. /**
  48669. * In XR mode and presenting
  48670. */
  48671. IN_XR = 2,
  48672. /**
  48673. * Not entered XR mode
  48674. */
  48675. NOT_IN_XR = 3
  48676. }
  48677. /**
  48678. * Abstraction of the XR render target
  48679. */
  48680. export interface WebXRRenderTarget extends IDisposable {
  48681. /**
  48682. * xrpresent context of the canvas which can be used to display/mirror xr content
  48683. */
  48684. canvasContext: WebGLRenderingContext;
  48685. /**
  48686. * xr layer for the canvas
  48687. */
  48688. xrLayer: Nullable<XRWebGLLayer>;
  48689. /**
  48690. * Initializes the xr layer for the session
  48691. * @param xrSession xr session
  48692. * @returns a promise that will resolve once the XR Layer has been created
  48693. */
  48694. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48695. }
  48696. }
  48697. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48698. import { Nullable } from "babylonjs/types";
  48699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48700. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48701. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48702. import { Observable } from "babylonjs/Misc/observable";
  48703. /**
  48704. * COnfiguration object for WebXR output canvas
  48705. */
  48706. export class WebXRManagedOutputCanvasOptions {
  48707. /**
  48708. * An optional canvas in case you wish to create it yourself and provide it here.
  48709. * If not provided, a new canvas will be created
  48710. */
  48711. canvasElement?: HTMLCanvasElement;
  48712. /**
  48713. * Options for this XR Layer output
  48714. */
  48715. canvasOptions?: XRWebGLLayerOptions;
  48716. /**
  48717. * CSS styling for a newly created canvas (if not provided)
  48718. */
  48719. newCanvasCssStyle?: string;
  48720. /**
  48721. * Get the default values of the configuration object
  48722. * @param engine defines the engine to use (can be null)
  48723. * @returns default values of this configuration object
  48724. */
  48725. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48726. }
  48727. /**
  48728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48729. */
  48730. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48731. private _options;
  48732. private _canvas;
  48733. private _engine;
  48734. private _originalCanvasSize;
  48735. /**
  48736. * Rendering context of the canvas which can be used to display/mirror xr content
  48737. */
  48738. canvasContext: WebGLRenderingContext;
  48739. /**
  48740. * xr layer for the canvas
  48741. */
  48742. xrLayer: Nullable<XRWebGLLayer>;
  48743. /**
  48744. * Obseervers registered here will be triggered when the xr layer was initialized
  48745. */
  48746. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48747. /**
  48748. * Initializes the canvas to be added/removed upon entering/exiting xr
  48749. * @param _xrSessionManager The XR Session manager
  48750. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48751. */
  48752. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48753. /**
  48754. * Disposes of the object
  48755. */
  48756. dispose(): void;
  48757. /**
  48758. * Initializes the xr layer for the session
  48759. * @param xrSession xr session
  48760. * @returns a promise that will resolve once the XR Layer has been created
  48761. */
  48762. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48763. private _addCanvas;
  48764. private _removeCanvas;
  48765. private _setCanvasSize;
  48766. private _setManagedOutputCanvas;
  48767. }
  48768. }
  48769. declare module "babylonjs/XR/webXRSessionManager" {
  48770. import { Observable } from "babylonjs/Misc/observable";
  48771. import { Nullable } from "babylonjs/types";
  48772. import { IDisposable, Scene } from "babylonjs/scene";
  48773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48774. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48775. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48776. /**
  48777. * Manages an XRSession to work with Babylon's engine
  48778. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48779. */
  48780. export class WebXRSessionManager implements IDisposable {
  48781. /** The scene which the session should be created for */
  48782. scene: Scene;
  48783. private _referenceSpace;
  48784. private _rttProvider;
  48785. private _sessionEnded;
  48786. private _xrNavigator;
  48787. private baseLayer;
  48788. /**
  48789. * The base reference space from which the session started. good if you want to reset your
  48790. * reference space
  48791. */
  48792. baseReferenceSpace: XRReferenceSpace;
  48793. /**
  48794. * Current XR frame
  48795. */
  48796. currentFrame: Nullable<XRFrame>;
  48797. /** WebXR timestamp updated every frame */
  48798. currentTimestamp: number;
  48799. /**
  48800. * Used just in case of a failure to initialize an immersive session.
  48801. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48802. */
  48803. defaultHeightCompensation: number;
  48804. /**
  48805. * Fires every time a new xrFrame arrives which can be used to update the camera
  48806. */
  48807. onXRFrameObservable: Observable<XRFrame>;
  48808. /**
  48809. * Fires when the reference space changed
  48810. */
  48811. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48812. /**
  48813. * Fires when the xr session is ended either by the device or manually done
  48814. */
  48815. onXRSessionEnded: Observable<any>;
  48816. /**
  48817. * Fires when the xr session is ended either by the device or manually done
  48818. */
  48819. onXRSessionInit: Observable<XRSession>;
  48820. /**
  48821. * Underlying xr session
  48822. */
  48823. session: XRSession;
  48824. /**
  48825. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48826. * or get the offset the player is currently at.
  48827. */
  48828. viewerReferenceSpace: XRReferenceSpace;
  48829. /**
  48830. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48831. * @param scene The scene which the session should be created for
  48832. */
  48833. constructor(
  48834. /** The scene which the session should be created for */
  48835. scene: Scene);
  48836. /**
  48837. * The current reference space used in this session. This reference space can constantly change!
  48838. * It is mainly used to offset the camera's position.
  48839. */
  48840. get referenceSpace(): XRReferenceSpace;
  48841. /**
  48842. * Set a new reference space and triggers the observable
  48843. */
  48844. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48845. /**
  48846. * Disposes of the session manager
  48847. */
  48848. dispose(): void;
  48849. /**
  48850. * Stops the xrSession and restores the render loop
  48851. * @returns Promise which resolves after it exits XR
  48852. */
  48853. exitXRAsync(): Promise<void>;
  48854. /**
  48855. * Gets the correct render target texture to be rendered this frame for this eye
  48856. * @param eye the eye for which to get the render target
  48857. * @returns the render target for the specified eye
  48858. */
  48859. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48860. /**
  48861. * Creates a WebXRRenderTarget object for the XR session
  48862. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48863. * @param options optional options to provide when creating a new render target
  48864. * @returns a WebXR render target to which the session can render
  48865. */
  48866. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48867. /**
  48868. * Initializes the manager
  48869. * After initialization enterXR can be called to start an XR session
  48870. * @returns Promise which resolves after it is initialized
  48871. */
  48872. initializeAsync(): Promise<void>;
  48873. /**
  48874. * Initializes an xr session
  48875. * @param xrSessionMode mode to initialize
  48876. * @param xrSessionInit defines optional and required values to pass to the session builder
  48877. * @returns a promise which will resolve once the session has been initialized
  48878. */
  48879. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48880. /**
  48881. * Checks if a session would be supported for the creation options specified
  48882. * @param sessionMode session mode to check if supported eg. immersive-vr
  48883. * @returns A Promise that resolves to true if supported and false if not
  48884. */
  48885. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48886. /**
  48887. * Resets the reference space to the one started the session
  48888. */
  48889. resetReferenceSpace(): void;
  48890. /**
  48891. * Starts rendering to the xr layer
  48892. */
  48893. runXRRenderLoop(): void;
  48894. /**
  48895. * Sets the reference space on the xr session
  48896. * @param referenceSpaceType space to set
  48897. * @returns a promise that will resolve once the reference space has been set
  48898. */
  48899. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48900. /**
  48901. * Updates the render state of the session
  48902. * @param state state to set
  48903. * @returns a promise that resolves once the render state has been updated
  48904. */
  48905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48906. /**
  48907. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48908. * @param sessionMode defines the session to test
  48909. * @returns a promise with boolean as final value
  48910. */
  48911. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48912. private _createRenderTargetTexture;
  48913. }
  48914. }
  48915. declare module "babylonjs/XR/webXRCamera" {
  48916. import { Vector3 } from "babylonjs/Maths/math.vector";
  48917. import { Scene } from "babylonjs/scene";
  48918. import { Camera } from "babylonjs/Cameras/camera";
  48919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48920. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48921. import { Observable } from "babylonjs/Misc/observable";
  48922. /**
  48923. * WebXR Camera which holds the views for the xrSession
  48924. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48925. */
  48926. export class WebXRCamera extends FreeCamera {
  48927. private _xrSessionManager;
  48928. private _firstFrame;
  48929. private _referenceQuaternion;
  48930. private _referencedPosition;
  48931. private _xrInvPositionCache;
  48932. private _xrInvQuaternionCache;
  48933. /**
  48934. * Observable raised before camera teleportation
  48935. */
  48936. onBeforeCameraTeleport: Observable<Vector3>;
  48937. /**
  48938. * Observable raised after camera teleportation
  48939. */
  48940. onAfterCameraTeleport: Observable<Vector3>;
  48941. /**
  48942. * Should position compensation execute on first frame.
  48943. * This is used when copying the position from a native (non XR) camera
  48944. */
  48945. compensateOnFirstFrame: boolean;
  48946. /**
  48947. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48948. * @param name the name of the camera
  48949. * @param scene the scene to add the camera to
  48950. * @param _xrSessionManager a constructed xr session manager
  48951. */
  48952. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48953. /**
  48954. * Return the user's height, unrelated to the current ground.
  48955. * This will be the y position of this camera, when ground level is 0.
  48956. */
  48957. get realWorldHeight(): number;
  48958. /** @hidden */
  48959. _updateForDualEyeDebugging(): void;
  48960. /**
  48961. * Sets this camera's transformation based on a non-vr camera
  48962. * @param otherCamera the non-vr camera to copy the transformation from
  48963. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48964. */
  48965. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48966. /**
  48967. * Gets the current instance class name ("WebXRCamera").
  48968. * @returns the class name
  48969. */
  48970. getClassName(): string;
  48971. private _rotate180;
  48972. private _updateFromXRSession;
  48973. private _updateNumberOfRigCameras;
  48974. private _updateReferenceSpace;
  48975. private _updateReferenceSpaceOffset;
  48976. }
  48977. }
  48978. declare module "babylonjs/XR/webXRFeaturesManager" {
  48979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48980. import { IDisposable } from "babylonjs/scene";
  48981. /**
  48982. * Defining the interface required for a (webxr) feature
  48983. */
  48984. export interface IWebXRFeature extends IDisposable {
  48985. /**
  48986. * Is this feature attached
  48987. */
  48988. attached: boolean;
  48989. /**
  48990. * Should auto-attach be disabled?
  48991. */
  48992. disableAutoAttach: boolean;
  48993. /**
  48994. * Attach the feature to the session
  48995. * Will usually be called by the features manager
  48996. *
  48997. * @param force should attachment be forced (even when already attached)
  48998. * @returns true if successful.
  48999. */
  49000. attach(force?: boolean): boolean;
  49001. /**
  49002. * Detach the feature from the session
  49003. * Will usually be called by the features manager
  49004. *
  49005. * @returns true if successful.
  49006. */
  49007. detach(): boolean;
  49008. /**
  49009. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49010. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49011. *
  49012. * @returns whether or not the feature is compatible in this environment
  49013. */
  49014. isCompatible(): boolean;
  49015. /**
  49016. * Was this feature disposed;
  49017. */
  49018. isDisposed: boolean;
  49019. /**
  49020. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49021. */
  49022. xrNativeFeatureName?: string;
  49023. /**
  49024. * A list of (Babylon WebXR) features this feature depends on
  49025. */
  49026. dependsOn?: string[];
  49027. }
  49028. /**
  49029. * A list of the currently available features without referencing them
  49030. */
  49031. export class WebXRFeatureName {
  49032. /**
  49033. * The name of the anchor system feature
  49034. */
  49035. static readonly ANCHOR_SYSTEM: string;
  49036. /**
  49037. * The name of the background remover feature
  49038. */
  49039. static readonly BACKGROUND_REMOVER: string;
  49040. /**
  49041. * The name of the hit test feature
  49042. */
  49043. static readonly HIT_TEST: string;
  49044. /**
  49045. * physics impostors for xr controllers feature
  49046. */
  49047. static readonly PHYSICS_CONTROLLERS: string;
  49048. /**
  49049. * The name of the plane detection feature
  49050. */
  49051. static readonly PLANE_DETECTION: string;
  49052. /**
  49053. * The name of the pointer selection feature
  49054. */
  49055. static readonly POINTER_SELECTION: string;
  49056. /**
  49057. * The name of the teleportation feature
  49058. */
  49059. static readonly TELEPORTATION: string;
  49060. /**
  49061. * The name of the feature points feature.
  49062. */
  49063. static readonly FEATURE_POINTS: string;
  49064. /**
  49065. * The name of the hand tracking feature.
  49066. */
  49067. static readonly HAND_TRACKING: string;
  49068. }
  49069. /**
  49070. * Defining the constructor of a feature. Used to register the modules.
  49071. */
  49072. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49073. /**
  49074. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49075. * It is mainly used in AR sessions.
  49076. *
  49077. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49078. */
  49079. export class WebXRFeaturesManager implements IDisposable {
  49080. private _xrSessionManager;
  49081. private static readonly _AvailableFeatures;
  49082. private _features;
  49083. /**
  49084. * constructs a new features manages.
  49085. *
  49086. * @param _xrSessionManager an instance of WebXRSessionManager
  49087. */
  49088. constructor(_xrSessionManager: WebXRSessionManager);
  49089. /**
  49090. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49091. * Mainly used internally.
  49092. *
  49093. * @param featureName the name of the feature to register
  49094. * @param constructorFunction the function used to construct the module
  49095. * @param version the (babylon) version of the module
  49096. * @param stable is that a stable version of this module
  49097. */
  49098. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49099. /**
  49100. * Returns a constructor of a specific feature.
  49101. *
  49102. * @param featureName the name of the feature to construct
  49103. * @param version the version of the feature to load
  49104. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49105. * @param options optional options provided to the module.
  49106. * @returns a function that, when called, will return a new instance of this feature
  49107. */
  49108. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49109. /**
  49110. * Can be used to return the list of features currently registered
  49111. *
  49112. * @returns an Array of available features
  49113. */
  49114. static GetAvailableFeatures(): string[];
  49115. /**
  49116. * Gets the versions available for a specific feature
  49117. * @param featureName the name of the feature
  49118. * @returns an array with the available versions
  49119. */
  49120. static GetAvailableVersions(featureName: string): string[];
  49121. /**
  49122. * Return the latest unstable version of this feature
  49123. * @param featureName the name of the feature to search
  49124. * @returns the version number. if not found will return -1
  49125. */
  49126. static GetLatestVersionOfFeature(featureName: string): number;
  49127. /**
  49128. * Return the latest stable version of this feature
  49129. * @param featureName the name of the feature to search
  49130. * @returns the version number. if not found will return -1
  49131. */
  49132. static GetStableVersionOfFeature(featureName: string): number;
  49133. /**
  49134. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49135. * Can be used during a session to start a feature
  49136. * @param featureName the name of feature to attach
  49137. */
  49138. attachFeature(featureName: string): void;
  49139. /**
  49140. * Can be used inside a session or when the session ends to detach a specific feature
  49141. * @param featureName the name of the feature to detach
  49142. */
  49143. detachFeature(featureName: string): void;
  49144. /**
  49145. * Used to disable an already-enabled feature
  49146. * The feature will be disposed and will be recreated once enabled.
  49147. * @param featureName the feature to disable
  49148. * @returns true if disable was successful
  49149. */
  49150. disableFeature(featureName: string | {
  49151. Name: string;
  49152. }): boolean;
  49153. /**
  49154. * dispose this features manager
  49155. */
  49156. dispose(): void;
  49157. /**
  49158. * 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.
  49159. * 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.
  49160. *
  49161. * @param featureName the name of the feature to load or the class of the feature
  49162. * @param version optional version to load. if not provided the latest version will be enabled
  49163. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49164. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49165. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49166. * @returns a new constructed feature or throws an error if feature not found.
  49167. */
  49168. enableFeature(featureName: string | {
  49169. Name: string;
  49170. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49171. /**
  49172. * get the implementation of an enabled feature.
  49173. * @param featureName the name of the feature to load
  49174. * @returns the feature class, if found
  49175. */
  49176. getEnabledFeature(featureName: string): IWebXRFeature;
  49177. /**
  49178. * Get the list of enabled features
  49179. * @returns an array of enabled features
  49180. */
  49181. getEnabledFeatures(): string[];
  49182. /**
  49183. * This function will exten the session creation configuration object with enabled features.
  49184. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49185. * according to the defined "required" variable, provided during enableFeature call
  49186. * @param xrSessionInit the xr Session init object to extend
  49187. *
  49188. * @returns an extended XRSessionInit object
  49189. */
  49190. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49191. }
  49192. }
  49193. declare module "babylonjs/XR/webXRExperienceHelper" {
  49194. import { Observable } from "babylonjs/Misc/observable";
  49195. import { IDisposable, Scene } from "babylonjs/scene";
  49196. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49197. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49198. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49199. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49200. /**
  49201. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49202. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49203. */
  49204. export class WebXRExperienceHelper implements IDisposable {
  49205. private scene;
  49206. private _nonVRCamera;
  49207. private _originalSceneAutoClear;
  49208. private _supported;
  49209. /**
  49210. * Camera used to render xr content
  49211. */
  49212. camera: WebXRCamera;
  49213. /** A features manager for this xr session */
  49214. featuresManager: WebXRFeaturesManager;
  49215. /**
  49216. * Observers registered here will be triggered after the camera's initial transformation is set
  49217. * This can be used to set a different ground level or an extra rotation.
  49218. *
  49219. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49220. * to the position set after this observable is done executing.
  49221. */
  49222. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49223. /**
  49224. * Fires when the state of the experience helper has changed
  49225. */
  49226. onStateChangedObservable: Observable<WebXRState>;
  49227. /** Session manager used to keep track of xr session */
  49228. sessionManager: WebXRSessionManager;
  49229. /**
  49230. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49231. */
  49232. state: WebXRState;
  49233. /**
  49234. * Creates a WebXRExperienceHelper
  49235. * @param scene The scene the helper should be created in
  49236. */
  49237. private constructor();
  49238. /**
  49239. * Creates the experience helper
  49240. * @param scene the scene to attach the experience helper to
  49241. * @returns a promise for the experience helper
  49242. */
  49243. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49244. /**
  49245. * Disposes of the experience helper
  49246. */
  49247. dispose(): void;
  49248. /**
  49249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49250. * @param sessionMode options for the XR session
  49251. * @param referenceSpaceType frame of reference of the XR session
  49252. * @param renderTarget the output canvas that will be used to enter XR mode
  49253. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49254. * @returns promise that resolves after xr mode has entered
  49255. */
  49256. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49257. /**
  49258. * Exits XR mode and returns the scene to its original state
  49259. * @returns promise that resolves after xr mode has exited
  49260. */
  49261. exitXRAsync(): Promise<void>;
  49262. private _nonXRToXRCamera;
  49263. private _setState;
  49264. }
  49265. }
  49266. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49267. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49268. import { Observable } from "babylonjs/Misc/observable";
  49269. import { IDisposable } from "babylonjs/scene";
  49270. /**
  49271. * X-Y values for axes in WebXR
  49272. */
  49273. export interface IWebXRMotionControllerAxesValue {
  49274. /**
  49275. * The value of the x axis
  49276. */
  49277. x: number;
  49278. /**
  49279. * The value of the y-axis
  49280. */
  49281. y: number;
  49282. }
  49283. /**
  49284. * changed / previous values for the values of this component
  49285. */
  49286. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49287. /**
  49288. * current (this frame) value
  49289. */
  49290. current: T;
  49291. /**
  49292. * previous (last change) value
  49293. */
  49294. previous: T;
  49295. }
  49296. /**
  49297. * Represents changes in the component between current frame and last values recorded
  49298. */
  49299. export interface IWebXRMotionControllerComponentChanges {
  49300. /**
  49301. * will be populated with previous and current values if axes changed
  49302. */
  49303. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49304. /**
  49305. * will be populated with previous and current values if pressed changed
  49306. */
  49307. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49308. /**
  49309. * will be populated with previous and current values if touched changed
  49310. */
  49311. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49312. /**
  49313. * will be populated with previous and current values if value changed
  49314. */
  49315. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49316. }
  49317. /**
  49318. * This class represents a single component (for example button or thumbstick) of a motion controller
  49319. */
  49320. export class WebXRControllerComponent implements IDisposable {
  49321. /**
  49322. * the id of this component
  49323. */
  49324. id: string;
  49325. /**
  49326. * the type of the component
  49327. */
  49328. type: MotionControllerComponentType;
  49329. private _buttonIndex;
  49330. private _axesIndices;
  49331. private _axes;
  49332. private _changes;
  49333. private _currentValue;
  49334. private _hasChanges;
  49335. private _pressed;
  49336. private _touched;
  49337. /**
  49338. * button component type
  49339. */
  49340. static BUTTON_TYPE: MotionControllerComponentType;
  49341. /**
  49342. * squeeze component type
  49343. */
  49344. static SQUEEZE_TYPE: MotionControllerComponentType;
  49345. /**
  49346. * Thumbstick component type
  49347. */
  49348. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49349. /**
  49350. * Touchpad component type
  49351. */
  49352. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49353. /**
  49354. * trigger component type
  49355. */
  49356. static TRIGGER_TYPE: MotionControllerComponentType;
  49357. /**
  49358. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49359. * the axes data changes
  49360. */
  49361. onAxisValueChangedObservable: Observable<{
  49362. x: number;
  49363. y: number;
  49364. }>;
  49365. /**
  49366. * Observers registered here will be triggered when the state of a button changes
  49367. * State change is either pressed / touched / value
  49368. */
  49369. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49370. /**
  49371. * Creates a new component for a motion controller.
  49372. * It is created by the motion controller itself
  49373. *
  49374. * @param id the id of this component
  49375. * @param type the type of the component
  49376. * @param _buttonIndex index in the buttons array of the gamepad
  49377. * @param _axesIndices indices of the values in the axes array of the gamepad
  49378. */
  49379. constructor(
  49380. /**
  49381. * the id of this component
  49382. */
  49383. id: string,
  49384. /**
  49385. * the type of the component
  49386. */
  49387. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49388. /**
  49389. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49390. */
  49391. get axes(): IWebXRMotionControllerAxesValue;
  49392. /**
  49393. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49394. */
  49395. get changes(): IWebXRMotionControllerComponentChanges;
  49396. /**
  49397. * Return whether or not the component changed the last frame
  49398. */
  49399. get hasChanges(): boolean;
  49400. /**
  49401. * is the button currently pressed
  49402. */
  49403. get pressed(): boolean;
  49404. /**
  49405. * is the button currently touched
  49406. */
  49407. get touched(): boolean;
  49408. /**
  49409. * Get the current value of this component
  49410. */
  49411. get value(): number;
  49412. /**
  49413. * Dispose this component
  49414. */
  49415. dispose(): void;
  49416. /**
  49417. * Are there axes correlating to this component
  49418. * @return true is axes data is available
  49419. */
  49420. isAxes(): boolean;
  49421. /**
  49422. * Is this component a button (hence - pressable)
  49423. * @returns true if can be pressed
  49424. */
  49425. isButton(): boolean;
  49426. /**
  49427. * update this component using the gamepad object it is in. Called on every frame
  49428. * @param nativeController the native gamepad controller object
  49429. */
  49430. update(nativeController: IMinimalMotionControllerObject): void;
  49431. }
  49432. }
  49433. declare module "babylonjs/Loading/sceneLoader" {
  49434. import { Observable } from "babylonjs/Misc/observable";
  49435. import { Nullable } from "babylonjs/types";
  49436. import { Scene } from "babylonjs/scene";
  49437. import { Engine } from "babylonjs/Engines/engine";
  49438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49439. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49440. import { AssetContainer } from "babylonjs/assetContainer";
  49441. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49442. import { Skeleton } from "babylonjs/Bones/skeleton";
  49443. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49444. import { WebRequest } from "babylonjs/Misc/webRequest";
  49445. /**
  49446. * Interface used to represent data loading progression
  49447. */
  49448. export interface ISceneLoaderProgressEvent {
  49449. /**
  49450. * Defines if data length to load can be evaluated
  49451. */
  49452. readonly lengthComputable: boolean;
  49453. /**
  49454. * Defines the loaded data length
  49455. */
  49456. readonly loaded: number;
  49457. /**
  49458. * Defines the data length to load
  49459. */
  49460. readonly total: number;
  49461. }
  49462. /**
  49463. * Interface used by SceneLoader plugins to define supported file extensions
  49464. */
  49465. export interface ISceneLoaderPluginExtensions {
  49466. /**
  49467. * Defines the list of supported extensions
  49468. */
  49469. [extension: string]: {
  49470. isBinary: boolean;
  49471. };
  49472. }
  49473. /**
  49474. * Interface used by SceneLoader plugin factory
  49475. */
  49476. export interface ISceneLoaderPluginFactory {
  49477. /**
  49478. * Defines the name of the factory
  49479. */
  49480. name: string;
  49481. /**
  49482. * Function called to create a new plugin
  49483. * @return the new plugin
  49484. */
  49485. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49486. /**
  49487. * The callback that returns true if the data can be directly loaded.
  49488. * @param data string containing the file data
  49489. * @returns if the data can be loaded directly
  49490. */
  49491. canDirectLoad?(data: string): boolean;
  49492. }
  49493. /**
  49494. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49495. */
  49496. export interface ISceneLoaderPluginBase {
  49497. /**
  49498. * The friendly name of this plugin.
  49499. */
  49500. name: string;
  49501. /**
  49502. * The file extensions supported by this plugin.
  49503. */
  49504. extensions: string | ISceneLoaderPluginExtensions;
  49505. /**
  49506. * The callback called when loading from a url.
  49507. * @param scene scene loading this url
  49508. * @param url url to load
  49509. * @param onSuccess callback called when the file successfully loads
  49510. * @param onProgress callback called while file is loading (if the server supports this mode)
  49511. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49512. * @param onError callback called when the file fails to load
  49513. * @returns a file request object
  49514. */
  49515. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49516. /**
  49517. * The callback called when loading from a file object.
  49518. * @param scene scene loading this file
  49519. * @param file defines the file to load
  49520. * @param onSuccess defines the callback to call when data is loaded
  49521. * @param onProgress defines the callback to call during loading process
  49522. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49523. * @param onError defines the callback to call when an error occurs
  49524. * @returns a file request object
  49525. */
  49526. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49527. /**
  49528. * The callback that returns true if the data can be directly loaded.
  49529. * @param data string containing the file data
  49530. * @returns if the data can be loaded directly
  49531. */
  49532. canDirectLoad?(data: string): boolean;
  49533. /**
  49534. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49535. * @param scene scene loading this data
  49536. * @param data string containing the data
  49537. * @returns data to pass to the plugin
  49538. */
  49539. directLoad?(scene: Scene, data: string): any;
  49540. /**
  49541. * The callback that allows custom handling of the root url based on the response url.
  49542. * @param rootUrl the original root url
  49543. * @param responseURL the response url if available
  49544. * @returns the new root url
  49545. */
  49546. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49547. }
  49548. /**
  49549. * Interface used to define a SceneLoader plugin
  49550. */
  49551. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49552. /**
  49553. * Import meshes into a scene.
  49554. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49555. * @param scene The scene to import into
  49556. * @param data The data to import
  49557. * @param rootUrl The root url for scene and resources
  49558. * @param meshes The meshes array to import into
  49559. * @param particleSystems The particle systems array to import into
  49560. * @param skeletons The skeletons array to import into
  49561. * @param onError The callback when import fails
  49562. * @returns True if successful or false otherwise
  49563. */
  49564. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49565. /**
  49566. * Load into a scene.
  49567. * @param scene The scene to load into
  49568. * @param data The data to import
  49569. * @param rootUrl The root url for scene and resources
  49570. * @param onError The callback when import fails
  49571. * @returns True if successful or false otherwise
  49572. */
  49573. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49574. /**
  49575. * Load into an asset container.
  49576. * @param scene The scene to load into
  49577. * @param data The data to import
  49578. * @param rootUrl The root url for scene and resources
  49579. * @param onError The callback when import fails
  49580. * @returns The loaded asset container
  49581. */
  49582. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49583. }
  49584. /**
  49585. * Interface used to define an async SceneLoader plugin
  49586. */
  49587. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49588. /**
  49589. * Import meshes into a scene.
  49590. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49591. * @param scene The scene to import into
  49592. * @param data The data to import
  49593. * @param rootUrl The root url for scene and resources
  49594. * @param onProgress The callback when the load progresses
  49595. * @param fileName Defines the name of the file to load
  49596. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49597. */
  49598. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49599. meshes: AbstractMesh[];
  49600. particleSystems: IParticleSystem[];
  49601. skeletons: Skeleton[];
  49602. animationGroups: AnimationGroup[];
  49603. }>;
  49604. /**
  49605. * Load into a scene.
  49606. * @param scene The scene to load into
  49607. * @param data The data to import
  49608. * @param rootUrl The root url for scene and resources
  49609. * @param onProgress The callback when the load progresses
  49610. * @param fileName Defines the name of the file to load
  49611. * @returns Nothing
  49612. */
  49613. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49614. /**
  49615. * Load into an asset container.
  49616. * @param scene The scene to load into
  49617. * @param data The data to import
  49618. * @param rootUrl The root url for scene and resources
  49619. * @param onProgress The callback when the load progresses
  49620. * @param fileName Defines the name of the file to load
  49621. * @returns The loaded asset container
  49622. */
  49623. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49624. }
  49625. /**
  49626. * Mode that determines how to handle old animation groups before loading new ones.
  49627. */
  49628. export enum SceneLoaderAnimationGroupLoadingMode {
  49629. /**
  49630. * Reset all old animations to initial state then dispose them.
  49631. */
  49632. Clean = 0,
  49633. /**
  49634. * Stop all old animations.
  49635. */
  49636. Stop = 1,
  49637. /**
  49638. * Restart old animations from first frame.
  49639. */
  49640. Sync = 2,
  49641. /**
  49642. * Old animations remains untouched.
  49643. */
  49644. NoSync = 3
  49645. }
  49646. /**
  49647. * Defines a plugin registered by the SceneLoader
  49648. */
  49649. interface IRegisteredPlugin {
  49650. /**
  49651. * Defines the plugin to use
  49652. */
  49653. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49654. /**
  49655. * Defines if the plugin supports binary data
  49656. */
  49657. isBinary: boolean;
  49658. }
  49659. /**
  49660. * Class used to load scene from various file formats using registered plugins
  49661. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49662. */
  49663. export class SceneLoader {
  49664. /**
  49665. * No logging while loading
  49666. */
  49667. static readonly NO_LOGGING: number;
  49668. /**
  49669. * Minimal logging while loading
  49670. */
  49671. static readonly MINIMAL_LOGGING: number;
  49672. /**
  49673. * Summary logging while loading
  49674. */
  49675. static readonly SUMMARY_LOGGING: number;
  49676. /**
  49677. * Detailled logging while loading
  49678. */
  49679. static readonly DETAILED_LOGGING: number;
  49680. /**
  49681. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49682. */
  49683. static get ForceFullSceneLoadingForIncremental(): boolean;
  49684. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49685. /**
  49686. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49687. */
  49688. static get ShowLoadingScreen(): boolean;
  49689. static set ShowLoadingScreen(value: boolean);
  49690. /**
  49691. * Defines the current logging level (while loading the scene)
  49692. * @ignorenaming
  49693. */
  49694. static get loggingLevel(): number;
  49695. static set loggingLevel(value: number);
  49696. /**
  49697. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49698. */
  49699. static get CleanBoneMatrixWeights(): boolean;
  49700. static set CleanBoneMatrixWeights(value: boolean);
  49701. /**
  49702. * Event raised when a plugin is used to load a scene
  49703. */
  49704. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49705. private static _registeredPlugins;
  49706. private static _showingLoadingScreen;
  49707. /**
  49708. * Gets the default plugin (used to load Babylon files)
  49709. * @returns the .babylon plugin
  49710. */
  49711. static GetDefaultPlugin(): IRegisteredPlugin;
  49712. private static _GetPluginForExtension;
  49713. private static _GetPluginForDirectLoad;
  49714. private static _GetPluginForFilename;
  49715. private static _GetDirectLoad;
  49716. private static _LoadData;
  49717. private static _GetFileInfo;
  49718. /**
  49719. * Gets a plugin that can load the given extension
  49720. * @param extension defines the extension to load
  49721. * @returns a plugin or null if none works
  49722. */
  49723. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49724. /**
  49725. * Gets a boolean indicating that the given extension can be loaded
  49726. * @param extension defines the extension to load
  49727. * @returns true if the extension is supported
  49728. */
  49729. static IsPluginForExtensionAvailable(extension: string): boolean;
  49730. /**
  49731. * Adds a new plugin to the list of registered plugins
  49732. * @param plugin defines the plugin to add
  49733. */
  49734. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49735. /**
  49736. * Import meshes into a scene
  49737. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49738. * @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)
  49739. * @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)
  49740. * @param scene the instance of BABYLON.Scene to append to
  49741. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49742. * @param onProgress a callback with a progress event for each file being loaded
  49743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49744. * @param pluginExtension the extension used to determine the plugin
  49745. * @returns The loaded plugin
  49746. */
  49747. 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>;
  49748. /**
  49749. * Import meshes into a scene
  49750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49751. * @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)
  49752. * @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)
  49753. * @param scene the instance of BABYLON.Scene to append to
  49754. * @param onProgress a callback with a progress event for each file being loaded
  49755. * @param pluginExtension the extension used to determine the plugin
  49756. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49757. */
  49758. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49759. meshes: AbstractMesh[];
  49760. particleSystems: IParticleSystem[];
  49761. skeletons: Skeleton[];
  49762. animationGroups: AnimationGroup[];
  49763. }>;
  49764. /**
  49765. * Load a scene
  49766. * @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)
  49767. * @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)
  49768. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49769. * @param onSuccess a callback with the scene when import succeeds
  49770. * @param onProgress a callback with a progress event for each file being loaded
  49771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49772. * @param pluginExtension the extension used to determine the plugin
  49773. * @returns The loaded plugin
  49774. */
  49775. 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>;
  49776. /**
  49777. * Load a scene
  49778. * @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)
  49779. * @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)
  49780. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49781. * @param onProgress a callback with a progress event for each file being loaded
  49782. * @param pluginExtension the extension used to determine the plugin
  49783. * @returns The loaded scene
  49784. */
  49785. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49786. /**
  49787. * Append a scene
  49788. * @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)
  49789. * @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)
  49790. * @param scene is the instance of BABYLON.Scene to append to
  49791. * @param onSuccess a callback with the scene when import succeeds
  49792. * @param onProgress a callback with a progress event for each file being loaded
  49793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49794. * @param pluginExtension the extension used to determine the plugin
  49795. * @returns The loaded plugin
  49796. */
  49797. 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>;
  49798. /**
  49799. * Append a scene
  49800. * @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)
  49801. * @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)
  49802. * @param scene is the instance of BABYLON.Scene to append to
  49803. * @param onProgress a callback with a progress event for each file being loaded
  49804. * @param pluginExtension the extension used to determine the plugin
  49805. * @returns The given scene
  49806. */
  49807. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49808. /**
  49809. * Load a scene into an asset container
  49810. * @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)
  49811. * @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)
  49812. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49813. * @param onSuccess a callback with the scene when import succeeds
  49814. * @param onProgress a callback with a progress event for each file being loaded
  49815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49816. * @param pluginExtension the extension used to determine the plugin
  49817. * @returns The loaded plugin
  49818. */
  49819. 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>;
  49820. /**
  49821. * Load a scene into an asset container
  49822. * @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)
  49823. * @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)
  49824. * @param scene is the instance of Scene to append to
  49825. * @param onProgress a callback with a progress event for each file being loaded
  49826. * @param pluginExtension the extension used to determine the plugin
  49827. * @returns The loaded asset container
  49828. */
  49829. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49830. /**
  49831. * Import animations from a file into a scene
  49832. * @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)
  49833. * @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)
  49834. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49835. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49836. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49837. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49838. * @param onSuccess a callback with the scene when import succeeds
  49839. * @param onProgress a callback with a progress event for each file being loaded
  49840. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49841. * @param pluginExtension the extension used to determine the plugin
  49842. */
  49843. 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;
  49844. /**
  49845. * Import animations from a file into a scene
  49846. * @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)
  49847. * @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)
  49848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49849. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49850. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49851. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49852. * @param onSuccess a callback with the scene when import succeeds
  49853. * @param onProgress a callback with a progress event for each file being loaded
  49854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49855. * @param pluginExtension the extension used to determine the plugin
  49856. * @returns the updated scene with imported animations
  49857. */
  49858. 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>;
  49859. }
  49860. }
  49861. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49862. import { IDisposable, Scene } from "babylonjs/scene";
  49863. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49864. import { Observable } from "babylonjs/Misc/observable";
  49865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49866. import { Nullable } from "babylonjs/types";
  49867. /**
  49868. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49869. */
  49870. export type MotionControllerHandedness = "none" | "left" | "right";
  49871. /**
  49872. * The type of components available in motion controllers.
  49873. * This is not the name of the component.
  49874. */
  49875. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49876. /**
  49877. * The state of a controller component
  49878. */
  49879. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49880. /**
  49881. * The schema of motion controller layout.
  49882. * No object will be initialized using this interface
  49883. * This is used just to define the profile.
  49884. */
  49885. export interface IMotionControllerLayout {
  49886. /**
  49887. * Path to load the assets. Usually relative to the base path
  49888. */
  49889. assetPath: string;
  49890. /**
  49891. * Available components (unsorted)
  49892. */
  49893. components: {
  49894. /**
  49895. * A map of component Ids
  49896. */
  49897. [componentId: string]: {
  49898. /**
  49899. * The type of input the component outputs
  49900. */
  49901. type: MotionControllerComponentType;
  49902. /**
  49903. * The indices of this component in the gamepad object
  49904. */
  49905. gamepadIndices: {
  49906. /**
  49907. * Index of button
  49908. */
  49909. button?: number;
  49910. /**
  49911. * If available, index of x-axis
  49912. */
  49913. xAxis?: number;
  49914. /**
  49915. * If available, index of y-axis
  49916. */
  49917. yAxis?: number;
  49918. };
  49919. /**
  49920. * The mesh's root node name
  49921. */
  49922. rootNodeName: string;
  49923. /**
  49924. * Animation definitions for this model
  49925. */
  49926. visualResponses: {
  49927. [stateKey: string]: {
  49928. /**
  49929. * What property will be animated
  49930. */
  49931. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49932. /**
  49933. * What states influence this visual response
  49934. */
  49935. states: MotionControllerComponentStateType[];
  49936. /**
  49937. * Type of animation - movement or visibility
  49938. */
  49939. valueNodeProperty: "transform" | "visibility";
  49940. /**
  49941. * Base node name to move. Its position will be calculated according to the min and max nodes
  49942. */
  49943. valueNodeName?: string;
  49944. /**
  49945. * Minimum movement node
  49946. */
  49947. minNodeName?: string;
  49948. /**
  49949. * Max movement node
  49950. */
  49951. maxNodeName?: string;
  49952. };
  49953. };
  49954. /**
  49955. * If touch enabled, what is the name of node to display user feedback
  49956. */
  49957. touchPointNodeName?: string;
  49958. };
  49959. };
  49960. /**
  49961. * Is it xr standard mapping or not
  49962. */
  49963. gamepadMapping: "" | "xr-standard";
  49964. /**
  49965. * Base root node of this entire model
  49966. */
  49967. rootNodeName: string;
  49968. /**
  49969. * Defines the main button component id
  49970. */
  49971. selectComponentId: string;
  49972. }
  49973. /**
  49974. * A definition for the layout map in the input profile
  49975. */
  49976. export interface IMotionControllerLayoutMap {
  49977. /**
  49978. * Layouts with handedness type as a key
  49979. */
  49980. [handedness: string]: IMotionControllerLayout;
  49981. }
  49982. /**
  49983. * The XR Input profile schema
  49984. * Profiles can be found here:
  49985. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49986. */
  49987. export interface IMotionControllerProfile {
  49988. /**
  49989. * fallback profiles for this profileId
  49990. */
  49991. fallbackProfileIds: string[];
  49992. /**
  49993. * The layout map, with handedness as key
  49994. */
  49995. layouts: IMotionControllerLayoutMap;
  49996. /**
  49997. * The id of this profile
  49998. * correlates to the profile(s) in the xrInput.profiles array
  49999. */
  50000. profileId: string;
  50001. }
  50002. /**
  50003. * A helper-interface for the 3 meshes needed for controller button animation
  50004. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50005. */
  50006. export interface IMotionControllerButtonMeshMap {
  50007. /**
  50008. * the mesh that defines the pressed value mesh position.
  50009. * This is used to find the max-position of this button
  50010. */
  50011. pressedMesh: AbstractMesh;
  50012. /**
  50013. * the mesh that defines the unpressed value mesh position.
  50014. * This is used to find the min (or initial) position of this button
  50015. */
  50016. unpressedMesh: AbstractMesh;
  50017. /**
  50018. * The mesh that will be changed when value changes
  50019. */
  50020. valueMesh: AbstractMesh;
  50021. }
  50022. /**
  50023. * A helper-interface for the 3 meshes needed for controller axis animation.
  50024. * This will be expanded when touchpad animations are fully supported
  50025. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50026. */
  50027. export interface IMotionControllerMeshMap {
  50028. /**
  50029. * the mesh that defines the maximum value mesh position.
  50030. */
  50031. maxMesh?: AbstractMesh;
  50032. /**
  50033. * the mesh that defines the minimum value mesh position.
  50034. */
  50035. minMesh?: AbstractMesh;
  50036. /**
  50037. * The mesh that will be changed when axis value changes
  50038. */
  50039. valueMesh?: AbstractMesh;
  50040. }
  50041. /**
  50042. * The elements needed for change-detection of the gamepad objects in motion controllers
  50043. */
  50044. export interface IMinimalMotionControllerObject {
  50045. /**
  50046. * Available axes of this controller
  50047. */
  50048. axes: number[];
  50049. /**
  50050. * An array of available buttons
  50051. */
  50052. buttons: Array<{
  50053. /**
  50054. * Value of the button/trigger
  50055. */
  50056. value: number;
  50057. /**
  50058. * If the button/trigger is currently touched
  50059. */
  50060. touched: boolean;
  50061. /**
  50062. * If the button/trigger is currently pressed
  50063. */
  50064. pressed: boolean;
  50065. }>;
  50066. /**
  50067. * EXPERIMENTAL haptic support.
  50068. */
  50069. hapticActuators?: Array<{
  50070. pulse: (value: number, duration: number) => Promise<boolean>;
  50071. }>;
  50072. }
  50073. /**
  50074. * An Abstract Motion controller
  50075. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50076. * Each component has an observable to check for changes in value and state
  50077. */
  50078. export abstract class WebXRAbstractMotionController implements IDisposable {
  50079. protected scene: Scene;
  50080. protected layout: IMotionControllerLayout;
  50081. /**
  50082. * The gamepad object correlating to this controller
  50083. */
  50084. gamepadObject: IMinimalMotionControllerObject;
  50085. /**
  50086. * handedness (left/right/none) of this controller
  50087. */
  50088. handedness: MotionControllerHandedness;
  50089. private _initComponent;
  50090. private _modelReady;
  50091. /**
  50092. * A map of components (WebXRControllerComponent) in this motion controller
  50093. * Components have a ComponentType and can also have both button and axis definitions
  50094. */
  50095. readonly components: {
  50096. [id: string]: WebXRControllerComponent;
  50097. };
  50098. /**
  50099. * Disable the model's animation. Can be set at any time.
  50100. */
  50101. disableAnimation: boolean;
  50102. /**
  50103. * Observers registered here will be triggered when the model of this controller is done loading
  50104. */
  50105. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50106. /**
  50107. * The profile id of this motion controller
  50108. */
  50109. abstract profileId: string;
  50110. /**
  50111. * The root mesh of the model. It is null if the model was not yet initialized
  50112. */
  50113. rootMesh: Nullable<AbstractMesh>;
  50114. /**
  50115. * constructs a new abstract motion controller
  50116. * @param scene the scene to which the model of the controller will be added
  50117. * @param layout The profile layout to load
  50118. * @param gamepadObject The gamepad object correlating to this controller
  50119. * @param handedness handedness (left/right/none) of this controller
  50120. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50121. */
  50122. constructor(scene: Scene, layout: IMotionControllerLayout,
  50123. /**
  50124. * The gamepad object correlating to this controller
  50125. */
  50126. gamepadObject: IMinimalMotionControllerObject,
  50127. /**
  50128. * handedness (left/right/none) of this controller
  50129. */
  50130. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50131. /**
  50132. * Dispose this controller, the model mesh and all its components
  50133. */
  50134. dispose(): void;
  50135. /**
  50136. * Returns all components of specific type
  50137. * @param type the type to search for
  50138. * @return an array of components with this type
  50139. */
  50140. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50141. /**
  50142. * get a component based an its component id as defined in layout.components
  50143. * @param id the id of the component
  50144. * @returns the component correlates to the id or undefined if not found
  50145. */
  50146. getComponent(id: string): WebXRControllerComponent;
  50147. /**
  50148. * Get the list of components available in this motion controller
  50149. * @returns an array of strings correlating to available components
  50150. */
  50151. getComponentIds(): string[];
  50152. /**
  50153. * Get the first component of specific type
  50154. * @param type type of component to find
  50155. * @return a controller component or null if not found
  50156. */
  50157. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50158. /**
  50159. * Get the main (Select) component of this controller as defined in the layout
  50160. * @returns the main component of this controller
  50161. */
  50162. getMainComponent(): WebXRControllerComponent;
  50163. /**
  50164. * Loads the model correlating to this controller
  50165. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50166. * @returns A promise fulfilled with the result of the model loading
  50167. */
  50168. loadModel(): Promise<boolean>;
  50169. /**
  50170. * Update this model using the current XRFrame
  50171. * @param xrFrame the current xr frame to use and update the model
  50172. */
  50173. updateFromXRFrame(xrFrame: XRFrame): void;
  50174. /**
  50175. * Backwards compatibility due to a deeply-integrated typo
  50176. */
  50177. get handness(): XREye;
  50178. /**
  50179. * Pulse (vibrate) this controller
  50180. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50181. * Consecutive calls to this function will cancel the last pulse call
  50182. *
  50183. * @param value the strength of the pulse in 0.0...1.0 range
  50184. * @param duration Duration of the pulse in milliseconds
  50185. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50186. * @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
  50187. */
  50188. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50189. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50190. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50191. /**
  50192. * Moves the axis on the controller mesh based on its current state
  50193. * @param axis the index of the axis
  50194. * @param axisValue the value of the axis which determines the meshes new position
  50195. * @hidden
  50196. */
  50197. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50198. /**
  50199. * Update the model itself with the current frame data
  50200. * @param xrFrame the frame to use for updating the model mesh
  50201. */
  50202. protected updateModel(xrFrame: XRFrame): void;
  50203. /**
  50204. * Get the filename and path for this controller's model
  50205. * @returns a map of filename and path
  50206. */
  50207. protected abstract _getFilenameAndPath(): {
  50208. filename: string;
  50209. path: string;
  50210. };
  50211. /**
  50212. * This function is called before the mesh is loaded. It checks for loading constraints.
  50213. * For example, this function can check if the GLB loader is available
  50214. * If this function returns false, the generic controller will be loaded instead
  50215. * @returns Is the client ready to load the mesh
  50216. */
  50217. protected abstract _getModelLoadingConstraints(): boolean;
  50218. /**
  50219. * This function will be called after the model was successfully loaded and can be used
  50220. * for mesh transformations before it is available for the user
  50221. * @param meshes the loaded meshes
  50222. */
  50223. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50224. /**
  50225. * Set the root mesh for this controller. Important for the WebXR controller class
  50226. * @param meshes the loaded meshes
  50227. */
  50228. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50229. /**
  50230. * A function executed each frame that updates the mesh (if needed)
  50231. * @param xrFrame the current xrFrame
  50232. */
  50233. protected abstract _updateModel(xrFrame: XRFrame): void;
  50234. private _getGenericFilenameAndPath;
  50235. private _getGenericParentMesh;
  50236. }
  50237. }
  50238. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50239. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50241. import { Scene } from "babylonjs/scene";
  50242. /**
  50243. * A generic trigger-only motion controller for WebXR
  50244. */
  50245. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50246. /**
  50247. * Static version of the profile id of this controller
  50248. */
  50249. static ProfileId: string;
  50250. profileId: string;
  50251. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50252. protected _getFilenameAndPath(): {
  50253. filename: string;
  50254. path: string;
  50255. };
  50256. protected _getModelLoadingConstraints(): boolean;
  50257. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50259. protected _updateModel(): void;
  50260. }
  50261. }
  50262. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50263. import { Vector4 } from "babylonjs/Maths/math.vector";
  50264. import { Mesh } from "babylonjs/Meshes/mesh";
  50265. import { Scene } from "babylonjs/scene";
  50266. import { Nullable } from "babylonjs/types";
  50267. /**
  50268. * Class containing static functions to help procedurally build meshes
  50269. */
  50270. export class SphereBuilder {
  50271. /**
  50272. * Creates a sphere mesh
  50273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50274. * * 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`)
  50275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50276. * * 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
  50277. * * 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)
  50278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50281. * @param name defines the name of the mesh
  50282. * @param options defines the options used to create the mesh
  50283. * @param scene defines the hosting scene
  50284. * @returns the sphere mesh
  50285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50286. */
  50287. static CreateSphere(name: string, options: {
  50288. segments?: number;
  50289. diameter?: number;
  50290. diameterX?: number;
  50291. diameterY?: number;
  50292. diameterZ?: number;
  50293. arc?: number;
  50294. slice?: number;
  50295. sideOrientation?: number;
  50296. frontUVs?: Vector4;
  50297. backUVs?: Vector4;
  50298. updatable?: boolean;
  50299. }, scene?: Nullable<Scene>): Mesh;
  50300. }
  50301. }
  50302. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50304. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50305. import { Scene } from "babylonjs/scene";
  50306. /**
  50307. * A profiled motion controller has its profile loaded from an online repository.
  50308. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50309. */
  50310. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50311. private _repositoryUrl;
  50312. private _buttonMeshMapping;
  50313. private _touchDots;
  50314. /**
  50315. * The profile ID of this controller. Will be populated when the controller initializes.
  50316. */
  50317. profileId: string;
  50318. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50319. dispose(): void;
  50320. protected _getFilenameAndPath(): {
  50321. filename: string;
  50322. path: string;
  50323. };
  50324. protected _getModelLoadingConstraints(): boolean;
  50325. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50326. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50327. protected _updateModel(_xrFrame: XRFrame): void;
  50328. }
  50329. }
  50330. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50331. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50332. import { Scene } from "babylonjs/scene";
  50333. /**
  50334. * A construction function type to create a new controller based on an xrInput object
  50335. */
  50336. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50337. /**
  50338. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50339. *
  50340. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50341. * it should be replaced with auto-loaded controllers.
  50342. *
  50343. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50344. */
  50345. export class WebXRMotionControllerManager {
  50346. private static _AvailableControllers;
  50347. private static _Fallbacks;
  50348. private static _ProfileLoadingPromises;
  50349. private static _ProfilesList;
  50350. /**
  50351. * The base URL of the online controller repository. Can be changed at any time.
  50352. */
  50353. static BaseRepositoryUrl: string;
  50354. /**
  50355. * Which repository gets priority - local or online
  50356. */
  50357. static PrioritizeOnlineRepository: boolean;
  50358. /**
  50359. * Use the online repository, or use only locally-defined controllers
  50360. */
  50361. static UseOnlineRepository: boolean;
  50362. /**
  50363. * Clear the cache used for profile loading and reload when requested again
  50364. */
  50365. static ClearProfilesCache(): void;
  50366. /**
  50367. * Register the default fallbacks.
  50368. * This function is called automatically when this file is imported.
  50369. */
  50370. static DefaultFallbacks(): void;
  50371. /**
  50372. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50373. * @param profileId the profile to which a fallback needs to be found
  50374. * @return an array with corresponding fallback profiles
  50375. */
  50376. static FindFallbackWithProfileId(profileId: string): string[];
  50377. /**
  50378. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50379. * The order of search:
  50380. *
  50381. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50382. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50383. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50384. * 4) return the generic trigger controller if none were found
  50385. *
  50386. * @param xrInput the xrInput to which a new controller is initialized
  50387. * @param scene the scene to which the model will be added
  50388. * @param forceProfile force a certain profile for this controller
  50389. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50390. */
  50391. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50392. /**
  50393. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50394. *
  50395. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50396. *
  50397. * @param type the profile type to register
  50398. * @param constructFunction the function to be called when loading this profile
  50399. */
  50400. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50401. /**
  50402. * Register a fallback to a specific profile.
  50403. * @param profileId the profileId that will receive the fallbacks
  50404. * @param fallbacks A list of fallback profiles
  50405. */
  50406. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50407. /**
  50408. * Will update the list of profiles available in the repository
  50409. * @return a promise that resolves to a map of profiles available online
  50410. */
  50411. static UpdateProfilesList(): Promise<{
  50412. [profile: string]: string;
  50413. }>;
  50414. private static _LoadProfileFromRepository;
  50415. private static _LoadProfilesFromAvailableControllers;
  50416. }
  50417. }
  50418. declare module "babylonjs/XR/webXRInputSource" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50421. import { Ray } from "babylonjs/Culling/ray";
  50422. import { Scene } from "babylonjs/scene";
  50423. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50424. /**
  50425. * Configuration options for the WebXR controller creation
  50426. */
  50427. export interface IWebXRControllerOptions {
  50428. /**
  50429. * Should the controller mesh be animated when a user interacts with it
  50430. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50431. */
  50432. disableMotionControllerAnimation?: boolean;
  50433. /**
  50434. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50435. */
  50436. doNotLoadControllerMesh?: boolean;
  50437. /**
  50438. * Force a specific controller type for this controller.
  50439. * This can be used when creating your own profile or when testing different controllers
  50440. */
  50441. forceControllerProfile?: string;
  50442. /**
  50443. * Defines a rendering group ID for meshes that will be loaded.
  50444. * This is for the default controllers only.
  50445. */
  50446. renderingGroupId?: number;
  50447. }
  50448. /**
  50449. * Represents an XR controller
  50450. */
  50451. export class WebXRInputSource {
  50452. private _scene;
  50453. /** The underlying input source for the controller */
  50454. inputSource: XRInputSource;
  50455. private _options;
  50456. private _tmpVector;
  50457. private _uniqueId;
  50458. private _disposed;
  50459. /**
  50460. * 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
  50461. */
  50462. grip?: AbstractMesh;
  50463. /**
  50464. * If available, this is the gamepad object related to this controller.
  50465. * Using this object it is possible to get click events and trackpad changes of the
  50466. * webxr controller that is currently being used.
  50467. */
  50468. motionController?: WebXRAbstractMotionController;
  50469. /**
  50470. * Event that fires when the controller is removed/disposed.
  50471. * The object provided as event data is this controller, after associated assets were disposed.
  50472. * uniqueId is still available.
  50473. */
  50474. onDisposeObservable: Observable<WebXRInputSource>;
  50475. /**
  50476. * Will be triggered when the mesh associated with the motion controller is done loading.
  50477. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50478. * A shortened version of controller -> motion controller -> on mesh loaded.
  50479. */
  50480. onMeshLoadedObservable: Observable<AbstractMesh>;
  50481. /**
  50482. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50483. */
  50484. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50485. /**
  50486. * Pointer which can be used to select objects or attach a visible laser to
  50487. */
  50488. pointer: AbstractMesh;
  50489. /**
  50490. * Creates the input source object
  50491. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50492. * @param _scene the scene which the controller should be associated to
  50493. * @param inputSource the underlying input source for the controller
  50494. * @param _options options for this controller creation
  50495. */
  50496. constructor(_scene: Scene,
  50497. /** The underlying input source for the controller */
  50498. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50499. /**
  50500. * Get this controllers unique id
  50501. */
  50502. get uniqueId(): string;
  50503. /**
  50504. * Disposes of the object
  50505. */
  50506. dispose(): void;
  50507. /**
  50508. * Gets a world space ray coming from the pointer or grip
  50509. * @param result the resulting ray
  50510. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50511. */
  50512. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50513. /**
  50514. * Updates the controller pose based on the given XRFrame
  50515. * @param xrFrame xr frame to update the pose with
  50516. * @param referenceSpace reference space to use
  50517. */
  50518. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50519. }
  50520. }
  50521. declare module "babylonjs/XR/webXRInput" {
  50522. import { Observable } from "babylonjs/Misc/observable";
  50523. import { IDisposable } from "babylonjs/scene";
  50524. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50525. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50526. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50527. /**
  50528. * The schema for initialization options of the XR Input class
  50529. */
  50530. export interface IWebXRInputOptions {
  50531. /**
  50532. * If set to true no model will be automatically loaded
  50533. */
  50534. doNotLoadControllerMeshes?: boolean;
  50535. /**
  50536. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50537. * If not found, the xr input profile data will be used.
  50538. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50539. */
  50540. forceInputProfile?: string;
  50541. /**
  50542. * Do not send a request to the controller repository to load the profile.
  50543. *
  50544. * Instead, use the controllers available in babylon itself.
  50545. */
  50546. disableOnlineControllerRepository?: boolean;
  50547. /**
  50548. * A custom URL for the controllers repository
  50549. */
  50550. customControllersRepositoryURL?: string;
  50551. /**
  50552. * Should the controller model's components not move according to the user input
  50553. */
  50554. disableControllerAnimation?: boolean;
  50555. /**
  50556. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50557. */
  50558. controllerOptions?: IWebXRControllerOptions;
  50559. }
  50560. /**
  50561. * XR input used to track XR inputs such as controllers/rays
  50562. */
  50563. export class WebXRInput implements IDisposable {
  50564. /**
  50565. * the xr session manager for this session
  50566. */
  50567. xrSessionManager: WebXRSessionManager;
  50568. /**
  50569. * the WebXR camera for this session. Mainly used for teleportation
  50570. */
  50571. xrCamera: WebXRCamera;
  50572. private readonly options;
  50573. /**
  50574. * XR controllers being tracked
  50575. */
  50576. controllers: Array<WebXRInputSource>;
  50577. private _frameObserver;
  50578. private _sessionEndedObserver;
  50579. private _sessionInitObserver;
  50580. /**
  50581. * Event when a controller has been connected/added
  50582. */
  50583. onControllerAddedObservable: Observable<WebXRInputSource>;
  50584. /**
  50585. * Event when a controller has been removed/disconnected
  50586. */
  50587. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50588. /**
  50589. * Initializes the WebXRInput
  50590. * @param xrSessionManager the xr session manager for this session
  50591. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50592. * @param options = initialization options for this xr input
  50593. */
  50594. constructor(
  50595. /**
  50596. * the xr session manager for this session
  50597. */
  50598. xrSessionManager: WebXRSessionManager,
  50599. /**
  50600. * the WebXR camera for this session. Mainly used for teleportation
  50601. */
  50602. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50603. private _onInputSourcesChange;
  50604. private _addAndRemoveControllers;
  50605. /**
  50606. * Disposes of the object
  50607. */
  50608. dispose(): void;
  50609. }
  50610. }
  50611. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50612. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50613. import { Observable, EventState } from "babylonjs/Misc/observable";
  50614. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50615. /**
  50616. * This is the base class for all WebXR features.
  50617. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50618. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50619. */
  50620. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50621. protected _xrSessionManager: WebXRSessionManager;
  50622. private _attached;
  50623. private _removeOnDetach;
  50624. /**
  50625. * Is this feature disposed?
  50626. */
  50627. isDisposed: boolean;
  50628. /**
  50629. * Should auto-attach be disabled?
  50630. */
  50631. disableAutoAttach: boolean;
  50632. /**
  50633. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50634. */
  50635. xrNativeFeatureName: string;
  50636. /**
  50637. * Construct a new (abstract) WebXR feature
  50638. * @param _xrSessionManager the xr session manager for this feature
  50639. */
  50640. constructor(_xrSessionManager: WebXRSessionManager);
  50641. /**
  50642. * Is this feature attached
  50643. */
  50644. get attached(): boolean;
  50645. /**
  50646. * attach this feature
  50647. *
  50648. * @param force should attachment be forced (even when already attached)
  50649. * @returns true if successful, false is failed or already attached
  50650. */
  50651. attach(force?: boolean): boolean;
  50652. /**
  50653. * detach this feature.
  50654. *
  50655. * @returns true if successful, false if failed or already detached
  50656. */
  50657. detach(): boolean;
  50658. /**
  50659. * Dispose this feature and all of the resources attached
  50660. */
  50661. dispose(): void;
  50662. /**
  50663. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50664. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50665. *
  50666. * @returns whether or not the feature is compatible in this environment
  50667. */
  50668. isCompatible(): boolean;
  50669. /**
  50670. * This is used to register callbacks that will automatically be removed when detach is called.
  50671. * @param observable the observable to which the observer will be attached
  50672. * @param callback the callback to register
  50673. */
  50674. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50675. /**
  50676. * Code in this function will be executed on each xrFrame received from the browser.
  50677. * This function will not execute after the feature is detached.
  50678. * @param _xrFrame the current frame
  50679. */
  50680. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50681. }
  50682. }
  50683. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50684. import { IDisposable, Scene } from "babylonjs/scene";
  50685. import { Nullable } from "babylonjs/types";
  50686. import { Observable } from "babylonjs/Misc/observable";
  50687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50688. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50689. import { Camera } from "babylonjs/Cameras/camera";
  50690. /**
  50691. * Renders a layer on top of an existing scene
  50692. */
  50693. export class UtilityLayerRenderer implements IDisposable {
  50694. /** the original scene that will be rendered on top of */
  50695. originalScene: Scene;
  50696. private _pointerCaptures;
  50697. private _lastPointerEvents;
  50698. private static _DefaultUtilityLayer;
  50699. private static _DefaultKeepDepthUtilityLayer;
  50700. private _sharedGizmoLight;
  50701. private _renderCamera;
  50702. /**
  50703. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50704. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50705. * @returns the camera that is used when rendering the utility layer
  50706. */
  50707. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50708. /**
  50709. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50710. * @param cam the camera that should be used when rendering the utility layer
  50711. */
  50712. setRenderCamera(cam: Nullable<Camera>): void;
  50713. /**
  50714. * @hidden
  50715. * Light which used by gizmos to get light shading
  50716. */
  50717. _getSharedGizmoLight(): HemisphericLight;
  50718. /**
  50719. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50720. */
  50721. pickUtilitySceneFirst: boolean;
  50722. /**
  50723. * 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)
  50724. */
  50725. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50726. /**
  50727. * 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)
  50728. */
  50729. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50730. /**
  50731. * The scene that is rendered on top of the original scene
  50732. */
  50733. utilityLayerScene: Scene;
  50734. /**
  50735. * If the utility layer should automatically be rendered on top of existing scene
  50736. */
  50737. shouldRender: boolean;
  50738. /**
  50739. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50740. */
  50741. onlyCheckPointerDownEvents: boolean;
  50742. /**
  50743. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50744. */
  50745. processAllEvents: boolean;
  50746. /**
  50747. * Observable raised when the pointer move from the utility layer scene to the main scene
  50748. */
  50749. onPointerOutObservable: Observable<number>;
  50750. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50751. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50752. private _afterRenderObserver;
  50753. private _sceneDisposeObserver;
  50754. private _originalPointerObserver;
  50755. /**
  50756. * Instantiates a UtilityLayerRenderer
  50757. * @param originalScene the original scene that will be rendered on top of
  50758. * @param handleEvents boolean indicating if the utility layer should handle events
  50759. */
  50760. constructor(
  50761. /** the original scene that will be rendered on top of */
  50762. originalScene: Scene, handleEvents?: boolean);
  50763. private _notifyObservers;
  50764. /**
  50765. * Renders the utility layers scene on top of the original scene
  50766. */
  50767. render(): void;
  50768. /**
  50769. * Disposes of the renderer
  50770. */
  50771. dispose(): void;
  50772. private _updateCamera;
  50773. }
  50774. }
  50775. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50778. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50779. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50780. import { Scene } from "babylonjs/scene";
  50781. import { Nullable } from "babylonjs/types";
  50782. import { Color3 } from "babylonjs/Maths/math.color";
  50783. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50784. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50785. /**
  50786. * Options interface for the pointer selection module
  50787. */
  50788. export interface IWebXRControllerPointerSelectionOptions {
  50789. /**
  50790. * if provided, this scene will be used to render meshes.
  50791. */
  50792. customUtilityLayerScene?: Scene;
  50793. /**
  50794. * 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)
  50795. * If not disabled, the last picked point will be used to execute a pointer up event
  50796. * If disabled, pointer up event will be triggered right after the pointer down event.
  50797. * Used in screen and gaze target ray mode only
  50798. */
  50799. disablePointerUpOnTouchOut: boolean;
  50800. /**
  50801. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50802. */
  50803. forceGazeMode: boolean;
  50804. /**
  50805. * 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
  50806. * to start a new countdown to the pointer down event.
  50807. * Defaults to 1.
  50808. */
  50809. gazeModePointerMovedFactor?: number;
  50810. /**
  50811. * Different button type to use instead of the main component
  50812. */
  50813. overrideButtonId?: string;
  50814. /**
  50815. * use this rendering group id for the meshes (optional)
  50816. */
  50817. renderingGroupId?: number;
  50818. /**
  50819. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50820. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50821. * 3000 means 3 seconds between pointing at something and selecting it
  50822. */
  50823. timeToSelect?: number;
  50824. /**
  50825. * Should meshes created here be added to a utility layer or the main scene
  50826. */
  50827. useUtilityLayer?: boolean;
  50828. /**
  50829. * Optional WebXR camera to be used for gaze selection
  50830. */
  50831. gazeCamera?: WebXRCamera;
  50832. /**
  50833. * the xr input to use with this pointer selection
  50834. */
  50835. xrInput: WebXRInput;
  50836. }
  50837. /**
  50838. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50839. */
  50840. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50841. private readonly _options;
  50842. private static _idCounter;
  50843. private _attachController;
  50844. private _controllers;
  50845. private _scene;
  50846. private _tmpVectorForPickCompare;
  50847. /**
  50848. * The module's name
  50849. */
  50850. static readonly Name: string;
  50851. /**
  50852. * The (Babylon) version of this module.
  50853. * This is an integer representing the implementation version.
  50854. * This number does not correspond to the WebXR specs version
  50855. */
  50856. static readonly Version: number;
  50857. /**
  50858. * Disable lighting on the laser pointer (so it will always be visible)
  50859. */
  50860. disablePointerLighting: boolean;
  50861. /**
  50862. * Disable lighting on the selection mesh (so it will always be visible)
  50863. */
  50864. disableSelectionMeshLighting: boolean;
  50865. /**
  50866. * Should the laser pointer be displayed
  50867. */
  50868. displayLaserPointer: boolean;
  50869. /**
  50870. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50871. */
  50872. displaySelectionMesh: boolean;
  50873. /**
  50874. * This color will be set to the laser pointer when selection is triggered
  50875. */
  50876. laserPointerPickedColor: Color3;
  50877. /**
  50878. * Default color of the laser pointer
  50879. */
  50880. laserPointerDefaultColor: Color3;
  50881. /**
  50882. * default color of the selection ring
  50883. */
  50884. selectionMeshDefaultColor: Color3;
  50885. /**
  50886. * This color will be applied to the selection ring when selection is triggered
  50887. */
  50888. selectionMeshPickedColor: Color3;
  50889. /**
  50890. * Optional filter to be used for ray selection. This predicate shares behavior with
  50891. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50892. */
  50893. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50894. /**
  50895. * constructs a new background remover module
  50896. * @param _xrSessionManager the session manager for this module
  50897. * @param _options read-only options to be used in this module
  50898. */
  50899. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50900. /**
  50901. * attach this feature
  50902. * Will usually be called by the features manager
  50903. *
  50904. * @returns true if successful.
  50905. */
  50906. attach(): boolean;
  50907. /**
  50908. * detach this feature.
  50909. * Will usually be called by the features manager
  50910. *
  50911. * @returns true if successful.
  50912. */
  50913. detach(): boolean;
  50914. /**
  50915. * Will get the mesh under a specific pointer.
  50916. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50917. * @param controllerId the controllerId to check
  50918. * @returns The mesh under pointer or null if no mesh is under the pointer
  50919. */
  50920. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50921. /**
  50922. * Get the xr controller that correlates to the pointer id in the pointer event
  50923. *
  50924. * @param id the pointer id to search for
  50925. * @returns the controller that correlates to this id or null if not found
  50926. */
  50927. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50928. protected _onXRFrame(_xrFrame: XRFrame): void;
  50929. private _attachGazeMode;
  50930. private _attachScreenRayMode;
  50931. private _attachTrackedPointerRayMode;
  50932. private _convertNormalToDirectionOfRay;
  50933. private _detachController;
  50934. private _generateNewMeshPair;
  50935. private _pickingMoved;
  50936. private _updatePointerDistance;
  50937. /** @hidden */
  50938. get lasterPointerDefaultColor(): Color3;
  50939. }
  50940. }
  50941. declare module "babylonjs/XR/webXREnterExitUI" {
  50942. import { Nullable } from "babylonjs/types";
  50943. import { Observable } from "babylonjs/Misc/observable";
  50944. import { IDisposable, Scene } from "babylonjs/scene";
  50945. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50946. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50947. /**
  50948. * Button which can be used to enter a different mode of XR
  50949. */
  50950. export class WebXREnterExitUIButton {
  50951. /** button element */
  50952. element: HTMLElement;
  50953. /** XR initialization options for the button */
  50954. sessionMode: XRSessionMode;
  50955. /** Reference space type */
  50956. referenceSpaceType: XRReferenceSpaceType;
  50957. /**
  50958. * Creates a WebXREnterExitUIButton
  50959. * @param element button element
  50960. * @param sessionMode XR initialization session mode
  50961. * @param referenceSpaceType the type of reference space to be used
  50962. */
  50963. constructor(
  50964. /** button element */
  50965. element: HTMLElement,
  50966. /** XR initialization options for the button */
  50967. sessionMode: XRSessionMode,
  50968. /** Reference space type */
  50969. referenceSpaceType: XRReferenceSpaceType);
  50970. /**
  50971. * Extendable function which can be used to update the button's visuals when the state changes
  50972. * @param activeButton the current active button in the UI
  50973. */
  50974. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50975. }
  50976. /**
  50977. * Options to create the webXR UI
  50978. */
  50979. export class WebXREnterExitUIOptions {
  50980. /**
  50981. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50982. */
  50983. customButtons?: Array<WebXREnterExitUIButton>;
  50984. /**
  50985. * A reference space type to use when creating the default button.
  50986. * Default is local-floor
  50987. */
  50988. referenceSpaceType?: XRReferenceSpaceType;
  50989. /**
  50990. * Context to enter xr with
  50991. */
  50992. renderTarget?: Nullable<WebXRRenderTarget>;
  50993. /**
  50994. * A session mode to use when creating the default button.
  50995. * Default is immersive-vr
  50996. */
  50997. sessionMode?: XRSessionMode;
  50998. /**
  50999. * A list of optional features to init the session with
  51000. */
  51001. optionalFeatures?: string[];
  51002. /**
  51003. * A list of optional features to init the session with
  51004. */
  51005. requiredFeatures?: string[];
  51006. }
  51007. /**
  51008. * UI to allow the user to enter/exit XR mode
  51009. */
  51010. export class WebXREnterExitUI implements IDisposable {
  51011. private scene;
  51012. /** version of the options passed to this UI */
  51013. options: WebXREnterExitUIOptions;
  51014. private _activeButton;
  51015. private _buttons;
  51016. /**
  51017. * The HTML Div Element to which buttons are added.
  51018. */
  51019. readonly overlay: HTMLDivElement;
  51020. /**
  51021. * Fired every time the active button is changed.
  51022. *
  51023. * When xr is entered via a button that launches xr that button will be the callback parameter
  51024. *
  51025. * When exiting xr the callback parameter will be null)
  51026. */
  51027. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51028. /**
  51029. *
  51030. * @param scene babylon scene object to use
  51031. * @param options (read-only) version of the options passed to this UI
  51032. */
  51033. private constructor();
  51034. /**
  51035. * Creates UI to allow the user to enter/exit XR mode
  51036. * @param scene the scene to add the ui to
  51037. * @param helper the xr experience helper to enter/exit xr with
  51038. * @param options options to configure the UI
  51039. * @returns the created ui
  51040. */
  51041. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51042. /**
  51043. * Disposes of the XR UI component
  51044. */
  51045. dispose(): void;
  51046. private _updateButtons;
  51047. }
  51048. }
  51049. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51050. import { Vector3 } from "babylonjs/Maths/math.vector";
  51051. import { Color4 } from "babylonjs/Maths/math.color";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51054. import { Scene } from "babylonjs/scene";
  51055. /**
  51056. * Class containing static functions to help procedurally build meshes
  51057. */
  51058. export class LinesBuilder {
  51059. /**
  51060. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51061. * * 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
  51062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51063. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51064. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51065. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51067. * * 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
  51068. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51071. * @param name defines the name of the new line system
  51072. * @param options defines the options used to create the line system
  51073. * @param scene defines the hosting scene
  51074. * @returns a new line system mesh
  51075. */
  51076. static CreateLineSystem(name: string, options: {
  51077. lines: Vector3[][];
  51078. updatable?: boolean;
  51079. instance?: Nullable<LinesMesh>;
  51080. colors?: Nullable<Color4[][]>;
  51081. useVertexAlpha?: boolean;
  51082. }, scene: Nullable<Scene>): LinesMesh;
  51083. /**
  51084. * Creates a line mesh
  51085. * 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
  51086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51087. * * The parameter `points` is an array successive Vector3
  51088. * * 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
  51089. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51091. * * When updating an instance, remember that only point positions can change, not the number of points
  51092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51094. * @param name defines the name of the new line system
  51095. * @param options defines the options used to create the line system
  51096. * @param scene defines the hosting scene
  51097. * @returns a new line mesh
  51098. */
  51099. static CreateLines(name: string, options: {
  51100. points: Vector3[];
  51101. updatable?: boolean;
  51102. instance?: Nullable<LinesMesh>;
  51103. colors?: Color4[];
  51104. useVertexAlpha?: boolean;
  51105. }, scene?: Nullable<Scene>): LinesMesh;
  51106. /**
  51107. * Creates a dashed line mesh
  51108. * * 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
  51109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51110. * * The parameter `points` is an array successive Vector3
  51111. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51112. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51113. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51114. * * 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
  51115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51116. * * When updating an instance, remember that only point positions can change, not the number of points
  51117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51118. * @param name defines the name of the mesh
  51119. * @param options defines the options used to create the mesh
  51120. * @param scene defines the hosting scene
  51121. * @returns the dashed line mesh
  51122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51123. */
  51124. static CreateDashedLines(name: string, options: {
  51125. points: Vector3[];
  51126. dashSize?: number;
  51127. gapSize?: number;
  51128. dashNb?: number;
  51129. updatable?: boolean;
  51130. instance?: LinesMesh;
  51131. useVertexAlpha?: boolean;
  51132. }, scene?: Nullable<Scene>): LinesMesh;
  51133. }
  51134. }
  51135. declare module "babylonjs/Misc/timer" {
  51136. import { Observable, Observer } from "babylonjs/Misc/observable";
  51137. import { Nullable } from "babylonjs/types";
  51138. import { IDisposable } from "babylonjs/scene";
  51139. /**
  51140. * Construction options for a timer
  51141. */
  51142. export interface ITimerOptions<T> {
  51143. /**
  51144. * Time-to-end
  51145. */
  51146. timeout: number;
  51147. /**
  51148. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51149. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51150. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51151. */
  51152. contextObservable: Observable<T>;
  51153. /**
  51154. * Optional parameters when adding an observer to the observable
  51155. */
  51156. observableParameters?: {
  51157. mask?: number;
  51158. insertFirst?: boolean;
  51159. scope?: any;
  51160. };
  51161. /**
  51162. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51163. */
  51164. breakCondition?: (data?: ITimerData<T>) => boolean;
  51165. /**
  51166. * Will be triggered when the time condition has met
  51167. */
  51168. onEnded?: (data: ITimerData<any>) => void;
  51169. /**
  51170. * Will be triggered when the break condition has met (prematurely ended)
  51171. */
  51172. onAborted?: (data: ITimerData<any>) => void;
  51173. /**
  51174. * Optional function to execute on each tick (or count)
  51175. */
  51176. onTick?: (data: ITimerData<any>) => void;
  51177. }
  51178. /**
  51179. * An interface defining the data sent by the timer
  51180. */
  51181. export interface ITimerData<T> {
  51182. /**
  51183. * When did it start
  51184. */
  51185. startTime: number;
  51186. /**
  51187. * Time now
  51188. */
  51189. currentTime: number;
  51190. /**
  51191. * Time passed since started
  51192. */
  51193. deltaTime: number;
  51194. /**
  51195. * How much is completed, in [0.0...1.0].
  51196. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51197. */
  51198. completeRate: number;
  51199. /**
  51200. * What the registered observable sent in the last count
  51201. */
  51202. payload: T;
  51203. }
  51204. /**
  51205. * The current state of the timer
  51206. */
  51207. export enum TimerState {
  51208. /**
  51209. * Timer initialized, not yet started
  51210. */
  51211. INIT = 0,
  51212. /**
  51213. * Timer started and counting
  51214. */
  51215. STARTED = 1,
  51216. /**
  51217. * Timer ended (whether aborted or time reached)
  51218. */
  51219. ENDED = 2
  51220. }
  51221. /**
  51222. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51223. *
  51224. * @param options options with which to initialize this timer
  51225. */
  51226. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51227. /**
  51228. * An advanced implementation of a timer class
  51229. */
  51230. export class AdvancedTimer<T = any> implements IDisposable {
  51231. /**
  51232. * Will notify each time the timer calculates the remaining time
  51233. */
  51234. onEachCountObservable: Observable<ITimerData<T>>;
  51235. /**
  51236. * Will trigger when the timer was aborted due to the break condition
  51237. */
  51238. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51239. /**
  51240. * Will trigger when the timer ended successfully
  51241. */
  51242. onTimerEndedObservable: Observable<ITimerData<T>>;
  51243. /**
  51244. * Will trigger when the timer state has changed
  51245. */
  51246. onStateChangedObservable: Observable<TimerState>;
  51247. private _observer;
  51248. private _contextObservable;
  51249. private _observableParameters;
  51250. private _startTime;
  51251. private _timer;
  51252. private _state;
  51253. private _breakCondition;
  51254. private _timeToEnd;
  51255. private _breakOnNextTick;
  51256. /**
  51257. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51258. * @param options construction options for this advanced timer
  51259. */
  51260. constructor(options: ITimerOptions<T>);
  51261. /**
  51262. * set a breaking condition for this timer. Default is to never break during count
  51263. * @param predicate the new break condition. Returns true to break, false otherwise
  51264. */
  51265. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51266. /**
  51267. * Reset ALL associated observables in this advanced timer
  51268. */
  51269. clearObservables(): void;
  51270. /**
  51271. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51272. *
  51273. * @param timeToEnd how much time to measure until timer ended
  51274. */
  51275. start(timeToEnd?: number): void;
  51276. /**
  51277. * Will force a stop on the next tick.
  51278. */
  51279. stop(): void;
  51280. /**
  51281. * Dispose this timer, clearing all resources
  51282. */
  51283. dispose(): void;
  51284. private _setState;
  51285. private _tick;
  51286. private _stop;
  51287. }
  51288. }
  51289. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51290. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51291. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51292. import { Nullable } from "babylonjs/types";
  51293. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51295. import { Vector3 } from "babylonjs/Maths/math.vector";
  51296. import { Material } from "babylonjs/Materials/material";
  51297. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51298. import { Scene } from "babylonjs/scene";
  51299. /**
  51300. * The options container for the teleportation module
  51301. */
  51302. export interface IWebXRTeleportationOptions {
  51303. /**
  51304. * if provided, this scene will be used to render meshes.
  51305. */
  51306. customUtilityLayerScene?: Scene;
  51307. /**
  51308. * Values to configure the default target mesh
  51309. */
  51310. defaultTargetMeshOptions?: {
  51311. /**
  51312. * Fill color of the teleportation area
  51313. */
  51314. teleportationFillColor?: string;
  51315. /**
  51316. * Border color for the teleportation area
  51317. */
  51318. teleportationBorderColor?: string;
  51319. /**
  51320. * Disable the mesh's animation sequence
  51321. */
  51322. disableAnimation?: boolean;
  51323. /**
  51324. * Disable lighting on the material or the ring and arrow
  51325. */
  51326. disableLighting?: boolean;
  51327. /**
  51328. * Override the default material of the torus and arrow
  51329. */
  51330. torusArrowMaterial?: Material;
  51331. };
  51332. /**
  51333. * A list of meshes to use as floor meshes.
  51334. * Meshes can be added and removed after initializing the feature using the
  51335. * addFloorMesh and removeFloorMesh functions
  51336. * If empty, rotation will still work
  51337. */
  51338. floorMeshes?: AbstractMesh[];
  51339. /**
  51340. * use this rendering group id for the meshes (optional)
  51341. */
  51342. renderingGroupId?: number;
  51343. /**
  51344. * Should teleportation move only to snap points
  51345. */
  51346. snapPointsOnly?: boolean;
  51347. /**
  51348. * An array of points to which the teleportation will snap to.
  51349. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51350. */
  51351. snapPositions?: Vector3[];
  51352. /**
  51353. * How close should the teleportation ray be in order to snap to position.
  51354. * Default to 0.8 units (meters)
  51355. */
  51356. snapToPositionRadius?: number;
  51357. /**
  51358. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51359. * If you want to support rotation, make sure your mesh has a direction indicator.
  51360. *
  51361. * When left untouched, the default mesh will be initialized.
  51362. */
  51363. teleportationTargetMesh?: AbstractMesh;
  51364. /**
  51365. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51366. */
  51367. timeToTeleport?: number;
  51368. /**
  51369. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51370. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51371. */
  51372. useMainComponentOnly?: boolean;
  51373. /**
  51374. * Should meshes created here be added to a utility layer or the main scene
  51375. */
  51376. useUtilityLayer?: boolean;
  51377. /**
  51378. * Babylon XR Input class for controller
  51379. */
  51380. xrInput: WebXRInput;
  51381. /**
  51382. * Meshes that the teleportation ray cannot go through
  51383. */
  51384. pickBlockerMeshes?: AbstractMesh[];
  51385. }
  51386. /**
  51387. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51388. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51389. * the input of the attached controllers.
  51390. */
  51391. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51392. private _options;
  51393. private _controllers;
  51394. private _currentTeleportationControllerId;
  51395. private _floorMeshes;
  51396. private _quadraticBezierCurve;
  51397. private _selectionFeature;
  51398. private _snapToPositions;
  51399. private _snappedToPoint;
  51400. private _teleportationRingMaterial?;
  51401. private _tmpRay;
  51402. private _tmpVector;
  51403. private _tmpQuaternion;
  51404. /**
  51405. * The module's name
  51406. */
  51407. static readonly Name: string;
  51408. /**
  51409. * The (Babylon) version of this module.
  51410. * This is an integer representing the implementation version.
  51411. * This number does not correspond to the webxr specs version
  51412. */
  51413. static readonly Version: number;
  51414. /**
  51415. * Is movement backwards enabled
  51416. */
  51417. backwardsMovementEnabled: boolean;
  51418. /**
  51419. * Distance to travel when moving backwards
  51420. */
  51421. backwardsTeleportationDistance: number;
  51422. /**
  51423. * The distance from the user to the inspection point in the direction of the controller
  51424. * A higher number will allow the user to move further
  51425. * defaults to 5 (meters, in xr units)
  51426. */
  51427. parabolicCheckRadius: number;
  51428. /**
  51429. * Should the module support parabolic ray on top of direct ray
  51430. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51431. * Very helpful when moving between floors / different heights
  51432. */
  51433. parabolicRayEnabled: boolean;
  51434. /**
  51435. * How much rotation should be applied when rotating right and left
  51436. */
  51437. rotationAngle: number;
  51438. /**
  51439. * Is rotation enabled when moving forward?
  51440. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51441. */
  51442. rotationEnabled: boolean;
  51443. /**
  51444. * constructs a new anchor system
  51445. * @param _xrSessionManager an instance of WebXRSessionManager
  51446. * @param _options configuration object for this feature
  51447. */
  51448. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51449. /**
  51450. * Get the snapPointsOnly flag
  51451. */
  51452. get snapPointsOnly(): boolean;
  51453. /**
  51454. * Sets the snapPointsOnly flag
  51455. * @param snapToPoints should teleportation be exclusively to snap points
  51456. */
  51457. set snapPointsOnly(snapToPoints: boolean);
  51458. /**
  51459. * Add a new mesh to the floor meshes array
  51460. * @param mesh the mesh to use as floor mesh
  51461. */
  51462. addFloorMesh(mesh: AbstractMesh): void;
  51463. /**
  51464. * Add a new snap-to point to fix teleportation to this position
  51465. * @param newSnapPoint The new Snap-To point
  51466. */
  51467. addSnapPoint(newSnapPoint: Vector3): void;
  51468. attach(): boolean;
  51469. detach(): boolean;
  51470. dispose(): void;
  51471. /**
  51472. * Remove a mesh from the floor meshes array
  51473. * @param mesh the mesh to remove
  51474. */
  51475. removeFloorMesh(mesh: AbstractMesh): void;
  51476. /**
  51477. * Remove a mesh from the floor meshes array using its name
  51478. * @param name the mesh name to remove
  51479. */
  51480. removeFloorMeshByName(name: string): void;
  51481. /**
  51482. * 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
  51483. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51484. * @returns was the point found and removed or not
  51485. */
  51486. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51487. /**
  51488. * This function sets a selection feature that will be disabled when
  51489. * the forward ray is shown and will be reattached when hidden.
  51490. * This is used to remove the selection rays when moving.
  51491. * @param selectionFeature the feature to disable when forward movement is enabled
  51492. */
  51493. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51494. protected _onXRFrame(_xrFrame: XRFrame): void;
  51495. private _attachController;
  51496. private _createDefaultTargetMesh;
  51497. private _detachController;
  51498. private _findClosestSnapPointWithRadius;
  51499. private _setTargetMeshPosition;
  51500. private _setTargetMeshVisibility;
  51501. private _showParabolicPath;
  51502. private _teleportForward;
  51503. }
  51504. }
  51505. declare module "babylonjs/XR/webXRDefaultExperience" {
  51506. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51507. import { Scene } from "babylonjs/scene";
  51508. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51509. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51510. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51511. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51513. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51514. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51515. /**
  51516. * Options for the default xr helper
  51517. */
  51518. export class WebXRDefaultExperienceOptions {
  51519. /**
  51520. * Enable or disable default UI to enter XR
  51521. */
  51522. disableDefaultUI?: boolean;
  51523. /**
  51524. * Should teleportation not initialize. defaults to false.
  51525. */
  51526. disableTeleportation?: boolean;
  51527. /**
  51528. * Floor meshes that will be used for teleport
  51529. */
  51530. floorMeshes?: Array<AbstractMesh>;
  51531. /**
  51532. * If set to true, the first frame will not be used to reset position
  51533. * The first frame is mainly used when copying transformation from the old camera
  51534. * Mainly used in AR
  51535. */
  51536. ignoreNativeCameraTransformation?: boolean;
  51537. /**
  51538. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51539. */
  51540. inputOptions?: IWebXRInputOptions;
  51541. /**
  51542. * optional configuration for the output canvas
  51543. */
  51544. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51545. /**
  51546. * optional UI options. This can be used among other to change session mode and reference space type
  51547. */
  51548. uiOptions?: WebXREnterExitUIOptions;
  51549. /**
  51550. * When loading teleportation and pointer select, use stable versions instead of latest.
  51551. */
  51552. useStablePlugins?: boolean;
  51553. /**
  51554. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51555. */
  51556. renderingGroupId?: number;
  51557. /**
  51558. * A list of optional features to init the session with
  51559. * If set to true, all features we support will be added
  51560. */
  51561. optionalFeatures?: boolean | string[];
  51562. }
  51563. /**
  51564. * Default experience which provides a similar setup to the previous webVRExperience
  51565. */
  51566. export class WebXRDefaultExperience {
  51567. /**
  51568. * Base experience
  51569. */
  51570. baseExperience: WebXRExperienceHelper;
  51571. /**
  51572. * Enables ui for entering/exiting xr
  51573. */
  51574. enterExitUI: WebXREnterExitUI;
  51575. /**
  51576. * Input experience extension
  51577. */
  51578. input: WebXRInput;
  51579. /**
  51580. * Enables laser pointer and selection
  51581. */
  51582. pointerSelection: WebXRControllerPointerSelection;
  51583. /**
  51584. * Default target xr should render to
  51585. */
  51586. renderTarget: WebXRRenderTarget;
  51587. /**
  51588. * Enables teleportation
  51589. */
  51590. teleportation: WebXRMotionControllerTeleportation;
  51591. private constructor();
  51592. /**
  51593. * Creates the default xr experience
  51594. * @param scene scene
  51595. * @param options options for basic configuration
  51596. * @returns resulting WebXRDefaultExperience
  51597. */
  51598. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51599. /**
  51600. * DIsposes of the experience helper
  51601. */
  51602. dispose(): void;
  51603. }
  51604. }
  51605. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51606. import { Observable } from "babylonjs/Misc/observable";
  51607. import { Nullable } from "babylonjs/types";
  51608. import { Camera } from "babylonjs/Cameras/camera";
  51609. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51610. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51611. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51612. import { Scene } from "babylonjs/scene";
  51613. import { Vector3 } from "babylonjs/Maths/math.vector";
  51614. import { Color3 } from "babylonjs/Maths/math.color";
  51615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51617. import { Mesh } from "babylonjs/Meshes/mesh";
  51618. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51619. import { EasingFunction } from "babylonjs/Animations/easing";
  51620. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51621. import "babylonjs/Meshes/Builders/groundBuilder";
  51622. import "babylonjs/Meshes/Builders/torusBuilder";
  51623. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51624. import "babylonjs/Gamepads/gamepadSceneComponent";
  51625. import "babylonjs/Animations/animatable";
  51626. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51627. /**
  51628. * Options to modify the vr teleportation behavior.
  51629. */
  51630. export interface VRTeleportationOptions {
  51631. /**
  51632. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51633. */
  51634. floorMeshName?: string;
  51635. /**
  51636. * A list of meshes to be used as the teleportation floor. (default: empty)
  51637. */
  51638. floorMeshes?: Mesh[];
  51639. /**
  51640. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51641. */
  51642. teleportationMode?: number;
  51643. /**
  51644. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51645. */
  51646. teleportationTime?: number;
  51647. /**
  51648. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51649. */
  51650. teleportationSpeed?: number;
  51651. /**
  51652. * The easing function used in the animation or null for Linear. (default CircleEase)
  51653. */
  51654. easingFunction?: EasingFunction;
  51655. }
  51656. /**
  51657. * Options to modify the vr experience helper's behavior.
  51658. */
  51659. export interface VRExperienceHelperOptions extends WebVROptions {
  51660. /**
  51661. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51662. */
  51663. createDeviceOrientationCamera?: boolean;
  51664. /**
  51665. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51666. */
  51667. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51668. /**
  51669. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51670. */
  51671. laserToggle?: boolean;
  51672. /**
  51673. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51674. */
  51675. floorMeshes?: Mesh[];
  51676. /**
  51677. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51678. */
  51679. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51680. /**
  51681. * Defines if WebXR should be used instead of WebVR (if available)
  51682. */
  51683. useXR?: boolean;
  51684. }
  51685. /**
  51686. * Event containing information after VR has been entered
  51687. */
  51688. export class OnAfterEnteringVRObservableEvent {
  51689. /**
  51690. * If entering vr was successful
  51691. */
  51692. success: boolean;
  51693. }
  51694. /**
  51695. * Helps to quickly add VR support to an existing scene.
  51696. * See https://doc.babylonjs.com/how_to/webvr_helper
  51697. */
  51698. export class VRExperienceHelper {
  51699. /** Options to modify the vr experience helper's behavior. */
  51700. webVROptions: VRExperienceHelperOptions;
  51701. private _scene;
  51702. private _position;
  51703. private _btnVR;
  51704. private _btnVRDisplayed;
  51705. private _webVRsupported;
  51706. private _webVRready;
  51707. private _webVRrequesting;
  51708. private _webVRpresenting;
  51709. private _hasEnteredVR;
  51710. private _fullscreenVRpresenting;
  51711. private _inputElement;
  51712. private _webVRCamera;
  51713. private _vrDeviceOrientationCamera;
  51714. private _deviceOrientationCamera;
  51715. private _existingCamera;
  51716. private _onKeyDown;
  51717. private _onVrDisplayPresentChange;
  51718. private _onVRDisplayChanged;
  51719. private _onVRRequestPresentStart;
  51720. private _onVRRequestPresentComplete;
  51721. /**
  51722. * 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)
  51723. */
  51724. enableGazeEvenWhenNoPointerLock: boolean;
  51725. /**
  51726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51727. */
  51728. exitVROnDoubleTap: boolean;
  51729. /**
  51730. * Observable raised right before entering VR.
  51731. */
  51732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51733. /**
  51734. * Observable raised when entering VR has completed.
  51735. */
  51736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51737. /**
  51738. * Observable raised when exiting VR.
  51739. */
  51740. onExitingVRObservable: Observable<VRExperienceHelper>;
  51741. /**
  51742. * Observable raised when controller mesh is loaded.
  51743. */
  51744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51745. /** Return this.onEnteringVRObservable
  51746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51747. */
  51748. get onEnteringVR(): Observable<VRExperienceHelper>;
  51749. /** Return this.onExitingVRObservable
  51750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51751. */
  51752. get onExitingVR(): Observable<VRExperienceHelper>;
  51753. /** Return this.onControllerMeshLoadedObservable
  51754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51755. */
  51756. get onControllerMeshLoaded(): Observable<WebVRController>;
  51757. private _rayLength;
  51758. private _useCustomVRButton;
  51759. private _teleportationRequested;
  51760. private _teleportActive;
  51761. private _floorMeshName;
  51762. private _floorMeshesCollection;
  51763. private _teleportationMode;
  51764. private _teleportationTime;
  51765. private _teleportationSpeed;
  51766. private _teleportationEasing;
  51767. private _rotationAllowed;
  51768. private _teleportBackwardsVector;
  51769. private _teleportationTarget;
  51770. private _isDefaultTeleportationTarget;
  51771. private _postProcessMove;
  51772. private _teleportationFillColor;
  51773. private _teleportationBorderColor;
  51774. private _rotationAngle;
  51775. private _haloCenter;
  51776. private _cameraGazer;
  51777. private _padSensibilityUp;
  51778. private _padSensibilityDown;
  51779. private _leftController;
  51780. private _rightController;
  51781. private _gazeColor;
  51782. private _laserColor;
  51783. private _pickedLaserColor;
  51784. private _pickedGazeColor;
  51785. /**
  51786. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51787. */
  51788. onNewMeshSelected: Observable<AbstractMesh>;
  51789. /**
  51790. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51791. * This observable will provide the mesh and the controller used to select the mesh
  51792. */
  51793. onMeshSelectedWithController: Observable<{
  51794. mesh: AbstractMesh;
  51795. controller: WebVRController;
  51796. }>;
  51797. /**
  51798. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51799. */
  51800. onNewMeshPicked: Observable<PickingInfo>;
  51801. private _circleEase;
  51802. /**
  51803. * Observable raised before camera teleportation
  51804. */
  51805. onBeforeCameraTeleport: Observable<Vector3>;
  51806. /**
  51807. * Observable raised after camera teleportation
  51808. */
  51809. onAfterCameraTeleport: Observable<Vector3>;
  51810. /**
  51811. * Observable raised when current selected mesh gets unselected
  51812. */
  51813. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51814. private _raySelectionPredicate;
  51815. /**
  51816. * To be optionaly changed by user to define custom ray selection
  51817. */
  51818. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51819. /**
  51820. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51821. */
  51822. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51823. /**
  51824. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51825. */
  51826. teleportationEnabled: boolean;
  51827. private _defaultHeight;
  51828. private _teleportationInitialized;
  51829. private _interactionsEnabled;
  51830. private _interactionsRequested;
  51831. private _displayGaze;
  51832. private _displayLaserPointer;
  51833. /**
  51834. * The mesh used to display where the user is going to teleport.
  51835. */
  51836. get teleportationTarget(): Mesh;
  51837. /**
  51838. * Sets the mesh to be used to display where the user is going to teleport.
  51839. */
  51840. set teleportationTarget(value: Mesh);
  51841. /**
  51842. * 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
  51843. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51844. * See https://doc.babylonjs.com/resources/baking_transformations
  51845. */
  51846. get gazeTrackerMesh(): Mesh;
  51847. set gazeTrackerMesh(value: Mesh);
  51848. /**
  51849. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51850. */
  51851. updateGazeTrackerScale: boolean;
  51852. /**
  51853. * If the gaze trackers color should be updated when selecting meshes
  51854. */
  51855. updateGazeTrackerColor: boolean;
  51856. /**
  51857. * If the controller laser color should be updated when selecting meshes
  51858. */
  51859. updateControllerLaserColor: boolean;
  51860. /**
  51861. * The gaze tracking mesh corresponding to the left controller
  51862. */
  51863. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51864. /**
  51865. * The gaze tracking mesh corresponding to the right controller
  51866. */
  51867. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51868. /**
  51869. * If the ray of the gaze should be displayed.
  51870. */
  51871. get displayGaze(): boolean;
  51872. /**
  51873. * Sets if the ray of the gaze should be displayed.
  51874. */
  51875. set displayGaze(value: boolean);
  51876. /**
  51877. * If the ray of the LaserPointer should be displayed.
  51878. */
  51879. get displayLaserPointer(): boolean;
  51880. /**
  51881. * Sets if the ray of the LaserPointer should be displayed.
  51882. */
  51883. set displayLaserPointer(value: boolean);
  51884. /**
  51885. * The deviceOrientationCamera used as the camera when not in VR.
  51886. */
  51887. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51888. /**
  51889. * Based on the current WebVR support, returns the current VR camera used.
  51890. */
  51891. get currentVRCamera(): Nullable<Camera>;
  51892. /**
  51893. * The webVRCamera which is used when in VR.
  51894. */
  51895. get webVRCamera(): WebVRFreeCamera;
  51896. /**
  51897. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51898. */
  51899. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51900. /**
  51901. * The html button that is used to trigger entering into VR.
  51902. */
  51903. get vrButton(): Nullable<HTMLButtonElement>;
  51904. private get _teleportationRequestInitiated();
  51905. /**
  51906. * Defines whether or not Pointer lock should be requested when switching to
  51907. * full screen.
  51908. */
  51909. requestPointerLockOnFullScreen: boolean;
  51910. /**
  51911. * If asking to force XR, this will be populated with the default xr experience
  51912. */
  51913. xr: WebXRDefaultExperience;
  51914. /**
  51915. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51916. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51917. */
  51918. xrTestDone: boolean;
  51919. /**
  51920. * Instantiates a VRExperienceHelper.
  51921. * Helps to quickly add VR support to an existing scene.
  51922. * @param scene The scene the VRExperienceHelper belongs to.
  51923. * @param webVROptions Options to modify the vr experience helper's behavior.
  51924. */
  51925. constructor(scene: Scene,
  51926. /** Options to modify the vr experience helper's behavior. */
  51927. webVROptions?: VRExperienceHelperOptions);
  51928. private completeVRInit;
  51929. private _onDefaultMeshLoaded;
  51930. private _onResize;
  51931. private _onFullscreenChange;
  51932. /**
  51933. * Gets a value indicating if we are currently in VR mode.
  51934. */
  51935. get isInVRMode(): boolean;
  51936. private onVrDisplayPresentChange;
  51937. private onVRDisplayChanged;
  51938. private moveButtonToBottomRight;
  51939. private displayVRButton;
  51940. private updateButtonVisibility;
  51941. private _cachedAngularSensibility;
  51942. /**
  51943. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51944. * Otherwise, will use the fullscreen API.
  51945. */
  51946. enterVR(): void;
  51947. /**
  51948. * Attempt to exit VR, or fullscreen.
  51949. */
  51950. exitVR(): void;
  51951. /**
  51952. * The position of the vr experience helper.
  51953. */
  51954. get position(): Vector3;
  51955. /**
  51956. * Sets the position of the vr experience helper.
  51957. */
  51958. set position(value: Vector3);
  51959. /**
  51960. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51961. */
  51962. enableInteractions(): void;
  51963. private get _noControllerIsActive();
  51964. private beforeRender;
  51965. private _isTeleportationFloor;
  51966. /**
  51967. * Adds a floor mesh to be used for teleportation.
  51968. * @param floorMesh the mesh to be used for teleportation.
  51969. */
  51970. addFloorMesh(floorMesh: Mesh): void;
  51971. /**
  51972. * Removes a floor mesh from being used for teleportation.
  51973. * @param floorMesh the mesh to be removed.
  51974. */
  51975. removeFloorMesh(floorMesh: Mesh): void;
  51976. /**
  51977. * Enables interactions and teleportation using the VR controllers and gaze.
  51978. * @param vrTeleportationOptions options to modify teleportation behavior.
  51979. */
  51980. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51981. private _onNewGamepadConnected;
  51982. private _tryEnableInteractionOnController;
  51983. private _onNewGamepadDisconnected;
  51984. private _enableInteractionOnController;
  51985. private _checkTeleportWithRay;
  51986. private _checkRotate;
  51987. private _checkTeleportBackwards;
  51988. private _enableTeleportationOnController;
  51989. private _createTeleportationCircles;
  51990. private _displayTeleportationTarget;
  51991. private _hideTeleportationTarget;
  51992. private _rotateCamera;
  51993. private _moveTeleportationSelectorTo;
  51994. private _workingVector;
  51995. private _workingQuaternion;
  51996. private _workingMatrix;
  51997. /**
  51998. * Time Constant Teleportation Mode
  51999. */
  52000. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52001. /**
  52002. * Speed Constant Teleportation Mode
  52003. */
  52004. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52005. /**
  52006. * Teleports the users feet to the desired location
  52007. * @param location The location where the user's feet should be placed
  52008. */
  52009. teleportCamera(location: Vector3): void;
  52010. private _convertNormalToDirectionOfRay;
  52011. private _castRayAndSelectObject;
  52012. private _notifySelectedMeshUnselected;
  52013. /**
  52014. * Permanently set new colors for the laser pointer
  52015. * @param color the new laser color
  52016. * @param pickedColor the new laser color when picked mesh detected
  52017. */
  52018. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52019. /**
  52020. * Set lighting enabled / disabled on the laser pointer of both controllers
  52021. * @param enabled should the lighting be enabled on the laser pointer
  52022. */
  52023. setLaserLightingState(enabled?: boolean): void;
  52024. /**
  52025. * Permanently set new colors for the gaze pointer
  52026. * @param color the new gaze color
  52027. * @param pickedColor the new gaze color when picked mesh detected
  52028. */
  52029. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52030. /**
  52031. * Sets the color of the laser ray from the vr controllers.
  52032. * @param color new color for the ray.
  52033. */
  52034. changeLaserColor(color: Color3): void;
  52035. /**
  52036. * Sets the color of the ray from the vr headsets gaze.
  52037. * @param color new color for the ray.
  52038. */
  52039. changeGazeColor(color: Color3): void;
  52040. /**
  52041. * Exits VR and disposes of the vr experience helper
  52042. */
  52043. dispose(): void;
  52044. /**
  52045. * Gets the name of the VRExperienceHelper class
  52046. * @returns "VRExperienceHelper"
  52047. */
  52048. getClassName(): string;
  52049. }
  52050. }
  52051. declare module "babylonjs/Cameras/VR/index" {
  52052. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52053. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52056. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52057. export * from "babylonjs/Cameras/VR/webVRCamera";
  52058. }
  52059. declare module "babylonjs/Cameras/RigModes/index" {
  52060. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52061. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52062. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52063. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52064. }
  52065. declare module "babylonjs/Cameras/index" {
  52066. export * from "babylonjs/Cameras/Inputs/index";
  52067. export * from "babylonjs/Cameras/cameraInputsManager";
  52068. export * from "babylonjs/Cameras/camera";
  52069. export * from "babylonjs/Cameras/targetCamera";
  52070. export * from "babylonjs/Cameras/freeCamera";
  52071. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52072. export * from "babylonjs/Cameras/touchCamera";
  52073. export * from "babylonjs/Cameras/arcRotateCamera";
  52074. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52075. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52076. export * from "babylonjs/Cameras/flyCamera";
  52077. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52078. export * from "babylonjs/Cameras/followCamera";
  52079. export * from "babylonjs/Cameras/followCameraInputsManager";
  52080. export * from "babylonjs/Cameras/gamepadCamera";
  52081. export * from "babylonjs/Cameras/Stereoscopic/index";
  52082. export * from "babylonjs/Cameras/universalCamera";
  52083. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52084. export * from "babylonjs/Cameras/VR/index";
  52085. export * from "babylonjs/Cameras/RigModes/index";
  52086. }
  52087. declare module "babylonjs/Collisions/index" {
  52088. export * from "babylonjs/Collisions/collider";
  52089. export * from "babylonjs/Collisions/collisionCoordinator";
  52090. export * from "babylonjs/Collisions/pickingInfo";
  52091. export * from "babylonjs/Collisions/intersectionInfo";
  52092. export * from "babylonjs/Collisions/meshCollisionData";
  52093. }
  52094. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52095. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52096. import { Vector3 } from "babylonjs/Maths/math.vector";
  52097. import { Ray } from "babylonjs/Culling/ray";
  52098. import { Plane } from "babylonjs/Maths/math.plane";
  52099. /**
  52100. * Contains an array of blocks representing the octree
  52101. */
  52102. export interface IOctreeContainer<T> {
  52103. /**
  52104. * Blocks within the octree
  52105. */
  52106. blocks: Array<OctreeBlock<T>>;
  52107. }
  52108. /**
  52109. * Class used to store a cell in an octree
  52110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52111. */
  52112. export class OctreeBlock<T> {
  52113. /**
  52114. * Gets the content of the current block
  52115. */
  52116. entries: T[];
  52117. /**
  52118. * Gets the list of block children
  52119. */
  52120. blocks: Array<OctreeBlock<T>>;
  52121. private _depth;
  52122. private _maxDepth;
  52123. private _capacity;
  52124. private _minPoint;
  52125. private _maxPoint;
  52126. private _boundingVectors;
  52127. private _creationFunc;
  52128. /**
  52129. * Creates a new block
  52130. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52131. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52132. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52133. * @param depth defines the current depth of this block in the octree
  52134. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52135. * @param creationFunc defines a callback to call when an element is added to the block
  52136. */
  52137. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52138. /**
  52139. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52140. */
  52141. get capacity(): number;
  52142. /**
  52143. * Gets the minimum vector (in world space) of the block's bounding box
  52144. */
  52145. get minPoint(): Vector3;
  52146. /**
  52147. * Gets the maximum vector (in world space) of the block's bounding box
  52148. */
  52149. get maxPoint(): Vector3;
  52150. /**
  52151. * Add a new element to this block
  52152. * @param entry defines the element to add
  52153. */
  52154. addEntry(entry: T): void;
  52155. /**
  52156. * Remove an element from this block
  52157. * @param entry defines the element to remove
  52158. */
  52159. removeEntry(entry: T): void;
  52160. /**
  52161. * Add an array of elements to this block
  52162. * @param entries defines the array of elements to add
  52163. */
  52164. addEntries(entries: T[]): void;
  52165. /**
  52166. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52167. * @param frustumPlanes defines the frustum planes to test
  52168. * @param selection defines the array to store current content if selection is positive
  52169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52170. */
  52171. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52172. /**
  52173. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52174. * @param sphereCenter defines the bounding sphere center
  52175. * @param sphereRadius defines the bounding sphere radius
  52176. * @param selection defines the array to store current content if selection is positive
  52177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52178. */
  52179. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52180. /**
  52181. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52182. * @param ray defines the ray to test with
  52183. * @param selection defines the array to store current content if selection is positive
  52184. */
  52185. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52186. /**
  52187. * Subdivide the content into child blocks (this block will then be empty)
  52188. */
  52189. createInnerBlocks(): void;
  52190. /**
  52191. * @hidden
  52192. */
  52193. 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;
  52194. }
  52195. }
  52196. declare module "babylonjs/Culling/Octrees/octree" {
  52197. import { SmartArray } from "babylonjs/Misc/smartArray";
  52198. import { Vector3 } from "babylonjs/Maths/math.vector";
  52199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52201. import { Ray } from "babylonjs/Culling/ray";
  52202. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52203. import { Plane } from "babylonjs/Maths/math.plane";
  52204. /**
  52205. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52207. */
  52208. export class Octree<T> {
  52209. /** 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.) */
  52210. maxDepth: number;
  52211. /**
  52212. * Blocks within the octree containing objects
  52213. */
  52214. blocks: Array<OctreeBlock<T>>;
  52215. /**
  52216. * Content stored in the octree
  52217. */
  52218. dynamicContent: T[];
  52219. private _maxBlockCapacity;
  52220. private _selectionContent;
  52221. private _creationFunc;
  52222. /**
  52223. * Creates a octree
  52224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52225. * @param creationFunc function to be used to instatiate the octree
  52226. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52227. * @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.)
  52228. */
  52229. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52230. /** 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.) */
  52231. maxDepth?: number);
  52232. /**
  52233. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52234. * @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);
  52235. * @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);
  52236. * @param entries meshes to be added to the octree blocks
  52237. */
  52238. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52239. /**
  52240. * Adds a mesh to the octree
  52241. * @param entry Mesh to add to the octree
  52242. */
  52243. addMesh(entry: T): void;
  52244. /**
  52245. * Remove an element from the octree
  52246. * @param entry defines the element to remove
  52247. */
  52248. removeMesh(entry: T): void;
  52249. /**
  52250. * Selects an array of meshes within the frustum
  52251. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52252. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52253. * @returns array of meshes within the frustum
  52254. */
  52255. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52256. /**
  52257. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52258. * @param sphereCenter defines the bounding sphere center
  52259. * @param sphereRadius defines the bounding sphere radius
  52260. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52261. * @returns an array of objects that intersect the sphere
  52262. */
  52263. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52264. /**
  52265. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52266. * @param ray defines the ray to test with
  52267. * @returns array of intersected objects
  52268. */
  52269. intersectsRay(ray: Ray): SmartArray<T>;
  52270. /**
  52271. * Adds a mesh into the octree block if it intersects the block
  52272. */
  52273. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52274. /**
  52275. * Adds a submesh into the octree block if it intersects the block
  52276. */
  52277. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52278. }
  52279. }
  52280. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52281. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52282. import { Scene } from "babylonjs/scene";
  52283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52285. import { Ray } from "babylonjs/Culling/ray";
  52286. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52287. import { Collider } from "babylonjs/Collisions/collider";
  52288. module "babylonjs/scene" {
  52289. interface Scene {
  52290. /**
  52291. * @hidden
  52292. * Backing Filed
  52293. */
  52294. _selectionOctree: Octree<AbstractMesh>;
  52295. /**
  52296. * Gets the octree used to boost mesh selection (picking)
  52297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52298. */
  52299. selectionOctree: Octree<AbstractMesh>;
  52300. /**
  52301. * Creates or updates the octree used to boost selection (picking)
  52302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52303. * @param maxCapacity defines the maximum capacity per leaf
  52304. * @param maxDepth defines the maximum depth of the octree
  52305. * @returns an octree of AbstractMesh
  52306. */
  52307. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52308. }
  52309. }
  52310. module "babylonjs/Meshes/abstractMesh" {
  52311. interface AbstractMesh {
  52312. /**
  52313. * @hidden
  52314. * Backing Field
  52315. */
  52316. _submeshesOctree: Octree<SubMesh>;
  52317. /**
  52318. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52320. * @param maxCapacity defines the maximum size of each block (64 by default)
  52321. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52322. * @returns the new octree
  52323. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52325. */
  52326. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52327. }
  52328. }
  52329. /**
  52330. * Defines the octree scene component responsible to manage any octrees
  52331. * in a given scene.
  52332. */
  52333. export class OctreeSceneComponent {
  52334. /**
  52335. * The component name help to identify the component in the list of scene components.
  52336. */
  52337. readonly name: string;
  52338. /**
  52339. * The scene the component belongs to.
  52340. */
  52341. scene: Scene;
  52342. /**
  52343. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52344. */
  52345. readonly checksIsEnabled: boolean;
  52346. /**
  52347. * Creates a new instance of the component for the given scene
  52348. * @param scene Defines the scene to register the component in
  52349. */
  52350. constructor(scene: Scene);
  52351. /**
  52352. * Registers the component in a given scene
  52353. */
  52354. register(): void;
  52355. /**
  52356. * Return the list of active meshes
  52357. * @returns the list of active meshes
  52358. */
  52359. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52360. /**
  52361. * Return the list of active sub meshes
  52362. * @param mesh The mesh to get the candidates sub meshes from
  52363. * @returns the list of active sub meshes
  52364. */
  52365. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52366. private _tempRay;
  52367. /**
  52368. * Return the list of sub meshes intersecting with a given local ray
  52369. * @param mesh defines the mesh to find the submesh for
  52370. * @param localRay defines the ray in local space
  52371. * @returns the list of intersecting sub meshes
  52372. */
  52373. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52374. /**
  52375. * Return the list of sub meshes colliding with a collider
  52376. * @param mesh defines the mesh to find the submesh for
  52377. * @param collider defines the collider to evaluate the collision against
  52378. * @returns the list of colliding sub meshes
  52379. */
  52380. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52381. /**
  52382. * Rebuilds the elements related to this component in case of
  52383. * context lost for instance.
  52384. */
  52385. rebuild(): void;
  52386. /**
  52387. * Disposes the component and the associated ressources.
  52388. */
  52389. dispose(): void;
  52390. }
  52391. }
  52392. declare module "babylonjs/Culling/Octrees/index" {
  52393. export * from "babylonjs/Culling/Octrees/octree";
  52394. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52395. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52396. }
  52397. declare module "babylonjs/Culling/index" {
  52398. export * from "babylonjs/Culling/boundingBox";
  52399. export * from "babylonjs/Culling/boundingInfo";
  52400. export * from "babylonjs/Culling/boundingSphere";
  52401. export * from "babylonjs/Culling/Octrees/index";
  52402. export * from "babylonjs/Culling/ray";
  52403. }
  52404. declare module "babylonjs/Gizmos/gizmo" {
  52405. import { Nullable } from "babylonjs/types";
  52406. import { IDisposable } from "babylonjs/scene";
  52407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52408. import { Mesh } from "babylonjs/Meshes/mesh";
  52409. import { Node } from "babylonjs/node";
  52410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52411. /**
  52412. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52413. */
  52414. export class Gizmo implements IDisposable {
  52415. /** The utility layer the gizmo will be added to */
  52416. gizmoLayer: UtilityLayerRenderer;
  52417. /**
  52418. * The root mesh of the gizmo
  52419. */
  52420. _rootMesh: Mesh;
  52421. private _attachedMesh;
  52422. private _attachedNode;
  52423. /**
  52424. * Ratio for the scale of the gizmo (Default: 1)
  52425. */
  52426. protected _scaleRatio: number;
  52427. /**
  52428. * boolean updated by pointermove when a gizmo mesh is hovered
  52429. */
  52430. protected _isHovered: boolean;
  52431. /**
  52432. * Ratio for the scale of the gizmo (Default: 1)
  52433. */
  52434. set scaleRatio(value: number);
  52435. get scaleRatio(): number;
  52436. /**
  52437. * True when the mouse pointer is hovered a gizmo mesh
  52438. */
  52439. get isHovered(): boolean;
  52440. /**
  52441. * If a custom mesh has been set (Default: false)
  52442. */
  52443. protected _customMeshSet: boolean;
  52444. /**
  52445. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52446. * * When set, interactions will be enabled
  52447. */
  52448. get attachedMesh(): Nullable<AbstractMesh>;
  52449. set attachedMesh(value: Nullable<AbstractMesh>);
  52450. /**
  52451. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52452. * * When set, interactions will be enabled
  52453. */
  52454. get attachedNode(): Nullable<Node>;
  52455. set attachedNode(value: Nullable<Node>);
  52456. /**
  52457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52458. * @param mesh The mesh to replace the default mesh of the gizmo
  52459. */
  52460. setCustomMesh(mesh: Mesh): void;
  52461. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52462. /**
  52463. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52464. */
  52465. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52466. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52467. /**
  52468. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52469. */
  52470. updateGizmoPositionToMatchAttachedMesh: boolean;
  52471. /**
  52472. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52473. */
  52474. updateScale: boolean;
  52475. protected _interactionsEnabled: boolean;
  52476. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52477. private _beforeRenderObserver;
  52478. private _tempQuaternion;
  52479. private _tempVector;
  52480. private _tempVector2;
  52481. private _tempMatrix1;
  52482. private _tempMatrix2;
  52483. private _rightHandtoLeftHandMatrix;
  52484. /**
  52485. * Creates a gizmo
  52486. * @param gizmoLayer The utility layer the gizmo will be added to
  52487. */
  52488. constructor(
  52489. /** The utility layer the gizmo will be added to */
  52490. gizmoLayer?: UtilityLayerRenderer);
  52491. /**
  52492. * Updates the gizmo to match the attached mesh's position/rotation
  52493. */
  52494. protected _update(): void;
  52495. /**
  52496. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52497. * @param value Node, TransformNode or mesh
  52498. */
  52499. protected _matrixChanged(): void;
  52500. /**
  52501. * Disposes of the gizmo
  52502. */
  52503. dispose(): void;
  52504. }
  52505. }
  52506. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. import { Nullable } from "babylonjs/types";
  52509. import { Vector3 } from "babylonjs/Maths/math.vector";
  52510. import { Color3 } from "babylonjs/Maths/math.color";
  52511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52512. import { Node } from "babylonjs/node";
  52513. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52514. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52516. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52517. import { Scene } from "babylonjs/scene";
  52518. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52519. /**
  52520. * Single plane drag gizmo
  52521. */
  52522. export class PlaneDragGizmo extends Gizmo {
  52523. /**
  52524. * Drag behavior responsible for the gizmos dragging interactions
  52525. */
  52526. dragBehavior: PointerDragBehavior;
  52527. private _pointerObserver;
  52528. /**
  52529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52530. */
  52531. snapDistance: number;
  52532. /**
  52533. * Event that fires each time the gizmo snaps to a new location.
  52534. * * snapDistance is the the change in distance
  52535. */
  52536. onSnapObservable: Observable<{
  52537. snapDistance: number;
  52538. }>;
  52539. private _plane;
  52540. private _coloredMaterial;
  52541. private _hoverMaterial;
  52542. private _isEnabled;
  52543. private _parent;
  52544. /** @hidden */
  52545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52546. /** @hidden */
  52547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52548. /**
  52549. * Creates a PlaneDragGizmo
  52550. * @param gizmoLayer The utility layer the gizmo will be added to
  52551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52552. * @param color The color of the gizmo
  52553. */
  52554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52555. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52556. /**
  52557. * If the gizmo is enabled
  52558. */
  52559. set isEnabled(value: boolean);
  52560. get isEnabled(): boolean;
  52561. /**
  52562. * Disposes of the gizmo
  52563. */
  52564. dispose(): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Gizmos/positionGizmo" {
  52568. import { Observable } from "babylonjs/Misc/observable";
  52569. import { Nullable } from "babylonjs/types";
  52570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52571. import { Node } from "babylonjs/node";
  52572. import { Mesh } from "babylonjs/Meshes/mesh";
  52573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52574. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52575. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52577. /**
  52578. * Gizmo that enables dragging a mesh along 3 axis
  52579. */
  52580. export class PositionGizmo extends Gizmo {
  52581. /**
  52582. * Internal gizmo used for interactions on the x axis
  52583. */
  52584. xGizmo: AxisDragGizmo;
  52585. /**
  52586. * Internal gizmo used for interactions on the y axis
  52587. */
  52588. yGizmo: AxisDragGizmo;
  52589. /**
  52590. * Internal gizmo used for interactions on the z axis
  52591. */
  52592. zGizmo: AxisDragGizmo;
  52593. /**
  52594. * Internal gizmo used for interactions on the yz plane
  52595. */
  52596. xPlaneGizmo: PlaneDragGizmo;
  52597. /**
  52598. * Internal gizmo used for interactions on the xz plane
  52599. */
  52600. yPlaneGizmo: PlaneDragGizmo;
  52601. /**
  52602. * Internal gizmo used for interactions on the xy plane
  52603. */
  52604. zPlaneGizmo: PlaneDragGizmo;
  52605. /**
  52606. * private variables
  52607. */
  52608. private _meshAttached;
  52609. private _nodeAttached;
  52610. private _snapDistance;
  52611. /** Fires an event when any of it's sub gizmos are dragged */
  52612. onDragStartObservable: Observable<unknown>;
  52613. /** Fires an event when any of it's sub gizmos are released from dragging */
  52614. onDragEndObservable: Observable<unknown>;
  52615. /**
  52616. * If set to true, planar drag is enabled
  52617. */
  52618. private _planarGizmoEnabled;
  52619. get attachedMesh(): Nullable<AbstractMesh>;
  52620. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52621. get attachedNode(): Nullable<Node>;
  52622. set attachedNode(node: Nullable<Node>);
  52623. /**
  52624. * True when the mouse pointer is hovering a gizmo mesh
  52625. */
  52626. get isHovered(): boolean;
  52627. /**
  52628. * Creates a PositionGizmo
  52629. * @param gizmoLayer The utility layer the gizmo will be added to
  52630. @param thickness display gizmo axis thickness
  52631. */
  52632. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52633. /**
  52634. * If the planar drag gizmo is enabled
  52635. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52636. */
  52637. set planarGizmoEnabled(value: boolean);
  52638. get planarGizmoEnabled(): boolean;
  52639. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52640. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52641. /**
  52642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52643. */
  52644. set snapDistance(value: number);
  52645. get snapDistance(): number;
  52646. /**
  52647. * Ratio for the scale of the gizmo (Default: 1)
  52648. */
  52649. set scaleRatio(value: number);
  52650. get scaleRatio(): number;
  52651. /**
  52652. * Disposes of the gizmo
  52653. */
  52654. dispose(): void;
  52655. /**
  52656. * CustomMeshes are not supported by this gizmo
  52657. * @param mesh The mesh to replace the default mesh of the gizmo
  52658. */
  52659. setCustomMesh(mesh: Mesh): void;
  52660. }
  52661. }
  52662. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52663. import { Observable } from "babylonjs/Misc/observable";
  52664. import { Nullable } from "babylonjs/types";
  52665. import { Vector3 } from "babylonjs/Maths/math.vector";
  52666. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52667. import { Node } from "babylonjs/node";
  52668. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52671. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52672. import { Scene } from "babylonjs/scene";
  52673. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52674. import { Color3 } from "babylonjs/Maths/math.color";
  52675. /**
  52676. * Single axis drag gizmo
  52677. */
  52678. export class AxisDragGizmo extends Gizmo {
  52679. /**
  52680. * Drag behavior responsible for the gizmos dragging interactions
  52681. */
  52682. dragBehavior: PointerDragBehavior;
  52683. private _pointerObserver;
  52684. /**
  52685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52686. */
  52687. snapDistance: number;
  52688. /**
  52689. * Event that fires each time the gizmo snaps to a new location.
  52690. * * snapDistance is the the change in distance
  52691. */
  52692. onSnapObservable: Observable<{
  52693. snapDistance: number;
  52694. }>;
  52695. private _isEnabled;
  52696. private _parent;
  52697. private _arrow;
  52698. private _coloredMaterial;
  52699. private _hoverMaterial;
  52700. /** @hidden */
  52701. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52702. /** @hidden */
  52703. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52704. /**
  52705. * Creates an AxisDragGizmo
  52706. * @param gizmoLayer The utility layer the gizmo will be added to
  52707. * @param dragAxis The axis which the gizmo will be able to drag on
  52708. * @param color The color of the gizmo
  52709. * @param thickness display gizmo axis thickness
  52710. */
  52711. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52712. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52713. /**
  52714. * If the gizmo is enabled
  52715. */
  52716. set isEnabled(value: boolean);
  52717. get isEnabled(): boolean;
  52718. /**
  52719. * Disposes of the gizmo
  52720. */
  52721. dispose(): void;
  52722. }
  52723. }
  52724. declare module "babylonjs/Debug/axesViewer" {
  52725. import { Vector3 } from "babylonjs/Maths/math.vector";
  52726. import { Nullable } from "babylonjs/types";
  52727. import { Scene } from "babylonjs/scene";
  52728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52729. /**
  52730. * The Axes viewer will show 3 axes in a specific point in space
  52731. */
  52732. export class AxesViewer {
  52733. private _xAxis;
  52734. private _yAxis;
  52735. private _zAxis;
  52736. private _scaleLinesFactor;
  52737. private _instanced;
  52738. /**
  52739. * Gets the hosting scene
  52740. */
  52741. scene: Nullable<Scene>;
  52742. /**
  52743. * Gets or sets a number used to scale line length
  52744. */
  52745. scaleLines: number;
  52746. /** Gets the node hierarchy used to render x-axis */
  52747. get xAxis(): TransformNode;
  52748. /** Gets the node hierarchy used to render y-axis */
  52749. get yAxis(): TransformNode;
  52750. /** Gets the node hierarchy used to render z-axis */
  52751. get zAxis(): TransformNode;
  52752. /**
  52753. * Creates a new AxesViewer
  52754. * @param scene defines the hosting scene
  52755. * @param scaleLines defines a number used to scale line length (1 by default)
  52756. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52757. * @param xAxis defines the node hierarchy used to render the x-axis
  52758. * @param yAxis defines the node hierarchy used to render the y-axis
  52759. * @param zAxis defines the node hierarchy used to render the z-axis
  52760. */
  52761. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52762. /**
  52763. * Force the viewer to update
  52764. * @param position defines the position of the viewer
  52765. * @param xaxis defines the x axis of the viewer
  52766. * @param yaxis defines the y axis of the viewer
  52767. * @param zaxis defines the z axis of the viewer
  52768. */
  52769. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52770. /**
  52771. * Creates an instance of this axes viewer.
  52772. * @returns a new axes viewer with instanced meshes
  52773. */
  52774. createInstance(): AxesViewer;
  52775. /** Releases resources */
  52776. dispose(): void;
  52777. private static _SetRenderingGroupId;
  52778. }
  52779. }
  52780. declare module "babylonjs/Debug/boneAxesViewer" {
  52781. import { Nullable } from "babylonjs/types";
  52782. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52783. import { Vector3 } from "babylonjs/Maths/math.vector";
  52784. import { Mesh } from "babylonjs/Meshes/mesh";
  52785. import { Bone } from "babylonjs/Bones/bone";
  52786. import { Scene } from "babylonjs/scene";
  52787. /**
  52788. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52789. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52790. */
  52791. export class BoneAxesViewer extends AxesViewer {
  52792. /**
  52793. * Gets or sets the target mesh where to display the axes viewer
  52794. */
  52795. mesh: Nullable<Mesh>;
  52796. /**
  52797. * Gets or sets the target bone where to display the axes viewer
  52798. */
  52799. bone: Nullable<Bone>;
  52800. /** Gets current position */
  52801. pos: Vector3;
  52802. /** Gets direction of X axis */
  52803. xaxis: Vector3;
  52804. /** Gets direction of Y axis */
  52805. yaxis: Vector3;
  52806. /** Gets direction of Z axis */
  52807. zaxis: Vector3;
  52808. /**
  52809. * Creates a new BoneAxesViewer
  52810. * @param scene defines the hosting scene
  52811. * @param bone defines the target bone
  52812. * @param mesh defines the target mesh
  52813. * @param scaleLines defines a scaling factor for line length (1 by default)
  52814. */
  52815. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52816. /**
  52817. * Force the viewer to update
  52818. */
  52819. update(): void;
  52820. /** Releases resources */
  52821. dispose(): void;
  52822. }
  52823. }
  52824. declare module "babylonjs/Debug/debugLayer" {
  52825. import { Scene } from "babylonjs/scene";
  52826. /**
  52827. * Interface used to define scene explorer extensibility option
  52828. */
  52829. export interface IExplorerExtensibilityOption {
  52830. /**
  52831. * Define the option label
  52832. */
  52833. label: string;
  52834. /**
  52835. * Defines the action to execute on click
  52836. */
  52837. action: (entity: any) => void;
  52838. }
  52839. /**
  52840. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52841. */
  52842. export interface IExplorerExtensibilityGroup {
  52843. /**
  52844. * Defines a predicate to test if a given type mut be extended
  52845. */
  52846. predicate: (entity: any) => boolean;
  52847. /**
  52848. * Gets the list of options added to a type
  52849. */
  52850. entries: IExplorerExtensibilityOption[];
  52851. }
  52852. /**
  52853. * Interface used to define the options to use to create the Inspector
  52854. */
  52855. export interface IInspectorOptions {
  52856. /**
  52857. * Display in overlay mode (default: false)
  52858. */
  52859. overlay?: boolean;
  52860. /**
  52861. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52862. */
  52863. globalRoot?: HTMLElement;
  52864. /**
  52865. * Display the Scene explorer
  52866. */
  52867. showExplorer?: boolean;
  52868. /**
  52869. * Display the property inspector
  52870. */
  52871. showInspector?: boolean;
  52872. /**
  52873. * Display in embed mode (both panes on the right)
  52874. */
  52875. embedMode?: boolean;
  52876. /**
  52877. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52878. */
  52879. handleResize?: boolean;
  52880. /**
  52881. * Allow the panes to popup (default: true)
  52882. */
  52883. enablePopup?: boolean;
  52884. /**
  52885. * Allow the panes to be closed by users (default: true)
  52886. */
  52887. enableClose?: boolean;
  52888. /**
  52889. * Optional list of extensibility entries
  52890. */
  52891. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52892. /**
  52893. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52894. */
  52895. inspectorURL?: string;
  52896. /**
  52897. * Optional initial tab (default to DebugLayerTab.Properties)
  52898. */
  52899. initialTab?: DebugLayerTab;
  52900. }
  52901. module "babylonjs/scene" {
  52902. interface Scene {
  52903. /**
  52904. * @hidden
  52905. * Backing field
  52906. */
  52907. _debugLayer: DebugLayer;
  52908. /**
  52909. * Gets the debug layer (aka Inspector) associated with the scene
  52910. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52911. */
  52912. debugLayer: DebugLayer;
  52913. }
  52914. }
  52915. /**
  52916. * Enum of inspector action tab
  52917. */
  52918. export enum DebugLayerTab {
  52919. /**
  52920. * Properties tag (default)
  52921. */
  52922. Properties = 0,
  52923. /**
  52924. * Debug tab
  52925. */
  52926. Debug = 1,
  52927. /**
  52928. * Statistics tab
  52929. */
  52930. Statistics = 2,
  52931. /**
  52932. * Tools tab
  52933. */
  52934. Tools = 3,
  52935. /**
  52936. * Settings tab
  52937. */
  52938. Settings = 4
  52939. }
  52940. /**
  52941. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52942. * what is happening in your scene
  52943. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52944. */
  52945. export class DebugLayer {
  52946. /**
  52947. * Define the url to get the inspector script from.
  52948. * By default it uses the babylonjs CDN.
  52949. * @ignoreNaming
  52950. */
  52951. static InspectorURL: string;
  52952. private _scene;
  52953. private BJSINSPECTOR;
  52954. private _onPropertyChangedObservable?;
  52955. /**
  52956. * Observable triggered when a property is changed through the inspector.
  52957. */
  52958. get onPropertyChangedObservable(): any;
  52959. /**
  52960. * Instantiates a new debug layer.
  52961. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52962. * what is happening in your scene
  52963. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52964. * @param scene Defines the scene to inspect
  52965. */
  52966. constructor(scene: Scene);
  52967. /** Creates the inspector window. */
  52968. private _createInspector;
  52969. /**
  52970. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52971. * @param entity defines the entity to select
  52972. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52973. */
  52974. select(entity: any, lineContainerTitles?: string | string[]): void;
  52975. /** Get the inspector from bundle or global */
  52976. private _getGlobalInspector;
  52977. /**
  52978. * Get if the inspector is visible or not.
  52979. * @returns true if visible otherwise, false
  52980. */
  52981. isVisible(): boolean;
  52982. /**
  52983. * Hide the inspector and close its window.
  52984. */
  52985. hide(): void;
  52986. /**
  52987. * Update the scene in the inspector
  52988. */
  52989. setAsActiveScene(): void;
  52990. /**
  52991. * Launch the debugLayer.
  52992. * @param config Define the configuration of the inspector
  52993. * @return a promise fulfilled when the debug layer is visible
  52994. */
  52995. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52996. }
  52997. }
  52998. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52999. import { Nullable } from "babylonjs/types";
  53000. import { Scene } from "babylonjs/scene";
  53001. import { Vector4 } from "babylonjs/Maths/math.vector";
  53002. import { Color4 } from "babylonjs/Maths/math.color";
  53003. import { Mesh } from "babylonjs/Meshes/mesh";
  53004. /**
  53005. * Class containing static functions to help procedurally build meshes
  53006. */
  53007. export class BoxBuilder {
  53008. /**
  53009. * Creates a box mesh
  53010. * * The parameter `size` sets the size (float) of each box side (default 1)
  53011. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53012. * * 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)
  53013. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53017. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53018. * @param name defines the name of the mesh
  53019. * @param options defines the options used to create the mesh
  53020. * @param scene defines the hosting scene
  53021. * @returns the box mesh
  53022. */
  53023. static CreateBox(name: string, options: {
  53024. size?: number;
  53025. width?: number;
  53026. height?: number;
  53027. depth?: number;
  53028. faceUV?: Vector4[];
  53029. faceColors?: Color4[];
  53030. sideOrientation?: number;
  53031. frontUVs?: Vector4;
  53032. backUVs?: Vector4;
  53033. wrap?: boolean;
  53034. topBaseAt?: number;
  53035. bottomBaseAt?: number;
  53036. updatable?: boolean;
  53037. }, scene?: Nullable<Scene>): Mesh;
  53038. }
  53039. }
  53040. declare module "babylonjs/Debug/physicsViewer" {
  53041. import { Nullable } from "babylonjs/types";
  53042. import { Scene } from "babylonjs/scene";
  53043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53044. import { Mesh } from "babylonjs/Meshes/mesh";
  53045. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53046. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53047. /**
  53048. * Used to show the physics impostor around the specific mesh
  53049. */
  53050. export class PhysicsViewer {
  53051. /** @hidden */
  53052. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53053. /** @hidden */
  53054. protected _meshes: Array<Nullable<AbstractMesh>>;
  53055. /** @hidden */
  53056. protected _scene: Nullable<Scene>;
  53057. /** @hidden */
  53058. protected _numMeshes: number;
  53059. /** @hidden */
  53060. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53061. private _renderFunction;
  53062. private _utilityLayer;
  53063. private _debugBoxMesh;
  53064. private _debugSphereMesh;
  53065. private _debugCylinderMesh;
  53066. private _debugMaterial;
  53067. private _debugMeshMeshes;
  53068. /**
  53069. * Creates a new PhysicsViewer
  53070. * @param scene defines the hosting scene
  53071. */
  53072. constructor(scene: Scene);
  53073. /** @hidden */
  53074. protected _updateDebugMeshes(): void;
  53075. /**
  53076. * Renders a specified physic impostor
  53077. * @param impostor defines the impostor to render
  53078. * @param targetMesh defines the mesh represented by the impostor
  53079. * @returns the new debug mesh used to render the impostor
  53080. */
  53081. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53082. /**
  53083. * Hides a specified physic impostor
  53084. * @param impostor defines the impostor to hide
  53085. */
  53086. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53087. private _getDebugMaterial;
  53088. private _getDebugBoxMesh;
  53089. private _getDebugSphereMesh;
  53090. private _getDebugCylinderMesh;
  53091. private _getDebugMeshMesh;
  53092. private _getDebugMesh;
  53093. /** Releases all resources */
  53094. dispose(): void;
  53095. }
  53096. }
  53097. declare module "babylonjs/Debug/rayHelper" {
  53098. import { Nullable } from "babylonjs/types";
  53099. import { Ray } from "babylonjs/Culling/ray";
  53100. import { Vector3 } from "babylonjs/Maths/math.vector";
  53101. import { Color3 } from "babylonjs/Maths/math.color";
  53102. import { Scene } from "babylonjs/scene";
  53103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53104. import "babylonjs/Meshes/Builders/linesBuilder";
  53105. /**
  53106. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53107. * in order to better appreciate the issue one might have.
  53108. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53109. */
  53110. export class RayHelper {
  53111. /**
  53112. * Defines the ray we are currently tryin to visualize.
  53113. */
  53114. ray: Nullable<Ray>;
  53115. private _renderPoints;
  53116. private _renderLine;
  53117. private _renderFunction;
  53118. private _scene;
  53119. private _onAfterRenderObserver;
  53120. private _onAfterStepObserver;
  53121. private _attachedToMesh;
  53122. private _meshSpaceDirection;
  53123. private _meshSpaceOrigin;
  53124. /**
  53125. * Helper function to create a colored helper in a scene in one line.
  53126. * @param ray Defines the ray we are currently tryin to visualize
  53127. * @param scene Defines the scene the ray is used in
  53128. * @param color Defines the color we want to see the ray in
  53129. * @returns The newly created ray helper.
  53130. */
  53131. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53132. /**
  53133. * Instantiate a new ray helper.
  53134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53135. * in order to better appreciate the issue one might have.
  53136. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53137. * @param ray Defines the ray we are currently tryin to visualize
  53138. */
  53139. constructor(ray: Ray);
  53140. /**
  53141. * Shows the ray we are willing to debug.
  53142. * @param scene Defines the scene the ray needs to be rendered in
  53143. * @param color Defines the color the ray needs to be rendered in
  53144. */
  53145. show(scene: Scene, color?: Color3): void;
  53146. /**
  53147. * Hides the ray we are debugging.
  53148. */
  53149. hide(): void;
  53150. private _render;
  53151. /**
  53152. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53153. * @param mesh Defines the mesh we want the helper attached to
  53154. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53155. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53156. * @param length Defines the length of the ray
  53157. */
  53158. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53159. /**
  53160. * Detach the ray helper from the mesh it has previously been attached to.
  53161. */
  53162. detachFromMesh(): void;
  53163. private _updateToMesh;
  53164. /**
  53165. * Dispose the helper and release its associated resources.
  53166. */
  53167. dispose(): void;
  53168. }
  53169. }
  53170. declare module "babylonjs/Debug/ISkeletonViewer" {
  53171. import { Skeleton } from "babylonjs/Bones/skeleton";
  53172. import { Color3 } from "babylonjs/Maths/math.color";
  53173. /**
  53174. * Defines the options associated with the creation of a SkeletonViewer.
  53175. */
  53176. export interface ISkeletonViewerOptions {
  53177. /** Should the system pause animations before building the Viewer? */
  53178. pauseAnimations: boolean;
  53179. /** Should the system return the skeleton to rest before building? */
  53180. returnToRest: boolean;
  53181. /** public Display Mode of the Viewer */
  53182. displayMode: number;
  53183. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53184. displayOptions: ISkeletonViewerDisplayOptions;
  53185. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53186. computeBonesUsingShaders: boolean;
  53187. /** Flag ignore non weighted bones */
  53188. useAllBones: boolean;
  53189. }
  53190. /**
  53191. * Defines how to display the various bone meshes for the viewer.
  53192. */
  53193. export interface ISkeletonViewerDisplayOptions {
  53194. /** How far down to start tapering the bone spurs */
  53195. midStep?: number;
  53196. /** How big is the midStep? */
  53197. midStepFactor?: number;
  53198. /** Base for the Sphere Size */
  53199. sphereBaseSize?: number;
  53200. /** The ratio of the sphere to the longest bone in units */
  53201. sphereScaleUnit?: number;
  53202. /** Ratio for the Sphere Size */
  53203. sphereFactor?: number;
  53204. /** Whether to show local axes or not */
  53205. showLocalAxes?: boolean;
  53206. /** Length of each local axis */
  53207. localAxesSize?: number;
  53208. }
  53209. /**
  53210. * Defines the constructor options for the BoneWeight Shader.
  53211. */
  53212. export interface IBoneWeightShaderOptions {
  53213. /** Skeleton to Map */
  53214. skeleton: Skeleton;
  53215. /** Colors for Uninfluenced bones */
  53216. colorBase?: Color3;
  53217. /** Colors for 0.0-0.25 Weight bones */
  53218. colorZero?: Color3;
  53219. /** Color for 0.25-0.5 Weight Influence */
  53220. colorQuarter?: Color3;
  53221. /** Color for 0.5-0.75 Weight Influence */
  53222. colorHalf?: Color3;
  53223. /** Color for 0.75-1 Weight Influence */
  53224. colorFull?: Color3;
  53225. /** Color for Zero Weight Influence */
  53226. targetBoneIndex?: number;
  53227. }
  53228. /**
  53229. * Simple structure of the gradient steps for the Color Map.
  53230. */
  53231. export interface ISkeletonMapShaderColorMapKnot {
  53232. /** Color of the Knot */
  53233. color: Color3;
  53234. /** Location of the Knot */
  53235. location: number;
  53236. }
  53237. /**
  53238. * Defines the constructor options for the SkeletonMap Shader.
  53239. */
  53240. export interface ISkeletonMapShaderOptions {
  53241. /** Skeleton to Map */
  53242. skeleton: Skeleton;
  53243. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53244. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53245. }
  53246. }
  53247. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53248. import { Nullable } from "babylonjs/types";
  53249. import { Scene } from "babylonjs/scene";
  53250. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53251. import { Color4 } from "babylonjs/Maths/math.color";
  53252. import { Mesh } from "babylonjs/Meshes/mesh";
  53253. /**
  53254. * Class containing static functions to help procedurally build meshes
  53255. */
  53256. export class RibbonBuilder {
  53257. /**
  53258. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53259. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53260. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53261. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53262. * * 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
  53263. * * 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
  53264. * * 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
  53265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53268. * * 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
  53269. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53270. * * 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
  53271. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53273. * @param name defines the name of the mesh
  53274. * @param options defines the options used to create the mesh
  53275. * @param scene defines the hosting scene
  53276. * @returns the ribbon mesh
  53277. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53279. */
  53280. static CreateRibbon(name: string, options: {
  53281. pathArray: Vector3[][];
  53282. closeArray?: boolean;
  53283. closePath?: boolean;
  53284. offset?: number;
  53285. updatable?: boolean;
  53286. sideOrientation?: number;
  53287. frontUVs?: Vector4;
  53288. backUVs?: Vector4;
  53289. instance?: Mesh;
  53290. invertUV?: boolean;
  53291. uvs?: Vector2[];
  53292. colors?: Color4[];
  53293. }, scene?: Nullable<Scene>): Mesh;
  53294. }
  53295. }
  53296. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53297. import { Nullable } from "babylonjs/types";
  53298. import { Scene } from "babylonjs/scene";
  53299. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53300. import { Mesh } from "babylonjs/Meshes/mesh";
  53301. /**
  53302. * Class containing static functions to help procedurally build meshes
  53303. */
  53304. export class ShapeBuilder {
  53305. /**
  53306. * 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.
  53307. * * 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.
  53308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53309. * * 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.
  53310. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53311. * * 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
  53312. * * 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
  53313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53318. * @param name defines the name of the mesh
  53319. * @param options defines the options used to create the mesh
  53320. * @param scene defines the hosting scene
  53321. * @returns the extruded shape mesh
  53322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53324. */
  53325. static ExtrudeShape(name: string, options: {
  53326. shape: Vector3[];
  53327. path: Vector3[];
  53328. scale?: number;
  53329. rotation?: number;
  53330. cap?: number;
  53331. updatable?: boolean;
  53332. sideOrientation?: number;
  53333. frontUVs?: Vector4;
  53334. backUVs?: Vector4;
  53335. instance?: Mesh;
  53336. invertUV?: boolean;
  53337. }, scene?: Nullable<Scene>): Mesh;
  53338. /**
  53339. * Creates an custom extruded shape mesh.
  53340. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53341. * * 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.
  53342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53343. * * 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
  53344. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53345. * * 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
  53346. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53347. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53348. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53349. * * 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
  53350. * * 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
  53351. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53356. * @param name defines the name of the mesh
  53357. * @param options defines the options used to create the mesh
  53358. * @param scene defines the hosting scene
  53359. * @returns the custom extruded shape mesh
  53360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53363. */
  53364. static ExtrudeShapeCustom(name: string, options: {
  53365. shape: Vector3[];
  53366. path: Vector3[];
  53367. scaleFunction?: any;
  53368. rotationFunction?: any;
  53369. ribbonCloseArray?: boolean;
  53370. ribbonClosePath?: boolean;
  53371. cap?: number;
  53372. updatable?: boolean;
  53373. sideOrientation?: number;
  53374. frontUVs?: Vector4;
  53375. backUVs?: Vector4;
  53376. instance?: Mesh;
  53377. invertUV?: boolean;
  53378. }, scene?: Nullable<Scene>): Mesh;
  53379. private static _ExtrudeShapeGeneric;
  53380. }
  53381. }
  53382. declare module "babylonjs/Debug/skeletonViewer" {
  53383. import { Color3 } from "babylonjs/Maths/math.color";
  53384. import { Scene } from "babylonjs/scene";
  53385. import { Nullable } from "babylonjs/types";
  53386. import { Skeleton } from "babylonjs/Bones/skeleton";
  53387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53388. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53390. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53391. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53392. /**
  53393. * Class used to render a debug view of a given skeleton
  53394. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53395. */
  53396. export class SkeletonViewer {
  53397. /** defines the skeleton to render */
  53398. skeleton: Skeleton;
  53399. /** defines the mesh attached to the skeleton */
  53400. mesh: AbstractMesh;
  53401. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53402. autoUpdateBonesMatrices: boolean;
  53403. /** defines the rendering group id to use with the viewer */
  53404. renderingGroupId: number;
  53405. /** is the options for the viewer */
  53406. options: Partial<ISkeletonViewerOptions>;
  53407. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53408. static readonly DISPLAY_LINES: number;
  53409. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53410. static readonly DISPLAY_SPHERES: number;
  53411. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53412. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53413. /** public static method to create a BoneWeight Shader
  53414. * @param options The constructor options
  53415. * @param scene The scene that the shader is scoped to
  53416. * @returns The created ShaderMaterial
  53417. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53418. */
  53419. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53420. /** public static method to create a BoneWeight Shader
  53421. * @param options The constructor options
  53422. * @param scene The scene that the shader is scoped to
  53423. * @returns The created ShaderMaterial
  53424. */
  53425. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53426. /** private static method to create a BoneWeight Shader
  53427. * @param size The size of the buffer to create (usually the bone count)
  53428. * @param colorMap The gradient data to generate
  53429. * @param scene The scene that the shader is scoped to
  53430. * @returns an Array of floats from the color gradient values
  53431. */
  53432. private static _CreateBoneMapColorBuffer;
  53433. /** If SkeletonViewer scene scope. */
  53434. private _scene;
  53435. /** Gets or sets the color used to render the skeleton */
  53436. color: Color3;
  53437. /** Array of the points of the skeleton fo the line view. */
  53438. private _debugLines;
  53439. /** The SkeletonViewers Mesh. */
  53440. private _debugMesh;
  53441. /** The local axes Meshes. */
  53442. private _localAxes;
  53443. /** If SkeletonViewer is enabled. */
  53444. private _isEnabled;
  53445. /** If SkeletonViewer is ready. */
  53446. private _ready;
  53447. /** SkeletonViewer render observable. */
  53448. private _obs;
  53449. /** The Utility Layer to render the gizmos in. */
  53450. private _utilityLayer;
  53451. private _boneIndices;
  53452. /** Gets the Scene. */
  53453. get scene(): Scene;
  53454. /** Gets the utilityLayer. */
  53455. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53456. /** Checks Ready Status. */
  53457. get isReady(): Boolean;
  53458. /** Sets Ready Status. */
  53459. set ready(value: boolean);
  53460. /** Gets the debugMesh */
  53461. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53462. /** Sets the debugMesh */
  53463. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53464. /** Gets the displayMode */
  53465. get displayMode(): number;
  53466. /** Sets the displayMode */
  53467. set displayMode(value: number);
  53468. /**
  53469. * Creates a new SkeletonViewer
  53470. * @param skeleton defines the skeleton to render
  53471. * @param mesh defines the mesh attached to the skeleton
  53472. * @param scene defines the hosting scene
  53473. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53474. * @param renderingGroupId defines the rendering group id to use with the viewer
  53475. * @param options All of the extra constructor options for the SkeletonViewer
  53476. */
  53477. constructor(
  53478. /** defines the skeleton to render */
  53479. skeleton: Skeleton,
  53480. /** defines the mesh attached to the skeleton */
  53481. mesh: AbstractMesh,
  53482. /** The Scene scope*/
  53483. scene: Scene,
  53484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53485. autoUpdateBonesMatrices?: boolean,
  53486. /** defines the rendering group id to use with the viewer */
  53487. renderingGroupId?: number,
  53488. /** is the options for the viewer */
  53489. options?: Partial<ISkeletonViewerOptions>);
  53490. /** The Dynamic bindings for the update functions */
  53491. private _bindObs;
  53492. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53493. update(): void;
  53494. /** Gets or sets a boolean indicating if the viewer is enabled */
  53495. set isEnabled(value: boolean);
  53496. get isEnabled(): boolean;
  53497. private _getBonePosition;
  53498. private _getLinesForBonesWithLength;
  53499. private _getLinesForBonesNoLength;
  53500. /** function to revert the mesh and scene back to the initial state. */
  53501. private _revert;
  53502. private getAbsoluteRestPose;
  53503. /** function to build and bind sphere joint points and spur bone representations. */
  53504. private _buildSpheresAndSpurs;
  53505. private _buildLocalAxes;
  53506. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53507. private _displayLinesUpdate;
  53508. /** Changes the displayMode of the skeleton viewer
  53509. * @param mode The displayMode numerical value
  53510. */
  53511. changeDisplayMode(mode: number): void;
  53512. /** Sets a display option of the skeleton viewer
  53513. *
  53514. * | Option | Type | Default | Description |
  53515. * | --------------- | ------- | ------- | ----------- |
  53516. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53517. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53518. *
  53519. * @param option String of the option name
  53520. * @param value The numerical option value
  53521. */
  53522. changeDisplayOptions(option: string, value: number): void;
  53523. /** Release associated resources */
  53524. dispose(): void;
  53525. }
  53526. }
  53527. declare module "babylonjs/Debug/index" {
  53528. export * from "babylonjs/Debug/axesViewer";
  53529. export * from "babylonjs/Debug/boneAxesViewer";
  53530. export * from "babylonjs/Debug/debugLayer";
  53531. export * from "babylonjs/Debug/physicsViewer";
  53532. export * from "babylonjs/Debug/rayHelper";
  53533. export * from "babylonjs/Debug/skeletonViewer";
  53534. export * from "babylonjs/Debug/ISkeletonViewer";
  53535. }
  53536. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53537. /**
  53538. * Enum for Device Types
  53539. */
  53540. export enum DeviceType {
  53541. /** Generic */
  53542. Generic = 0,
  53543. /** Keyboard */
  53544. Keyboard = 1,
  53545. /** Mouse */
  53546. Mouse = 2,
  53547. /** Touch Pointers */
  53548. Touch = 3,
  53549. /** PS4 Dual Shock */
  53550. DualShock = 4,
  53551. /** Xbox */
  53552. Xbox = 5,
  53553. /** Switch Controller */
  53554. Switch = 6
  53555. }
  53556. /**
  53557. * Enum for All Pointers (Touch/Mouse)
  53558. */
  53559. export enum PointerInput {
  53560. /** Horizontal Axis */
  53561. Horizontal = 0,
  53562. /** Vertical Axis */
  53563. Vertical = 1,
  53564. /** Left Click or Touch */
  53565. LeftClick = 2,
  53566. /** Middle Click */
  53567. MiddleClick = 3,
  53568. /** Right Click */
  53569. RightClick = 4,
  53570. /** Browser Back */
  53571. BrowserBack = 5,
  53572. /** Browser Forward */
  53573. BrowserForward = 6
  53574. }
  53575. /**
  53576. * Enum for Dual Shock Gamepad
  53577. */
  53578. export enum DualShockInput {
  53579. /** Cross */
  53580. Cross = 0,
  53581. /** Circle */
  53582. Circle = 1,
  53583. /** Square */
  53584. Square = 2,
  53585. /** Triangle */
  53586. Triangle = 3,
  53587. /** L1 */
  53588. L1 = 4,
  53589. /** R1 */
  53590. R1 = 5,
  53591. /** L2 */
  53592. L2 = 6,
  53593. /** R2 */
  53594. R2 = 7,
  53595. /** Share */
  53596. Share = 8,
  53597. /** Options */
  53598. Options = 9,
  53599. /** L3 */
  53600. L3 = 10,
  53601. /** R3 */
  53602. R3 = 11,
  53603. /** DPadUp */
  53604. DPadUp = 12,
  53605. /** DPadDown */
  53606. DPadDown = 13,
  53607. /** DPadLeft */
  53608. DPadLeft = 14,
  53609. /** DRight */
  53610. DPadRight = 15,
  53611. /** Home */
  53612. Home = 16,
  53613. /** TouchPad */
  53614. TouchPad = 17,
  53615. /** LStickXAxis */
  53616. LStickXAxis = 18,
  53617. /** LStickYAxis */
  53618. LStickYAxis = 19,
  53619. /** RStickXAxis */
  53620. RStickXAxis = 20,
  53621. /** RStickYAxis */
  53622. RStickYAxis = 21
  53623. }
  53624. /**
  53625. * Enum for Xbox Gamepad
  53626. */
  53627. export enum XboxInput {
  53628. /** A */
  53629. A = 0,
  53630. /** B */
  53631. B = 1,
  53632. /** X */
  53633. X = 2,
  53634. /** Y */
  53635. Y = 3,
  53636. /** LB */
  53637. LB = 4,
  53638. /** RB */
  53639. RB = 5,
  53640. /** LT */
  53641. LT = 6,
  53642. /** RT */
  53643. RT = 7,
  53644. /** Back */
  53645. Back = 8,
  53646. /** Start */
  53647. Start = 9,
  53648. /** LS */
  53649. LS = 10,
  53650. /** RS */
  53651. RS = 11,
  53652. /** DPadUp */
  53653. DPadUp = 12,
  53654. /** DPadDown */
  53655. DPadDown = 13,
  53656. /** DPadLeft */
  53657. DPadLeft = 14,
  53658. /** DRight */
  53659. DPadRight = 15,
  53660. /** Home */
  53661. Home = 16,
  53662. /** LStickXAxis */
  53663. LStickXAxis = 17,
  53664. /** LStickYAxis */
  53665. LStickYAxis = 18,
  53666. /** RStickXAxis */
  53667. RStickXAxis = 19,
  53668. /** RStickYAxis */
  53669. RStickYAxis = 20
  53670. }
  53671. /**
  53672. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53673. */
  53674. export enum SwitchInput {
  53675. /** B */
  53676. B = 0,
  53677. /** A */
  53678. A = 1,
  53679. /** Y */
  53680. Y = 2,
  53681. /** X */
  53682. X = 3,
  53683. /** L */
  53684. L = 4,
  53685. /** R */
  53686. R = 5,
  53687. /** ZL */
  53688. ZL = 6,
  53689. /** ZR */
  53690. ZR = 7,
  53691. /** Minus */
  53692. Minus = 8,
  53693. /** Plus */
  53694. Plus = 9,
  53695. /** LS */
  53696. LS = 10,
  53697. /** RS */
  53698. RS = 11,
  53699. /** DPadUp */
  53700. DPadUp = 12,
  53701. /** DPadDown */
  53702. DPadDown = 13,
  53703. /** DPadLeft */
  53704. DPadLeft = 14,
  53705. /** DRight */
  53706. DPadRight = 15,
  53707. /** Home */
  53708. Home = 16,
  53709. /** Capture */
  53710. Capture = 17,
  53711. /** LStickXAxis */
  53712. LStickXAxis = 18,
  53713. /** LStickYAxis */
  53714. LStickYAxis = 19,
  53715. /** RStickXAxis */
  53716. RStickXAxis = 20,
  53717. /** RStickYAxis */
  53718. RStickYAxis = 21
  53719. }
  53720. }
  53721. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53722. import { Engine } from "babylonjs/Engines/engine";
  53723. import { IDisposable } from "babylonjs/scene";
  53724. import { Nullable } from "babylonjs/types";
  53725. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53726. /**
  53727. * This class will take all inputs from Keyboard, Pointer, and
  53728. * any Gamepads and provide a polling system that all devices
  53729. * will use. This class assumes that there will only be one
  53730. * pointer device and one keyboard.
  53731. */
  53732. export class DeviceInputSystem implements IDisposable {
  53733. /**
  53734. * Callback to be triggered when a device is connected
  53735. */
  53736. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53737. /**
  53738. * Callback to be triggered when a device is disconnected
  53739. */
  53740. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53741. /**
  53742. * Callback to be triggered when event driven input is updated
  53743. */
  53744. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53745. private _inputs;
  53746. private _gamepads;
  53747. private _keyboardActive;
  53748. private _pointerActive;
  53749. private _elementToAttachTo;
  53750. private _keyboardDownEvent;
  53751. private _keyboardUpEvent;
  53752. private _pointerMoveEvent;
  53753. private _pointerDownEvent;
  53754. private _pointerUpEvent;
  53755. private _gamepadConnectedEvent;
  53756. private _gamepadDisconnectedEvent;
  53757. private static _MAX_KEYCODES;
  53758. private static _MAX_POINTER_INPUTS;
  53759. private constructor();
  53760. /**
  53761. * Creates a new DeviceInputSystem instance
  53762. * @param engine Engine to pull input element from
  53763. * @returns The new instance
  53764. */
  53765. static Create(engine: Engine): DeviceInputSystem;
  53766. /**
  53767. * Checks for current device input value, given an id and input index
  53768. * @param deviceName Id of connected device
  53769. * @param inputIndex Index of device input
  53770. * @returns Current value of input
  53771. */
  53772. /**
  53773. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53774. * @param deviceType Enum specifiying device type
  53775. * @param deviceSlot "Slot" or index that device is referenced in
  53776. * @param inputIndex Id of input to be checked
  53777. * @returns Current value of input
  53778. */
  53779. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53780. /**
  53781. * Dispose of all the eventlisteners
  53782. */
  53783. dispose(): void;
  53784. /**
  53785. * Add device and inputs to device array
  53786. * @param deviceType Enum specifiying device type
  53787. * @param deviceSlot "Slot" or index that device is referenced in
  53788. * @param numberOfInputs Number of input entries to create for given device
  53789. */
  53790. private _registerDevice;
  53791. /**
  53792. * Given a specific device name, remove that device from the device map
  53793. * @param deviceType Enum specifiying device type
  53794. * @param deviceSlot "Slot" or index that device is referenced in
  53795. */
  53796. private _unregisterDevice;
  53797. /**
  53798. * Handle all actions that come from keyboard interaction
  53799. */
  53800. private _handleKeyActions;
  53801. /**
  53802. * Handle all actions that come from pointer interaction
  53803. */
  53804. private _handlePointerActions;
  53805. /**
  53806. * Handle all actions that come from gamepad interaction
  53807. */
  53808. private _handleGamepadActions;
  53809. /**
  53810. * Update all non-event based devices with each frame
  53811. * @param deviceType Enum specifiying device type
  53812. * @param deviceSlot "Slot" or index that device is referenced in
  53813. * @param inputIndex Id of input to be checked
  53814. */
  53815. private _updateDevice;
  53816. /**
  53817. * Gets DeviceType from the device name
  53818. * @param deviceName Name of Device from DeviceInputSystem
  53819. * @returns DeviceType enum value
  53820. */
  53821. private _getGamepadDeviceType;
  53822. }
  53823. }
  53824. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53825. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53826. /**
  53827. * Type to handle enforcement of inputs
  53828. */
  53829. 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;
  53830. }
  53831. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53832. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53833. import { Engine } from "babylonjs/Engines/engine";
  53834. import { IDisposable } from "babylonjs/scene";
  53835. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53836. import { Nullable } from "babylonjs/types";
  53837. import { Observable } from "babylonjs/Misc/observable";
  53838. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53839. /**
  53840. * Class that handles all input for a specific device
  53841. */
  53842. export class DeviceSource<T extends DeviceType> {
  53843. /** Type of device */
  53844. readonly deviceType: DeviceType;
  53845. /** "Slot" or index that device is referenced in */
  53846. readonly deviceSlot: number;
  53847. /**
  53848. * Observable to handle device input changes per device
  53849. */
  53850. readonly onInputChangedObservable: Observable<{
  53851. inputIndex: DeviceInput<T>;
  53852. previousState: Nullable<number>;
  53853. currentState: Nullable<number>;
  53854. }>;
  53855. private readonly _deviceInputSystem;
  53856. /**
  53857. * Default Constructor
  53858. * @param deviceInputSystem Reference to DeviceInputSystem
  53859. * @param deviceType Type of device
  53860. * @param deviceSlot "Slot" or index that device is referenced in
  53861. */
  53862. constructor(deviceInputSystem: DeviceInputSystem,
  53863. /** Type of device */
  53864. deviceType: DeviceType,
  53865. /** "Slot" or index that device is referenced in */
  53866. deviceSlot?: number);
  53867. /**
  53868. * Get input for specific input
  53869. * @param inputIndex index of specific input on device
  53870. * @returns Input value from DeviceInputSystem
  53871. */
  53872. getInput(inputIndex: DeviceInput<T>): number;
  53873. }
  53874. /**
  53875. * Class to keep track of devices
  53876. */
  53877. export class DeviceSourceManager implements IDisposable {
  53878. /**
  53879. * Observable to be triggered when before a device is connected
  53880. */
  53881. readonly onBeforeDeviceConnectedObservable: Observable<{
  53882. deviceType: DeviceType;
  53883. deviceSlot: number;
  53884. }>;
  53885. /**
  53886. * Observable to be triggered when before a device is disconnected
  53887. */
  53888. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53889. deviceType: DeviceType;
  53890. deviceSlot: number;
  53891. }>;
  53892. /**
  53893. * Observable to be triggered when after a device is connected
  53894. */
  53895. readonly onAfterDeviceConnectedObservable: Observable<{
  53896. deviceType: DeviceType;
  53897. deviceSlot: number;
  53898. }>;
  53899. /**
  53900. * Observable to be triggered when after a device is disconnected
  53901. */
  53902. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53903. deviceType: DeviceType;
  53904. deviceSlot: number;
  53905. }>;
  53906. private readonly _devices;
  53907. private readonly _firstDevice;
  53908. private readonly _deviceInputSystem;
  53909. /**
  53910. * Default Constructor
  53911. * @param engine engine to pull input element from
  53912. */
  53913. constructor(engine: Engine);
  53914. /**
  53915. * Gets a DeviceSource, given a type and slot
  53916. * @param deviceType Enum specifying device type
  53917. * @param deviceSlot "Slot" or index that device is referenced in
  53918. * @returns DeviceSource object
  53919. */
  53920. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53921. /**
  53922. * Gets an array of DeviceSource objects for a given device type
  53923. * @param deviceType Enum specifying device type
  53924. * @returns Array of DeviceSource objects
  53925. */
  53926. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53927. /**
  53928. * Dispose of DeviceInputSystem and other parts
  53929. */
  53930. dispose(): void;
  53931. /**
  53932. * Function to add device name to device list
  53933. * @param deviceType Enum specifying device type
  53934. * @param deviceSlot "Slot" or index that device is referenced in
  53935. */
  53936. private _addDevice;
  53937. /**
  53938. * Function to remove device name to device list
  53939. * @param deviceType Enum specifying device type
  53940. * @param deviceSlot "Slot" or index that device is referenced in
  53941. */
  53942. private _removeDevice;
  53943. /**
  53944. * Updates array storing first connected device of each type
  53945. * @param type Type of Device
  53946. */
  53947. private _updateFirstDevices;
  53948. }
  53949. }
  53950. declare module "babylonjs/DeviceInput/index" {
  53951. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53952. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53953. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53954. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53955. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53956. }
  53957. declare module "babylonjs/Engines/nullEngine" {
  53958. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53959. import { Engine } from "babylonjs/Engines/engine";
  53960. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53961. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53963. import { Effect } from "babylonjs/Materials/effect";
  53964. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53965. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53966. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53967. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53968. /**
  53969. * Options to create the null engine
  53970. */
  53971. export class NullEngineOptions {
  53972. /**
  53973. * Render width (Default: 512)
  53974. */
  53975. renderWidth: number;
  53976. /**
  53977. * Render height (Default: 256)
  53978. */
  53979. renderHeight: number;
  53980. /**
  53981. * Texture size (Default: 512)
  53982. */
  53983. textureSize: number;
  53984. /**
  53985. * If delta time between frames should be constant
  53986. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53987. */
  53988. deterministicLockstep: boolean;
  53989. /**
  53990. * Maximum about of steps between frames (Default: 4)
  53991. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53992. */
  53993. lockstepMaxSteps: number;
  53994. /**
  53995. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53996. */
  53997. useHighPrecisionMatrix?: boolean;
  53998. }
  53999. /**
  54000. * The null engine class provides support for headless version of babylon.js.
  54001. * This can be used in server side scenario or for testing purposes
  54002. */
  54003. export class NullEngine extends Engine {
  54004. private _options;
  54005. /**
  54006. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54007. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54008. * @returns true if engine is in deterministic lock step mode
  54009. */
  54010. isDeterministicLockStep(): boolean;
  54011. /**
  54012. * Gets the max steps when engine is running in deterministic lock step
  54013. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54014. * @returns the max steps
  54015. */
  54016. getLockstepMaxSteps(): number;
  54017. /**
  54018. * Gets the current hardware scaling level.
  54019. * By default the hardware scaling level is computed from the window device ratio.
  54020. * 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.
  54021. * @returns a number indicating the current hardware scaling level
  54022. */
  54023. getHardwareScalingLevel(): number;
  54024. constructor(options?: NullEngineOptions);
  54025. /**
  54026. * Creates a vertex buffer
  54027. * @param vertices the data for the vertex buffer
  54028. * @returns the new WebGL static buffer
  54029. */
  54030. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54031. /**
  54032. * Creates a new index buffer
  54033. * @param indices defines the content of the index buffer
  54034. * @param updatable defines if the index buffer must be updatable
  54035. * @returns a new webGL buffer
  54036. */
  54037. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54038. /**
  54039. * Clear the current render buffer or the current render target (if any is set up)
  54040. * @param color defines the color to use
  54041. * @param backBuffer defines if the back buffer must be cleared
  54042. * @param depth defines if the depth buffer must be cleared
  54043. * @param stencil defines if the stencil buffer must be cleared
  54044. */
  54045. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54046. /**
  54047. * Gets the current render width
  54048. * @param useScreen defines if screen size must be used (or the current render target if any)
  54049. * @returns a number defining the current render width
  54050. */
  54051. getRenderWidth(useScreen?: boolean): number;
  54052. /**
  54053. * Gets the current render height
  54054. * @param useScreen defines if screen size must be used (or the current render target if any)
  54055. * @returns a number defining the current render height
  54056. */
  54057. getRenderHeight(useScreen?: boolean): number;
  54058. /**
  54059. * Set the WebGL's viewport
  54060. * @param viewport defines the viewport element to be used
  54061. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54062. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54063. */
  54064. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54065. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54066. /**
  54067. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54068. * @param pipelineContext defines the pipeline context to use
  54069. * @param uniformsNames defines the list of uniform names
  54070. * @returns an array of webGL uniform locations
  54071. */
  54072. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54073. /**
  54074. * Gets the lsit of active attributes for a given webGL program
  54075. * @param pipelineContext defines the pipeline context to use
  54076. * @param attributesNames defines the list of attribute names to get
  54077. * @returns an array of indices indicating the offset of each attribute
  54078. */
  54079. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54080. /**
  54081. * Binds an effect to the webGL context
  54082. * @param effect defines the effect to bind
  54083. */
  54084. bindSamplers(effect: Effect): void;
  54085. /**
  54086. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54087. * @param effect defines the effect to activate
  54088. */
  54089. enableEffect(effect: Effect): void;
  54090. /**
  54091. * Set various states to the webGL context
  54092. * @param culling defines backface culling state
  54093. * @param zOffset defines the value to apply to zOffset (0 by default)
  54094. * @param force defines if states must be applied even if cache is up to date
  54095. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54096. */
  54097. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54098. /**
  54099. * Set the value of an uniform to an array of int32
  54100. * @param uniform defines the webGL uniform location where to store the value
  54101. * @param array defines the array of int32 to store
  54102. * @returns true if value was set
  54103. */
  54104. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54105. /**
  54106. * Set the value of an uniform to an array of int32 (stored as vec2)
  54107. * @param uniform defines the webGL uniform location where to store the value
  54108. * @param array defines the array of int32 to store
  54109. * @returns true if value was set
  54110. */
  54111. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54112. /**
  54113. * Set the value of an uniform to an array of int32 (stored as vec3)
  54114. * @param uniform defines the webGL uniform location where to store the value
  54115. * @param array defines the array of int32 to store
  54116. * @returns true if value was set
  54117. */
  54118. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54119. /**
  54120. * Set the value of an uniform to an array of int32 (stored as vec4)
  54121. * @param uniform defines the webGL uniform location where to store the value
  54122. * @param array defines the array of int32 to store
  54123. * @returns true if value was set
  54124. */
  54125. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54126. /**
  54127. * Set the value of an uniform to an array of float32
  54128. * @param uniform defines the webGL uniform location where to store the value
  54129. * @param array defines the array of float32 to store
  54130. * @returns true if value was set
  54131. */
  54132. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54133. /**
  54134. * Set the value of an uniform to an array of float32 (stored as vec2)
  54135. * @param uniform defines the webGL uniform location where to store the value
  54136. * @param array defines the array of float32 to store
  54137. * @returns true if value was set
  54138. */
  54139. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54140. /**
  54141. * Set the value of an uniform to an array of float32 (stored as vec3)
  54142. * @param uniform defines the webGL uniform location where to store the value
  54143. * @param array defines the array of float32 to store
  54144. * @returns true if value was set
  54145. */
  54146. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54147. /**
  54148. * Set the value of an uniform to an array of float32 (stored as vec4)
  54149. * @param uniform defines the webGL uniform location where to store the value
  54150. * @param array defines the array of float32 to store
  54151. * @returns true if value was set
  54152. */
  54153. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54154. /**
  54155. * Set the value of an uniform to an array of number
  54156. * @param uniform defines the webGL uniform location where to store the value
  54157. * @param array defines the array of number to store
  54158. * @returns true if value was set
  54159. */
  54160. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54161. /**
  54162. * Set the value of an uniform to an array of number (stored as vec2)
  54163. * @param uniform defines the webGL uniform location where to store the value
  54164. * @param array defines the array of number to store
  54165. * @returns true if value was set
  54166. */
  54167. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54168. /**
  54169. * Set the value of an uniform to an array of number (stored as vec3)
  54170. * @param uniform defines the webGL uniform location where to store the value
  54171. * @param array defines the array of number to store
  54172. * @returns true if value was set
  54173. */
  54174. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54175. /**
  54176. * Set the value of an uniform to an array of number (stored as vec4)
  54177. * @param uniform defines the webGL uniform location where to store the value
  54178. * @param array defines the array of number to store
  54179. * @returns true if value was set
  54180. */
  54181. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54182. /**
  54183. * Set the value of an uniform to an array of float32 (stored as matrices)
  54184. * @param uniform defines the webGL uniform location where to store the value
  54185. * @param matrices defines the array of float32 to store
  54186. * @returns true if value was set
  54187. */
  54188. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54189. /**
  54190. * Set the value of an uniform to a matrix (3x3)
  54191. * @param uniform defines the webGL uniform location where to store the value
  54192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54193. * @returns true if value was set
  54194. */
  54195. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54196. /**
  54197. * Set the value of an uniform to a matrix (2x2)
  54198. * @param uniform defines the webGL uniform location where to store the value
  54199. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54200. * @returns true if value was set
  54201. */
  54202. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54203. /**
  54204. * Set the value of an uniform to a number (float)
  54205. * @param uniform defines the webGL uniform location where to store the value
  54206. * @param value defines the float number to store
  54207. * @returns true if value was set
  54208. */
  54209. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54210. /**
  54211. * Set the value of an uniform to a vec2
  54212. * @param uniform defines the webGL uniform location where to store the value
  54213. * @param x defines the 1st component of the value
  54214. * @param y defines the 2nd component of the value
  54215. * @returns true if value was set
  54216. */
  54217. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54218. /**
  54219. * Set the value of an uniform to a vec3
  54220. * @param uniform defines the webGL uniform location where to store the value
  54221. * @param x defines the 1st component of the value
  54222. * @param y defines the 2nd component of the value
  54223. * @param z defines the 3rd component of the value
  54224. * @returns true if value was set
  54225. */
  54226. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54227. /**
  54228. * Set the value of an uniform to a boolean
  54229. * @param uniform defines the webGL uniform location where to store the value
  54230. * @param bool defines the boolean to store
  54231. * @returns true if value was set
  54232. */
  54233. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54234. /**
  54235. * Set the value of an uniform to a vec4
  54236. * @param uniform defines the webGL uniform location where to store the value
  54237. * @param x defines the 1st component of the value
  54238. * @param y defines the 2nd component of the value
  54239. * @param z defines the 3rd component of the value
  54240. * @param w defines the 4th component of the value
  54241. * @returns true if value was set
  54242. */
  54243. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54244. /**
  54245. * Sets the current alpha mode
  54246. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54247. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54248. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54249. */
  54250. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54251. /**
  54252. * Bind webGl buffers directly to the webGL context
  54253. * @param vertexBuffers defines the vertex buffer to bind
  54254. * @param indexBuffer defines the index buffer to bind
  54255. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54256. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54257. * @param effect defines the effect associated with the vertex buffer
  54258. */
  54259. bindBuffers(vertexBuffers: {
  54260. [key: string]: VertexBuffer;
  54261. }, indexBuffer: DataBuffer, effect: Effect): void;
  54262. /**
  54263. * Force the entire cache to be cleared
  54264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54266. */
  54267. wipeCaches(bruteForce?: boolean): void;
  54268. /**
  54269. * Send a draw order
  54270. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54271. * @param indexStart defines the starting index
  54272. * @param indexCount defines the number of index to draw
  54273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54274. */
  54275. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54276. /**
  54277. * Draw a list of indexed primitives
  54278. * @param fillMode defines the primitive to use
  54279. * @param indexStart defines the starting index
  54280. * @param indexCount defines the number of index to draw
  54281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54282. */
  54283. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54284. /**
  54285. * Draw a list of unindexed primitives
  54286. * @param fillMode defines the primitive to use
  54287. * @param verticesStart defines the index of first vertex to draw
  54288. * @param verticesCount defines the count of vertices to draw
  54289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54290. */
  54291. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54292. /** @hidden */
  54293. _createTexture(): WebGLTexture;
  54294. /** @hidden */
  54295. _releaseTexture(texture: InternalTexture): void;
  54296. /**
  54297. * Usually called from Texture.ts.
  54298. * Passed information to create a WebGLTexture
  54299. * @param urlArg defines a value which contains one of the following:
  54300. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54301. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54302. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54303. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54304. * @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)
  54305. * @param scene needed for loading to the correct scene
  54306. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54307. * @param onLoad optional callback to be called upon successful completion
  54308. * @param onError optional callback to be called upon failure
  54309. * @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
  54310. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54311. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54312. * @param forcedExtension defines the extension to use to pick the right loader
  54313. * @param mimeType defines an optional mime type
  54314. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54315. */
  54316. 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;
  54317. /**
  54318. * Creates a new render target texture
  54319. * @param size defines the size of the texture
  54320. * @param options defines the options used to create the texture
  54321. * @returns a new render target texture stored in an InternalTexture
  54322. */
  54323. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54324. /**
  54325. * Update the sampling mode of a given texture
  54326. * @param samplingMode defines the required sampling mode
  54327. * @param texture defines the texture to update
  54328. */
  54329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54330. /**
  54331. * Binds the frame buffer to the specified texture.
  54332. * @param texture The texture to render to or null for the default canvas
  54333. * @param faceIndex The face of the texture to render to in case of cube texture
  54334. * @param requiredWidth The width of the target to render to
  54335. * @param requiredHeight The height of the target to render to
  54336. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54337. * @param lodLevel defines le lod level to bind to the frame buffer
  54338. */
  54339. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54340. /**
  54341. * Unbind the current render target texture from the webGL context
  54342. * @param texture defines the render target texture to unbind
  54343. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54344. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54345. */
  54346. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54347. /**
  54348. * Creates a dynamic vertex buffer
  54349. * @param vertices the data for the dynamic vertex buffer
  54350. * @returns the new WebGL dynamic buffer
  54351. */
  54352. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54353. /**
  54354. * Update the content of a dynamic texture
  54355. * @param texture defines the texture to update
  54356. * @param canvas defines the canvas containing the source
  54357. * @param invertY defines if data must be stored with Y axis inverted
  54358. * @param premulAlpha defines if alpha is stored as premultiplied
  54359. * @param format defines the format of the data
  54360. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54361. */
  54362. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54363. /**
  54364. * Gets a boolean indicating if all created effects are ready
  54365. * @returns true if all effects are ready
  54366. */
  54367. areAllEffectsReady(): boolean;
  54368. /**
  54369. * @hidden
  54370. * Get the current error code of the webGL context
  54371. * @returns the error code
  54372. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54373. */
  54374. getError(): number;
  54375. /** @hidden */
  54376. _getUnpackAlignement(): number;
  54377. /** @hidden */
  54378. _unpackFlipY(value: boolean): void;
  54379. /**
  54380. * Update a dynamic index buffer
  54381. * @param indexBuffer defines the target index buffer
  54382. * @param indices defines the data to update
  54383. * @param offset defines the offset in the target index buffer where update should start
  54384. */
  54385. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54386. /**
  54387. * Updates a dynamic vertex buffer.
  54388. * @param vertexBuffer the vertex buffer to update
  54389. * @param vertices the data used to update the vertex buffer
  54390. * @param byteOffset the byte offset of the data (optional)
  54391. * @param byteLength the byte length of the data (optional)
  54392. */
  54393. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54394. /** @hidden */
  54395. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54396. /** @hidden */
  54397. _bindTexture(channel: number, texture: InternalTexture): void;
  54398. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54399. /**
  54400. * 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
  54401. */
  54402. releaseEffects(): void;
  54403. displayLoadingUI(): void;
  54404. hideLoadingUI(): void;
  54405. /** @hidden */
  54406. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54407. /** @hidden */
  54408. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54409. /** @hidden */
  54410. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54411. /** @hidden */
  54412. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54413. }
  54414. }
  54415. declare module "babylonjs/Instrumentation/timeToken" {
  54416. import { Nullable } from "babylonjs/types";
  54417. /**
  54418. * @hidden
  54419. **/
  54420. export class _TimeToken {
  54421. _startTimeQuery: Nullable<WebGLQuery>;
  54422. _endTimeQuery: Nullable<WebGLQuery>;
  54423. _timeElapsedQuery: Nullable<WebGLQuery>;
  54424. _timeElapsedQueryEnded: boolean;
  54425. }
  54426. }
  54427. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54428. import { Nullable, int } from "babylonjs/types";
  54429. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54430. /** @hidden */
  54431. export class _OcclusionDataStorage {
  54432. /** @hidden */
  54433. occlusionInternalRetryCounter: number;
  54434. /** @hidden */
  54435. isOcclusionQueryInProgress: boolean;
  54436. /** @hidden */
  54437. isOccluded: boolean;
  54438. /** @hidden */
  54439. occlusionRetryCount: number;
  54440. /** @hidden */
  54441. occlusionType: number;
  54442. /** @hidden */
  54443. occlusionQueryAlgorithmType: number;
  54444. }
  54445. module "babylonjs/Engines/engine" {
  54446. interface Engine {
  54447. /**
  54448. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54449. * @return the new query
  54450. */
  54451. createQuery(): WebGLQuery;
  54452. /**
  54453. * Delete and release a webGL query
  54454. * @param query defines the query to delete
  54455. * @return the current engine
  54456. */
  54457. deleteQuery(query: WebGLQuery): Engine;
  54458. /**
  54459. * Check if a given query has resolved and got its value
  54460. * @param query defines the query to check
  54461. * @returns true if the query got its value
  54462. */
  54463. isQueryResultAvailable(query: WebGLQuery): boolean;
  54464. /**
  54465. * Gets the value of a given query
  54466. * @param query defines the query to check
  54467. * @returns the value of the query
  54468. */
  54469. getQueryResult(query: WebGLQuery): number;
  54470. /**
  54471. * Initiates an occlusion query
  54472. * @param algorithmType defines the algorithm to use
  54473. * @param query defines the query to use
  54474. * @returns the current engine
  54475. * @see https://doc.babylonjs.com/features/occlusionquery
  54476. */
  54477. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54478. /**
  54479. * Ends an occlusion query
  54480. * @see https://doc.babylonjs.com/features/occlusionquery
  54481. * @param algorithmType defines the algorithm to use
  54482. * @returns the current engine
  54483. */
  54484. endOcclusionQuery(algorithmType: number): Engine;
  54485. /**
  54486. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54487. * Please note that only one query can be issued at a time
  54488. * @returns a time token used to track the time span
  54489. */
  54490. startTimeQuery(): Nullable<_TimeToken>;
  54491. /**
  54492. * Ends a time query
  54493. * @param token defines the token used to measure the time span
  54494. * @returns the time spent (in ns)
  54495. */
  54496. endTimeQuery(token: _TimeToken): int;
  54497. /** @hidden */
  54498. _currentNonTimestampToken: Nullable<_TimeToken>;
  54499. /** @hidden */
  54500. _createTimeQuery(): WebGLQuery;
  54501. /** @hidden */
  54502. _deleteTimeQuery(query: WebGLQuery): void;
  54503. /** @hidden */
  54504. _getGlAlgorithmType(algorithmType: number): number;
  54505. /** @hidden */
  54506. _getTimeQueryResult(query: WebGLQuery): any;
  54507. /** @hidden */
  54508. _getTimeQueryAvailability(query: WebGLQuery): any;
  54509. }
  54510. }
  54511. module "babylonjs/Meshes/abstractMesh" {
  54512. interface AbstractMesh {
  54513. /**
  54514. * Backing filed
  54515. * @hidden
  54516. */
  54517. __occlusionDataStorage: _OcclusionDataStorage;
  54518. /**
  54519. * Access property
  54520. * @hidden
  54521. */
  54522. _occlusionDataStorage: _OcclusionDataStorage;
  54523. /**
  54524. * 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.
  54525. * The default value is -1 which means don't break the query and wait till the result
  54526. * @see https://doc.babylonjs.com/features/occlusionquery
  54527. */
  54528. occlusionRetryCount: number;
  54529. /**
  54530. * 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:
  54531. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54532. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54533. * * 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.
  54534. * @see https://doc.babylonjs.com/features/occlusionquery
  54535. */
  54536. occlusionType: number;
  54537. /**
  54538. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54539. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54540. * * 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.
  54541. * @see https://doc.babylonjs.com/features/occlusionquery
  54542. */
  54543. occlusionQueryAlgorithmType: number;
  54544. /**
  54545. * 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
  54546. * @see https://doc.babylonjs.com/features/occlusionquery
  54547. */
  54548. isOccluded: boolean;
  54549. /**
  54550. * Flag to check the progress status of the query
  54551. * @see https://doc.babylonjs.com/features/occlusionquery
  54552. */
  54553. isOcclusionQueryInProgress: boolean;
  54554. }
  54555. }
  54556. }
  54557. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54558. import { Nullable } from "babylonjs/types";
  54559. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54560. /** @hidden */
  54561. export var _forceTransformFeedbackToBundle: boolean;
  54562. module "babylonjs/Engines/engine" {
  54563. interface Engine {
  54564. /**
  54565. * Creates a webGL transform feedback object
  54566. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54567. * @returns the webGL transform feedback object
  54568. */
  54569. createTransformFeedback(): WebGLTransformFeedback;
  54570. /**
  54571. * Delete a webGL transform feedback object
  54572. * @param value defines the webGL transform feedback object to delete
  54573. */
  54574. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54575. /**
  54576. * Bind a webGL transform feedback object to the webgl context
  54577. * @param value defines the webGL transform feedback object to bind
  54578. */
  54579. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54580. /**
  54581. * Begins a transform feedback operation
  54582. * @param usePoints defines if points or triangles must be used
  54583. */
  54584. beginTransformFeedback(usePoints: boolean): void;
  54585. /**
  54586. * Ends a transform feedback operation
  54587. */
  54588. endTransformFeedback(): void;
  54589. /**
  54590. * Specify the varyings to use with transform feedback
  54591. * @param program defines the associated webGL program
  54592. * @param value defines the list of strings representing the varying names
  54593. */
  54594. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54595. /**
  54596. * Bind a webGL buffer for a transform feedback operation
  54597. * @param value defines the webGL buffer to bind
  54598. */
  54599. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54600. }
  54601. }
  54602. }
  54603. declare module "babylonjs/Engines/Extensions/engine.views" {
  54604. import { Camera } from "babylonjs/Cameras/camera";
  54605. import { Nullable } from "babylonjs/types";
  54606. /**
  54607. * Class used to define an additional view for the engine
  54608. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54609. */
  54610. export class EngineView {
  54611. /** Defines the canvas where to render the view */
  54612. target: HTMLCanvasElement;
  54613. /** Defines an optional camera used to render the view (will use active camera else) */
  54614. camera?: Camera;
  54615. }
  54616. module "babylonjs/Engines/engine" {
  54617. interface Engine {
  54618. /**
  54619. * Gets or sets the HTML element to use for attaching events
  54620. */
  54621. inputElement: Nullable<HTMLElement>;
  54622. /**
  54623. * Gets the current engine view
  54624. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54625. */
  54626. activeView: Nullable<EngineView>;
  54627. /** Gets or sets the list of views */
  54628. views: EngineView[];
  54629. /**
  54630. * Register a new child canvas
  54631. * @param canvas defines the canvas to register
  54632. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54633. * @returns the associated view
  54634. */
  54635. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54636. /**
  54637. * Remove a registered child canvas
  54638. * @param canvas defines the canvas to remove
  54639. * @returns the current engine
  54640. */
  54641. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54642. }
  54643. }
  54644. }
  54645. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54646. import { Nullable } from "babylonjs/types";
  54647. module "babylonjs/Engines/engine" {
  54648. interface Engine {
  54649. /** @hidden */
  54650. _excludedCompressedTextures: string[];
  54651. /** @hidden */
  54652. _textureFormatInUse: string;
  54653. /**
  54654. * Gets the list of texture formats supported
  54655. */
  54656. readonly texturesSupported: Array<string>;
  54657. /**
  54658. * Gets the texture format in use
  54659. */
  54660. readonly textureFormatInUse: Nullable<string>;
  54661. /**
  54662. * Set the compressed texture extensions or file names to skip.
  54663. *
  54664. * @param skippedFiles defines the list of those texture files you want to skip
  54665. * Example: [".dds", ".env", "myfile.png"]
  54666. */
  54667. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54668. /**
  54669. * Set the compressed texture format to use, based on the formats you have, and the formats
  54670. * supported by the hardware / browser.
  54671. *
  54672. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54673. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54674. * to API arguments needed to compressed textures. This puts the burden on the container
  54675. * generator to house the arcane code for determining these for current & future formats.
  54676. *
  54677. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54678. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54679. *
  54680. * Note: The result of this call is not taken into account when a texture is base64.
  54681. *
  54682. * @param formatsAvailable defines the list of those format families you have created
  54683. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54684. *
  54685. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54686. * @returns The extension selected.
  54687. */
  54688. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54689. }
  54690. }
  54691. }
  54692. declare module "babylonjs/Engines/Extensions/index" {
  54693. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54694. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54695. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54696. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54697. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54698. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54699. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54700. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54701. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54702. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54703. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54704. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54705. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54706. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54707. export * from "babylonjs/Engines/Extensions/engine.views";
  54708. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54709. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54710. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54711. }
  54712. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54713. import { Nullable } from "babylonjs/types";
  54714. /**
  54715. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54716. */
  54717. export interface CubeMapInfo {
  54718. /**
  54719. * The pixel array for the front face.
  54720. * This is stored in format, left to right, up to down format.
  54721. */
  54722. front: Nullable<ArrayBufferView>;
  54723. /**
  54724. * The pixel array for the back face.
  54725. * This is stored in format, left to right, up to down format.
  54726. */
  54727. back: Nullable<ArrayBufferView>;
  54728. /**
  54729. * The pixel array for the left face.
  54730. * This is stored in format, left to right, up to down format.
  54731. */
  54732. left: Nullable<ArrayBufferView>;
  54733. /**
  54734. * The pixel array for the right face.
  54735. * This is stored in format, left to right, up to down format.
  54736. */
  54737. right: Nullable<ArrayBufferView>;
  54738. /**
  54739. * The pixel array for the up face.
  54740. * This is stored in format, left to right, up to down format.
  54741. */
  54742. up: Nullable<ArrayBufferView>;
  54743. /**
  54744. * The pixel array for the down face.
  54745. * This is stored in format, left to right, up to down format.
  54746. */
  54747. down: Nullable<ArrayBufferView>;
  54748. /**
  54749. * The size of the cubemap stored.
  54750. *
  54751. * Each faces will be size * size pixels.
  54752. */
  54753. size: number;
  54754. /**
  54755. * The format of the texture.
  54756. *
  54757. * RGBA, RGB.
  54758. */
  54759. format: number;
  54760. /**
  54761. * The type of the texture data.
  54762. *
  54763. * UNSIGNED_INT, FLOAT.
  54764. */
  54765. type: number;
  54766. /**
  54767. * Specifies whether the texture is in gamma space.
  54768. */
  54769. gammaSpace: boolean;
  54770. }
  54771. /**
  54772. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54773. */
  54774. export class PanoramaToCubeMapTools {
  54775. private static FACE_LEFT;
  54776. private static FACE_RIGHT;
  54777. private static FACE_FRONT;
  54778. private static FACE_BACK;
  54779. private static FACE_DOWN;
  54780. private static FACE_UP;
  54781. /**
  54782. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54783. *
  54784. * @param float32Array The source data.
  54785. * @param inputWidth The width of the input panorama.
  54786. * @param inputHeight The height of the input panorama.
  54787. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54788. * @return The cubemap data
  54789. */
  54790. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54791. private static CreateCubemapTexture;
  54792. private static CalcProjectionSpherical;
  54793. }
  54794. }
  54795. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54796. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54798. import { Nullable } from "babylonjs/types";
  54799. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54800. /**
  54801. * Helper class dealing with the extraction of spherical polynomial dataArray
  54802. * from a cube map.
  54803. */
  54804. export class CubeMapToSphericalPolynomialTools {
  54805. private static FileFaces;
  54806. /**
  54807. * Converts a texture to the according Spherical Polynomial data.
  54808. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54809. *
  54810. * @param texture The texture to extract the information from.
  54811. * @return The Spherical Polynomial data.
  54812. */
  54813. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54814. /**
  54815. * Converts a cubemap to the according Spherical Polynomial data.
  54816. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54817. *
  54818. * @param cubeInfo The Cube map to extract the information from.
  54819. * @return The Spherical Polynomial data.
  54820. */
  54821. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54822. }
  54823. }
  54824. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54825. import { Nullable } from "babylonjs/types";
  54826. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54827. module "babylonjs/Materials/Textures/baseTexture" {
  54828. interface BaseTexture {
  54829. /**
  54830. * Get the polynomial representation of the texture data.
  54831. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54832. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54833. */
  54834. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54835. }
  54836. }
  54837. }
  54838. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54840. /** @hidden */
  54841. export var rgbdEncodePixelShader: {
  54842. name: string;
  54843. shader: string;
  54844. };
  54845. }
  54846. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54848. /** @hidden */
  54849. export var rgbdDecodePixelShader: {
  54850. name: string;
  54851. shader: string;
  54852. };
  54853. }
  54854. declare module "babylonjs/Misc/environmentTextureTools" {
  54855. import { Nullable } from "babylonjs/types";
  54856. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54859. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54860. import "babylonjs/Engines/Extensions/engine.readTexture";
  54861. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54862. import "babylonjs/Shaders/rgbdEncode.fragment";
  54863. import "babylonjs/Shaders/rgbdDecode.fragment";
  54864. /**
  54865. * Raw texture data and descriptor sufficient for WebGL texture upload
  54866. */
  54867. export interface EnvironmentTextureInfo {
  54868. /**
  54869. * Version of the environment map
  54870. */
  54871. version: number;
  54872. /**
  54873. * Width of image
  54874. */
  54875. width: number;
  54876. /**
  54877. * Irradiance information stored in the file.
  54878. */
  54879. irradiance: any;
  54880. /**
  54881. * Specular information stored in the file.
  54882. */
  54883. specular: any;
  54884. }
  54885. /**
  54886. * Defines One Image in the file. It requires only the position in the file
  54887. * as well as the length.
  54888. */
  54889. interface BufferImageData {
  54890. /**
  54891. * Length of the image data.
  54892. */
  54893. length: number;
  54894. /**
  54895. * Position of the data from the null terminator delimiting the end of the JSON.
  54896. */
  54897. position: number;
  54898. }
  54899. /**
  54900. * Defines the specular data enclosed in the file.
  54901. * This corresponds to the version 1 of the data.
  54902. */
  54903. export interface EnvironmentTextureSpecularInfoV1 {
  54904. /**
  54905. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54906. */
  54907. specularDataPosition?: number;
  54908. /**
  54909. * This contains all the images data needed to reconstruct the cubemap.
  54910. */
  54911. mipmaps: Array<BufferImageData>;
  54912. /**
  54913. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54914. */
  54915. lodGenerationScale: number;
  54916. }
  54917. /**
  54918. * Sets of helpers addressing the serialization and deserialization of environment texture
  54919. * stored in a BabylonJS env file.
  54920. * Those files are usually stored as .env files.
  54921. */
  54922. export class EnvironmentTextureTools {
  54923. /**
  54924. * Magic number identifying the env file.
  54925. */
  54926. private static _MagicBytes;
  54927. /**
  54928. * Gets the environment info from an env file.
  54929. * @param data The array buffer containing the .env bytes.
  54930. * @returns the environment file info (the json header) if successfully parsed.
  54931. */
  54932. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54933. /**
  54934. * Creates an environment texture from a loaded cube texture.
  54935. * @param texture defines the cube texture to convert in env file
  54936. * @return a promise containing the environment data if succesfull.
  54937. */
  54938. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54939. /**
  54940. * Creates a JSON representation of the spherical data.
  54941. * @param texture defines the texture containing the polynomials
  54942. * @return the JSON representation of the spherical info
  54943. */
  54944. private static _CreateEnvTextureIrradiance;
  54945. /**
  54946. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54947. * @param data the image data
  54948. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54949. * @return the views described by info providing access to the underlying buffer
  54950. */
  54951. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54952. /**
  54953. * Uploads the texture info contained in the env file to the GPU.
  54954. * @param texture defines the internal texture to upload to
  54955. * @param data defines the data to load
  54956. * @param info defines the texture info retrieved through the GetEnvInfo method
  54957. * @returns a promise
  54958. */
  54959. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54960. private static _OnImageReadyAsync;
  54961. /**
  54962. * Uploads the levels of image data to the GPU.
  54963. * @param texture defines the internal texture to upload to
  54964. * @param imageData defines the array buffer views of image data [mipmap][face]
  54965. * @returns a promise
  54966. */
  54967. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54968. /**
  54969. * Uploads spherical polynomials information to the texture.
  54970. * @param texture defines the texture we are trying to upload the information to
  54971. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54972. */
  54973. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54974. /** @hidden */
  54975. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54976. }
  54977. }
  54978. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54979. /**
  54980. * Class used to inline functions in shader code
  54981. */
  54982. export class ShaderCodeInliner {
  54983. private static readonly _RegexpFindFunctionNameAndType;
  54984. private _sourceCode;
  54985. private _functionDescr;
  54986. private _numMaxIterations;
  54987. /** Gets or sets the token used to mark the functions to inline */
  54988. inlineToken: string;
  54989. /** Gets or sets the debug mode */
  54990. debug: boolean;
  54991. /** Gets the code after the inlining process */
  54992. get code(): string;
  54993. /**
  54994. * Initializes the inliner
  54995. * @param sourceCode shader code source to inline
  54996. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54997. */
  54998. constructor(sourceCode: string, numMaxIterations?: number);
  54999. /**
  55000. * Start the processing of the shader code
  55001. */
  55002. processCode(): void;
  55003. private _collectFunctions;
  55004. private _processInlining;
  55005. private _extractBetweenMarkers;
  55006. private _skipWhitespaces;
  55007. private _removeComments;
  55008. private _replaceFunctionCallsByCode;
  55009. private _findBackward;
  55010. private _escapeRegExp;
  55011. private _replaceNames;
  55012. }
  55013. }
  55014. declare module "babylonjs/Engines/nativeEngine" {
  55015. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55016. import { Engine } from "babylonjs/Engines/engine";
  55017. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55018. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55020. import { Effect } from "babylonjs/Materials/effect";
  55021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55022. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55023. import { IColor4Like } from "babylonjs/Maths/math.like";
  55024. import { Scene } from "babylonjs/scene";
  55025. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55026. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55027. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55028. /**
  55029. * Container for accessors for natively-stored mesh data buffers.
  55030. */
  55031. class NativeDataBuffer extends DataBuffer {
  55032. /**
  55033. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55034. */
  55035. nativeIndexBuffer?: any;
  55036. /**
  55037. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55038. */
  55039. nativeVertexBuffer?: any;
  55040. }
  55041. /** @hidden */
  55042. class NativeTexture extends InternalTexture {
  55043. getInternalTexture(): InternalTexture;
  55044. getViewCount(): number;
  55045. }
  55046. /** @hidden */
  55047. export class NativeEngine extends Engine {
  55048. private readonly _native;
  55049. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55050. private readonly INVALID_HANDLE;
  55051. private _boundBuffersVertexArray;
  55052. private _currentDepthTest;
  55053. getHardwareScalingLevel(): number;
  55054. constructor();
  55055. dispose(): void;
  55056. /**
  55057. * Can be used to override the current requestAnimationFrame requester.
  55058. * @hidden
  55059. */
  55060. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55061. /**
  55062. * Override default engine behavior.
  55063. * @param color
  55064. * @param backBuffer
  55065. * @param depth
  55066. * @param stencil
  55067. */
  55068. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55069. /**
  55070. * Gets host document
  55071. * @returns the host document object
  55072. */
  55073. getHostDocument(): Nullable<Document>;
  55074. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55075. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55076. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55077. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55078. [key: string]: VertexBuffer;
  55079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55080. bindBuffers(vertexBuffers: {
  55081. [key: string]: VertexBuffer;
  55082. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55083. recordVertexArrayObject(vertexBuffers: {
  55084. [key: string]: VertexBuffer;
  55085. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55086. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55087. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55088. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55089. /**
  55090. * Draw a list of indexed primitives
  55091. * @param fillMode defines the primitive to use
  55092. * @param indexStart defines the starting index
  55093. * @param indexCount defines the number of index to draw
  55094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55095. */
  55096. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55097. /**
  55098. * Draw a list of unindexed primitives
  55099. * @param fillMode defines the primitive to use
  55100. * @param verticesStart defines the index of first vertex to draw
  55101. * @param verticesCount defines the count of vertices to draw
  55102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55103. */
  55104. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55105. createPipelineContext(): IPipelineContext;
  55106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55107. /** @hidden */
  55108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55109. /** @hidden */
  55110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55111. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55112. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55113. protected _setProgram(program: WebGLProgram): void;
  55114. _releaseEffect(effect: Effect): void;
  55115. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55117. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55118. bindSamplers(effect: Effect): void;
  55119. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55120. getRenderWidth(useScreen?: boolean): number;
  55121. getRenderHeight(useScreen?: boolean): number;
  55122. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55124. /**
  55125. * Set the z offset to apply to current rendering
  55126. * @param value defines the offset to apply
  55127. */
  55128. setZOffset(value: number): void;
  55129. /**
  55130. * Gets the current value of the zOffset
  55131. * @returns the current zOffset state
  55132. */
  55133. getZOffset(): number;
  55134. /**
  55135. * Enable or disable depth buffering
  55136. * @param enable defines the state to set
  55137. */
  55138. setDepthBuffer(enable: boolean): void;
  55139. /**
  55140. * Gets a boolean indicating if depth writing is enabled
  55141. * @returns the current depth writing state
  55142. */
  55143. getDepthWrite(): boolean;
  55144. setDepthFunctionToGreater(): void;
  55145. setDepthFunctionToGreaterOrEqual(): void;
  55146. setDepthFunctionToLess(): void;
  55147. setDepthFunctionToLessOrEqual(): void;
  55148. /**
  55149. * Enable or disable depth writing
  55150. * @param enable defines the state to set
  55151. */
  55152. setDepthWrite(enable: boolean): void;
  55153. /**
  55154. * Enable or disable color writing
  55155. * @param enable defines the state to set
  55156. */
  55157. setColorWrite(enable: boolean): void;
  55158. /**
  55159. * Gets a boolean indicating if color writing is enabled
  55160. * @returns the current color writing state
  55161. */
  55162. getColorWrite(): boolean;
  55163. /**
  55164. * Sets alpha constants used by some alpha blending modes
  55165. * @param r defines the red component
  55166. * @param g defines the green component
  55167. * @param b defines the blue component
  55168. * @param a defines the alpha component
  55169. */
  55170. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55171. /**
  55172. * Sets the current alpha mode
  55173. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55174. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55175. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55176. */
  55177. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55178. /**
  55179. * Gets the current alpha mode
  55180. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55181. * @returns the current alpha mode
  55182. */
  55183. getAlphaMode(): number;
  55184. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55185. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55186. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55187. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55188. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55189. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55190. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55191. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55192. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55193. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55194. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55195. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55196. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55197. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55198. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55199. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55200. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55201. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55204. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55205. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55206. wipeCaches(bruteForce?: boolean): void;
  55207. _createTexture(): WebGLTexture;
  55208. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55209. /**
  55210. * Usually called from Texture.ts.
  55211. * Passed information to create a WebGLTexture
  55212. * @param url defines a value which contains one of the following:
  55213. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55214. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55215. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55216. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55217. * @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)
  55218. * @param scene needed for loading to the correct scene
  55219. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55220. * @param onLoad optional callback to be called upon successful completion
  55221. * @param onError optional callback to be called upon failure
  55222. * @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
  55223. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55224. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55225. * @param forcedExtension defines the extension to use to pick the right loader
  55226. * @param mimeType defines an optional mime type
  55227. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55228. */
  55229. 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;
  55230. /**
  55231. * Creates a cube texture
  55232. * @param rootUrl defines the url where the files to load is located
  55233. * @param scene defines the current scene
  55234. * @param files defines the list of files to load (1 per face)
  55235. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55236. * @param onLoad defines an optional callback raised when the texture is loaded
  55237. * @param onError defines an optional callback raised if there is an issue to load the texture
  55238. * @param format defines the format of the data
  55239. * @param forcedExtension defines the extension to use to pick the right loader
  55240. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55241. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55242. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55243. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55244. * @returns the cube texture as an InternalTexture
  55245. */
  55246. 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;
  55247. private _getSamplingFilter;
  55248. private static _GetNativeTextureFormat;
  55249. createRenderTargetTexture(size: number | {
  55250. width: number;
  55251. height: number;
  55252. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55253. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55254. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55255. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55256. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55257. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55258. /**
  55259. * Updates a dynamic vertex buffer.
  55260. * @param vertexBuffer the vertex buffer to update
  55261. * @param data the data used to update the vertex buffer
  55262. * @param byteOffset the byte offset of the data (optional)
  55263. * @param byteLength the byte length of the data (optional)
  55264. */
  55265. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55266. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55267. private _updateAnisotropicLevel;
  55268. private _getAddressMode;
  55269. /** @hidden */
  55270. _bindTexture(channel: number, texture: InternalTexture): void;
  55271. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55272. releaseEffects(): void;
  55273. /** @hidden */
  55274. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55275. /** @hidden */
  55276. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55277. /** @hidden */
  55278. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55279. /** @hidden */
  55280. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Engines/index" {
  55284. export * from "babylonjs/Engines/constants";
  55285. export * from "babylonjs/Engines/engineCapabilities";
  55286. export * from "babylonjs/Engines/instancingAttributeInfo";
  55287. export * from "babylonjs/Engines/thinEngine";
  55288. export * from "babylonjs/Engines/engine";
  55289. export * from "babylonjs/Engines/engineStore";
  55290. export * from "babylonjs/Engines/nullEngine";
  55291. export * from "babylonjs/Engines/Extensions/index";
  55292. export * from "babylonjs/Engines/IPipelineContext";
  55293. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55294. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55295. export * from "babylonjs/Engines/nativeEngine";
  55296. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55297. export * from "babylonjs/Engines/performanceConfigurator";
  55298. }
  55299. declare module "babylonjs/Events/clipboardEvents" {
  55300. /**
  55301. * Gather the list of clipboard event types as constants.
  55302. */
  55303. export class ClipboardEventTypes {
  55304. /**
  55305. * The clipboard event is fired when a copy command is active (pressed).
  55306. */
  55307. static readonly COPY: number;
  55308. /**
  55309. * The clipboard event is fired when a cut command is active (pressed).
  55310. */
  55311. static readonly CUT: number;
  55312. /**
  55313. * The clipboard event is fired when a paste command is active (pressed).
  55314. */
  55315. static readonly PASTE: number;
  55316. }
  55317. /**
  55318. * This class is used to store clipboard related info for the onClipboardObservable event.
  55319. */
  55320. export class ClipboardInfo {
  55321. /**
  55322. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55323. */
  55324. type: number;
  55325. /**
  55326. * Defines the related dom event
  55327. */
  55328. event: ClipboardEvent;
  55329. /**
  55330. *Creates an instance of ClipboardInfo.
  55331. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55332. * @param event Defines the related dom event
  55333. */
  55334. constructor(
  55335. /**
  55336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55337. */
  55338. type: number,
  55339. /**
  55340. * Defines the related dom event
  55341. */
  55342. event: ClipboardEvent);
  55343. /**
  55344. * Get the clipboard event's type from the keycode.
  55345. * @param keyCode Defines the keyCode for the current keyboard event.
  55346. * @return {number}
  55347. */
  55348. static GetTypeFromCharacter(keyCode: number): number;
  55349. }
  55350. }
  55351. declare module "babylonjs/Events/index" {
  55352. export * from "babylonjs/Events/keyboardEvents";
  55353. export * from "babylonjs/Events/pointerEvents";
  55354. export * from "babylonjs/Events/clipboardEvents";
  55355. }
  55356. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55357. import { Scene } from "babylonjs/scene";
  55358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55359. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55360. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55361. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55362. /**
  55363. * Google Daydream controller
  55364. */
  55365. export class DaydreamController extends WebVRController {
  55366. /**
  55367. * Base Url for the controller model.
  55368. */
  55369. static MODEL_BASE_URL: string;
  55370. /**
  55371. * File name for the controller model.
  55372. */
  55373. static MODEL_FILENAME: string;
  55374. /**
  55375. * Gamepad Id prefix used to identify Daydream Controller.
  55376. */
  55377. static readonly GAMEPAD_ID_PREFIX: string;
  55378. /**
  55379. * Creates a new DaydreamController from a gamepad
  55380. * @param vrGamepad the gamepad that the controller should be created from
  55381. */
  55382. constructor(vrGamepad: any);
  55383. /**
  55384. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55385. * @param scene scene in which to add meshes
  55386. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55387. */
  55388. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55389. /**
  55390. * Called once for each button that changed state since the last frame
  55391. * @param buttonIdx Which button index changed
  55392. * @param state New state of the button
  55393. * @param changes Which properties on the state changed since last frame
  55394. */
  55395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55396. }
  55397. }
  55398. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55399. import { Scene } from "babylonjs/scene";
  55400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55401. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55402. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55403. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55404. /**
  55405. * Gear VR Controller
  55406. */
  55407. export class GearVRController extends WebVRController {
  55408. /**
  55409. * Base Url for the controller model.
  55410. */
  55411. static MODEL_BASE_URL: string;
  55412. /**
  55413. * File name for the controller model.
  55414. */
  55415. static MODEL_FILENAME: string;
  55416. /**
  55417. * Gamepad Id prefix used to identify this controller.
  55418. */
  55419. static readonly GAMEPAD_ID_PREFIX: string;
  55420. private readonly _buttonIndexToObservableNameMap;
  55421. /**
  55422. * Creates a new GearVRController from a gamepad
  55423. * @param vrGamepad the gamepad that the controller should be created from
  55424. */
  55425. constructor(vrGamepad: any);
  55426. /**
  55427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55428. * @param scene scene in which to add meshes
  55429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55430. */
  55431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55432. /**
  55433. * Called once for each button that changed state since the last frame
  55434. * @param buttonIdx Which button index changed
  55435. * @param state New state of the button
  55436. * @param changes Which properties on the state changed since last frame
  55437. */
  55438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55439. }
  55440. }
  55441. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55442. import { Scene } from "babylonjs/scene";
  55443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55444. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55445. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55446. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55447. /**
  55448. * Generic Controller
  55449. */
  55450. export class GenericController extends WebVRController {
  55451. /**
  55452. * Base Url for the controller model.
  55453. */
  55454. static readonly MODEL_BASE_URL: string;
  55455. /**
  55456. * File name for the controller model.
  55457. */
  55458. static readonly MODEL_FILENAME: string;
  55459. /**
  55460. * Creates a new GenericController from a gamepad
  55461. * @param vrGamepad the gamepad that the controller should be created from
  55462. */
  55463. constructor(vrGamepad: any);
  55464. /**
  55465. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55466. * @param scene scene in which to add meshes
  55467. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55468. */
  55469. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55470. /**
  55471. * Called once for each button that changed state since the last frame
  55472. * @param buttonIdx Which button index changed
  55473. * @param state New state of the button
  55474. * @param changes Which properties on the state changed since last frame
  55475. */
  55476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55477. }
  55478. }
  55479. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55480. import { Observable } from "babylonjs/Misc/observable";
  55481. import { Scene } from "babylonjs/scene";
  55482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55483. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55484. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55485. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55486. /**
  55487. * Oculus Touch Controller
  55488. */
  55489. export class OculusTouchController extends WebVRController {
  55490. /**
  55491. * Base Url for the controller model.
  55492. */
  55493. static MODEL_BASE_URL: string;
  55494. /**
  55495. * File name for the left controller model.
  55496. */
  55497. static MODEL_LEFT_FILENAME: string;
  55498. /**
  55499. * File name for the right controller model.
  55500. */
  55501. static MODEL_RIGHT_FILENAME: string;
  55502. /**
  55503. * Base Url for the Quest controller model.
  55504. */
  55505. static QUEST_MODEL_BASE_URL: string;
  55506. /**
  55507. * @hidden
  55508. * If the controllers are running on a device that needs the updated Quest controller models
  55509. */
  55510. static _IsQuest: boolean;
  55511. /**
  55512. * Fired when the secondary trigger on this controller is modified
  55513. */
  55514. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55515. /**
  55516. * Fired when the thumb rest on this controller is modified
  55517. */
  55518. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55519. /**
  55520. * Creates a new OculusTouchController from a gamepad
  55521. * @param vrGamepad the gamepad that the controller should be created from
  55522. */
  55523. constructor(vrGamepad: any);
  55524. /**
  55525. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55526. * @param scene scene in which to add meshes
  55527. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55528. */
  55529. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55530. /**
  55531. * Fired when the A button on this controller is modified
  55532. */
  55533. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55534. /**
  55535. * Fired when the B button on this controller is modified
  55536. */
  55537. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55538. /**
  55539. * Fired when the X button on this controller is modified
  55540. */
  55541. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55542. /**
  55543. * Fired when the Y button on this controller is modified
  55544. */
  55545. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55546. /**
  55547. * Called once for each button that changed state since the last frame
  55548. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55549. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55550. * 2) secondary trigger (same)
  55551. * 3) A (right) X (left), touch, pressed = value
  55552. * 4) B / Y
  55553. * 5) thumb rest
  55554. * @param buttonIdx Which button index changed
  55555. * @param state New state of the button
  55556. * @param changes Which properties on the state changed since last frame
  55557. */
  55558. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55559. }
  55560. }
  55561. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55562. import { Scene } from "babylonjs/scene";
  55563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55564. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55565. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55566. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55567. import { Observable } from "babylonjs/Misc/observable";
  55568. /**
  55569. * Vive Controller
  55570. */
  55571. export class ViveController extends WebVRController {
  55572. /**
  55573. * Base Url for the controller model.
  55574. */
  55575. static MODEL_BASE_URL: string;
  55576. /**
  55577. * File name for the controller model.
  55578. */
  55579. static MODEL_FILENAME: string;
  55580. /**
  55581. * Creates a new ViveController from a gamepad
  55582. * @param vrGamepad the gamepad that the controller should be created from
  55583. */
  55584. constructor(vrGamepad: any);
  55585. /**
  55586. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55587. * @param scene scene in which to add meshes
  55588. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55589. */
  55590. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55591. /**
  55592. * Fired when the left button on this controller is modified
  55593. */
  55594. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55595. /**
  55596. * Fired when the right button on this controller is modified
  55597. */
  55598. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55599. /**
  55600. * Fired when the menu button on this controller is modified
  55601. */
  55602. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55603. /**
  55604. * Called once for each button that changed state since the last frame
  55605. * Vive mapping:
  55606. * 0: touchpad
  55607. * 1: trigger
  55608. * 2: left AND right buttons
  55609. * 3: menu button
  55610. * @param buttonIdx Which button index changed
  55611. * @param state New state of the button
  55612. * @param changes Which properties on the state changed since last frame
  55613. */
  55614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55615. }
  55616. }
  55617. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55618. import { Observable } from "babylonjs/Misc/observable";
  55619. import { Scene } from "babylonjs/scene";
  55620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55621. import { Ray } from "babylonjs/Culling/ray";
  55622. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55623. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55624. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55625. /**
  55626. * Defines the WindowsMotionController object that the state of the windows motion controller
  55627. */
  55628. export class WindowsMotionController extends WebVRController {
  55629. /**
  55630. * The base url used to load the left and right controller models
  55631. */
  55632. static MODEL_BASE_URL: string;
  55633. /**
  55634. * The name of the left controller model file
  55635. */
  55636. static MODEL_LEFT_FILENAME: string;
  55637. /**
  55638. * The name of the right controller model file
  55639. */
  55640. static MODEL_RIGHT_FILENAME: string;
  55641. /**
  55642. * The controller name prefix for this controller type
  55643. */
  55644. static readonly GAMEPAD_ID_PREFIX: string;
  55645. /**
  55646. * The controller id pattern for this controller type
  55647. */
  55648. private static readonly GAMEPAD_ID_PATTERN;
  55649. private _loadedMeshInfo;
  55650. protected readonly _mapping: {
  55651. buttons: string[];
  55652. buttonMeshNames: {
  55653. trigger: string;
  55654. menu: string;
  55655. grip: string;
  55656. thumbstick: string;
  55657. trackpad: string;
  55658. };
  55659. buttonObservableNames: {
  55660. trigger: string;
  55661. menu: string;
  55662. grip: string;
  55663. thumbstick: string;
  55664. trackpad: string;
  55665. };
  55666. axisMeshNames: string[];
  55667. pointingPoseMeshName: string;
  55668. };
  55669. /**
  55670. * Fired when the trackpad on this controller is clicked
  55671. */
  55672. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55673. /**
  55674. * Fired when the trackpad on this controller is modified
  55675. */
  55676. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55677. /**
  55678. * The current x and y values of this controller's trackpad
  55679. */
  55680. trackpad: StickValues;
  55681. /**
  55682. * Creates a new WindowsMotionController from a gamepad
  55683. * @param vrGamepad the gamepad that the controller should be created from
  55684. */
  55685. constructor(vrGamepad: any);
  55686. /**
  55687. * Fired when the trigger on this controller is modified
  55688. */
  55689. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55690. /**
  55691. * Fired when the menu button on this controller is modified
  55692. */
  55693. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55694. /**
  55695. * Fired when the grip button on this controller is modified
  55696. */
  55697. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55698. /**
  55699. * Fired when the thumbstick button on this controller is modified
  55700. */
  55701. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55702. /**
  55703. * Fired when the touchpad button on this controller is modified
  55704. */
  55705. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55706. /**
  55707. * Fired when the touchpad values on this controller are modified
  55708. */
  55709. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55710. protected _updateTrackpad(): void;
  55711. /**
  55712. * Called once per frame by the engine.
  55713. */
  55714. update(): void;
  55715. /**
  55716. * Called once for each button that changed state since the last frame
  55717. * @param buttonIdx Which button index changed
  55718. * @param state New state of the button
  55719. * @param changes Which properties on the state changed since last frame
  55720. */
  55721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55722. /**
  55723. * Moves the buttons on the controller mesh based on their current state
  55724. * @param buttonName the name of the button to move
  55725. * @param buttonValue the value of the button which determines the buttons new position
  55726. */
  55727. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55728. /**
  55729. * Moves the axis on the controller mesh based on its current state
  55730. * @param axis the index of the axis
  55731. * @param axisValue the value of the axis which determines the meshes new position
  55732. * @hidden
  55733. */
  55734. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55735. /**
  55736. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55737. * @param scene scene in which to add meshes
  55738. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55739. */
  55740. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55741. /**
  55742. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55743. * can be transformed by button presses and axes values, based on this._mapping.
  55744. *
  55745. * @param scene scene in which the meshes exist
  55746. * @param meshes list of meshes that make up the controller model to process
  55747. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55748. */
  55749. private processModel;
  55750. private createMeshInfo;
  55751. /**
  55752. * Gets the ray of the controller in the direction the controller is pointing
  55753. * @param length the length the resulting ray should be
  55754. * @returns a ray in the direction the controller is pointing
  55755. */
  55756. getForwardRay(length?: number): Ray;
  55757. /**
  55758. * Disposes of the controller
  55759. */
  55760. dispose(): void;
  55761. }
  55762. /**
  55763. * This class represents a new windows motion controller in XR.
  55764. */
  55765. export class XRWindowsMotionController extends WindowsMotionController {
  55766. /**
  55767. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55768. */
  55769. protected readonly _mapping: {
  55770. buttons: string[];
  55771. buttonMeshNames: {
  55772. trigger: string;
  55773. menu: string;
  55774. grip: string;
  55775. thumbstick: string;
  55776. trackpad: string;
  55777. };
  55778. buttonObservableNames: {
  55779. trigger: string;
  55780. menu: string;
  55781. grip: string;
  55782. thumbstick: string;
  55783. trackpad: string;
  55784. };
  55785. axisMeshNames: string[];
  55786. pointingPoseMeshName: string;
  55787. };
  55788. /**
  55789. * Construct a new XR-Based windows motion controller
  55790. *
  55791. * @param gamepadInfo the gamepad object from the browser
  55792. */
  55793. constructor(gamepadInfo: any);
  55794. /**
  55795. * holds the thumbstick values (X,Y)
  55796. */
  55797. thumbstickValues: StickValues;
  55798. /**
  55799. * Fired when the thumbstick on this controller is clicked
  55800. */
  55801. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55802. /**
  55803. * Fired when the thumbstick on this controller is modified
  55804. */
  55805. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55806. /**
  55807. * Fired when the touchpad button on this controller is modified
  55808. */
  55809. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55810. /**
  55811. * Fired when the touchpad values on this controller are modified
  55812. */
  55813. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55814. /**
  55815. * Fired when the thumbstick button on this controller is modified
  55816. * here to prevent breaking changes
  55817. */
  55818. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55819. /**
  55820. * updating the thumbstick(!) and not the trackpad.
  55821. * This is named this way due to the difference between WebVR and XR and to avoid
  55822. * changing the parent class.
  55823. */
  55824. protected _updateTrackpad(): void;
  55825. /**
  55826. * Disposes the class with joy
  55827. */
  55828. dispose(): void;
  55829. }
  55830. }
  55831. declare module "babylonjs/Gamepads/Controllers/index" {
  55832. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55833. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55834. export * from "babylonjs/Gamepads/Controllers/genericController";
  55835. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55836. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55837. export * from "babylonjs/Gamepads/Controllers/viveController";
  55838. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55839. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55840. }
  55841. declare module "babylonjs/Gamepads/index" {
  55842. export * from "babylonjs/Gamepads/Controllers/index";
  55843. export * from "babylonjs/Gamepads/gamepad";
  55844. export * from "babylonjs/Gamepads/gamepadManager";
  55845. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55846. export * from "babylonjs/Gamepads/xboxGamepad";
  55847. export * from "babylonjs/Gamepads/dualShockGamepad";
  55848. }
  55849. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55850. import { Scene } from "babylonjs/scene";
  55851. import { Vector4 } from "babylonjs/Maths/math.vector";
  55852. import { Color4 } from "babylonjs/Maths/math.color";
  55853. import { Mesh } from "babylonjs/Meshes/mesh";
  55854. import { Nullable } from "babylonjs/types";
  55855. /**
  55856. * Class containing static functions to help procedurally build meshes
  55857. */
  55858. export class PolyhedronBuilder {
  55859. /**
  55860. * Creates a polyhedron mesh
  55861. * * 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
  55862. * * The parameter `size` (positive float, default 1) sets the polygon size
  55863. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55864. * * 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`
  55865. * * 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
  55866. * * 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)`)
  55867. * * 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
  55868. * * 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
  55869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55872. * @param name defines the name of the mesh
  55873. * @param options defines the options used to create the mesh
  55874. * @param scene defines the hosting scene
  55875. * @returns the polyhedron mesh
  55876. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55877. */
  55878. static CreatePolyhedron(name: string, options: {
  55879. type?: number;
  55880. size?: number;
  55881. sizeX?: number;
  55882. sizeY?: number;
  55883. sizeZ?: number;
  55884. custom?: any;
  55885. faceUV?: Vector4[];
  55886. faceColors?: Color4[];
  55887. flat?: boolean;
  55888. updatable?: boolean;
  55889. sideOrientation?: number;
  55890. frontUVs?: Vector4;
  55891. backUVs?: Vector4;
  55892. }, scene?: Nullable<Scene>): Mesh;
  55893. }
  55894. }
  55895. declare module "babylonjs/Gizmos/scaleGizmo" {
  55896. import { Observable } from "babylonjs/Misc/observable";
  55897. import { Nullable } from "babylonjs/types";
  55898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55900. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55901. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55902. import { Node } from "babylonjs/node";
  55903. /**
  55904. * Gizmo that enables scaling a mesh along 3 axis
  55905. */
  55906. export class ScaleGizmo extends Gizmo {
  55907. /**
  55908. * Internal gizmo used for interactions on the x axis
  55909. */
  55910. xGizmo: AxisScaleGizmo;
  55911. /**
  55912. * Internal gizmo used for interactions on the y axis
  55913. */
  55914. yGizmo: AxisScaleGizmo;
  55915. /**
  55916. * Internal gizmo used for interactions on the z axis
  55917. */
  55918. zGizmo: AxisScaleGizmo;
  55919. /**
  55920. * Internal gizmo used to scale all axis equally
  55921. */
  55922. uniformScaleGizmo: AxisScaleGizmo;
  55923. private _meshAttached;
  55924. private _nodeAttached;
  55925. private _snapDistance;
  55926. private _uniformScalingMesh;
  55927. private _octahedron;
  55928. private _sensitivity;
  55929. /** Fires an event when any of it's sub gizmos are dragged */
  55930. onDragStartObservable: Observable<unknown>;
  55931. /** Fires an event when any of it's sub gizmos are released from dragging */
  55932. onDragEndObservable: Observable<unknown>;
  55933. get attachedMesh(): Nullable<AbstractMesh>;
  55934. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55935. get attachedNode(): Nullable<Node>;
  55936. set attachedNode(node: Nullable<Node>);
  55937. /**
  55938. * True when the mouse pointer is hovering a gizmo mesh
  55939. */
  55940. get isHovered(): boolean;
  55941. /**
  55942. * Creates a ScaleGizmo
  55943. * @param gizmoLayer The utility layer the gizmo will be added to
  55944. * @param thickness display gizmo axis thickness
  55945. */
  55946. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55947. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55948. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55949. /**
  55950. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55951. */
  55952. set snapDistance(value: number);
  55953. get snapDistance(): number;
  55954. /**
  55955. * Ratio for the scale of the gizmo (Default: 1)
  55956. */
  55957. set scaleRatio(value: number);
  55958. get scaleRatio(): number;
  55959. /**
  55960. * Sensitivity factor for dragging (Default: 1)
  55961. */
  55962. set sensitivity(value: number);
  55963. get sensitivity(): number;
  55964. /**
  55965. * Disposes of the gizmo
  55966. */
  55967. dispose(): void;
  55968. }
  55969. }
  55970. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55971. import { Observable } from "babylonjs/Misc/observable";
  55972. import { Nullable } from "babylonjs/types";
  55973. import { Vector3 } from "babylonjs/Maths/math.vector";
  55974. import { Node } from "babylonjs/node";
  55975. import { Mesh } from "babylonjs/Meshes/mesh";
  55976. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55977. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55978. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55979. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55980. import { Color3 } from "babylonjs/Maths/math.color";
  55981. /**
  55982. * Single axis scale gizmo
  55983. */
  55984. export class AxisScaleGizmo extends Gizmo {
  55985. /**
  55986. * Drag behavior responsible for the gizmos dragging interactions
  55987. */
  55988. dragBehavior: PointerDragBehavior;
  55989. private _pointerObserver;
  55990. /**
  55991. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55992. */
  55993. snapDistance: number;
  55994. /**
  55995. * Event that fires each time the gizmo snaps to a new location.
  55996. * * snapDistance is the the change in distance
  55997. */
  55998. onSnapObservable: Observable<{
  55999. snapDistance: number;
  56000. }>;
  56001. /**
  56002. * If the scaling operation should be done on all axis (default: false)
  56003. */
  56004. uniformScaling: boolean;
  56005. /**
  56006. * Custom sensitivity value for the drag strength
  56007. */
  56008. sensitivity: number;
  56009. private _isEnabled;
  56010. private _parent;
  56011. private _arrow;
  56012. private _coloredMaterial;
  56013. private _hoverMaterial;
  56014. /**
  56015. * Creates an AxisScaleGizmo
  56016. * @param gizmoLayer The utility layer the gizmo will be added to
  56017. * @param dragAxis The axis which the gizmo will be able to scale on
  56018. * @param color The color of the gizmo
  56019. * @param thickness display gizmo axis thickness
  56020. */
  56021. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56022. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56023. /**
  56024. * If the gizmo is enabled
  56025. */
  56026. set isEnabled(value: boolean);
  56027. get isEnabled(): boolean;
  56028. /**
  56029. * Disposes of the gizmo
  56030. */
  56031. dispose(): void;
  56032. /**
  56033. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56034. * @param mesh The mesh to replace the default mesh of the gizmo
  56035. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56036. */
  56037. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56038. }
  56039. }
  56040. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56041. import { Observable } from "babylonjs/Misc/observable";
  56042. import { Nullable } from "babylonjs/types";
  56043. import { Vector3 } from "babylonjs/Maths/math.vector";
  56044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56045. import { Mesh } from "babylonjs/Meshes/mesh";
  56046. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56048. import { Color3 } from "babylonjs/Maths/math.color";
  56049. import "babylonjs/Meshes/Builders/boxBuilder";
  56050. /**
  56051. * Bounding box gizmo
  56052. */
  56053. export class BoundingBoxGizmo extends Gizmo {
  56054. private _lineBoundingBox;
  56055. private _rotateSpheresParent;
  56056. private _scaleBoxesParent;
  56057. private _boundingDimensions;
  56058. private _renderObserver;
  56059. private _pointerObserver;
  56060. private _scaleDragSpeed;
  56061. private _tmpQuaternion;
  56062. private _tmpVector;
  56063. private _tmpRotationMatrix;
  56064. /**
  56065. * 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)
  56066. */
  56067. ignoreChildren: boolean;
  56068. /**
  56069. * 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)
  56070. */
  56071. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56072. /**
  56073. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56074. */
  56075. rotationSphereSize: number;
  56076. /**
  56077. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56078. */
  56079. scaleBoxSize: number;
  56080. /**
  56081. * 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)
  56082. */
  56083. fixedDragMeshScreenSize: boolean;
  56084. /**
  56085. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56086. */
  56087. fixedDragMeshScreenSizeDistanceFactor: number;
  56088. /**
  56089. * Fired when a rotation sphere or scale box is dragged
  56090. */
  56091. onDragStartObservable: Observable<{}>;
  56092. /**
  56093. * Fired when a scale box is dragged
  56094. */
  56095. onScaleBoxDragObservable: Observable<{}>;
  56096. /**
  56097. * Fired when a scale box drag is ended
  56098. */
  56099. onScaleBoxDragEndObservable: Observable<{}>;
  56100. /**
  56101. * Fired when a rotation sphere is dragged
  56102. */
  56103. onRotationSphereDragObservable: Observable<{}>;
  56104. /**
  56105. * Fired when a rotation sphere drag is ended
  56106. */
  56107. onRotationSphereDragEndObservable: Observable<{}>;
  56108. /**
  56109. * 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)
  56110. */
  56111. scalePivot: Nullable<Vector3>;
  56112. /**
  56113. * Mesh used as a pivot to rotate the attached node
  56114. */
  56115. private _anchorMesh;
  56116. private _existingMeshScale;
  56117. private _dragMesh;
  56118. private pointerDragBehavior;
  56119. private coloredMaterial;
  56120. private hoverColoredMaterial;
  56121. /**
  56122. * Sets the color of the bounding box gizmo
  56123. * @param color the color to set
  56124. */
  56125. setColor(color: Color3): void;
  56126. /**
  56127. * Creates an BoundingBoxGizmo
  56128. * @param gizmoLayer The utility layer the gizmo will be added to
  56129. * @param color The color of the gizmo
  56130. */
  56131. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56132. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56133. private _selectNode;
  56134. /**
  56135. * Updates the bounding box information for the Gizmo
  56136. */
  56137. updateBoundingBox(): void;
  56138. private _updateRotationSpheres;
  56139. private _updateScaleBoxes;
  56140. /**
  56141. * Enables rotation on the specified axis and disables rotation on the others
  56142. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56143. */
  56144. setEnabledRotationAxis(axis: string): void;
  56145. /**
  56146. * Enables/disables scaling
  56147. * @param enable if scaling should be enabled
  56148. * @param homogeneousScaling defines if scaling should only be homogeneous
  56149. */
  56150. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56151. private _updateDummy;
  56152. /**
  56153. * Enables a pointer drag behavior on the bounding box of the gizmo
  56154. */
  56155. enableDragBehavior(): void;
  56156. /**
  56157. * Disposes of the gizmo
  56158. */
  56159. dispose(): void;
  56160. /**
  56161. * 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)
  56162. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56163. * @returns the bounding box mesh with the passed in mesh as a child
  56164. */
  56165. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56166. /**
  56167. * CustomMeshes are not supported by this gizmo
  56168. * @param mesh The mesh to replace the default mesh of the gizmo
  56169. */
  56170. setCustomMesh(mesh: Mesh): void;
  56171. }
  56172. }
  56173. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56174. import { Observable } from "babylonjs/Misc/observable";
  56175. import { Nullable } from "babylonjs/types";
  56176. import { Vector3 } from "babylonjs/Maths/math.vector";
  56177. import { Color3 } from "babylonjs/Maths/math.color";
  56178. import { Node } from "babylonjs/node";
  56179. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56180. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56181. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56182. import "babylonjs/Meshes/Builders/linesBuilder";
  56183. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56184. /**
  56185. * Single plane rotation gizmo
  56186. */
  56187. export class PlaneRotationGizmo extends Gizmo {
  56188. /**
  56189. * Drag behavior responsible for the gizmos dragging interactions
  56190. */
  56191. dragBehavior: PointerDragBehavior;
  56192. private _pointerObserver;
  56193. /**
  56194. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56195. */
  56196. snapDistance: number;
  56197. /**
  56198. * Event that fires each time the gizmo snaps to a new location.
  56199. * * snapDistance is the the change in distance
  56200. */
  56201. onSnapObservable: Observable<{
  56202. snapDistance: number;
  56203. }>;
  56204. private _isEnabled;
  56205. private _parent;
  56206. /**
  56207. * Creates a PlaneRotationGizmo
  56208. * @param gizmoLayer The utility layer the gizmo will be added to
  56209. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56210. * @param color The color of the gizmo
  56211. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56212. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56213. * @param thickness display gizmo axis thickness
  56214. */
  56215. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56216. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56217. /**
  56218. * If the gizmo is enabled
  56219. */
  56220. set isEnabled(value: boolean);
  56221. get isEnabled(): boolean;
  56222. /**
  56223. * Disposes of the gizmo
  56224. */
  56225. dispose(): void;
  56226. }
  56227. }
  56228. declare module "babylonjs/Gizmos/rotationGizmo" {
  56229. import { Observable } from "babylonjs/Misc/observable";
  56230. import { Nullable } from "babylonjs/types";
  56231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56232. import { Mesh } from "babylonjs/Meshes/mesh";
  56233. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56234. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56236. import { Node } from "babylonjs/node";
  56237. /**
  56238. * Gizmo that enables rotating a mesh along 3 axis
  56239. */
  56240. export class RotationGizmo extends Gizmo {
  56241. /**
  56242. * Internal gizmo used for interactions on the x axis
  56243. */
  56244. xGizmo: PlaneRotationGizmo;
  56245. /**
  56246. * Internal gizmo used for interactions on the y axis
  56247. */
  56248. yGizmo: PlaneRotationGizmo;
  56249. /**
  56250. * Internal gizmo used for interactions on the z axis
  56251. */
  56252. zGizmo: PlaneRotationGizmo;
  56253. /** Fires an event when any of it's sub gizmos are dragged */
  56254. onDragStartObservable: Observable<unknown>;
  56255. /** Fires an event when any of it's sub gizmos are released from dragging */
  56256. onDragEndObservable: Observable<unknown>;
  56257. private _meshAttached;
  56258. private _nodeAttached;
  56259. get attachedMesh(): Nullable<AbstractMesh>;
  56260. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56261. get attachedNode(): Nullable<Node>;
  56262. set attachedNode(node: Nullable<Node>);
  56263. /**
  56264. * True when the mouse pointer is hovering a gizmo mesh
  56265. */
  56266. get isHovered(): boolean;
  56267. /**
  56268. * Creates a RotationGizmo
  56269. * @param gizmoLayer The utility layer the gizmo will be added to
  56270. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56271. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56272. * @param thickness display gizmo axis thickness
  56273. */
  56274. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56275. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56276. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56277. /**
  56278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56279. */
  56280. set snapDistance(value: number);
  56281. get snapDistance(): number;
  56282. /**
  56283. * Ratio for the scale of the gizmo (Default: 1)
  56284. */
  56285. set scaleRatio(value: number);
  56286. get scaleRatio(): number;
  56287. /**
  56288. * Disposes of the gizmo
  56289. */
  56290. dispose(): void;
  56291. /**
  56292. * CustomMeshes are not supported by this gizmo
  56293. * @param mesh The mesh to replace the default mesh of the gizmo
  56294. */
  56295. setCustomMesh(mesh: Mesh): void;
  56296. }
  56297. }
  56298. declare module "babylonjs/Gizmos/gizmoManager" {
  56299. import { Observable } from "babylonjs/Misc/observable";
  56300. import { Nullable } from "babylonjs/types";
  56301. import { Scene, IDisposable } from "babylonjs/scene";
  56302. import { Node } from "babylonjs/node";
  56303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56304. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56305. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56306. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56307. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56308. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56309. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56310. /**
  56311. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56312. */
  56313. export class GizmoManager implements IDisposable {
  56314. private scene;
  56315. /**
  56316. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56317. */
  56318. gizmos: {
  56319. positionGizmo: Nullable<PositionGizmo>;
  56320. rotationGizmo: Nullable<RotationGizmo>;
  56321. scaleGizmo: Nullable<ScaleGizmo>;
  56322. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56323. };
  56324. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56325. clearGizmoOnEmptyPointerEvent: boolean;
  56326. /** Fires an event when the manager is attached to a mesh */
  56327. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56328. /** Fires an event when the manager is attached to a node */
  56329. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56330. private _gizmosEnabled;
  56331. private _pointerObserver;
  56332. private _attachedMesh;
  56333. private _attachedNode;
  56334. private _boundingBoxColor;
  56335. private _defaultUtilityLayer;
  56336. private _defaultKeepDepthUtilityLayer;
  56337. private _thickness;
  56338. /**
  56339. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56340. */
  56341. boundingBoxDragBehavior: SixDofDragBehavior;
  56342. /**
  56343. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56344. */
  56345. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56346. /**
  56347. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56348. */
  56349. attachableNodes: Nullable<Array<Node>>;
  56350. /**
  56351. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56352. */
  56353. usePointerToAttachGizmos: boolean;
  56354. /**
  56355. * Utility layer that the bounding box gizmo belongs to
  56356. */
  56357. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56358. /**
  56359. * Utility layer that all gizmos besides bounding box belong to
  56360. */
  56361. get utilityLayer(): UtilityLayerRenderer;
  56362. /**
  56363. * True when the mouse pointer is hovering a gizmo mesh
  56364. */
  56365. get isHovered(): boolean;
  56366. /**
  56367. * Instatiates a gizmo manager
  56368. * @param scene the scene to overlay the gizmos on top of
  56369. * @param thickness display gizmo axis thickness
  56370. */
  56371. constructor(scene: Scene, thickness?: number);
  56372. /**
  56373. * Attaches a set of gizmos to the specified mesh
  56374. * @param mesh The mesh the gizmo's should be attached to
  56375. */
  56376. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56377. /**
  56378. * Attaches a set of gizmos to the specified node
  56379. * @param node The node the gizmo's should be attached to
  56380. */
  56381. attachToNode(node: Nullable<Node>): void;
  56382. /**
  56383. * If the position gizmo is enabled
  56384. */
  56385. set positionGizmoEnabled(value: boolean);
  56386. get positionGizmoEnabled(): boolean;
  56387. /**
  56388. * If the rotation gizmo is enabled
  56389. */
  56390. set rotationGizmoEnabled(value: boolean);
  56391. get rotationGizmoEnabled(): boolean;
  56392. /**
  56393. * If the scale gizmo is enabled
  56394. */
  56395. set scaleGizmoEnabled(value: boolean);
  56396. get scaleGizmoEnabled(): boolean;
  56397. /**
  56398. * If the boundingBox gizmo is enabled
  56399. */
  56400. set boundingBoxGizmoEnabled(value: boolean);
  56401. get boundingBoxGizmoEnabled(): boolean;
  56402. /**
  56403. * Disposes of the gizmo manager
  56404. */
  56405. dispose(): void;
  56406. }
  56407. }
  56408. declare module "babylonjs/Lights/directionalLight" {
  56409. import { Camera } from "babylonjs/Cameras/camera";
  56410. import { Scene } from "babylonjs/scene";
  56411. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56413. import { Light } from "babylonjs/Lights/light";
  56414. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56415. import { Effect } from "babylonjs/Materials/effect";
  56416. /**
  56417. * A directional light is defined by a direction (what a surprise!).
  56418. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56419. * 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.
  56420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56421. */
  56422. export class DirectionalLight extends ShadowLight {
  56423. private _shadowFrustumSize;
  56424. /**
  56425. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56426. */
  56427. get shadowFrustumSize(): number;
  56428. /**
  56429. * Specifies a fix frustum size for the shadow generation.
  56430. */
  56431. set shadowFrustumSize(value: number);
  56432. private _shadowOrthoScale;
  56433. /**
  56434. * Gets the shadow projection scale against the optimal computed one.
  56435. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56436. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56437. */
  56438. get shadowOrthoScale(): number;
  56439. /**
  56440. * Sets the shadow projection scale against the optimal computed one.
  56441. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56442. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56443. */
  56444. set shadowOrthoScale(value: number);
  56445. /**
  56446. * Automatically compute the projection matrix to best fit (including all the casters)
  56447. * on each frame.
  56448. */
  56449. autoUpdateExtends: boolean;
  56450. /**
  56451. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56452. * on each frame. autoUpdateExtends must be set to true for this to work
  56453. */
  56454. autoCalcShadowZBounds: boolean;
  56455. private _orthoLeft;
  56456. private _orthoRight;
  56457. private _orthoTop;
  56458. private _orthoBottom;
  56459. /**
  56460. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56461. * The directional light is emitted from everywhere in the given direction.
  56462. * It can cast shadows.
  56463. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56464. * @param name The friendly name of the light
  56465. * @param direction The direction of the light
  56466. * @param scene The scene the light belongs to
  56467. */
  56468. constructor(name: string, direction: Vector3, scene: Scene);
  56469. /**
  56470. * Returns the string "DirectionalLight".
  56471. * @return The class name
  56472. */
  56473. getClassName(): string;
  56474. /**
  56475. * Returns the integer 1.
  56476. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56477. */
  56478. getTypeID(): number;
  56479. /**
  56480. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56481. * Returns the DirectionalLight Shadow projection matrix.
  56482. */
  56483. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56484. /**
  56485. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56486. * Returns the DirectionalLight Shadow projection matrix.
  56487. */
  56488. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56489. /**
  56490. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56491. * Returns the DirectionalLight Shadow projection matrix.
  56492. */
  56493. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56494. protected _buildUniformLayout(): void;
  56495. /**
  56496. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56497. * @param effect The effect to update
  56498. * @param lightIndex The index of the light in the effect to update
  56499. * @returns The directional light
  56500. */
  56501. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56502. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56503. /**
  56504. * Gets the minZ used for shadow according to both the scene and the light.
  56505. *
  56506. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56507. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56508. * @param activeCamera The camera we are returning the min for
  56509. * @returns the depth min z
  56510. */
  56511. getDepthMinZ(activeCamera: Camera): number;
  56512. /**
  56513. * Gets the maxZ used for shadow according to both the scene and the light.
  56514. *
  56515. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56516. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56517. * @param activeCamera The camera we are returning the max for
  56518. * @returns the depth max z
  56519. */
  56520. getDepthMaxZ(activeCamera: Camera): number;
  56521. /**
  56522. * Prepares the list of defines specific to the light type.
  56523. * @param defines the list of defines
  56524. * @param lightIndex defines the index of the light for the effect
  56525. */
  56526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56527. }
  56528. }
  56529. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56530. import { Mesh } from "babylonjs/Meshes/mesh";
  56531. /**
  56532. * Class containing static functions to help procedurally build meshes
  56533. */
  56534. export class HemisphereBuilder {
  56535. /**
  56536. * Creates a hemisphere mesh
  56537. * @param name defines the name of the mesh
  56538. * @param options defines the options used to create the mesh
  56539. * @param scene defines the hosting scene
  56540. * @returns the hemisphere mesh
  56541. */
  56542. static CreateHemisphere(name: string, options: {
  56543. segments?: number;
  56544. diameter?: number;
  56545. sideOrientation?: number;
  56546. }, scene: any): Mesh;
  56547. }
  56548. }
  56549. declare module "babylonjs/Lights/spotLight" {
  56550. import { Nullable } from "babylonjs/types";
  56551. import { Scene } from "babylonjs/scene";
  56552. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56554. import { Effect } from "babylonjs/Materials/effect";
  56555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56556. import { Light } from "babylonjs/Lights/light";
  56557. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56558. /**
  56559. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56560. * These values define a cone of light starting from the position, emitting toward the direction.
  56561. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56562. * and the exponent defines the speed of the decay of the light with distance (reach).
  56563. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56564. */
  56565. export class SpotLight extends ShadowLight {
  56566. private _angle;
  56567. private _innerAngle;
  56568. private _cosHalfAngle;
  56569. private _lightAngleScale;
  56570. private _lightAngleOffset;
  56571. /**
  56572. * Gets the cone angle of the spot light in Radians.
  56573. */
  56574. get angle(): number;
  56575. /**
  56576. * Sets the cone angle of the spot light in Radians.
  56577. */
  56578. set angle(value: number);
  56579. /**
  56580. * Only used in gltf falloff mode, this defines the angle where
  56581. * the directional falloff will start before cutting at angle which could be seen
  56582. * as outer angle.
  56583. */
  56584. get innerAngle(): number;
  56585. /**
  56586. * Only used in gltf falloff mode, this defines the angle where
  56587. * the directional falloff will start before cutting at angle which could be seen
  56588. * as outer angle.
  56589. */
  56590. set innerAngle(value: number);
  56591. private _shadowAngleScale;
  56592. /**
  56593. * Allows scaling the angle of the light for shadow generation only.
  56594. */
  56595. get shadowAngleScale(): number;
  56596. /**
  56597. * Allows scaling the angle of the light for shadow generation only.
  56598. */
  56599. set shadowAngleScale(value: number);
  56600. /**
  56601. * The light decay speed with the distance from the emission spot.
  56602. */
  56603. exponent: number;
  56604. private _projectionTextureMatrix;
  56605. /**
  56606. * Allows reading the projecton texture
  56607. */
  56608. get projectionTextureMatrix(): Matrix;
  56609. protected _projectionTextureLightNear: number;
  56610. /**
  56611. * Gets the near clip of the Spotlight for texture projection.
  56612. */
  56613. get projectionTextureLightNear(): number;
  56614. /**
  56615. * Sets the near clip of the Spotlight for texture projection.
  56616. */
  56617. set projectionTextureLightNear(value: number);
  56618. protected _projectionTextureLightFar: number;
  56619. /**
  56620. * Gets the far clip of the Spotlight for texture projection.
  56621. */
  56622. get projectionTextureLightFar(): number;
  56623. /**
  56624. * Sets the far clip of the Spotlight for texture projection.
  56625. */
  56626. set projectionTextureLightFar(value: number);
  56627. protected _projectionTextureUpDirection: Vector3;
  56628. /**
  56629. * Gets the Up vector of the Spotlight for texture projection.
  56630. */
  56631. get projectionTextureUpDirection(): Vector3;
  56632. /**
  56633. * Sets the Up vector of the Spotlight for texture projection.
  56634. */
  56635. set projectionTextureUpDirection(value: Vector3);
  56636. private _projectionTexture;
  56637. /**
  56638. * Gets the projection texture of the light.
  56639. */
  56640. get projectionTexture(): Nullable<BaseTexture>;
  56641. /**
  56642. * Sets the projection texture of the light.
  56643. */
  56644. set projectionTexture(value: Nullable<BaseTexture>);
  56645. private _projectionTextureViewLightDirty;
  56646. private _projectionTextureProjectionLightDirty;
  56647. private _projectionTextureDirty;
  56648. private _projectionTextureViewTargetVector;
  56649. private _projectionTextureViewLightMatrix;
  56650. private _projectionTextureProjectionLightMatrix;
  56651. private _projectionTextureScalingMatrix;
  56652. /**
  56653. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56654. * It can cast shadows.
  56655. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56656. * @param name The light friendly name
  56657. * @param position The position of the spot light in the scene
  56658. * @param direction The direction of the light in the scene
  56659. * @param angle The cone angle of the light in Radians
  56660. * @param exponent The light decay speed with the distance from the emission spot
  56661. * @param scene The scene the lights belongs to
  56662. */
  56663. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56664. /**
  56665. * Returns the string "SpotLight".
  56666. * @returns the class name
  56667. */
  56668. getClassName(): string;
  56669. /**
  56670. * Returns the integer 2.
  56671. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56672. */
  56673. getTypeID(): number;
  56674. /**
  56675. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56676. */
  56677. protected _setDirection(value: Vector3): void;
  56678. /**
  56679. * Overrides the position setter to recompute the projection texture view light Matrix.
  56680. */
  56681. protected _setPosition(value: Vector3): void;
  56682. /**
  56683. * 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.
  56684. * Returns the SpotLight.
  56685. */
  56686. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56687. protected _computeProjectionTextureViewLightMatrix(): void;
  56688. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56689. /**
  56690. * Main function for light texture projection matrix computing.
  56691. */
  56692. protected _computeProjectionTextureMatrix(): void;
  56693. protected _buildUniformLayout(): void;
  56694. private _computeAngleValues;
  56695. /**
  56696. * Sets the passed Effect "effect" with the Light textures.
  56697. * @param effect The effect to update
  56698. * @param lightIndex The index of the light in the effect to update
  56699. * @returns The light
  56700. */
  56701. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56702. /**
  56703. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56704. * @param effect The effect to update
  56705. * @param lightIndex The index of the light in the effect to update
  56706. * @returns The spot light
  56707. */
  56708. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56709. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56710. /**
  56711. * Disposes the light and the associated resources.
  56712. */
  56713. dispose(): void;
  56714. /**
  56715. * Prepares the list of defines specific to the light type.
  56716. * @param defines the list of defines
  56717. * @param lightIndex defines the index of the light for the effect
  56718. */
  56719. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56720. }
  56721. }
  56722. declare module "babylonjs/Gizmos/lightGizmo" {
  56723. import { Nullable } from "babylonjs/types";
  56724. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56726. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56727. import { Light } from "babylonjs/Lights/light";
  56728. import { Observable } from "babylonjs/Misc/observable";
  56729. /**
  56730. * Gizmo that enables viewing a light
  56731. */
  56732. export class LightGizmo extends Gizmo {
  56733. private _lightMesh;
  56734. private _material;
  56735. private _cachedPosition;
  56736. private _cachedForward;
  56737. private _attachedMeshParent;
  56738. private _pointerObserver;
  56739. /**
  56740. * Event that fires each time the gizmo is clicked
  56741. */
  56742. onClickedObservable: Observable<Light>;
  56743. /**
  56744. * Creates a LightGizmo
  56745. * @param gizmoLayer The utility layer the gizmo will be added to
  56746. */
  56747. constructor(gizmoLayer?: UtilityLayerRenderer);
  56748. private _light;
  56749. /**
  56750. * The light that the gizmo is attached to
  56751. */
  56752. set light(light: Nullable<Light>);
  56753. get light(): Nullable<Light>;
  56754. /**
  56755. * Gets the material used to render the light gizmo
  56756. */
  56757. get material(): StandardMaterial;
  56758. /**
  56759. * @hidden
  56760. * Updates the gizmo to match the attached mesh's position/rotation
  56761. */
  56762. protected _update(): void;
  56763. private static _Scale;
  56764. /**
  56765. * Creates the lines for a light mesh
  56766. */
  56767. private static _CreateLightLines;
  56768. /**
  56769. * Disposes of the light gizmo
  56770. */
  56771. dispose(): void;
  56772. private static _CreateHemisphericLightMesh;
  56773. private static _CreatePointLightMesh;
  56774. private static _CreateSpotLightMesh;
  56775. private static _CreateDirectionalLightMesh;
  56776. }
  56777. }
  56778. declare module "babylonjs/Gizmos/cameraGizmo" {
  56779. import { Nullable } from "babylonjs/types";
  56780. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56781. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56782. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56783. import { Camera } from "babylonjs/Cameras/camera";
  56784. import { Observable } from "babylonjs/Misc/observable";
  56785. /**
  56786. * Gizmo that enables viewing a camera
  56787. */
  56788. export class CameraGizmo extends Gizmo {
  56789. private _cameraMesh;
  56790. private _cameraLinesMesh;
  56791. private _material;
  56792. private _pointerObserver;
  56793. /**
  56794. * Event that fires each time the gizmo is clicked
  56795. */
  56796. onClickedObservable: Observable<Camera>;
  56797. /**
  56798. * Creates a CameraGizmo
  56799. * @param gizmoLayer The utility layer the gizmo will be added to
  56800. */
  56801. constructor(gizmoLayer?: UtilityLayerRenderer);
  56802. private _camera;
  56803. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56804. get displayFrustum(): boolean;
  56805. set displayFrustum(value: boolean);
  56806. /**
  56807. * The camera that the gizmo is attached to
  56808. */
  56809. set camera(camera: Nullable<Camera>);
  56810. get camera(): Nullable<Camera>;
  56811. /**
  56812. * Gets the material used to render the camera gizmo
  56813. */
  56814. get material(): StandardMaterial;
  56815. /**
  56816. * @hidden
  56817. * Updates the gizmo to match the attached mesh's position/rotation
  56818. */
  56819. protected _update(): void;
  56820. private static _Scale;
  56821. private _invProjection;
  56822. /**
  56823. * Disposes of the camera gizmo
  56824. */
  56825. dispose(): void;
  56826. private static _CreateCameraMesh;
  56827. private static _CreateCameraFrustum;
  56828. }
  56829. }
  56830. declare module "babylonjs/Gizmos/index" {
  56831. export * from "babylonjs/Gizmos/axisDragGizmo";
  56832. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56833. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56834. export * from "babylonjs/Gizmos/gizmo";
  56835. export * from "babylonjs/Gizmos/gizmoManager";
  56836. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56837. export * from "babylonjs/Gizmos/positionGizmo";
  56838. export * from "babylonjs/Gizmos/rotationGizmo";
  56839. export * from "babylonjs/Gizmos/scaleGizmo";
  56840. export * from "babylonjs/Gizmos/lightGizmo";
  56841. export * from "babylonjs/Gizmos/cameraGizmo";
  56842. export * from "babylonjs/Gizmos/planeDragGizmo";
  56843. }
  56844. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56845. /** @hidden */
  56846. export var backgroundFragmentDeclaration: {
  56847. name: string;
  56848. shader: string;
  56849. };
  56850. }
  56851. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56852. /** @hidden */
  56853. export var backgroundUboDeclaration: {
  56854. name: string;
  56855. shader: string;
  56856. };
  56857. }
  56858. declare module "babylonjs/Shaders/background.fragment" {
  56859. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56860. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56861. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56862. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56863. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56866. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56867. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56868. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56870. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56871. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56872. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56873. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56874. /** @hidden */
  56875. export var backgroundPixelShader: {
  56876. name: string;
  56877. shader: string;
  56878. };
  56879. }
  56880. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56881. /** @hidden */
  56882. export var backgroundVertexDeclaration: {
  56883. name: string;
  56884. shader: string;
  56885. };
  56886. }
  56887. declare module "babylonjs/Shaders/background.vertex" {
  56888. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56889. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56890. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56891. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56893. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56894. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56895. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56896. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56897. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56898. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56899. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56900. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56901. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56902. /** @hidden */
  56903. export var backgroundVertexShader: {
  56904. name: string;
  56905. shader: string;
  56906. };
  56907. }
  56908. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56909. import { Nullable, int, float } from "babylonjs/types";
  56910. import { Scene } from "babylonjs/scene";
  56911. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56912. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56914. import { Mesh } from "babylonjs/Meshes/mesh";
  56915. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56916. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56919. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56920. import { Color3 } from "babylonjs/Maths/math.color";
  56921. import "babylonjs/Shaders/background.fragment";
  56922. import "babylonjs/Shaders/background.vertex";
  56923. /**
  56924. * Background material used to create an efficient environement around your scene.
  56925. */
  56926. export class BackgroundMaterial extends PushMaterial {
  56927. /**
  56928. * Standard reflectance value at parallel view angle.
  56929. */
  56930. static StandardReflectance0: number;
  56931. /**
  56932. * Standard reflectance value at grazing angle.
  56933. */
  56934. static StandardReflectance90: number;
  56935. protected _primaryColor: Color3;
  56936. /**
  56937. * Key light Color (multiply against the environement texture)
  56938. */
  56939. primaryColor: Color3;
  56940. protected __perceptualColor: Nullable<Color3>;
  56941. /**
  56942. * Experimental Internal Use Only.
  56943. *
  56944. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56945. * This acts as a helper to set the primary color to a more "human friendly" value.
  56946. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56947. * output color as close as possible from the chosen value.
  56948. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56949. * part of lighting setup.)
  56950. */
  56951. get _perceptualColor(): Nullable<Color3>;
  56952. set _perceptualColor(value: Nullable<Color3>);
  56953. protected _primaryColorShadowLevel: float;
  56954. /**
  56955. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56956. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56957. */
  56958. get primaryColorShadowLevel(): float;
  56959. set primaryColorShadowLevel(value: float);
  56960. protected _primaryColorHighlightLevel: float;
  56961. /**
  56962. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56963. * The primary color is used at the level chosen to define what the white area would look.
  56964. */
  56965. get primaryColorHighlightLevel(): float;
  56966. set primaryColorHighlightLevel(value: float);
  56967. protected _reflectionTexture: Nullable<BaseTexture>;
  56968. /**
  56969. * Reflection Texture used in the material.
  56970. * Should be author in a specific way for the best result (refer to the documentation).
  56971. */
  56972. reflectionTexture: Nullable<BaseTexture>;
  56973. protected _reflectionBlur: float;
  56974. /**
  56975. * Reflection Texture level of blur.
  56976. *
  56977. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56978. * texture twice.
  56979. */
  56980. reflectionBlur: float;
  56981. protected _diffuseTexture: Nullable<BaseTexture>;
  56982. /**
  56983. * Diffuse Texture used in the material.
  56984. * Should be author in a specific way for the best result (refer to the documentation).
  56985. */
  56986. diffuseTexture: Nullable<BaseTexture>;
  56987. protected _shadowLights: Nullable<IShadowLight[]>;
  56988. /**
  56989. * Specify the list of lights casting shadow on the material.
  56990. * All scene shadow lights will be included if null.
  56991. */
  56992. shadowLights: Nullable<IShadowLight[]>;
  56993. protected _shadowLevel: float;
  56994. /**
  56995. * Helps adjusting the shadow to a softer level if required.
  56996. * 0 means black shadows and 1 means no shadows.
  56997. */
  56998. shadowLevel: float;
  56999. protected _sceneCenter: Vector3;
  57000. /**
  57001. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57002. * It is usually zero but might be interesting to modify according to your setup.
  57003. */
  57004. sceneCenter: Vector3;
  57005. protected _opacityFresnel: boolean;
  57006. /**
  57007. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57008. * This helps ensuring a nice transition when the camera goes under the ground.
  57009. */
  57010. opacityFresnel: boolean;
  57011. protected _reflectionFresnel: boolean;
  57012. /**
  57013. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57014. * This helps adding a mirror texture on the ground.
  57015. */
  57016. reflectionFresnel: boolean;
  57017. protected _reflectionFalloffDistance: number;
  57018. /**
  57019. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57020. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57021. */
  57022. reflectionFalloffDistance: number;
  57023. protected _reflectionAmount: number;
  57024. /**
  57025. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57026. */
  57027. reflectionAmount: number;
  57028. protected _reflectionReflectance0: number;
  57029. /**
  57030. * This specifies the weight of the reflection at grazing angle.
  57031. */
  57032. reflectionReflectance0: number;
  57033. protected _reflectionReflectance90: number;
  57034. /**
  57035. * This specifies the weight of the reflection at a perpendicular point of view.
  57036. */
  57037. reflectionReflectance90: number;
  57038. /**
  57039. * Sets the reflection reflectance fresnel values according to the default standard
  57040. * empirically know to work well :-)
  57041. */
  57042. set reflectionStandardFresnelWeight(value: number);
  57043. protected _useRGBColor: boolean;
  57044. /**
  57045. * Helps to directly use the maps channels instead of their level.
  57046. */
  57047. useRGBColor: boolean;
  57048. protected _enableNoise: boolean;
  57049. /**
  57050. * This helps reducing the banding effect that could occur on the background.
  57051. */
  57052. enableNoise: boolean;
  57053. /**
  57054. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57055. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57056. * Recommended to be keep at 1.0 except for special cases.
  57057. */
  57058. get fovMultiplier(): number;
  57059. set fovMultiplier(value: number);
  57060. private _fovMultiplier;
  57061. /**
  57062. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57063. */
  57064. useEquirectangularFOV: boolean;
  57065. private _maxSimultaneousLights;
  57066. /**
  57067. * Number of Simultaneous lights allowed on the material.
  57068. */
  57069. maxSimultaneousLights: int;
  57070. private _shadowOnly;
  57071. /**
  57072. * Make the material only render shadows
  57073. */
  57074. shadowOnly: boolean;
  57075. /**
  57076. * Default configuration related to image processing available in the Background Material.
  57077. */
  57078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57079. /**
  57080. * Keep track of the image processing observer to allow dispose and replace.
  57081. */
  57082. private _imageProcessingObserver;
  57083. /**
  57084. * Attaches a new image processing configuration to the PBR Material.
  57085. * @param configuration (if null the scene configuration will be use)
  57086. */
  57087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57088. /**
  57089. * Gets the image processing configuration used either in this material.
  57090. */
  57091. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57092. /**
  57093. * Sets the Default image processing configuration used either in the this material.
  57094. *
  57095. * If sets to null, the scene one is in use.
  57096. */
  57097. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57098. /**
  57099. * Gets wether the color curves effect is enabled.
  57100. */
  57101. get cameraColorCurvesEnabled(): boolean;
  57102. /**
  57103. * Sets wether the color curves effect is enabled.
  57104. */
  57105. set cameraColorCurvesEnabled(value: boolean);
  57106. /**
  57107. * Gets wether the color grading effect is enabled.
  57108. */
  57109. get cameraColorGradingEnabled(): boolean;
  57110. /**
  57111. * Gets wether the color grading effect is enabled.
  57112. */
  57113. set cameraColorGradingEnabled(value: boolean);
  57114. /**
  57115. * Gets wether tonemapping is enabled or not.
  57116. */
  57117. get cameraToneMappingEnabled(): boolean;
  57118. /**
  57119. * Sets wether tonemapping is enabled or not
  57120. */
  57121. set cameraToneMappingEnabled(value: boolean);
  57122. /**
  57123. * The camera exposure used on this material.
  57124. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57125. * This corresponds to a photographic exposure.
  57126. */
  57127. get cameraExposure(): float;
  57128. /**
  57129. * The camera exposure used on this material.
  57130. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57131. * This corresponds to a photographic exposure.
  57132. */
  57133. set cameraExposure(value: float);
  57134. /**
  57135. * Gets The camera contrast used on this material.
  57136. */
  57137. get cameraContrast(): float;
  57138. /**
  57139. * Sets The camera contrast used on this material.
  57140. */
  57141. set cameraContrast(value: float);
  57142. /**
  57143. * Gets the Color Grading 2D Lookup Texture.
  57144. */
  57145. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57146. /**
  57147. * Sets the Color Grading 2D Lookup Texture.
  57148. */
  57149. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57150. /**
  57151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57153. * 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;
  57154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57155. */
  57156. get cameraColorCurves(): Nullable<ColorCurves>;
  57157. /**
  57158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57160. * 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;
  57161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57162. */
  57163. set cameraColorCurves(value: Nullable<ColorCurves>);
  57164. /**
  57165. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57166. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57167. */
  57168. switchToBGR: boolean;
  57169. private _renderTargets;
  57170. private _reflectionControls;
  57171. private _white;
  57172. private _primaryShadowColor;
  57173. private _primaryHighlightColor;
  57174. /**
  57175. * Instantiates a Background Material in the given scene
  57176. * @param name The friendly name of the material
  57177. * @param scene The scene to add the material to
  57178. */
  57179. constructor(name: string, scene: Scene);
  57180. /**
  57181. * Gets a boolean indicating that current material needs to register RTT
  57182. */
  57183. get hasRenderTargetTextures(): boolean;
  57184. /**
  57185. * The entire material has been created in order to prevent overdraw.
  57186. * @returns false
  57187. */
  57188. needAlphaTesting(): boolean;
  57189. /**
  57190. * The entire material has been created in order to prevent overdraw.
  57191. * @returns true if blending is enable
  57192. */
  57193. needAlphaBlending(): boolean;
  57194. /**
  57195. * Checks wether the material is ready to be rendered for a given mesh.
  57196. * @param mesh The mesh to render
  57197. * @param subMesh The submesh to check against
  57198. * @param useInstances Specify wether or not the material is used with instances
  57199. * @returns true if all the dependencies are ready (Textures, Effects...)
  57200. */
  57201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57202. /**
  57203. * Compute the primary color according to the chosen perceptual color.
  57204. */
  57205. private _computePrimaryColorFromPerceptualColor;
  57206. /**
  57207. * Compute the highlights and shadow colors according to their chosen levels.
  57208. */
  57209. private _computePrimaryColors;
  57210. /**
  57211. * Build the uniform buffer used in the material.
  57212. */
  57213. buildUniformLayout(): void;
  57214. /**
  57215. * Unbind the material.
  57216. */
  57217. unbind(): void;
  57218. /**
  57219. * Bind only the world matrix to the material.
  57220. * @param world The world matrix to bind.
  57221. */
  57222. bindOnlyWorldMatrix(world: Matrix): void;
  57223. /**
  57224. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57225. * @param world The world matrix to bind.
  57226. * @param subMesh The submesh to bind for.
  57227. */
  57228. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57229. /**
  57230. * Checks to see if a texture is used in the material.
  57231. * @param texture - Base texture to use.
  57232. * @returns - Boolean specifying if a texture is used in the material.
  57233. */
  57234. hasTexture(texture: BaseTexture): boolean;
  57235. /**
  57236. * Dispose the material.
  57237. * @param forceDisposeEffect Force disposal of the associated effect.
  57238. * @param forceDisposeTextures Force disposal of the associated textures.
  57239. */
  57240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57241. /**
  57242. * Clones the material.
  57243. * @param name The cloned name.
  57244. * @returns The cloned material.
  57245. */
  57246. clone(name: string): BackgroundMaterial;
  57247. /**
  57248. * Serializes the current material to its JSON representation.
  57249. * @returns The JSON representation.
  57250. */
  57251. serialize(): any;
  57252. /**
  57253. * Gets the class name of the material
  57254. * @returns "BackgroundMaterial"
  57255. */
  57256. getClassName(): string;
  57257. /**
  57258. * Parse a JSON input to create back a background material.
  57259. * @param source The JSON data to parse
  57260. * @param scene The scene to create the parsed material in
  57261. * @param rootUrl The root url of the assets the material depends upon
  57262. * @returns the instantiated BackgroundMaterial.
  57263. */
  57264. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57265. }
  57266. }
  57267. declare module "babylonjs/Helpers/environmentHelper" {
  57268. import { Observable } from "babylonjs/Misc/observable";
  57269. import { Nullable } from "babylonjs/types";
  57270. import { Scene } from "babylonjs/scene";
  57271. import { Vector3 } from "babylonjs/Maths/math.vector";
  57272. import { Color3 } from "babylonjs/Maths/math.color";
  57273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57274. import { Mesh } from "babylonjs/Meshes/mesh";
  57275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57276. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57277. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57278. import "babylonjs/Meshes/Builders/planeBuilder";
  57279. import "babylonjs/Meshes/Builders/boxBuilder";
  57280. /**
  57281. * Represents the different options available during the creation of
  57282. * a Environment helper.
  57283. *
  57284. * This can control the default ground, skybox and image processing setup of your scene.
  57285. */
  57286. export interface IEnvironmentHelperOptions {
  57287. /**
  57288. * Specifies whether or not to create a ground.
  57289. * True by default.
  57290. */
  57291. createGround: boolean;
  57292. /**
  57293. * Specifies the ground size.
  57294. * 15 by default.
  57295. */
  57296. groundSize: number;
  57297. /**
  57298. * The texture used on the ground for the main color.
  57299. * Comes from the BabylonJS CDN by default.
  57300. *
  57301. * Remarks: Can be either a texture or a url.
  57302. */
  57303. groundTexture: string | BaseTexture;
  57304. /**
  57305. * The color mixed in the ground texture by default.
  57306. * BabylonJS clearColor by default.
  57307. */
  57308. groundColor: Color3;
  57309. /**
  57310. * Specifies the ground opacity.
  57311. * 1 by default.
  57312. */
  57313. groundOpacity: number;
  57314. /**
  57315. * Enables the ground to receive shadows.
  57316. * True by default.
  57317. */
  57318. enableGroundShadow: boolean;
  57319. /**
  57320. * Helps preventing the shadow to be fully black on the ground.
  57321. * 0.5 by default.
  57322. */
  57323. groundShadowLevel: number;
  57324. /**
  57325. * Creates a mirror texture attach to the ground.
  57326. * false by default.
  57327. */
  57328. enableGroundMirror: boolean;
  57329. /**
  57330. * Specifies the ground mirror size ratio.
  57331. * 0.3 by default as the default kernel is 64.
  57332. */
  57333. groundMirrorSizeRatio: number;
  57334. /**
  57335. * Specifies the ground mirror blur kernel size.
  57336. * 64 by default.
  57337. */
  57338. groundMirrorBlurKernel: number;
  57339. /**
  57340. * Specifies the ground mirror visibility amount.
  57341. * 1 by default
  57342. */
  57343. groundMirrorAmount: number;
  57344. /**
  57345. * Specifies the ground mirror reflectance weight.
  57346. * This uses the standard weight of the background material to setup the fresnel effect
  57347. * of the mirror.
  57348. * 1 by default.
  57349. */
  57350. groundMirrorFresnelWeight: number;
  57351. /**
  57352. * Specifies the ground mirror Falloff distance.
  57353. * This can helps reducing the size of the reflection.
  57354. * 0 by Default.
  57355. */
  57356. groundMirrorFallOffDistance: number;
  57357. /**
  57358. * Specifies the ground mirror texture type.
  57359. * Unsigned Int by Default.
  57360. */
  57361. groundMirrorTextureType: number;
  57362. /**
  57363. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57364. * the shown objects.
  57365. */
  57366. groundYBias: number;
  57367. /**
  57368. * Specifies whether or not to create a skybox.
  57369. * True by default.
  57370. */
  57371. createSkybox: boolean;
  57372. /**
  57373. * Specifies the skybox size.
  57374. * 20 by default.
  57375. */
  57376. skyboxSize: number;
  57377. /**
  57378. * The texture used on the skybox for the main color.
  57379. * Comes from the BabylonJS CDN by default.
  57380. *
  57381. * Remarks: Can be either a texture or a url.
  57382. */
  57383. skyboxTexture: string | BaseTexture;
  57384. /**
  57385. * The color mixed in the skybox texture by default.
  57386. * BabylonJS clearColor by default.
  57387. */
  57388. skyboxColor: Color3;
  57389. /**
  57390. * The background rotation around the Y axis of the scene.
  57391. * This helps aligning the key lights of your scene with the background.
  57392. * 0 by default.
  57393. */
  57394. backgroundYRotation: number;
  57395. /**
  57396. * Compute automatically the size of the elements to best fit with the scene.
  57397. */
  57398. sizeAuto: boolean;
  57399. /**
  57400. * Default position of the rootMesh if autoSize is not true.
  57401. */
  57402. rootPosition: Vector3;
  57403. /**
  57404. * Sets up the image processing in the scene.
  57405. * true by default.
  57406. */
  57407. setupImageProcessing: boolean;
  57408. /**
  57409. * The texture used as your environment texture in the scene.
  57410. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57411. *
  57412. * Remarks: Can be either a texture or a url.
  57413. */
  57414. environmentTexture: string | BaseTexture;
  57415. /**
  57416. * The value of the exposure to apply to the scene.
  57417. * 0.6 by default if setupImageProcessing is true.
  57418. */
  57419. cameraExposure: number;
  57420. /**
  57421. * The value of the contrast to apply to the scene.
  57422. * 1.6 by default if setupImageProcessing is true.
  57423. */
  57424. cameraContrast: number;
  57425. /**
  57426. * Specifies whether or not tonemapping should be enabled in the scene.
  57427. * true by default if setupImageProcessing is true.
  57428. */
  57429. toneMappingEnabled: boolean;
  57430. }
  57431. /**
  57432. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57433. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57434. * It also helps with the default setup of your imageProcessing configuration.
  57435. */
  57436. export class EnvironmentHelper {
  57437. /**
  57438. * Default ground texture URL.
  57439. */
  57440. private static _groundTextureCDNUrl;
  57441. /**
  57442. * Default skybox texture URL.
  57443. */
  57444. private static _skyboxTextureCDNUrl;
  57445. /**
  57446. * Default environment texture URL.
  57447. */
  57448. private static _environmentTextureCDNUrl;
  57449. /**
  57450. * Creates the default options for the helper.
  57451. */
  57452. private static _getDefaultOptions;
  57453. private _rootMesh;
  57454. /**
  57455. * Gets the root mesh created by the helper.
  57456. */
  57457. get rootMesh(): Mesh;
  57458. private _skybox;
  57459. /**
  57460. * Gets the skybox created by the helper.
  57461. */
  57462. get skybox(): Nullable<Mesh>;
  57463. private _skyboxTexture;
  57464. /**
  57465. * Gets the skybox texture created by the helper.
  57466. */
  57467. get skyboxTexture(): Nullable<BaseTexture>;
  57468. private _skyboxMaterial;
  57469. /**
  57470. * Gets the skybox material created by the helper.
  57471. */
  57472. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57473. private _ground;
  57474. /**
  57475. * Gets the ground mesh created by the helper.
  57476. */
  57477. get ground(): Nullable<Mesh>;
  57478. private _groundTexture;
  57479. /**
  57480. * Gets the ground texture created by the helper.
  57481. */
  57482. get groundTexture(): Nullable<BaseTexture>;
  57483. private _groundMirror;
  57484. /**
  57485. * Gets the ground mirror created by the helper.
  57486. */
  57487. get groundMirror(): Nullable<MirrorTexture>;
  57488. /**
  57489. * Gets the ground mirror render list to helps pushing the meshes
  57490. * you wish in the ground reflection.
  57491. */
  57492. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57493. private _groundMaterial;
  57494. /**
  57495. * Gets the ground material created by the helper.
  57496. */
  57497. get groundMaterial(): Nullable<BackgroundMaterial>;
  57498. /**
  57499. * Stores the creation options.
  57500. */
  57501. private readonly _scene;
  57502. private _options;
  57503. /**
  57504. * This observable will be notified with any error during the creation of the environment,
  57505. * mainly texture creation errors.
  57506. */
  57507. onErrorObservable: Observable<{
  57508. message?: string;
  57509. exception?: any;
  57510. }>;
  57511. /**
  57512. * constructor
  57513. * @param options Defines the options we want to customize the helper
  57514. * @param scene The scene to add the material to
  57515. */
  57516. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57517. /**
  57518. * Updates the background according to the new options
  57519. * @param options
  57520. */
  57521. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57522. /**
  57523. * Sets the primary color of all the available elements.
  57524. * @param color the main color to affect to the ground and the background
  57525. */
  57526. setMainColor(color: Color3): void;
  57527. /**
  57528. * Setup the image processing according to the specified options.
  57529. */
  57530. private _setupImageProcessing;
  57531. /**
  57532. * Setup the environment texture according to the specified options.
  57533. */
  57534. private _setupEnvironmentTexture;
  57535. /**
  57536. * Setup the background according to the specified options.
  57537. */
  57538. private _setupBackground;
  57539. /**
  57540. * Get the scene sizes according to the setup.
  57541. */
  57542. private _getSceneSize;
  57543. /**
  57544. * Setup the ground according to the specified options.
  57545. */
  57546. private _setupGround;
  57547. /**
  57548. * Setup the ground material according to the specified options.
  57549. */
  57550. private _setupGroundMaterial;
  57551. /**
  57552. * Setup the ground diffuse texture according to the specified options.
  57553. */
  57554. private _setupGroundDiffuseTexture;
  57555. /**
  57556. * Setup the ground mirror texture according to the specified options.
  57557. */
  57558. private _setupGroundMirrorTexture;
  57559. /**
  57560. * Setup the ground to receive the mirror texture.
  57561. */
  57562. private _setupMirrorInGroundMaterial;
  57563. /**
  57564. * Setup the skybox according to the specified options.
  57565. */
  57566. private _setupSkybox;
  57567. /**
  57568. * Setup the skybox material according to the specified options.
  57569. */
  57570. private _setupSkyboxMaterial;
  57571. /**
  57572. * Setup the skybox reflection texture according to the specified options.
  57573. */
  57574. private _setupSkyboxReflectionTexture;
  57575. private _errorHandler;
  57576. /**
  57577. * Dispose all the elements created by the Helper.
  57578. */
  57579. dispose(): void;
  57580. }
  57581. }
  57582. declare module "babylonjs/Helpers/textureDome" {
  57583. import { Scene } from "babylonjs/scene";
  57584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57585. import { Mesh } from "babylonjs/Meshes/mesh";
  57586. import { Texture } from "babylonjs/Materials/Textures/texture";
  57587. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57588. import "babylonjs/Meshes/Builders/sphereBuilder";
  57589. import { Nullable } from "babylonjs/types";
  57590. import { Observable } from "babylonjs/Misc/observable";
  57591. /**
  57592. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57593. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57594. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57595. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57596. */
  57597. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57598. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57599. /**
  57600. * Define the source as a Monoscopic panoramic 360/180.
  57601. */
  57602. static readonly MODE_MONOSCOPIC: number;
  57603. /**
  57604. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57605. */
  57606. static readonly MODE_TOPBOTTOM: number;
  57607. /**
  57608. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57609. */
  57610. static readonly MODE_SIDEBYSIDE: number;
  57611. private _halfDome;
  57612. protected _useDirectMapping: boolean;
  57613. /**
  57614. * The texture being displayed on the sphere
  57615. */
  57616. protected _texture: T;
  57617. /**
  57618. * Gets the texture being displayed on the sphere
  57619. */
  57620. get texture(): T;
  57621. /**
  57622. * Sets the texture being displayed on the sphere
  57623. */
  57624. set texture(newTexture: T);
  57625. /**
  57626. * The skybox material
  57627. */
  57628. protected _material: BackgroundMaterial;
  57629. /**
  57630. * The surface used for the dome
  57631. */
  57632. protected _mesh: Mesh;
  57633. /**
  57634. * Gets the mesh used for the dome.
  57635. */
  57636. get mesh(): Mesh;
  57637. /**
  57638. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57639. */
  57640. private _halfDomeMask;
  57641. /**
  57642. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57643. * Also see the options.resolution property.
  57644. */
  57645. get fovMultiplier(): number;
  57646. set fovMultiplier(value: number);
  57647. protected _textureMode: number;
  57648. /**
  57649. * Gets or set the current texture mode for the texture. It can be:
  57650. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57651. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57652. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57653. */
  57654. get textureMode(): number;
  57655. /**
  57656. * Sets the current texture mode for the texture. It can be:
  57657. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57658. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57659. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57660. */
  57661. set textureMode(value: number);
  57662. /**
  57663. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57664. */
  57665. get halfDome(): boolean;
  57666. /**
  57667. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57668. */
  57669. set halfDome(enabled: boolean);
  57670. /**
  57671. * Oberserver used in Stereoscopic VR Mode.
  57672. */
  57673. private _onBeforeCameraRenderObserver;
  57674. /**
  57675. * Observable raised when an error occured while loading the 360 image
  57676. */
  57677. onLoadErrorObservable: Observable<string>;
  57678. /**
  57679. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57680. * @param name Element's name, child elements will append suffixes for their own names.
  57681. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57682. * @param options An object containing optional or exposed sub element properties
  57683. */
  57684. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57685. resolution?: number;
  57686. clickToPlay?: boolean;
  57687. autoPlay?: boolean;
  57688. loop?: boolean;
  57689. size?: number;
  57690. poster?: string;
  57691. faceForward?: boolean;
  57692. useDirectMapping?: boolean;
  57693. halfDomeMode?: boolean;
  57694. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57695. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57696. protected _changeTextureMode(value: number): void;
  57697. /**
  57698. * Releases resources associated with this node.
  57699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57701. */
  57702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57703. }
  57704. }
  57705. declare module "babylonjs/Helpers/photoDome" {
  57706. import { Scene } from "babylonjs/scene";
  57707. import { Texture } from "babylonjs/Materials/Textures/texture";
  57708. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57709. /**
  57710. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57711. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57712. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57713. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57714. */
  57715. export class PhotoDome extends TextureDome<Texture> {
  57716. /**
  57717. * Define the image as a Monoscopic panoramic 360 image.
  57718. */
  57719. static readonly MODE_MONOSCOPIC: number;
  57720. /**
  57721. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57722. */
  57723. static readonly MODE_TOPBOTTOM: number;
  57724. /**
  57725. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57726. */
  57727. static readonly MODE_SIDEBYSIDE: number;
  57728. /**
  57729. * Gets or sets the texture being displayed on the sphere
  57730. */
  57731. get photoTexture(): Texture;
  57732. /**
  57733. * sets the texture being displayed on the sphere
  57734. */
  57735. set photoTexture(value: Texture);
  57736. /**
  57737. * Gets the current video mode for the video. It can be:
  57738. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57739. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57740. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57741. */
  57742. get imageMode(): number;
  57743. /**
  57744. * Sets the current video mode for the video. It can be:
  57745. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57746. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57747. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57748. */
  57749. set imageMode(value: number);
  57750. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57751. }
  57752. }
  57753. declare module "babylonjs/Misc/rgbdTextureTools" {
  57754. import "babylonjs/Shaders/rgbdDecode.fragment";
  57755. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57756. import { Texture } from "babylonjs/Materials/Textures/texture";
  57757. /**
  57758. * Class used to host RGBD texture specific utilities
  57759. */
  57760. export class RGBDTextureTools {
  57761. /**
  57762. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57763. * @param texture the texture to expand.
  57764. */
  57765. static ExpandRGBDTexture(texture: Texture): void;
  57766. }
  57767. }
  57768. declare module "babylonjs/Misc/brdfTextureTools" {
  57769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57770. import { Scene } from "babylonjs/scene";
  57771. /**
  57772. * Class used to host texture specific utilities
  57773. */
  57774. export class BRDFTextureTools {
  57775. /**
  57776. * Prevents texture cache collision
  57777. */
  57778. private static _instanceNumber;
  57779. /**
  57780. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57781. * @param scene defines the hosting scene
  57782. * @returns the environment BRDF texture
  57783. */
  57784. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57785. private static _environmentBRDFBase64Texture;
  57786. }
  57787. }
  57788. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57789. import { Nullable } from "babylonjs/types";
  57790. import { Color3 } from "babylonjs/Maths/math.color";
  57791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57792. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57794. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57795. import { Engine } from "babylonjs/Engines/engine";
  57796. import { Scene } from "babylonjs/scene";
  57797. /**
  57798. * @hidden
  57799. */
  57800. export interface IMaterialClearCoatDefines {
  57801. CLEARCOAT: boolean;
  57802. CLEARCOAT_DEFAULTIOR: boolean;
  57803. CLEARCOAT_TEXTURE: boolean;
  57804. CLEARCOAT_TEXTUREDIRECTUV: number;
  57805. CLEARCOAT_BUMP: boolean;
  57806. CLEARCOAT_BUMPDIRECTUV: number;
  57807. CLEARCOAT_TINT: boolean;
  57808. CLEARCOAT_TINT_TEXTURE: boolean;
  57809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57810. /** @hidden */
  57811. _areTexturesDirty: boolean;
  57812. }
  57813. /**
  57814. * Define the code related to the clear coat parameters of the pbr material.
  57815. */
  57816. export class PBRClearCoatConfiguration {
  57817. /**
  57818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57819. * The default fits with a polyurethane material.
  57820. */
  57821. private static readonly _DefaultIndexOfRefraction;
  57822. private _isEnabled;
  57823. /**
  57824. * Defines if the clear coat is enabled in the material.
  57825. */
  57826. isEnabled: boolean;
  57827. /**
  57828. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57829. */
  57830. intensity: number;
  57831. /**
  57832. * Defines the clear coat layer roughness.
  57833. */
  57834. roughness: number;
  57835. private _indexOfRefraction;
  57836. /**
  57837. * Defines the index of refraction of the clear coat.
  57838. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57839. * The default fits with a polyurethane material.
  57840. * Changing the default value is more performance intensive.
  57841. */
  57842. indexOfRefraction: number;
  57843. private _texture;
  57844. /**
  57845. * Stores the clear coat values in a texture.
  57846. */
  57847. texture: Nullable<BaseTexture>;
  57848. private _bumpTexture;
  57849. /**
  57850. * Define the clear coat specific bump texture.
  57851. */
  57852. bumpTexture: Nullable<BaseTexture>;
  57853. private _isTintEnabled;
  57854. /**
  57855. * Defines if the clear coat tint is enabled in the material.
  57856. */
  57857. isTintEnabled: boolean;
  57858. /**
  57859. * Defines the clear coat tint of the material.
  57860. * This is only use if tint is enabled
  57861. */
  57862. tintColor: Color3;
  57863. /**
  57864. * Defines the distance at which the tint color should be found in the
  57865. * clear coat media.
  57866. * This is only use if tint is enabled
  57867. */
  57868. tintColorAtDistance: number;
  57869. /**
  57870. * Defines the clear coat layer thickness.
  57871. * This is only use if tint is enabled
  57872. */
  57873. tintThickness: number;
  57874. private _tintTexture;
  57875. /**
  57876. * Stores the clear tint values in a texture.
  57877. * rgb is tint
  57878. * a is a thickness factor
  57879. */
  57880. tintTexture: Nullable<BaseTexture>;
  57881. /** @hidden */
  57882. private _internalMarkAllSubMeshesAsTexturesDirty;
  57883. /** @hidden */
  57884. _markAllSubMeshesAsTexturesDirty(): void;
  57885. /**
  57886. * Instantiate a new istance of clear coat configuration.
  57887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57888. */
  57889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57890. /**
  57891. * Gets wehter the submesh is ready to be used or not.
  57892. * @param defines the list of "defines" to update.
  57893. * @param scene defines the scene the material belongs to.
  57894. * @param engine defines the engine the material belongs to.
  57895. * @param disableBumpMap defines wether the material disables bump or not.
  57896. * @returns - boolean indicating that the submesh is ready or not.
  57897. */
  57898. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57899. /**
  57900. * Checks to see if a texture is used in the material.
  57901. * @param defines the list of "defines" to update.
  57902. * @param scene defines the scene to the material belongs to.
  57903. */
  57904. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57905. /**
  57906. * Binds the material data.
  57907. * @param uniformBuffer defines the Uniform buffer to fill in.
  57908. * @param scene defines the scene the material belongs to.
  57909. * @param engine defines the engine the material belongs to.
  57910. * @param disableBumpMap defines wether the material disables bump or not.
  57911. * @param isFrozen defines wether the material is frozen or not.
  57912. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57913. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57914. */
  57915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57916. /**
  57917. * Checks to see if a texture is used in the material.
  57918. * @param texture - Base texture to use.
  57919. * @returns - Boolean specifying if a texture is used in the material.
  57920. */
  57921. hasTexture(texture: BaseTexture): boolean;
  57922. /**
  57923. * Returns an array of the actively used textures.
  57924. * @param activeTextures Array of BaseTextures
  57925. */
  57926. getActiveTextures(activeTextures: BaseTexture[]): void;
  57927. /**
  57928. * Returns the animatable textures.
  57929. * @param animatables Array of animatable textures.
  57930. */
  57931. getAnimatables(animatables: IAnimatable[]): void;
  57932. /**
  57933. * Disposes the resources of the material.
  57934. * @param forceDisposeTextures - Forces the disposal of all textures.
  57935. */
  57936. dispose(forceDisposeTextures?: boolean): void;
  57937. /**
  57938. * Get the current class name of the texture useful for serialization or dynamic coding.
  57939. * @returns "PBRClearCoatConfiguration"
  57940. */
  57941. getClassName(): string;
  57942. /**
  57943. * Add fallbacks to the effect fallbacks list.
  57944. * @param defines defines the Base texture to use.
  57945. * @param fallbacks defines the current fallback list.
  57946. * @param currentRank defines the current fallback rank.
  57947. * @returns the new fallback rank.
  57948. */
  57949. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57950. /**
  57951. * Add the required uniforms to the current list.
  57952. * @param uniforms defines the current uniform list.
  57953. */
  57954. static AddUniforms(uniforms: string[]): void;
  57955. /**
  57956. * Add the required samplers to the current list.
  57957. * @param samplers defines the current sampler list.
  57958. */
  57959. static AddSamplers(samplers: string[]): void;
  57960. /**
  57961. * Add the required uniforms to the current buffer.
  57962. * @param uniformBuffer defines the current uniform buffer.
  57963. */
  57964. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57965. /**
  57966. * Makes a duplicate of the current configuration into another one.
  57967. * @param clearCoatConfiguration define the config where to copy the info
  57968. */
  57969. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57970. /**
  57971. * Serializes this clear coat configuration.
  57972. * @returns - An object with the serialized config.
  57973. */
  57974. serialize(): any;
  57975. /**
  57976. * Parses a anisotropy Configuration from a serialized object.
  57977. * @param source - Serialized object.
  57978. * @param scene Defines the scene we are parsing for
  57979. * @param rootUrl Defines the rootUrl to load from
  57980. */
  57981. parse(source: any, scene: Scene, rootUrl: string): void;
  57982. }
  57983. }
  57984. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57985. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57987. import { Vector2 } from "babylonjs/Maths/math.vector";
  57988. import { Scene } from "babylonjs/scene";
  57989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57990. import { Nullable } from "babylonjs/types";
  57991. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57992. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57993. /**
  57994. * @hidden
  57995. */
  57996. export interface IMaterialAnisotropicDefines {
  57997. ANISOTROPIC: boolean;
  57998. ANISOTROPIC_TEXTURE: boolean;
  57999. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58000. MAINUV1: boolean;
  58001. _areTexturesDirty: boolean;
  58002. _needUVs: boolean;
  58003. }
  58004. /**
  58005. * Define the code related to the anisotropic parameters of the pbr material.
  58006. */
  58007. export class PBRAnisotropicConfiguration {
  58008. private _isEnabled;
  58009. /**
  58010. * Defines if the anisotropy is enabled in the material.
  58011. */
  58012. isEnabled: boolean;
  58013. /**
  58014. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58015. */
  58016. intensity: number;
  58017. /**
  58018. * Defines if the effect is along the tangents, bitangents or in between.
  58019. * By default, the effect is "strectching" the highlights along the tangents.
  58020. */
  58021. direction: Vector2;
  58022. private _texture;
  58023. /**
  58024. * Stores the anisotropy values in a texture.
  58025. * rg is direction (like normal from -1 to 1)
  58026. * b is a intensity
  58027. */
  58028. texture: Nullable<BaseTexture>;
  58029. /** @hidden */
  58030. private _internalMarkAllSubMeshesAsTexturesDirty;
  58031. /** @hidden */
  58032. _markAllSubMeshesAsTexturesDirty(): void;
  58033. /**
  58034. * Instantiate a new istance of anisotropy configuration.
  58035. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58036. */
  58037. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58038. /**
  58039. * Specifies that the submesh is ready to be used.
  58040. * @param defines the list of "defines" to update.
  58041. * @param scene defines the scene the material belongs to.
  58042. * @returns - boolean indicating that the submesh is ready or not.
  58043. */
  58044. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58045. /**
  58046. * Checks to see if a texture is used in the material.
  58047. * @param defines the list of "defines" to update.
  58048. * @param mesh the mesh we are preparing the defines for.
  58049. * @param scene defines the scene the material belongs to.
  58050. */
  58051. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58052. /**
  58053. * Binds the material data.
  58054. * @param uniformBuffer defines the Uniform buffer to fill in.
  58055. * @param scene defines the scene the material belongs to.
  58056. * @param isFrozen defines wether the material is frozen or not.
  58057. */
  58058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58059. /**
  58060. * Checks to see if a texture is used in the material.
  58061. * @param texture - Base texture to use.
  58062. * @returns - Boolean specifying if a texture is used in the material.
  58063. */
  58064. hasTexture(texture: BaseTexture): boolean;
  58065. /**
  58066. * Returns an array of the actively used textures.
  58067. * @param activeTextures Array of BaseTextures
  58068. */
  58069. getActiveTextures(activeTextures: BaseTexture[]): void;
  58070. /**
  58071. * Returns the animatable textures.
  58072. * @param animatables Array of animatable textures.
  58073. */
  58074. getAnimatables(animatables: IAnimatable[]): void;
  58075. /**
  58076. * Disposes the resources of the material.
  58077. * @param forceDisposeTextures - Forces the disposal of all textures.
  58078. */
  58079. dispose(forceDisposeTextures?: boolean): void;
  58080. /**
  58081. * Get the current class name of the texture useful for serialization or dynamic coding.
  58082. * @returns "PBRAnisotropicConfiguration"
  58083. */
  58084. getClassName(): string;
  58085. /**
  58086. * Add fallbacks to the effect fallbacks list.
  58087. * @param defines defines the Base texture to use.
  58088. * @param fallbacks defines the current fallback list.
  58089. * @param currentRank defines the current fallback rank.
  58090. * @returns the new fallback rank.
  58091. */
  58092. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58093. /**
  58094. * Add the required uniforms to the current list.
  58095. * @param uniforms defines the current uniform list.
  58096. */
  58097. static AddUniforms(uniforms: string[]): void;
  58098. /**
  58099. * Add the required uniforms to the current buffer.
  58100. * @param uniformBuffer defines the current uniform buffer.
  58101. */
  58102. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58103. /**
  58104. * Add the required samplers to the current list.
  58105. * @param samplers defines the current sampler list.
  58106. */
  58107. static AddSamplers(samplers: string[]): void;
  58108. /**
  58109. * Makes a duplicate of the current configuration into another one.
  58110. * @param anisotropicConfiguration define the config where to copy the info
  58111. */
  58112. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58113. /**
  58114. * Serializes this anisotropy configuration.
  58115. * @returns - An object with the serialized config.
  58116. */
  58117. serialize(): any;
  58118. /**
  58119. * Parses a anisotropy Configuration from a serialized object.
  58120. * @param source - Serialized object.
  58121. * @param scene Defines the scene we are parsing for
  58122. * @param rootUrl Defines the rootUrl to load from
  58123. */
  58124. parse(source: any, scene: Scene, rootUrl: string): void;
  58125. }
  58126. }
  58127. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58128. import { Scene } from "babylonjs/scene";
  58129. /**
  58130. * @hidden
  58131. */
  58132. export interface IMaterialBRDFDefines {
  58133. BRDF_V_HEIGHT_CORRELATED: boolean;
  58134. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58135. SPHERICAL_HARMONICS: boolean;
  58136. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58137. /** @hidden */
  58138. _areMiscDirty: boolean;
  58139. }
  58140. /**
  58141. * Define the code related to the BRDF parameters of the pbr material.
  58142. */
  58143. export class PBRBRDFConfiguration {
  58144. /**
  58145. * Default value used for the energy conservation.
  58146. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58147. */
  58148. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58149. /**
  58150. * Default value used for the Smith Visibility Height Correlated mode.
  58151. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58152. */
  58153. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58154. /**
  58155. * Default value used for the IBL diffuse part.
  58156. * This can help switching back to the polynomials mode globally which is a tiny bit
  58157. * less GPU intensive at the drawback of a lower quality.
  58158. */
  58159. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58160. /**
  58161. * Default value used for activating energy conservation for the specular workflow.
  58162. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58163. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58164. */
  58165. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58166. private _useEnergyConservation;
  58167. /**
  58168. * Defines if the material uses energy conservation.
  58169. */
  58170. useEnergyConservation: boolean;
  58171. private _useSmithVisibilityHeightCorrelated;
  58172. /**
  58173. * LEGACY Mode set to false
  58174. * Defines if the material uses height smith correlated visibility term.
  58175. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58176. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58177. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58178. * Not relying on height correlated will also disable energy conservation.
  58179. */
  58180. useSmithVisibilityHeightCorrelated: boolean;
  58181. private _useSphericalHarmonics;
  58182. /**
  58183. * LEGACY Mode set to false
  58184. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58185. * diffuse part of the IBL.
  58186. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58187. * to the ground truth.
  58188. */
  58189. useSphericalHarmonics: boolean;
  58190. private _useSpecularGlossinessInputEnergyConservation;
  58191. /**
  58192. * Defines if the material uses energy conservation, when the specular workflow is active.
  58193. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58194. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58195. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58196. */
  58197. useSpecularGlossinessInputEnergyConservation: boolean;
  58198. /** @hidden */
  58199. private _internalMarkAllSubMeshesAsMiscDirty;
  58200. /** @hidden */
  58201. _markAllSubMeshesAsMiscDirty(): void;
  58202. /**
  58203. * Instantiate a new istance of clear coat configuration.
  58204. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58205. */
  58206. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58207. /**
  58208. * Checks to see if a texture is used in the material.
  58209. * @param defines the list of "defines" to update.
  58210. */
  58211. prepareDefines(defines: IMaterialBRDFDefines): void;
  58212. /**
  58213. * Get the current class name of the texture useful for serialization or dynamic coding.
  58214. * @returns "PBRClearCoatConfiguration"
  58215. */
  58216. getClassName(): string;
  58217. /**
  58218. * Makes a duplicate of the current configuration into another one.
  58219. * @param brdfConfiguration define the config where to copy the info
  58220. */
  58221. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58222. /**
  58223. * Serializes this BRDF configuration.
  58224. * @returns - An object with the serialized config.
  58225. */
  58226. serialize(): any;
  58227. /**
  58228. * Parses a anisotropy Configuration from a serialized object.
  58229. * @param source - Serialized object.
  58230. * @param scene Defines the scene we are parsing for
  58231. * @param rootUrl Defines the rootUrl to load from
  58232. */
  58233. parse(source: any, scene: Scene, rootUrl: string): void;
  58234. }
  58235. }
  58236. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58237. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58238. import { Color3 } from "babylonjs/Maths/math.color";
  58239. import { Scene } from "babylonjs/scene";
  58240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58241. import { Nullable } from "babylonjs/types";
  58242. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58243. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58244. /**
  58245. * @hidden
  58246. */
  58247. export interface IMaterialSheenDefines {
  58248. SHEEN: boolean;
  58249. SHEEN_TEXTURE: boolean;
  58250. SHEEN_TEXTUREDIRECTUV: number;
  58251. SHEEN_LINKWITHALBEDO: boolean;
  58252. SHEEN_ROUGHNESS: boolean;
  58253. SHEEN_ALBEDOSCALING: boolean;
  58254. /** @hidden */
  58255. _areTexturesDirty: boolean;
  58256. }
  58257. /**
  58258. * Define the code related to the Sheen parameters of the pbr material.
  58259. */
  58260. export class PBRSheenConfiguration {
  58261. private _isEnabled;
  58262. /**
  58263. * Defines if the material uses sheen.
  58264. */
  58265. isEnabled: boolean;
  58266. private _linkSheenWithAlbedo;
  58267. /**
  58268. * Defines if the sheen is linked to the sheen color.
  58269. */
  58270. linkSheenWithAlbedo: boolean;
  58271. /**
  58272. * Defines the sheen intensity.
  58273. */
  58274. intensity: number;
  58275. /**
  58276. * Defines the sheen color.
  58277. */
  58278. color: Color3;
  58279. private _texture;
  58280. /**
  58281. * Stores the sheen tint values in a texture.
  58282. * rgb is tint
  58283. * a is a intensity or roughness if roughness has been defined
  58284. */
  58285. texture: Nullable<BaseTexture>;
  58286. private _roughness;
  58287. /**
  58288. * Defines the sheen roughness.
  58289. * It is not taken into account if linkSheenWithAlbedo is true.
  58290. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58291. */
  58292. roughness: Nullable<number>;
  58293. private _albedoScaling;
  58294. /**
  58295. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58296. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58297. * making it easier to setup and tweak the effect
  58298. */
  58299. albedoScaling: boolean;
  58300. /** @hidden */
  58301. private _internalMarkAllSubMeshesAsTexturesDirty;
  58302. /** @hidden */
  58303. _markAllSubMeshesAsTexturesDirty(): void;
  58304. /**
  58305. * Instantiate a new istance of clear coat configuration.
  58306. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58307. */
  58308. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58309. /**
  58310. * Specifies that the submesh is ready to be used.
  58311. * @param defines the list of "defines" to update.
  58312. * @param scene defines the scene the material belongs to.
  58313. * @returns - boolean indicating that the submesh is ready or not.
  58314. */
  58315. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58316. /**
  58317. * Checks to see if a texture is used in the material.
  58318. * @param defines the list of "defines" to update.
  58319. * @param scene defines the scene the material belongs to.
  58320. */
  58321. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58322. /**
  58323. * Binds the material data.
  58324. * @param uniformBuffer defines the Uniform buffer to fill in.
  58325. * @param scene defines the scene the material belongs to.
  58326. * @param isFrozen defines wether the material is frozen or not.
  58327. */
  58328. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58329. /**
  58330. * Checks to see if a texture is used in the material.
  58331. * @param texture - Base texture to use.
  58332. * @returns - Boolean specifying if a texture is used in the material.
  58333. */
  58334. hasTexture(texture: BaseTexture): boolean;
  58335. /**
  58336. * Returns an array of the actively used textures.
  58337. * @param activeTextures Array of BaseTextures
  58338. */
  58339. getActiveTextures(activeTextures: BaseTexture[]): void;
  58340. /**
  58341. * Returns the animatable textures.
  58342. * @param animatables Array of animatable textures.
  58343. */
  58344. getAnimatables(animatables: IAnimatable[]): void;
  58345. /**
  58346. * Disposes the resources of the material.
  58347. * @param forceDisposeTextures - Forces the disposal of all textures.
  58348. */
  58349. dispose(forceDisposeTextures?: boolean): void;
  58350. /**
  58351. * Get the current class name of the texture useful for serialization or dynamic coding.
  58352. * @returns "PBRSheenConfiguration"
  58353. */
  58354. getClassName(): string;
  58355. /**
  58356. * Add fallbacks to the effect fallbacks list.
  58357. * @param defines defines the Base texture to use.
  58358. * @param fallbacks defines the current fallback list.
  58359. * @param currentRank defines the current fallback rank.
  58360. * @returns the new fallback rank.
  58361. */
  58362. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58363. /**
  58364. * Add the required uniforms to the current list.
  58365. * @param uniforms defines the current uniform list.
  58366. */
  58367. static AddUniforms(uniforms: string[]): void;
  58368. /**
  58369. * Add the required uniforms to the current buffer.
  58370. * @param uniformBuffer defines the current uniform buffer.
  58371. */
  58372. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58373. /**
  58374. * Add the required samplers to the current list.
  58375. * @param samplers defines the current sampler list.
  58376. */
  58377. static AddSamplers(samplers: string[]): void;
  58378. /**
  58379. * Makes a duplicate of the current configuration into another one.
  58380. * @param sheenConfiguration define the config where to copy the info
  58381. */
  58382. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58383. /**
  58384. * Serializes this BRDF configuration.
  58385. * @returns - An object with the serialized config.
  58386. */
  58387. serialize(): any;
  58388. /**
  58389. * Parses a anisotropy Configuration from a serialized object.
  58390. * @param source - Serialized object.
  58391. * @param scene Defines the scene we are parsing for
  58392. * @param rootUrl Defines the rootUrl to load from
  58393. */
  58394. parse(source: any, scene: Scene, rootUrl: string): void;
  58395. }
  58396. }
  58397. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58398. import { Nullable } from "babylonjs/types";
  58399. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58400. import { Color3 } from "babylonjs/Maths/math.color";
  58401. import { SmartArray } from "babylonjs/Misc/smartArray";
  58402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58404. import { Effect } from "babylonjs/Materials/effect";
  58405. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58406. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58407. import { Engine } from "babylonjs/Engines/engine";
  58408. import { Scene } from "babylonjs/scene";
  58409. /**
  58410. * @hidden
  58411. */
  58412. export interface IMaterialSubSurfaceDefines {
  58413. SUBSURFACE: boolean;
  58414. SS_REFRACTION: boolean;
  58415. SS_TRANSLUCENCY: boolean;
  58416. SS_SCATTERING: boolean;
  58417. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58418. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58419. SS_REFRACTIONMAP_3D: boolean;
  58420. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58421. SS_LODINREFRACTIONALPHA: boolean;
  58422. SS_GAMMAREFRACTION: boolean;
  58423. SS_RGBDREFRACTION: boolean;
  58424. SS_LINEARSPECULARREFRACTION: boolean;
  58425. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58426. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58427. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58428. /** @hidden */
  58429. _areTexturesDirty: boolean;
  58430. }
  58431. /**
  58432. * Define the code related to the sub surface parameters of the pbr material.
  58433. */
  58434. export class PBRSubSurfaceConfiguration {
  58435. private _isRefractionEnabled;
  58436. /**
  58437. * Defines if the refraction is enabled in the material.
  58438. */
  58439. isRefractionEnabled: boolean;
  58440. private _isTranslucencyEnabled;
  58441. /**
  58442. * Defines if the translucency is enabled in the material.
  58443. */
  58444. isTranslucencyEnabled: boolean;
  58445. private _isScatteringEnabled;
  58446. /**
  58447. * Defines if the sub surface scattering is enabled in the material.
  58448. */
  58449. isScatteringEnabled: boolean;
  58450. private _scatteringDiffusionProfileIndex;
  58451. /**
  58452. * Diffusion profile for subsurface scattering.
  58453. * Useful for better scattering in the skins or foliages.
  58454. */
  58455. get scatteringDiffusionProfile(): Nullable<Color3>;
  58456. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58457. /**
  58458. * Defines the refraction intensity of the material.
  58459. * The refraction when enabled replaces the Diffuse part of the material.
  58460. * The intensity helps transitionning between diffuse and refraction.
  58461. */
  58462. refractionIntensity: number;
  58463. /**
  58464. * Defines the translucency intensity of the material.
  58465. * When translucency has been enabled, this defines how much of the "translucency"
  58466. * is addded to the diffuse part of the material.
  58467. */
  58468. translucencyIntensity: number;
  58469. /**
  58470. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58471. */
  58472. useAlbedoToTintRefraction: boolean;
  58473. private _thicknessTexture;
  58474. /**
  58475. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58476. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58477. * 0 would mean minimumThickness
  58478. * 1 would mean maximumThickness
  58479. * The other channels might be use as a mask to vary the different effects intensity.
  58480. */
  58481. thicknessTexture: Nullable<BaseTexture>;
  58482. private _refractionTexture;
  58483. /**
  58484. * Defines the texture to use for refraction.
  58485. */
  58486. refractionTexture: Nullable<BaseTexture>;
  58487. private _indexOfRefraction;
  58488. /**
  58489. * Index of refraction of the material base layer.
  58490. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58491. *
  58492. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58493. *
  58494. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58495. */
  58496. indexOfRefraction: number;
  58497. private _volumeIndexOfRefraction;
  58498. /**
  58499. * Index of refraction of the material's volume.
  58500. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58501. *
  58502. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58503. * the volume will use the same IOR as the surface.
  58504. */
  58505. get volumeIndexOfRefraction(): number;
  58506. set volumeIndexOfRefraction(value: number);
  58507. private _invertRefractionY;
  58508. /**
  58509. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58510. */
  58511. invertRefractionY: boolean;
  58512. private _linkRefractionWithTransparency;
  58513. /**
  58514. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58515. * Materials half opaque for instance using refraction could benefit from this control.
  58516. */
  58517. linkRefractionWithTransparency: boolean;
  58518. /**
  58519. * Defines the minimum thickness stored in the thickness map.
  58520. * If no thickness map is defined, this value will be used to simulate thickness.
  58521. */
  58522. minimumThickness: number;
  58523. /**
  58524. * Defines the maximum thickness stored in the thickness map.
  58525. */
  58526. maximumThickness: number;
  58527. /**
  58528. * Defines the volume tint of the material.
  58529. * This is used for both translucency and scattering.
  58530. */
  58531. tintColor: Color3;
  58532. /**
  58533. * Defines the distance at which the tint color should be found in the media.
  58534. * This is used for refraction only.
  58535. */
  58536. tintColorAtDistance: number;
  58537. /**
  58538. * Defines how far each channel transmit through the media.
  58539. * It is defined as a color to simplify it selection.
  58540. */
  58541. diffusionDistance: Color3;
  58542. private _useMaskFromThicknessTexture;
  58543. /**
  58544. * Stores the intensity of the different subsurface effects in the thickness texture.
  58545. * * the green channel is the translucency intensity.
  58546. * * the blue channel is the scattering intensity.
  58547. * * the alpha channel is the refraction intensity.
  58548. */
  58549. useMaskFromThicknessTexture: boolean;
  58550. private _scene;
  58551. /** @hidden */
  58552. private _internalMarkAllSubMeshesAsTexturesDirty;
  58553. private _internalMarkScenePrePassDirty;
  58554. /** @hidden */
  58555. _markAllSubMeshesAsTexturesDirty(): void;
  58556. /** @hidden */
  58557. _markScenePrePassDirty(): void;
  58558. /**
  58559. * Instantiate a new istance of sub surface configuration.
  58560. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58561. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58562. * @param scene The scene
  58563. */
  58564. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58565. /**
  58566. * Gets wehter the submesh is ready to be used or not.
  58567. * @param defines the list of "defines" to update.
  58568. * @param scene defines the scene the material belongs to.
  58569. * @returns - boolean indicating that the submesh is ready or not.
  58570. */
  58571. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58572. /**
  58573. * Checks to see if a texture is used in the material.
  58574. * @param defines the list of "defines" to update.
  58575. * @param scene defines the scene to the material belongs to.
  58576. */
  58577. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58578. /**
  58579. * Binds the material data.
  58580. * @param uniformBuffer defines the Uniform buffer to fill in.
  58581. * @param scene defines the scene the material belongs to.
  58582. * @param engine defines the engine the material belongs to.
  58583. * @param isFrozen defines whether the material is frozen or not.
  58584. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58585. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58586. */
  58587. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58588. /**
  58589. * Unbinds the material from the mesh.
  58590. * @param activeEffect defines the effect that should be unbound from.
  58591. * @returns true if unbound, otherwise false
  58592. */
  58593. unbind(activeEffect: Effect): boolean;
  58594. /**
  58595. * Returns the texture used for refraction or null if none is used.
  58596. * @param scene defines the scene the material belongs to.
  58597. * @returns - Refraction texture if present. If no refraction texture and refraction
  58598. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58599. */
  58600. private _getRefractionTexture;
  58601. /**
  58602. * Returns true if alpha blending should be disabled.
  58603. */
  58604. get disableAlphaBlending(): boolean;
  58605. /**
  58606. * Fills the list of render target textures.
  58607. * @param renderTargets the list of render targets to update
  58608. */
  58609. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58610. /**
  58611. * Checks to see if a texture is used in the material.
  58612. * @param texture - Base texture to use.
  58613. * @returns - Boolean specifying if a texture is used in the material.
  58614. */
  58615. hasTexture(texture: BaseTexture): boolean;
  58616. /**
  58617. * Gets a boolean indicating that current material needs to register RTT
  58618. * @returns true if this uses a render target otherwise false.
  58619. */
  58620. hasRenderTargetTextures(): boolean;
  58621. /**
  58622. * Returns an array of the actively used textures.
  58623. * @param activeTextures Array of BaseTextures
  58624. */
  58625. getActiveTextures(activeTextures: BaseTexture[]): void;
  58626. /**
  58627. * Returns the animatable textures.
  58628. * @param animatables Array of animatable textures.
  58629. */
  58630. getAnimatables(animatables: IAnimatable[]): void;
  58631. /**
  58632. * Disposes the resources of the material.
  58633. * @param forceDisposeTextures - Forces the disposal of all textures.
  58634. */
  58635. dispose(forceDisposeTextures?: boolean): void;
  58636. /**
  58637. * Get the current class name of the texture useful for serialization or dynamic coding.
  58638. * @returns "PBRSubSurfaceConfiguration"
  58639. */
  58640. getClassName(): string;
  58641. /**
  58642. * Add fallbacks to the effect fallbacks list.
  58643. * @param defines defines the Base texture to use.
  58644. * @param fallbacks defines the current fallback list.
  58645. * @param currentRank defines the current fallback rank.
  58646. * @returns the new fallback rank.
  58647. */
  58648. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58649. /**
  58650. * Add the required uniforms to the current list.
  58651. * @param uniforms defines the current uniform list.
  58652. */
  58653. static AddUniforms(uniforms: string[]): void;
  58654. /**
  58655. * Add the required samplers to the current list.
  58656. * @param samplers defines the current sampler list.
  58657. */
  58658. static AddSamplers(samplers: string[]): void;
  58659. /**
  58660. * Add the required uniforms to the current buffer.
  58661. * @param uniformBuffer defines the current uniform buffer.
  58662. */
  58663. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58664. /**
  58665. * Makes a duplicate of the current configuration into another one.
  58666. * @param configuration define the config where to copy the info
  58667. */
  58668. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58669. /**
  58670. * Serializes this Sub Surface configuration.
  58671. * @returns - An object with the serialized config.
  58672. */
  58673. serialize(): any;
  58674. /**
  58675. * Parses a anisotropy Configuration from a serialized object.
  58676. * @param source - Serialized object.
  58677. * @param scene Defines the scene we are parsing for
  58678. * @param rootUrl Defines the rootUrl to load from
  58679. */
  58680. parse(source: any, scene: Scene, rootUrl: string): void;
  58681. }
  58682. }
  58683. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58684. /** @hidden */
  58685. export var pbrFragmentDeclaration: {
  58686. name: string;
  58687. shader: string;
  58688. };
  58689. }
  58690. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58691. /** @hidden */
  58692. export var pbrUboDeclaration: {
  58693. name: string;
  58694. shader: string;
  58695. };
  58696. }
  58697. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58698. /** @hidden */
  58699. export var pbrFragmentExtraDeclaration: {
  58700. name: string;
  58701. shader: string;
  58702. };
  58703. }
  58704. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58705. /** @hidden */
  58706. export var pbrFragmentSamplersDeclaration: {
  58707. name: string;
  58708. shader: string;
  58709. };
  58710. }
  58711. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58712. /** @hidden */
  58713. export var subSurfaceScatteringFunctions: {
  58714. name: string;
  58715. shader: string;
  58716. };
  58717. }
  58718. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58719. /** @hidden */
  58720. export var importanceSampling: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58726. /** @hidden */
  58727. export var pbrHelperFunctions: {
  58728. name: string;
  58729. shader: string;
  58730. };
  58731. }
  58732. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58733. /** @hidden */
  58734. export var harmonicsFunctions: {
  58735. name: string;
  58736. shader: string;
  58737. };
  58738. }
  58739. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58740. /** @hidden */
  58741. export var pbrDirectLightingSetupFunctions: {
  58742. name: string;
  58743. shader: string;
  58744. };
  58745. }
  58746. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58747. /** @hidden */
  58748. export var pbrDirectLightingFalloffFunctions: {
  58749. name: string;
  58750. shader: string;
  58751. };
  58752. }
  58753. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58754. /** @hidden */
  58755. export var pbrBRDFFunctions: {
  58756. name: string;
  58757. shader: string;
  58758. };
  58759. }
  58760. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58761. /** @hidden */
  58762. export var hdrFilteringFunctions: {
  58763. name: string;
  58764. shader: string;
  58765. };
  58766. }
  58767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58768. /** @hidden */
  58769. export var pbrDirectLightingFunctions: {
  58770. name: string;
  58771. shader: string;
  58772. };
  58773. }
  58774. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58775. /** @hidden */
  58776. export var pbrIBLFunctions: {
  58777. name: string;
  58778. shader: string;
  58779. };
  58780. }
  58781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58782. /** @hidden */
  58783. export var pbrBlockAlbedoOpacity: {
  58784. name: string;
  58785. shader: string;
  58786. };
  58787. }
  58788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58789. /** @hidden */
  58790. export var pbrBlockReflectivity: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58796. /** @hidden */
  58797. export var pbrBlockAmbientOcclusion: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58803. /** @hidden */
  58804. export var pbrBlockAlphaFresnel: {
  58805. name: string;
  58806. shader: string;
  58807. };
  58808. }
  58809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58810. /** @hidden */
  58811. export var pbrBlockAnisotropic: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58817. /** @hidden */
  58818. export var pbrBlockReflection: {
  58819. name: string;
  58820. shader: string;
  58821. };
  58822. }
  58823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58824. /** @hidden */
  58825. export var pbrBlockSheen: {
  58826. name: string;
  58827. shader: string;
  58828. };
  58829. }
  58830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58831. /** @hidden */
  58832. export var pbrBlockClearcoat: {
  58833. name: string;
  58834. shader: string;
  58835. };
  58836. }
  58837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58838. /** @hidden */
  58839. export var pbrBlockSubSurface: {
  58840. name: string;
  58841. shader: string;
  58842. };
  58843. }
  58844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58845. /** @hidden */
  58846. export var pbrBlockNormalGeometric: {
  58847. name: string;
  58848. shader: string;
  58849. };
  58850. }
  58851. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58852. /** @hidden */
  58853. export var pbrBlockNormalFinal: {
  58854. name: string;
  58855. shader: string;
  58856. };
  58857. }
  58858. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58859. /** @hidden */
  58860. export var pbrBlockLightmapInit: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58866. /** @hidden */
  58867. export var pbrBlockGeometryInfo: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58873. /** @hidden */
  58874. export var pbrBlockReflectance0: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58880. /** @hidden */
  58881. export var pbrBlockReflectance: {
  58882. name: string;
  58883. shader: string;
  58884. };
  58885. }
  58886. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58887. /** @hidden */
  58888. export var pbrBlockDirectLighting: {
  58889. name: string;
  58890. shader: string;
  58891. };
  58892. }
  58893. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58894. /** @hidden */
  58895. export var pbrBlockFinalLitComponents: {
  58896. name: string;
  58897. shader: string;
  58898. };
  58899. }
  58900. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58901. /** @hidden */
  58902. export var pbrBlockFinalUnlitComponents: {
  58903. name: string;
  58904. shader: string;
  58905. };
  58906. }
  58907. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58908. /** @hidden */
  58909. export var pbrBlockFinalColorComposition: {
  58910. name: string;
  58911. shader: string;
  58912. };
  58913. }
  58914. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58915. /** @hidden */
  58916. export var pbrBlockImageProcessing: {
  58917. name: string;
  58918. shader: string;
  58919. };
  58920. }
  58921. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58922. /** @hidden */
  58923. export var pbrDebug: {
  58924. name: string;
  58925. shader: string;
  58926. };
  58927. }
  58928. declare module "babylonjs/Shaders/pbr.fragment" {
  58929. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58930. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58931. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58932. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58933. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58934. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58935. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58936. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58937. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58938. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58939. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58940. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58941. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58942. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58943. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58944. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58945. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58946. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58947. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58948. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58949. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58950. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58951. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58952. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58953. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58954. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58955. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58956. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58957. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58958. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58959. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58960. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58964. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58965. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58966. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58967. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58968. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58969. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58971. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58972. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58973. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58974. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58975. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58976. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58977. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58978. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58979. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58980. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58981. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58982. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58983. /** @hidden */
  58984. export var pbrPixelShader: {
  58985. name: string;
  58986. shader: string;
  58987. };
  58988. }
  58989. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58990. /** @hidden */
  58991. export var pbrVertexDeclaration: {
  58992. name: string;
  58993. shader: string;
  58994. };
  58995. }
  58996. declare module "babylonjs/Shaders/pbr.vertex" {
  58997. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58998. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58999. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59000. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59001. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59002. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59003. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59004. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59005. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59006. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59007. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59009. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59010. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59011. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59012. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59013. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59014. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59015. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59016. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59017. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59018. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59019. /** @hidden */
  59020. export var pbrVertexShader: {
  59021. name: string;
  59022. shader: string;
  59023. };
  59024. }
  59025. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59026. import { Nullable } from "babylonjs/types";
  59027. import { Scene } from "babylonjs/scene";
  59028. import { Matrix } from "babylonjs/Maths/math.vector";
  59029. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59031. import { Mesh } from "babylonjs/Meshes/mesh";
  59032. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59033. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59034. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59035. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59036. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59037. import { Color3 } from "babylonjs/Maths/math.color";
  59038. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59039. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59041. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59043. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59044. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59045. import "babylonjs/Shaders/pbr.fragment";
  59046. import "babylonjs/Shaders/pbr.vertex";
  59047. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59048. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59049. /**
  59050. * Manages the defines for the PBR Material.
  59051. * @hidden
  59052. */
  59053. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59054. PBR: boolean;
  59055. NUM_SAMPLES: string;
  59056. REALTIME_FILTERING: boolean;
  59057. MAINUV1: boolean;
  59058. MAINUV2: boolean;
  59059. UV1: boolean;
  59060. UV2: boolean;
  59061. ALBEDO: boolean;
  59062. GAMMAALBEDO: boolean;
  59063. ALBEDODIRECTUV: number;
  59064. VERTEXCOLOR: boolean;
  59065. DETAIL: boolean;
  59066. DETAILDIRECTUV: number;
  59067. DETAIL_NORMALBLENDMETHOD: number;
  59068. AMBIENT: boolean;
  59069. AMBIENTDIRECTUV: number;
  59070. AMBIENTINGRAYSCALE: boolean;
  59071. OPACITY: boolean;
  59072. VERTEXALPHA: boolean;
  59073. OPACITYDIRECTUV: number;
  59074. OPACITYRGB: boolean;
  59075. ALPHATEST: boolean;
  59076. DEPTHPREPASS: boolean;
  59077. ALPHABLEND: boolean;
  59078. ALPHAFROMALBEDO: boolean;
  59079. ALPHATESTVALUE: string;
  59080. SPECULAROVERALPHA: boolean;
  59081. RADIANCEOVERALPHA: boolean;
  59082. ALPHAFRESNEL: boolean;
  59083. LINEARALPHAFRESNEL: boolean;
  59084. PREMULTIPLYALPHA: boolean;
  59085. EMISSIVE: boolean;
  59086. EMISSIVEDIRECTUV: number;
  59087. REFLECTIVITY: boolean;
  59088. REFLECTIVITYDIRECTUV: number;
  59089. SPECULARTERM: boolean;
  59090. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59091. MICROSURFACEAUTOMATIC: boolean;
  59092. LODBASEDMICROSFURACE: boolean;
  59093. MICROSURFACEMAP: boolean;
  59094. MICROSURFACEMAPDIRECTUV: number;
  59095. METALLICWORKFLOW: boolean;
  59096. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59097. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59098. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59099. AOSTOREINMETALMAPRED: boolean;
  59100. METALLIC_REFLECTANCE: boolean;
  59101. METALLIC_REFLECTANCEDIRECTUV: number;
  59102. ENVIRONMENTBRDF: boolean;
  59103. ENVIRONMENTBRDF_RGBD: boolean;
  59104. NORMAL: boolean;
  59105. TANGENT: boolean;
  59106. BUMP: boolean;
  59107. BUMPDIRECTUV: number;
  59108. OBJECTSPACE_NORMALMAP: boolean;
  59109. PARALLAX: boolean;
  59110. PARALLAXOCCLUSION: boolean;
  59111. NORMALXYSCALE: boolean;
  59112. LIGHTMAP: boolean;
  59113. LIGHTMAPDIRECTUV: number;
  59114. USELIGHTMAPASSHADOWMAP: boolean;
  59115. GAMMALIGHTMAP: boolean;
  59116. RGBDLIGHTMAP: boolean;
  59117. REFLECTION: boolean;
  59118. REFLECTIONMAP_3D: boolean;
  59119. REFLECTIONMAP_SPHERICAL: boolean;
  59120. REFLECTIONMAP_PLANAR: boolean;
  59121. REFLECTIONMAP_CUBIC: boolean;
  59122. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59123. REFLECTIONMAP_PROJECTION: boolean;
  59124. REFLECTIONMAP_SKYBOX: boolean;
  59125. REFLECTIONMAP_EXPLICIT: boolean;
  59126. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59127. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59128. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59129. INVERTCUBICMAP: boolean;
  59130. USESPHERICALFROMREFLECTIONMAP: boolean;
  59131. USEIRRADIANCEMAP: boolean;
  59132. SPHERICAL_HARMONICS: boolean;
  59133. USESPHERICALINVERTEX: boolean;
  59134. REFLECTIONMAP_OPPOSITEZ: boolean;
  59135. LODINREFLECTIONALPHA: boolean;
  59136. GAMMAREFLECTION: boolean;
  59137. RGBDREFLECTION: boolean;
  59138. LINEARSPECULARREFLECTION: boolean;
  59139. RADIANCEOCCLUSION: boolean;
  59140. HORIZONOCCLUSION: boolean;
  59141. INSTANCES: boolean;
  59142. THIN_INSTANCES: boolean;
  59143. PREPASS: boolean;
  59144. PREPASS_IRRADIANCE: boolean;
  59145. PREPASS_IRRADIANCE_INDEX: number;
  59146. PREPASS_ALBEDO: boolean;
  59147. PREPASS_ALBEDO_INDEX: number;
  59148. PREPASS_DEPTHNORMAL: boolean;
  59149. PREPASS_DEPTHNORMAL_INDEX: number;
  59150. SCENE_MRT_COUNT: number;
  59151. NUM_BONE_INFLUENCERS: number;
  59152. BonesPerMesh: number;
  59153. BONETEXTURE: boolean;
  59154. NONUNIFORMSCALING: boolean;
  59155. MORPHTARGETS: boolean;
  59156. MORPHTARGETS_NORMAL: boolean;
  59157. MORPHTARGETS_TANGENT: boolean;
  59158. MORPHTARGETS_UV: boolean;
  59159. NUM_MORPH_INFLUENCERS: number;
  59160. IMAGEPROCESSING: boolean;
  59161. VIGNETTE: boolean;
  59162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59163. VIGNETTEBLENDMODEOPAQUE: boolean;
  59164. TONEMAPPING: boolean;
  59165. TONEMAPPING_ACES: boolean;
  59166. CONTRAST: boolean;
  59167. COLORCURVES: boolean;
  59168. COLORGRADING: boolean;
  59169. COLORGRADING3D: boolean;
  59170. SAMPLER3DGREENDEPTH: boolean;
  59171. SAMPLER3DBGRMAP: boolean;
  59172. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59173. EXPOSURE: boolean;
  59174. MULTIVIEW: boolean;
  59175. USEPHYSICALLIGHTFALLOFF: boolean;
  59176. USEGLTFLIGHTFALLOFF: boolean;
  59177. TWOSIDEDLIGHTING: boolean;
  59178. SHADOWFLOAT: boolean;
  59179. CLIPPLANE: boolean;
  59180. CLIPPLANE2: boolean;
  59181. CLIPPLANE3: boolean;
  59182. CLIPPLANE4: boolean;
  59183. CLIPPLANE5: boolean;
  59184. CLIPPLANE6: boolean;
  59185. POINTSIZE: boolean;
  59186. FOG: boolean;
  59187. LOGARITHMICDEPTH: boolean;
  59188. FORCENORMALFORWARD: boolean;
  59189. SPECULARAA: boolean;
  59190. CLEARCOAT: boolean;
  59191. CLEARCOAT_DEFAULTIOR: boolean;
  59192. CLEARCOAT_TEXTURE: boolean;
  59193. CLEARCOAT_TEXTUREDIRECTUV: number;
  59194. CLEARCOAT_BUMP: boolean;
  59195. CLEARCOAT_BUMPDIRECTUV: number;
  59196. CLEARCOAT_TINT: boolean;
  59197. CLEARCOAT_TINT_TEXTURE: boolean;
  59198. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59199. ANISOTROPIC: boolean;
  59200. ANISOTROPIC_TEXTURE: boolean;
  59201. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59202. BRDF_V_HEIGHT_CORRELATED: boolean;
  59203. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59204. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59205. SHEEN: boolean;
  59206. SHEEN_TEXTURE: boolean;
  59207. SHEEN_TEXTUREDIRECTUV: number;
  59208. SHEEN_LINKWITHALBEDO: boolean;
  59209. SHEEN_ROUGHNESS: boolean;
  59210. SHEEN_ALBEDOSCALING: boolean;
  59211. SUBSURFACE: boolean;
  59212. SS_REFRACTION: boolean;
  59213. SS_TRANSLUCENCY: boolean;
  59214. SS_SCATTERING: boolean;
  59215. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59216. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59217. SS_REFRACTIONMAP_3D: boolean;
  59218. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59219. SS_LODINREFRACTIONALPHA: boolean;
  59220. SS_GAMMAREFRACTION: boolean;
  59221. SS_RGBDREFRACTION: boolean;
  59222. SS_LINEARSPECULARREFRACTION: boolean;
  59223. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59224. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59225. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59226. UNLIT: boolean;
  59227. DEBUGMODE: number;
  59228. /**
  59229. * Initializes the PBR Material defines.
  59230. */
  59231. constructor();
  59232. /**
  59233. * Resets the PBR Material defines.
  59234. */
  59235. reset(): void;
  59236. }
  59237. /**
  59238. * The Physically based material base class of BJS.
  59239. *
  59240. * This offers the main features of a standard PBR material.
  59241. * For more information, please refer to the documentation :
  59242. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59243. */
  59244. export abstract class PBRBaseMaterial extends PushMaterial {
  59245. /**
  59246. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59247. */
  59248. static readonly PBRMATERIAL_OPAQUE: number;
  59249. /**
  59250. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59251. */
  59252. static readonly PBRMATERIAL_ALPHATEST: number;
  59253. /**
  59254. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59255. */
  59256. static readonly PBRMATERIAL_ALPHABLEND: number;
  59257. /**
  59258. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59259. * They are also discarded below the alpha cutoff threshold to improve performances.
  59260. */
  59261. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59262. /**
  59263. * Defines the default value of how much AO map is occluding the analytical lights
  59264. * (point spot...).
  59265. */
  59266. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59267. /**
  59268. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59269. */
  59270. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59271. /**
  59272. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59273. * to enhance interoperability with other engines.
  59274. */
  59275. static readonly LIGHTFALLOFF_GLTF: number;
  59276. /**
  59277. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59278. * to enhance interoperability with other materials.
  59279. */
  59280. static readonly LIGHTFALLOFF_STANDARD: number;
  59281. /**
  59282. * Intensity of the direct lights e.g. the four lights available in your scene.
  59283. * This impacts both the direct diffuse and specular highlights.
  59284. */
  59285. protected _directIntensity: number;
  59286. /**
  59287. * Intensity of the emissive part of the material.
  59288. * This helps controlling the emissive effect without modifying the emissive color.
  59289. */
  59290. protected _emissiveIntensity: number;
  59291. /**
  59292. * Intensity of the environment e.g. how much the environment will light the object
  59293. * either through harmonics for rough material or through the refelction for shiny ones.
  59294. */
  59295. protected _environmentIntensity: number;
  59296. /**
  59297. * This is a special control allowing the reduction of the specular highlights coming from the
  59298. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59299. */
  59300. protected _specularIntensity: number;
  59301. /**
  59302. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59303. */
  59304. private _lightingInfos;
  59305. /**
  59306. * Debug Control allowing disabling the bump map on this material.
  59307. */
  59308. protected _disableBumpMap: boolean;
  59309. /**
  59310. * AKA Diffuse Texture in standard nomenclature.
  59311. */
  59312. protected _albedoTexture: Nullable<BaseTexture>;
  59313. /**
  59314. * AKA Occlusion Texture in other nomenclature.
  59315. */
  59316. protected _ambientTexture: Nullable<BaseTexture>;
  59317. /**
  59318. * AKA Occlusion Texture Intensity in other nomenclature.
  59319. */
  59320. protected _ambientTextureStrength: number;
  59321. /**
  59322. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59323. * 1 means it completely occludes it
  59324. * 0 mean it has no impact
  59325. */
  59326. protected _ambientTextureImpactOnAnalyticalLights: number;
  59327. /**
  59328. * Stores the alpha values in a texture.
  59329. */
  59330. protected _opacityTexture: Nullable<BaseTexture>;
  59331. /**
  59332. * Stores the reflection values in a texture.
  59333. */
  59334. protected _reflectionTexture: Nullable<BaseTexture>;
  59335. /**
  59336. * Stores the emissive values in a texture.
  59337. */
  59338. protected _emissiveTexture: Nullable<BaseTexture>;
  59339. /**
  59340. * AKA Specular texture in other nomenclature.
  59341. */
  59342. protected _reflectivityTexture: Nullable<BaseTexture>;
  59343. /**
  59344. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59345. */
  59346. protected _metallicTexture: Nullable<BaseTexture>;
  59347. /**
  59348. * Specifies the metallic scalar of the metallic/roughness workflow.
  59349. * Can also be used to scale the metalness values of the metallic texture.
  59350. */
  59351. protected _metallic: Nullable<number>;
  59352. /**
  59353. * Specifies the roughness scalar of the metallic/roughness workflow.
  59354. * Can also be used to scale the roughness values of the metallic texture.
  59355. */
  59356. protected _roughness: Nullable<number>;
  59357. /**
  59358. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59359. * By default the indexOfrefraction is used to compute F0;
  59360. *
  59361. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59362. *
  59363. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59364. * F90 = metallicReflectanceColor;
  59365. */
  59366. protected _metallicF0Factor: number;
  59367. /**
  59368. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59369. * By default the F90 is always 1;
  59370. *
  59371. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59372. *
  59373. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59374. * F90 = metallicReflectanceColor;
  59375. */
  59376. protected _metallicReflectanceColor: Color3;
  59377. /**
  59378. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59379. * This is multiply against the scalar values defined in the material.
  59380. */
  59381. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59382. /**
  59383. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59384. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59385. */
  59386. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59387. /**
  59388. * Stores surface normal data used to displace a mesh in a texture.
  59389. */
  59390. protected _bumpTexture: Nullable<BaseTexture>;
  59391. /**
  59392. * Stores the pre-calculated light information of a mesh in a texture.
  59393. */
  59394. protected _lightmapTexture: Nullable<BaseTexture>;
  59395. /**
  59396. * The color of a material in ambient lighting.
  59397. */
  59398. protected _ambientColor: Color3;
  59399. /**
  59400. * AKA Diffuse Color in other nomenclature.
  59401. */
  59402. protected _albedoColor: Color3;
  59403. /**
  59404. * AKA Specular Color in other nomenclature.
  59405. */
  59406. protected _reflectivityColor: Color3;
  59407. /**
  59408. * The color applied when light is reflected from a material.
  59409. */
  59410. protected _reflectionColor: Color3;
  59411. /**
  59412. * The color applied when light is emitted from a material.
  59413. */
  59414. protected _emissiveColor: Color3;
  59415. /**
  59416. * AKA Glossiness in other nomenclature.
  59417. */
  59418. protected _microSurface: number;
  59419. /**
  59420. * Specifies that the material will use the light map as a show map.
  59421. */
  59422. protected _useLightmapAsShadowmap: boolean;
  59423. /**
  59424. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59425. * makes the reflect vector face the model (under horizon).
  59426. */
  59427. protected _useHorizonOcclusion: boolean;
  59428. /**
  59429. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59430. * too much the area relying on ambient texture to define their ambient occlusion.
  59431. */
  59432. protected _useRadianceOcclusion: boolean;
  59433. /**
  59434. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59435. */
  59436. protected _useAlphaFromAlbedoTexture: boolean;
  59437. /**
  59438. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59439. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59440. */
  59441. protected _useSpecularOverAlpha: boolean;
  59442. /**
  59443. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59444. */
  59445. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59446. /**
  59447. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59448. */
  59449. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59450. /**
  59451. * Specifies if the metallic texture contains the roughness information in its green channel.
  59452. */
  59453. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59454. /**
  59455. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59456. */
  59457. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59458. /**
  59459. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59460. */
  59461. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59462. /**
  59463. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59464. */
  59465. protected _useAmbientInGrayScale: boolean;
  59466. /**
  59467. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59468. * The material will try to infer what glossiness each pixel should be.
  59469. */
  59470. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59471. /**
  59472. * Defines the falloff type used in this material.
  59473. * It by default is Physical.
  59474. */
  59475. protected _lightFalloff: number;
  59476. /**
  59477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59479. */
  59480. protected _useRadianceOverAlpha: boolean;
  59481. /**
  59482. * Allows using an object space normal map (instead of tangent space).
  59483. */
  59484. protected _useObjectSpaceNormalMap: boolean;
  59485. /**
  59486. * Allows using the bump map in parallax mode.
  59487. */
  59488. protected _useParallax: boolean;
  59489. /**
  59490. * Allows using the bump map in parallax occlusion mode.
  59491. */
  59492. protected _useParallaxOcclusion: boolean;
  59493. /**
  59494. * Controls the scale bias of the parallax mode.
  59495. */
  59496. protected _parallaxScaleBias: number;
  59497. /**
  59498. * If sets to true, disables all the lights affecting the material.
  59499. */
  59500. protected _disableLighting: boolean;
  59501. /**
  59502. * Number of Simultaneous lights allowed on the material.
  59503. */
  59504. protected _maxSimultaneousLights: number;
  59505. /**
  59506. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59507. */
  59508. protected _invertNormalMapX: boolean;
  59509. /**
  59510. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59511. */
  59512. protected _invertNormalMapY: boolean;
  59513. /**
  59514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59515. */
  59516. protected _twoSidedLighting: boolean;
  59517. /**
  59518. * Defines the alpha limits in alpha test mode.
  59519. */
  59520. protected _alphaCutOff: number;
  59521. /**
  59522. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59523. */
  59524. protected _forceAlphaTest: boolean;
  59525. /**
  59526. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59527. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59528. */
  59529. protected _useAlphaFresnel: boolean;
  59530. /**
  59531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59532. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59533. */
  59534. protected _useLinearAlphaFresnel: boolean;
  59535. /**
  59536. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59537. * from cos thetav and roughness:
  59538. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59539. */
  59540. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59541. /**
  59542. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59543. */
  59544. protected _forceIrradianceInFragment: boolean;
  59545. private _realTimeFiltering;
  59546. /**
  59547. * Enables realtime filtering on the texture.
  59548. */
  59549. get realTimeFiltering(): boolean;
  59550. set realTimeFiltering(b: boolean);
  59551. private _realTimeFilteringQuality;
  59552. /**
  59553. * Quality switch for realtime filtering
  59554. */
  59555. get realTimeFilteringQuality(): number;
  59556. set realTimeFilteringQuality(n: number);
  59557. /**
  59558. * Can this material render to several textures at once
  59559. */
  59560. get canRenderToMRT(): boolean;
  59561. /**
  59562. * Force normal to face away from face.
  59563. */
  59564. protected _forceNormalForward: boolean;
  59565. /**
  59566. * Enables specular anti aliasing in the PBR shader.
  59567. * It will both interacts on the Geometry for analytical and IBL lighting.
  59568. * It also prefilter the roughness map based on the bump values.
  59569. */
  59570. protected _enableSpecularAntiAliasing: boolean;
  59571. /**
  59572. * Default configuration related to image processing available in the PBR Material.
  59573. */
  59574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59575. /**
  59576. * Keep track of the image processing observer to allow dispose and replace.
  59577. */
  59578. private _imageProcessingObserver;
  59579. /**
  59580. * Attaches a new image processing configuration to the PBR Material.
  59581. * @param configuration
  59582. */
  59583. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59584. /**
  59585. * Stores the available render targets.
  59586. */
  59587. private _renderTargets;
  59588. /**
  59589. * Sets the global ambient color for the material used in lighting calculations.
  59590. */
  59591. private _globalAmbientColor;
  59592. /**
  59593. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59594. */
  59595. private _useLogarithmicDepth;
  59596. /**
  59597. * If set to true, no lighting calculations will be applied.
  59598. */
  59599. private _unlit;
  59600. private _debugMode;
  59601. /**
  59602. * @hidden
  59603. * This is reserved for the inspector.
  59604. * Defines the material debug mode.
  59605. * It helps seeing only some components of the material while troubleshooting.
  59606. */
  59607. debugMode: number;
  59608. /**
  59609. * @hidden
  59610. * This is reserved for the inspector.
  59611. * Specify from where on screen the debug mode should start.
  59612. * The value goes from -1 (full screen) to 1 (not visible)
  59613. * It helps with side by side comparison against the final render
  59614. * This defaults to -1
  59615. */
  59616. private debugLimit;
  59617. /**
  59618. * @hidden
  59619. * This is reserved for the inspector.
  59620. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59621. * You can use the factor to better multiply the final value.
  59622. */
  59623. private debugFactor;
  59624. /**
  59625. * Defines the clear coat layer parameters for the material.
  59626. */
  59627. readonly clearCoat: PBRClearCoatConfiguration;
  59628. /**
  59629. * Defines the anisotropic parameters for the material.
  59630. */
  59631. readonly anisotropy: PBRAnisotropicConfiguration;
  59632. /**
  59633. * Defines the BRDF parameters for the material.
  59634. */
  59635. readonly brdf: PBRBRDFConfiguration;
  59636. /**
  59637. * Defines the Sheen parameters for the material.
  59638. */
  59639. readonly sheen: PBRSheenConfiguration;
  59640. /**
  59641. * Defines the SubSurface parameters for the material.
  59642. */
  59643. readonly subSurface: PBRSubSurfaceConfiguration;
  59644. /**
  59645. * Defines the detail map parameters for the material.
  59646. */
  59647. readonly detailMap: DetailMapConfiguration;
  59648. protected _rebuildInParallel: boolean;
  59649. /**
  59650. * Instantiates a new PBRMaterial instance.
  59651. *
  59652. * @param name The material name
  59653. * @param scene The scene the material will be use in.
  59654. */
  59655. constructor(name: string, scene: Scene);
  59656. /**
  59657. * Gets a boolean indicating that current material needs to register RTT
  59658. */
  59659. get hasRenderTargetTextures(): boolean;
  59660. /**
  59661. * Gets the name of the material class.
  59662. */
  59663. getClassName(): string;
  59664. /**
  59665. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59666. */
  59667. get useLogarithmicDepth(): boolean;
  59668. /**
  59669. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59670. */
  59671. set useLogarithmicDepth(value: boolean);
  59672. /**
  59673. * Returns true if alpha blending should be disabled.
  59674. */
  59675. protected get _disableAlphaBlending(): boolean;
  59676. /**
  59677. * Specifies whether or not this material should be rendered in alpha blend mode.
  59678. */
  59679. needAlphaBlending(): boolean;
  59680. /**
  59681. * Specifies whether or not this material should be rendered in alpha test mode.
  59682. */
  59683. needAlphaTesting(): boolean;
  59684. /**
  59685. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59686. */
  59687. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59688. /**
  59689. * Gets the texture used for the alpha test.
  59690. */
  59691. getAlphaTestTexture(): Nullable<BaseTexture>;
  59692. /**
  59693. * Specifies that the submesh is ready to be used.
  59694. * @param mesh - BJS mesh.
  59695. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59696. * @param useInstances - Specifies that instances should be used.
  59697. * @returns - boolean indicating that the submesh is ready or not.
  59698. */
  59699. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59700. /**
  59701. * Specifies if the material uses metallic roughness workflow.
  59702. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59703. */
  59704. isMetallicWorkflow(): boolean;
  59705. private _prepareEffect;
  59706. private _prepareDefines;
  59707. /**
  59708. * Force shader compilation
  59709. */
  59710. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59711. /**
  59712. * Initializes the uniform buffer layout for the shader.
  59713. */
  59714. buildUniformLayout(): void;
  59715. /**
  59716. * Unbinds the material from the mesh
  59717. */
  59718. unbind(): void;
  59719. /**
  59720. * Binds the submesh data.
  59721. * @param world - The world matrix.
  59722. * @param mesh - The BJS mesh.
  59723. * @param subMesh - A submesh of the BJS mesh.
  59724. */
  59725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59726. /**
  59727. * Returns the animatable textures.
  59728. * @returns - Array of animatable textures.
  59729. */
  59730. getAnimatables(): IAnimatable[];
  59731. /**
  59732. * Returns the texture used for reflections.
  59733. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59734. */
  59735. private _getReflectionTexture;
  59736. /**
  59737. * Returns an array of the actively used textures.
  59738. * @returns - Array of BaseTextures
  59739. */
  59740. getActiveTextures(): BaseTexture[];
  59741. /**
  59742. * Checks to see if a texture is used in the material.
  59743. * @param texture - Base texture to use.
  59744. * @returns - Boolean specifying if a texture is used in the material.
  59745. */
  59746. hasTexture(texture: BaseTexture): boolean;
  59747. /**
  59748. * Sets the required values to the prepass renderer.
  59749. * @param prePassRenderer defines the prepass renderer to setup
  59750. */
  59751. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59752. /**
  59753. * Disposes the resources of the material.
  59754. * @param forceDisposeEffect - Forces the disposal of effects.
  59755. * @param forceDisposeTextures - Forces the disposal of all textures.
  59756. */
  59757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59758. }
  59759. }
  59760. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59761. import { Nullable } from "babylonjs/types";
  59762. import { Scene } from "babylonjs/scene";
  59763. import { Color3 } from "babylonjs/Maths/math.color";
  59764. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59765. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59767. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59768. /**
  59769. * The Physically based material of BJS.
  59770. *
  59771. * This offers the main features of a standard PBR material.
  59772. * For more information, please refer to the documentation :
  59773. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59774. */
  59775. export class PBRMaterial extends PBRBaseMaterial {
  59776. /**
  59777. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59778. */
  59779. static readonly PBRMATERIAL_OPAQUE: number;
  59780. /**
  59781. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59782. */
  59783. static readonly PBRMATERIAL_ALPHATEST: number;
  59784. /**
  59785. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59786. */
  59787. static readonly PBRMATERIAL_ALPHABLEND: number;
  59788. /**
  59789. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59790. * They are also discarded below the alpha cutoff threshold to improve performances.
  59791. */
  59792. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59793. /**
  59794. * Defines the default value of how much AO map is occluding the analytical lights
  59795. * (point spot...).
  59796. */
  59797. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59798. /**
  59799. * Intensity of the direct lights e.g. the four lights available in your scene.
  59800. * This impacts both the direct diffuse and specular highlights.
  59801. */
  59802. directIntensity: number;
  59803. /**
  59804. * Intensity of the emissive part of the material.
  59805. * This helps controlling the emissive effect without modifying the emissive color.
  59806. */
  59807. emissiveIntensity: number;
  59808. /**
  59809. * Intensity of the environment e.g. how much the environment will light the object
  59810. * either through harmonics for rough material or through the refelction for shiny ones.
  59811. */
  59812. environmentIntensity: number;
  59813. /**
  59814. * This is a special control allowing the reduction of the specular highlights coming from the
  59815. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59816. */
  59817. specularIntensity: number;
  59818. /**
  59819. * Debug Control allowing disabling the bump map on this material.
  59820. */
  59821. disableBumpMap: boolean;
  59822. /**
  59823. * AKA Diffuse Texture in standard nomenclature.
  59824. */
  59825. albedoTexture: BaseTexture;
  59826. /**
  59827. * AKA Occlusion Texture in other nomenclature.
  59828. */
  59829. ambientTexture: BaseTexture;
  59830. /**
  59831. * AKA Occlusion Texture Intensity in other nomenclature.
  59832. */
  59833. ambientTextureStrength: number;
  59834. /**
  59835. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59836. * 1 means it completely occludes it
  59837. * 0 mean it has no impact
  59838. */
  59839. ambientTextureImpactOnAnalyticalLights: number;
  59840. /**
  59841. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59842. */
  59843. opacityTexture: BaseTexture;
  59844. /**
  59845. * Stores the reflection values in a texture.
  59846. */
  59847. reflectionTexture: Nullable<BaseTexture>;
  59848. /**
  59849. * Stores the emissive values in a texture.
  59850. */
  59851. emissiveTexture: BaseTexture;
  59852. /**
  59853. * AKA Specular texture in other nomenclature.
  59854. */
  59855. reflectivityTexture: BaseTexture;
  59856. /**
  59857. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59858. */
  59859. metallicTexture: BaseTexture;
  59860. /**
  59861. * Specifies the metallic scalar of the metallic/roughness workflow.
  59862. * Can also be used to scale the metalness values of the metallic texture.
  59863. */
  59864. metallic: Nullable<number>;
  59865. /**
  59866. * Specifies the roughness scalar of the metallic/roughness workflow.
  59867. * Can also be used to scale the roughness values of the metallic texture.
  59868. */
  59869. roughness: Nullable<number>;
  59870. /**
  59871. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59872. * By default the indexOfrefraction is used to compute F0;
  59873. *
  59874. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59875. *
  59876. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59877. * F90 = metallicReflectanceColor;
  59878. */
  59879. metallicF0Factor: number;
  59880. /**
  59881. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59882. * By default the F90 is always 1;
  59883. *
  59884. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59885. *
  59886. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59887. * F90 = metallicReflectanceColor;
  59888. */
  59889. metallicReflectanceColor: Color3;
  59890. /**
  59891. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59892. * This is multiply against the scalar values defined in the material.
  59893. */
  59894. metallicReflectanceTexture: Nullable<BaseTexture>;
  59895. /**
  59896. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59897. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59898. */
  59899. microSurfaceTexture: BaseTexture;
  59900. /**
  59901. * Stores surface normal data used to displace a mesh in a texture.
  59902. */
  59903. bumpTexture: BaseTexture;
  59904. /**
  59905. * Stores the pre-calculated light information of a mesh in a texture.
  59906. */
  59907. lightmapTexture: BaseTexture;
  59908. /**
  59909. * Stores the refracted light information in a texture.
  59910. */
  59911. get refractionTexture(): Nullable<BaseTexture>;
  59912. set refractionTexture(value: Nullable<BaseTexture>);
  59913. /**
  59914. * The color of a material in ambient lighting.
  59915. */
  59916. ambientColor: Color3;
  59917. /**
  59918. * AKA Diffuse Color in other nomenclature.
  59919. */
  59920. albedoColor: Color3;
  59921. /**
  59922. * AKA Specular Color in other nomenclature.
  59923. */
  59924. reflectivityColor: Color3;
  59925. /**
  59926. * The color reflected from the material.
  59927. */
  59928. reflectionColor: Color3;
  59929. /**
  59930. * The color emitted from the material.
  59931. */
  59932. emissiveColor: Color3;
  59933. /**
  59934. * AKA Glossiness in other nomenclature.
  59935. */
  59936. microSurface: number;
  59937. /**
  59938. * Index of refraction of the material base layer.
  59939. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59940. *
  59941. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59942. *
  59943. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59944. */
  59945. get indexOfRefraction(): number;
  59946. set indexOfRefraction(value: number);
  59947. /**
  59948. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59949. */
  59950. get invertRefractionY(): boolean;
  59951. set invertRefractionY(value: boolean);
  59952. /**
  59953. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59954. * Materials half opaque for instance using refraction could benefit from this control.
  59955. */
  59956. get linkRefractionWithTransparency(): boolean;
  59957. set linkRefractionWithTransparency(value: boolean);
  59958. /**
  59959. * If true, the light map contains occlusion information instead of lighting info.
  59960. */
  59961. useLightmapAsShadowmap: boolean;
  59962. /**
  59963. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59964. */
  59965. useAlphaFromAlbedoTexture: boolean;
  59966. /**
  59967. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59968. */
  59969. forceAlphaTest: boolean;
  59970. /**
  59971. * Defines the alpha limits in alpha test mode.
  59972. */
  59973. alphaCutOff: number;
  59974. /**
  59975. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59976. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59977. */
  59978. useSpecularOverAlpha: boolean;
  59979. /**
  59980. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59981. */
  59982. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59983. /**
  59984. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59985. */
  59986. useRoughnessFromMetallicTextureAlpha: boolean;
  59987. /**
  59988. * Specifies if the metallic texture contains the roughness information in its green channel.
  59989. */
  59990. useRoughnessFromMetallicTextureGreen: boolean;
  59991. /**
  59992. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59993. */
  59994. useMetallnessFromMetallicTextureBlue: boolean;
  59995. /**
  59996. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59997. */
  59998. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59999. /**
  60000. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60001. */
  60002. useAmbientInGrayScale: boolean;
  60003. /**
  60004. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60005. * The material will try to infer what glossiness each pixel should be.
  60006. */
  60007. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60008. /**
  60009. * BJS is using an harcoded light falloff based on a manually sets up range.
  60010. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60011. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60012. */
  60013. get usePhysicalLightFalloff(): boolean;
  60014. /**
  60015. * BJS is using an harcoded light falloff based on a manually sets up range.
  60016. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60017. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60018. */
  60019. set usePhysicalLightFalloff(value: boolean);
  60020. /**
  60021. * In order to support the falloff compatibility with gltf, a special mode has been added
  60022. * to reproduce the gltf light falloff.
  60023. */
  60024. get useGLTFLightFalloff(): boolean;
  60025. /**
  60026. * In order to support the falloff compatibility with gltf, a special mode has been added
  60027. * to reproduce the gltf light falloff.
  60028. */
  60029. set useGLTFLightFalloff(value: boolean);
  60030. /**
  60031. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60032. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60033. */
  60034. useRadianceOverAlpha: boolean;
  60035. /**
  60036. * Allows using an object space normal map (instead of tangent space).
  60037. */
  60038. useObjectSpaceNormalMap: boolean;
  60039. /**
  60040. * Allows using the bump map in parallax mode.
  60041. */
  60042. useParallax: boolean;
  60043. /**
  60044. * Allows using the bump map in parallax occlusion mode.
  60045. */
  60046. useParallaxOcclusion: boolean;
  60047. /**
  60048. * Controls the scale bias of the parallax mode.
  60049. */
  60050. parallaxScaleBias: number;
  60051. /**
  60052. * If sets to true, disables all the lights affecting the material.
  60053. */
  60054. disableLighting: boolean;
  60055. /**
  60056. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60057. */
  60058. forceIrradianceInFragment: boolean;
  60059. /**
  60060. * Number of Simultaneous lights allowed on the material.
  60061. */
  60062. maxSimultaneousLights: number;
  60063. /**
  60064. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60065. */
  60066. invertNormalMapX: boolean;
  60067. /**
  60068. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60069. */
  60070. invertNormalMapY: boolean;
  60071. /**
  60072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60073. */
  60074. twoSidedLighting: boolean;
  60075. /**
  60076. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60077. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60078. */
  60079. useAlphaFresnel: boolean;
  60080. /**
  60081. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60082. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60083. */
  60084. useLinearAlphaFresnel: boolean;
  60085. /**
  60086. * Let user defines the brdf lookup texture used for IBL.
  60087. * A default 8bit version is embedded but you could point at :
  60088. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60089. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60090. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60091. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60092. */
  60093. environmentBRDFTexture: Nullable<BaseTexture>;
  60094. /**
  60095. * Force normal to face away from face.
  60096. */
  60097. forceNormalForward: boolean;
  60098. /**
  60099. * Enables specular anti aliasing in the PBR shader.
  60100. * It will both interacts on the Geometry for analytical and IBL lighting.
  60101. * It also prefilter the roughness map based on the bump values.
  60102. */
  60103. enableSpecularAntiAliasing: boolean;
  60104. /**
  60105. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60106. * makes the reflect vector face the model (under horizon).
  60107. */
  60108. useHorizonOcclusion: boolean;
  60109. /**
  60110. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60111. * too much the area relying on ambient texture to define their ambient occlusion.
  60112. */
  60113. useRadianceOcclusion: boolean;
  60114. /**
  60115. * If set to true, no lighting calculations will be applied.
  60116. */
  60117. unlit: boolean;
  60118. /**
  60119. * Gets the image processing configuration used either in this material.
  60120. */
  60121. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60122. /**
  60123. * Sets the Default image processing configuration used either in the this material.
  60124. *
  60125. * If sets to null, the scene one is in use.
  60126. */
  60127. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60128. /**
  60129. * Gets wether the color curves effect is enabled.
  60130. */
  60131. get cameraColorCurvesEnabled(): boolean;
  60132. /**
  60133. * Sets wether the color curves effect is enabled.
  60134. */
  60135. set cameraColorCurvesEnabled(value: boolean);
  60136. /**
  60137. * Gets wether the color grading effect is enabled.
  60138. */
  60139. get cameraColorGradingEnabled(): boolean;
  60140. /**
  60141. * Gets wether the color grading effect is enabled.
  60142. */
  60143. set cameraColorGradingEnabled(value: boolean);
  60144. /**
  60145. * Gets wether tonemapping is enabled or not.
  60146. */
  60147. get cameraToneMappingEnabled(): boolean;
  60148. /**
  60149. * Sets wether tonemapping is enabled or not
  60150. */
  60151. set cameraToneMappingEnabled(value: boolean);
  60152. /**
  60153. * The camera exposure used on this material.
  60154. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60155. * This corresponds to a photographic exposure.
  60156. */
  60157. get cameraExposure(): number;
  60158. /**
  60159. * The camera exposure used on this material.
  60160. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60161. * This corresponds to a photographic exposure.
  60162. */
  60163. set cameraExposure(value: number);
  60164. /**
  60165. * Gets The camera contrast used on this material.
  60166. */
  60167. get cameraContrast(): number;
  60168. /**
  60169. * Sets The camera contrast used on this material.
  60170. */
  60171. set cameraContrast(value: number);
  60172. /**
  60173. * Gets the Color Grading 2D Lookup Texture.
  60174. */
  60175. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60176. /**
  60177. * Sets the Color Grading 2D Lookup Texture.
  60178. */
  60179. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60180. /**
  60181. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60182. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60183. * 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;
  60184. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60185. */
  60186. get cameraColorCurves(): Nullable<ColorCurves>;
  60187. /**
  60188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60190. * 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;
  60191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60192. */
  60193. set cameraColorCurves(value: Nullable<ColorCurves>);
  60194. /**
  60195. * Instantiates a new PBRMaterial instance.
  60196. *
  60197. * @param name The material name
  60198. * @param scene The scene the material will be use in.
  60199. */
  60200. constructor(name: string, scene: Scene);
  60201. /**
  60202. * Returns the name of this material class.
  60203. */
  60204. getClassName(): string;
  60205. /**
  60206. * Makes a duplicate of the current material.
  60207. * @param name - name to use for the new material.
  60208. */
  60209. clone(name: string): PBRMaterial;
  60210. /**
  60211. * Serializes this PBR Material.
  60212. * @returns - An object with the serialized material.
  60213. */
  60214. serialize(): any;
  60215. /**
  60216. * Parses a PBR Material from a serialized object.
  60217. * @param source - Serialized object.
  60218. * @param scene - BJS scene instance.
  60219. * @param rootUrl - url for the scene object
  60220. * @returns - PBRMaterial
  60221. */
  60222. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60223. }
  60224. }
  60225. declare module "babylonjs/Misc/dds" {
  60226. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60228. import { Nullable } from "babylonjs/types";
  60229. import { Scene } from "babylonjs/scene";
  60230. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60231. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60232. /**
  60233. * Direct draw surface info
  60234. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60235. */
  60236. export interface DDSInfo {
  60237. /**
  60238. * Width of the texture
  60239. */
  60240. width: number;
  60241. /**
  60242. * Width of the texture
  60243. */
  60244. height: number;
  60245. /**
  60246. * Number of Mipmaps for the texture
  60247. * @see https://en.wikipedia.org/wiki/Mipmap
  60248. */
  60249. mipmapCount: number;
  60250. /**
  60251. * If the textures format is a known fourCC format
  60252. * @see https://www.fourcc.org/
  60253. */
  60254. isFourCC: boolean;
  60255. /**
  60256. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60257. */
  60258. isRGB: boolean;
  60259. /**
  60260. * If the texture is a lumincance format
  60261. */
  60262. isLuminance: boolean;
  60263. /**
  60264. * If this is a cube texture
  60265. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60266. */
  60267. isCube: boolean;
  60268. /**
  60269. * If the texture is a compressed format eg. FOURCC_DXT1
  60270. */
  60271. isCompressed: boolean;
  60272. /**
  60273. * The dxgiFormat of the texture
  60274. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60275. */
  60276. dxgiFormat: number;
  60277. /**
  60278. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60279. */
  60280. textureType: number;
  60281. /**
  60282. * Sphericle polynomial created for the dds texture
  60283. */
  60284. sphericalPolynomial?: SphericalPolynomial;
  60285. }
  60286. /**
  60287. * Class used to provide DDS decompression tools
  60288. */
  60289. export class DDSTools {
  60290. /**
  60291. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60292. */
  60293. static StoreLODInAlphaChannel: boolean;
  60294. /**
  60295. * Gets DDS information from an array buffer
  60296. * @param data defines the array buffer view to read data from
  60297. * @returns the DDS information
  60298. */
  60299. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60300. private static _FloatView;
  60301. private static _Int32View;
  60302. private static _ToHalfFloat;
  60303. private static _FromHalfFloat;
  60304. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60305. private static _GetHalfFloatRGBAArrayBuffer;
  60306. private static _GetFloatRGBAArrayBuffer;
  60307. private static _GetFloatAsUIntRGBAArrayBuffer;
  60308. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60309. private static _GetRGBAArrayBuffer;
  60310. private static _ExtractLongWordOrder;
  60311. private static _GetRGBArrayBuffer;
  60312. private static _GetLuminanceArrayBuffer;
  60313. /**
  60314. * Uploads DDS Levels to a Babylon Texture
  60315. * @hidden
  60316. */
  60317. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60318. }
  60319. module "babylonjs/Engines/thinEngine" {
  60320. interface ThinEngine {
  60321. /**
  60322. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60323. * @param rootUrl defines the url where the file to load is located
  60324. * @param scene defines the current scene
  60325. * @param lodScale defines scale to apply to the mip map selection
  60326. * @param lodOffset defines offset to apply to the mip map selection
  60327. * @param onLoad defines an optional callback raised when the texture is loaded
  60328. * @param onError defines an optional callback raised if there is an issue to load the texture
  60329. * @param format defines the format of the data
  60330. * @param forcedExtension defines the extension to use to pick the right loader
  60331. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60332. * @returns the cube texture as an InternalTexture
  60333. */
  60334. 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;
  60335. }
  60336. }
  60337. }
  60338. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60339. import { Nullable } from "babylonjs/types";
  60340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60341. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60342. /**
  60343. * Implementation of the DDS Texture Loader.
  60344. * @hidden
  60345. */
  60346. export class _DDSTextureLoader implements IInternalTextureLoader {
  60347. /**
  60348. * Defines wether the loader supports cascade loading the different faces.
  60349. */
  60350. readonly supportCascades: boolean;
  60351. /**
  60352. * This returns if the loader support the current file information.
  60353. * @param extension defines the file extension of the file being loaded
  60354. * @returns true if the loader can load the specified file
  60355. */
  60356. canLoad(extension: string): boolean;
  60357. /**
  60358. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60359. * @param data contains the texture data
  60360. * @param texture defines the BabylonJS internal texture
  60361. * @param createPolynomials will be true if polynomials have been requested
  60362. * @param onLoad defines the callback to trigger once the texture is ready
  60363. * @param onError defines the callback to trigger in case of error
  60364. */
  60365. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60366. /**
  60367. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60368. * @param data contains the texture data
  60369. * @param texture defines the BabylonJS internal texture
  60370. * @param callback defines the method to call once ready to upload
  60371. */
  60372. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60373. }
  60374. }
  60375. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60376. import { Nullable } from "babylonjs/types";
  60377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60378. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60379. /**
  60380. * Implementation of the ENV Texture Loader.
  60381. * @hidden
  60382. */
  60383. export class _ENVTextureLoader implements IInternalTextureLoader {
  60384. /**
  60385. * Defines wether the loader supports cascade loading the different faces.
  60386. */
  60387. readonly supportCascades: boolean;
  60388. /**
  60389. * This returns if the loader support the current file information.
  60390. * @param extension defines the file extension of the file being loaded
  60391. * @returns true if the loader can load the specified file
  60392. */
  60393. canLoad(extension: string): boolean;
  60394. /**
  60395. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60396. * @param data contains the texture data
  60397. * @param texture defines the BabylonJS internal texture
  60398. * @param createPolynomials will be true if polynomials have been requested
  60399. * @param onLoad defines the callback to trigger once the texture is ready
  60400. * @param onError defines the callback to trigger in case of error
  60401. */
  60402. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60403. /**
  60404. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60405. * @param data contains the texture data
  60406. * @param texture defines the BabylonJS internal texture
  60407. * @param callback defines the method to call once ready to upload
  60408. */
  60409. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60410. }
  60411. }
  60412. declare module "babylonjs/Misc/khronosTextureContainer" {
  60413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60414. /**
  60415. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60416. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60417. */
  60418. export class KhronosTextureContainer {
  60419. /** contents of the KTX container file */
  60420. data: ArrayBufferView;
  60421. private static HEADER_LEN;
  60422. private static COMPRESSED_2D;
  60423. private static COMPRESSED_3D;
  60424. private static TEX_2D;
  60425. private static TEX_3D;
  60426. /**
  60427. * Gets the openGL type
  60428. */
  60429. glType: number;
  60430. /**
  60431. * Gets the openGL type size
  60432. */
  60433. glTypeSize: number;
  60434. /**
  60435. * Gets the openGL format
  60436. */
  60437. glFormat: number;
  60438. /**
  60439. * Gets the openGL internal format
  60440. */
  60441. glInternalFormat: number;
  60442. /**
  60443. * Gets the base internal format
  60444. */
  60445. glBaseInternalFormat: number;
  60446. /**
  60447. * Gets image width in pixel
  60448. */
  60449. pixelWidth: number;
  60450. /**
  60451. * Gets image height in pixel
  60452. */
  60453. pixelHeight: number;
  60454. /**
  60455. * Gets image depth in pixels
  60456. */
  60457. pixelDepth: number;
  60458. /**
  60459. * Gets the number of array elements
  60460. */
  60461. numberOfArrayElements: number;
  60462. /**
  60463. * Gets the number of faces
  60464. */
  60465. numberOfFaces: number;
  60466. /**
  60467. * Gets the number of mipmap levels
  60468. */
  60469. numberOfMipmapLevels: number;
  60470. /**
  60471. * Gets the bytes of key value data
  60472. */
  60473. bytesOfKeyValueData: number;
  60474. /**
  60475. * Gets the load type
  60476. */
  60477. loadType: number;
  60478. /**
  60479. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60480. */
  60481. isInvalid: boolean;
  60482. /**
  60483. * Creates a new KhronosTextureContainer
  60484. * @param data contents of the KTX container file
  60485. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60486. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60487. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60488. */
  60489. constructor(
  60490. /** contents of the KTX container file */
  60491. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60492. /**
  60493. * Uploads KTX content to a Babylon Texture.
  60494. * It is assumed that the texture has already been created & is currently bound
  60495. * @hidden
  60496. */
  60497. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60498. private _upload2DCompressedLevels;
  60499. /**
  60500. * Checks if the given data starts with a KTX file identifier.
  60501. * @param data the data to check
  60502. * @returns true if the data is a KTX file or false otherwise
  60503. */
  60504. static IsValid(data: ArrayBufferView): boolean;
  60505. }
  60506. }
  60507. declare module "babylonjs/Misc/workerPool" {
  60508. import { IDisposable } from "babylonjs/scene";
  60509. /**
  60510. * Helper class to push actions to a pool of workers.
  60511. */
  60512. export class WorkerPool implements IDisposable {
  60513. private _workerInfos;
  60514. private _pendingActions;
  60515. /**
  60516. * Constructor
  60517. * @param workers Array of workers to use for actions
  60518. */
  60519. constructor(workers: Array<Worker>);
  60520. /**
  60521. * Terminates all workers and clears any pending actions.
  60522. */
  60523. dispose(): void;
  60524. /**
  60525. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60526. * pended until a worker has completed its action.
  60527. * @param action The action to perform. Call onComplete when the action is complete.
  60528. */
  60529. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60530. private _execute;
  60531. }
  60532. }
  60533. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60534. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60535. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60536. /**
  60537. * Class for loading KTX2 files
  60538. * @hidden
  60539. */
  60540. export class KhronosTextureContainer2 {
  60541. private static _WorkerPoolPromise?;
  60542. private static _Initialized;
  60543. private static _Ktx2Decoder;
  60544. /**
  60545. * URL to use when loading the KTX2 decoder module
  60546. */
  60547. static JSModuleURL: string;
  60548. /**
  60549. * Default number of workers used to handle data decoding
  60550. */
  60551. static DefaultNumWorkers: number;
  60552. private static GetDefaultNumWorkers;
  60553. private _engine;
  60554. private static _CreateWorkerPool;
  60555. /**
  60556. * Constructor
  60557. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60558. */
  60559. constructor(engine: ThinEngine, numWorkers?: number);
  60560. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60561. /**
  60562. * Stop all async operations and release resources.
  60563. */
  60564. dispose(): void;
  60565. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60566. /**
  60567. * Checks if the given data starts with a KTX2 file identifier.
  60568. * @param data the data to check
  60569. * @returns true if the data is a KTX2 file or false otherwise
  60570. */
  60571. static IsValid(data: ArrayBufferView): boolean;
  60572. }
  60573. export function workerFunc(): void;
  60574. }
  60575. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60576. import { Nullable } from "babylonjs/types";
  60577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60578. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60579. /**
  60580. * Implementation of the KTX Texture Loader.
  60581. * @hidden
  60582. */
  60583. export class _KTXTextureLoader implements IInternalTextureLoader {
  60584. /**
  60585. * Defines wether the loader supports cascade loading the different faces.
  60586. */
  60587. readonly supportCascades: boolean;
  60588. /**
  60589. * This returns if the loader support the current file information.
  60590. * @param extension defines the file extension of the file being loaded
  60591. * @param mimeType defines the optional mime type of the file being loaded
  60592. * @returns true if the loader can load the specified file
  60593. */
  60594. canLoad(extension: string, mimeType?: string): boolean;
  60595. /**
  60596. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60597. * @param data contains the texture data
  60598. * @param texture defines the BabylonJS internal texture
  60599. * @param createPolynomials will be true if polynomials have been requested
  60600. * @param onLoad defines the callback to trigger once the texture is ready
  60601. * @param onError defines the callback to trigger in case of error
  60602. */
  60603. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60604. /**
  60605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60606. * @param data contains the texture data
  60607. * @param texture defines the BabylonJS internal texture
  60608. * @param callback defines the method to call once ready to upload
  60609. */
  60610. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60611. }
  60612. }
  60613. declare module "babylonjs/Helpers/sceneHelpers" {
  60614. import { Nullable } from "babylonjs/types";
  60615. import { Mesh } from "babylonjs/Meshes/mesh";
  60616. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60617. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60618. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60619. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60620. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60621. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60622. import "babylonjs/Meshes/Builders/boxBuilder";
  60623. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60624. /** @hidden */
  60625. export var _forceSceneHelpersToBundle: boolean;
  60626. module "babylonjs/scene" {
  60627. interface Scene {
  60628. /**
  60629. * Creates a default light for the scene.
  60630. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60631. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60632. */
  60633. createDefaultLight(replace?: boolean): void;
  60634. /**
  60635. * Creates a default camera for the scene.
  60636. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60637. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60638. * @param replace has default false, when true replaces the active camera in the scene
  60639. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60640. */
  60641. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60642. /**
  60643. * Creates a default camera and a default light.
  60644. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60645. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60646. * @param replace has the default false, when true replaces the active camera/light in the scene
  60647. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60648. */
  60649. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60650. /**
  60651. * Creates a new sky box
  60652. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60653. * @param environmentTexture defines the texture to use as environment texture
  60654. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60655. * @param scale defines the overall scale of the skybox
  60656. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60657. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60658. * @returns a new mesh holding the sky box
  60659. */
  60660. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60661. /**
  60662. * Creates a new environment
  60663. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60664. * @param options defines the options you can use to configure the environment
  60665. * @returns the new EnvironmentHelper
  60666. */
  60667. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60668. /**
  60669. * Creates a new VREXperienceHelper
  60670. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60671. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60672. * @returns a new VREXperienceHelper
  60673. */
  60674. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60675. /**
  60676. * Creates a new WebXRDefaultExperience
  60677. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60678. * @param options experience options
  60679. * @returns a promise for a new WebXRDefaultExperience
  60680. */
  60681. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60682. }
  60683. }
  60684. }
  60685. declare module "babylonjs/Helpers/videoDome" {
  60686. import { Scene } from "babylonjs/scene";
  60687. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60688. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60689. /**
  60690. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60691. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60692. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60693. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60694. */
  60695. export class VideoDome extends TextureDome<VideoTexture> {
  60696. /**
  60697. * Define the video source as a Monoscopic panoramic 360 video.
  60698. */
  60699. static readonly MODE_MONOSCOPIC: number;
  60700. /**
  60701. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60702. */
  60703. static readonly MODE_TOPBOTTOM: number;
  60704. /**
  60705. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60706. */
  60707. static readonly MODE_SIDEBYSIDE: number;
  60708. /**
  60709. * Get the video texture associated with this video dome
  60710. */
  60711. get videoTexture(): VideoTexture;
  60712. /**
  60713. * Get the video mode of this dome
  60714. */
  60715. get videoMode(): number;
  60716. /**
  60717. * Set the video mode of this dome.
  60718. * @see textureMode
  60719. */
  60720. set videoMode(value: number);
  60721. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60722. }
  60723. }
  60724. declare module "babylonjs/Helpers/index" {
  60725. export * from "babylonjs/Helpers/environmentHelper";
  60726. export * from "babylonjs/Helpers/photoDome";
  60727. export * from "babylonjs/Helpers/sceneHelpers";
  60728. export * from "babylonjs/Helpers/videoDome";
  60729. }
  60730. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60731. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60732. import { IDisposable } from "babylonjs/scene";
  60733. import { Engine } from "babylonjs/Engines/engine";
  60734. /**
  60735. * This class can be used to get instrumentation data from a Babylon engine
  60736. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60737. */
  60738. export class EngineInstrumentation implements IDisposable {
  60739. /**
  60740. * Define the instrumented engine.
  60741. */
  60742. engine: Engine;
  60743. private _captureGPUFrameTime;
  60744. private _gpuFrameTimeToken;
  60745. private _gpuFrameTime;
  60746. private _captureShaderCompilationTime;
  60747. private _shaderCompilationTime;
  60748. private _onBeginFrameObserver;
  60749. private _onEndFrameObserver;
  60750. private _onBeforeShaderCompilationObserver;
  60751. private _onAfterShaderCompilationObserver;
  60752. /**
  60753. * Gets the perf counter used for GPU frame time
  60754. */
  60755. get gpuFrameTimeCounter(): PerfCounter;
  60756. /**
  60757. * Gets the GPU frame time capture status
  60758. */
  60759. get captureGPUFrameTime(): boolean;
  60760. /**
  60761. * Enable or disable the GPU frame time capture
  60762. */
  60763. set captureGPUFrameTime(value: boolean);
  60764. /**
  60765. * Gets the perf counter used for shader compilation time
  60766. */
  60767. get shaderCompilationTimeCounter(): PerfCounter;
  60768. /**
  60769. * Gets the shader compilation time capture status
  60770. */
  60771. get captureShaderCompilationTime(): boolean;
  60772. /**
  60773. * Enable or disable the shader compilation time capture
  60774. */
  60775. set captureShaderCompilationTime(value: boolean);
  60776. /**
  60777. * Instantiates a new engine instrumentation.
  60778. * This class can be used to get instrumentation data from a Babylon engine
  60779. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60780. * @param engine Defines the engine to instrument
  60781. */
  60782. constructor(
  60783. /**
  60784. * Define the instrumented engine.
  60785. */
  60786. engine: Engine);
  60787. /**
  60788. * Dispose and release associated resources.
  60789. */
  60790. dispose(): void;
  60791. }
  60792. }
  60793. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60794. import { Scene, IDisposable } from "babylonjs/scene";
  60795. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60796. /**
  60797. * This class can be used to get instrumentation data from a Babylon engine
  60798. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60799. */
  60800. export class SceneInstrumentation implements IDisposable {
  60801. /**
  60802. * Defines the scene to instrument
  60803. */
  60804. scene: Scene;
  60805. private _captureActiveMeshesEvaluationTime;
  60806. private _activeMeshesEvaluationTime;
  60807. private _captureRenderTargetsRenderTime;
  60808. private _renderTargetsRenderTime;
  60809. private _captureFrameTime;
  60810. private _frameTime;
  60811. private _captureRenderTime;
  60812. private _renderTime;
  60813. private _captureInterFrameTime;
  60814. private _interFrameTime;
  60815. private _captureParticlesRenderTime;
  60816. private _particlesRenderTime;
  60817. private _captureSpritesRenderTime;
  60818. private _spritesRenderTime;
  60819. private _capturePhysicsTime;
  60820. private _physicsTime;
  60821. private _captureAnimationsTime;
  60822. private _animationsTime;
  60823. private _captureCameraRenderTime;
  60824. private _cameraRenderTime;
  60825. private _onBeforeActiveMeshesEvaluationObserver;
  60826. private _onAfterActiveMeshesEvaluationObserver;
  60827. private _onBeforeRenderTargetsRenderObserver;
  60828. private _onAfterRenderTargetsRenderObserver;
  60829. private _onAfterRenderObserver;
  60830. private _onBeforeDrawPhaseObserver;
  60831. private _onAfterDrawPhaseObserver;
  60832. private _onBeforeAnimationsObserver;
  60833. private _onBeforeParticlesRenderingObserver;
  60834. private _onAfterParticlesRenderingObserver;
  60835. private _onBeforeSpritesRenderingObserver;
  60836. private _onAfterSpritesRenderingObserver;
  60837. private _onBeforePhysicsObserver;
  60838. private _onAfterPhysicsObserver;
  60839. private _onAfterAnimationsObserver;
  60840. private _onBeforeCameraRenderObserver;
  60841. private _onAfterCameraRenderObserver;
  60842. /**
  60843. * Gets the perf counter used for active meshes evaluation time
  60844. */
  60845. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60846. /**
  60847. * Gets the active meshes evaluation time capture status
  60848. */
  60849. get captureActiveMeshesEvaluationTime(): boolean;
  60850. /**
  60851. * Enable or disable the active meshes evaluation time capture
  60852. */
  60853. set captureActiveMeshesEvaluationTime(value: boolean);
  60854. /**
  60855. * Gets the perf counter used for render targets render time
  60856. */
  60857. get renderTargetsRenderTimeCounter(): PerfCounter;
  60858. /**
  60859. * Gets the render targets render time capture status
  60860. */
  60861. get captureRenderTargetsRenderTime(): boolean;
  60862. /**
  60863. * Enable or disable the render targets render time capture
  60864. */
  60865. set captureRenderTargetsRenderTime(value: boolean);
  60866. /**
  60867. * Gets the perf counter used for particles render time
  60868. */
  60869. get particlesRenderTimeCounter(): PerfCounter;
  60870. /**
  60871. * Gets the particles render time capture status
  60872. */
  60873. get captureParticlesRenderTime(): boolean;
  60874. /**
  60875. * Enable or disable the particles render time capture
  60876. */
  60877. set captureParticlesRenderTime(value: boolean);
  60878. /**
  60879. * Gets the perf counter used for sprites render time
  60880. */
  60881. get spritesRenderTimeCounter(): PerfCounter;
  60882. /**
  60883. * Gets the sprites render time capture status
  60884. */
  60885. get captureSpritesRenderTime(): boolean;
  60886. /**
  60887. * Enable or disable the sprites render time capture
  60888. */
  60889. set captureSpritesRenderTime(value: boolean);
  60890. /**
  60891. * Gets the perf counter used for physics time
  60892. */
  60893. get physicsTimeCounter(): PerfCounter;
  60894. /**
  60895. * Gets the physics time capture status
  60896. */
  60897. get capturePhysicsTime(): boolean;
  60898. /**
  60899. * Enable or disable the physics time capture
  60900. */
  60901. set capturePhysicsTime(value: boolean);
  60902. /**
  60903. * Gets the perf counter used for animations time
  60904. */
  60905. get animationsTimeCounter(): PerfCounter;
  60906. /**
  60907. * Gets the animations time capture status
  60908. */
  60909. get captureAnimationsTime(): boolean;
  60910. /**
  60911. * Enable or disable the animations time capture
  60912. */
  60913. set captureAnimationsTime(value: boolean);
  60914. /**
  60915. * Gets the perf counter used for frame time capture
  60916. */
  60917. get frameTimeCounter(): PerfCounter;
  60918. /**
  60919. * Gets the frame time capture status
  60920. */
  60921. get captureFrameTime(): boolean;
  60922. /**
  60923. * Enable or disable the frame time capture
  60924. */
  60925. set captureFrameTime(value: boolean);
  60926. /**
  60927. * Gets the perf counter used for inter-frames time capture
  60928. */
  60929. get interFrameTimeCounter(): PerfCounter;
  60930. /**
  60931. * Gets the inter-frames time capture status
  60932. */
  60933. get captureInterFrameTime(): boolean;
  60934. /**
  60935. * Enable or disable the inter-frames time capture
  60936. */
  60937. set captureInterFrameTime(value: boolean);
  60938. /**
  60939. * Gets the perf counter used for render time capture
  60940. */
  60941. get renderTimeCounter(): PerfCounter;
  60942. /**
  60943. * Gets the render time capture status
  60944. */
  60945. get captureRenderTime(): boolean;
  60946. /**
  60947. * Enable or disable the render time capture
  60948. */
  60949. set captureRenderTime(value: boolean);
  60950. /**
  60951. * Gets the perf counter used for camera render time capture
  60952. */
  60953. get cameraRenderTimeCounter(): PerfCounter;
  60954. /**
  60955. * Gets the camera render time capture status
  60956. */
  60957. get captureCameraRenderTime(): boolean;
  60958. /**
  60959. * Enable or disable the camera render time capture
  60960. */
  60961. set captureCameraRenderTime(value: boolean);
  60962. /**
  60963. * Gets the perf counter used for draw calls
  60964. */
  60965. get drawCallsCounter(): PerfCounter;
  60966. /**
  60967. * Instantiates a new scene instrumentation.
  60968. * This class can be used to get instrumentation data from a Babylon engine
  60969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60970. * @param scene Defines the scene to instrument
  60971. */
  60972. constructor(
  60973. /**
  60974. * Defines the scene to instrument
  60975. */
  60976. scene: Scene);
  60977. /**
  60978. * Dispose and release associated resources.
  60979. */
  60980. dispose(): void;
  60981. }
  60982. }
  60983. declare module "babylonjs/Instrumentation/index" {
  60984. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60985. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60986. export * from "babylonjs/Instrumentation/timeToken";
  60987. }
  60988. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60989. /** @hidden */
  60990. export var glowMapGenerationPixelShader: {
  60991. name: string;
  60992. shader: string;
  60993. };
  60994. }
  60995. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60996. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60997. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60998. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60999. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61000. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61001. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61002. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61003. /** @hidden */
  61004. export var glowMapGenerationVertexShader: {
  61005. name: string;
  61006. shader: string;
  61007. };
  61008. }
  61009. declare module "babylonjs/Layers/effectLayer" {
  61010. import { Observable } from "babylonjs/Misc/observable";
  61011. import { Nullable } from "babylonjs/types";
  61012. import { Camera } from "babylonjs/Cameras/camera";
  61013. import { Scene } from "babylonjs/scene";
  61014. import { ISize } from "babylonjs/Maths/math.size";
  61015. import { Color4 } from "babylonjs/Maths/math.color";
  61016. import { Engine } from "babylonjs/Engines/engine";
  61017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61019. import { Mesh } from "babylonjs/Meshes/mesh";
  61020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61023. import { Effect } from "babylonjs/Materials/effect";
  61024. import { Material } from "babylonjs/Materials/material";
  61025. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61026. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61027. /**
  61028. * Effect layer options. This helps customizing the behaviour
  61029. * of the effect layer.
  61030. */
  61031. export interface IEffectLayerOptions {
  61032. /**
  61033. * Multiplication factor apply to the canvas size to compute the render target size
  61034. * used to generated the objects (the smaller the faster).
  61035. */
  61036. mainTextureRatio: number;
  61037. /**
  61038. * Enforces a fixed size texture to ensure effect stability across devices.
  61039. */
  61040. mainTextureFixedSize?: number;
  61041. /**
  61042. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61043. */
  61044. alphaBlendingMode: number;
  61045. /**
  61046. * The camera attached to the layer.
  61047. */
  61048. camera: Nullable<Camera>;
  61049. /**
  61050. * The rendering group to draw the layer in.
  61051. */
  61052. renderingGroupId: number;
  61053. }
  61054. /**
  61055. * The effect layer Helps adding post process effect blended with the main pass.
  61056. *
  61057. * This can be for instance use to generate glow or higlight effects on the scene.
  61058. *
  61059. * The effect layer class can not be used directly and is intented to inherited from to be
  61060. * customized per effects.
  61061. */
  61062. export abstract class EffectLayer {
  61063. private _vertexBuffers;
  61064. private _indexBuffer;
  61065. private _cachedDefines;
  61066. private _effectLayerMapGenerationEffect;
  61067. private _effectLayerOptions;
  61068. private _mergeEffect;
  61069. protected _scene: Scene;
  61070. protected _engine: Engine;
  61071. protected _maxSize: number;
  61072. protected _mainTextureDesiredSize: ISize;
  61073. protected _mainTexture: RenderTargetTexture;
  61074. protected _shouldRender: boolean;
  61075. protected _postProcesses: PostProcess[];
  61076. protected _textures: BaseTexture[];
  61077. protected _emissiveTextureAndColor: {
  61078. texture: Nullable<BaseTexture>;
  61079. color: Color4;
  61080. };
  61081. /**
  61082. * The name of the layer
  61083. */
  61084. name: string;
  61085. /**
  61086. * The clear color of the texture used to generate the glow map.
  61087. */
  61088. neutralColor: Color4;
  61089. /**
  61090. * Specifies whether the highlight layer is enabled or not.
  61091. */
  61092. isEnabled: boolean;
  61093. /**
  61094. * Gets the camera attached to the layer.
  61095. */
  61096. get camera(): Nullable<Camera>;
  61097. /**
  61098. * Gets the rendering group id the layer should render in.
  61099. */
  61100. get renderingGroupId(): number;
  61101. set renderingGroupId(renderingGroupId: number);
  61102. /**
  61103. * An event triggered when the effect layer has been disposed.
  61104. */
  61105. onDisposeObservable: Observable<EffectLayer>;
  61106. /**
  61107. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61108. */
  61109. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61110. /**
  61111. * An event triggered when the generated texture is being merged in the scene.
  61112. */
  61113. onBeforeComposeObservable: Observable<EffectLayer>;
  61114. /**
  61115. * An event triggered when the mesh is rendered into the effect render target.
  61116. */
  61117. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61118. /**
  61119. * An event triggered after the mesh has been rendered into the effect render target.
  61120. */
  61121. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61122. /**
  61123. * An event triggered when the generated texture has been merged in the scene.
  61124. */
  61125. onAfterComposeObservable: Observable<EffectLayer>;
  61126. /**
  61127. * An event triggered when the efffect layer changes its size.
  61128. */
  61129. onSizeChangedObservable: Observable<EffectLayer>;
  61130. /** @hidden */
  61131. static _SceneComponentInitialization: (scene: Scene) => void;
  61132. /**
  61133. * Instantiates a new effect Layer and references it in the scene.
  61134. * @param name The name of the layer
  61135. * @param scene The scene to use the layer in
  61136. */
  61137. constructor(
  61138. /** The Friendly of the effect in the scene */
  61139. name: string, scene: Scene);
  61140. /**
  61141. * Get the effect name of the layer.
  61142. * @return The effect name
  61143. */
  61144. abstract getEffectName(): string;
  61145. /**
  61146. * Checks for the readiness of the element composing the layer.
  61147. * @param subMesh the mesh to check for
  61148. * @param useInstances specify whether or not to use instances to render the mesh
  61149. * @return true if ready otherwise, false
  61150. */
  61151. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61152. /**
  61153. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61154. * @returns true if the effect requires stencil during the main canvas render pass.
  61155. */
  61156. abstract needStencil(): boolean;
  61157. /**
  61158. * Create the merge effect. This is the shader use to blit the information back
  61159. * to the main canvas at the end of the scene rendering.
  61160. * @returns The effect containing the shader used to merge the effect on the main canvas
  61161. */
  61162. protected abstract _createMergeEffect(): Effect;
  61163. /**
  61164. * Creates the render target textures and post processes used in the effect layer.
  61165. */
  61166. protected abstract _createTextureAndPostProcesses(): void;
  61167. /**
  61168. * Implementation specific of rendering the generating effect on the main canvas.
  61169. * @param effect The effect used to render through
  61170. */
  61171. protected abstract _internalRender(effect: Effect): void;
  61172. /**
  61173. * Sets the required values for both the emissive texture and and the main color.
  61174. */
  61175. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61176. /**
  61177. * Free any resources and references associated to a mesh.
  61178. * Internal use
  61179. * @param mesh The mesh to free.
  61180. */
  61181. abstract _disposeMesh(mesh: Mesh): void;
  61182. /**
  61183. * Serializes this layer (Glow or Highlight for example)
  61184. * @returns a serialized layer object
  61185. */
  61186. abstract serialize?(): any;
  61187. /**
  61188. * Initializes the effect layer with the required options.
  61189. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61190. */
  61191. protected _init(options: Partial<IEffectLayerOptions>): void;
  61192. /**
  61193. * Generates the index buffer of the full screen quad blending to the main canvas.
  61194. */
  61195. private _generateIndexBuffer;
  61196. /**
  61197. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61198. */
  61199. private _generateVertexBuffer;
  61200. /**
  61201. * Sets the main texture desired size which is the closest power of two
  61202. * of the engine canvas size.
  61203. */
  61204. private _setMainTextureSize;
  61205. /**
  61206. * Creates the main texture for the effect layer.
  61207. */
  61208. protected _createMainTexture(): void;
  61209. /**
  61210. * Adds specific effects defines.
  61211. * @param defines The defines to add specifics to.
  61212. */
  61213. protected _addCustomEffectDefines(defines: string[]): void;
  61214. /**
  61215. * Checks for the readiness of the element composing the layer.
  61216. * @param subMesh the mesh to check for
  61217. * @param useInstances specify whether or not to use instances to render the mesh
  61218. * @param emissiveTexture the associated emissive texture used to generate the glow
  61219. * @return true if ready otherwise, false
  61220. */
  61221. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61222. /**
  61223. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61224. */
  61225. render(): void;
  61226. /**
  61227. * Determine if a given mesh will be used in the current effect.
  61228. * @param mesh mesh to test
  61229. * @returns true if the mesh will be used
  61230. */
  61231. hasMesh(mesh: AbstractMesh): boolean;
  61232. /**
  61233. * Returns true if the layer contains information to display, otherwise false.
  61234. * @returns true if the glow layer should be rendered
  61235. */
  61236. shouldRender(): boolean;
  61237. /**
  61238. * Returns true if the mesh should render, otherwise false.
  61239. * @param mesh The mesh to render
  61240. * @returns true if it should render otherwise false
  61241. */
  61242. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61243. /**
  61244. * Returns true if the mesh can be rendered, otherwise false.
  61245. * @param mesh The mesh to render
  61246. * @param material The material used on the mesh
  61247. * @returns true if it can be rendered otherwise false
  61248. */
  61249. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61250. /**
  61251. * Returns true if the mesh should render, otherwise false.
  61252. * @param mesh The mesh to render
  61253. * @returns true if it should render otherwise false
  61254. */
  61255. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61256. /**
  61257. * Renders the submesh passed in parameter to the generation map.
  61258. */
  61259. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61260. /**
  61261. * Defines whether the current material of the mesh should be use to render the effect.
  61262. * @param mesh defines the current mesh to render
  61263. */
  61264. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61265. /**
  61266. * Rebuild the required buffers.
  61267. * @hidden Internal use only.
  61268. */
  61269. _rebuild(): void;
  61270. /**
  61271. * Dispose only the render target textures and post process.
  61272. */
  61273. private _disposeTextureAndPostProcesses;
  61274. /**
  61275. * Dispose the highlight layer and free resources.
  61276. */
  61277. dispose(): void;
  61278. /**
  61279. * Gets the class name of the effect layer
  61280. * @returns the string with the class name of the effect layer
  61281. */
  61282. getClassName(): string;
  61283. /**
  61284. * Creates an effect layer from parsed effect layer data
  61285. * @param parsedEffectLayer defines effect layer data
  61286. * @param scene defines the current scene
  61287. * @param rootUrl defines the root URL containing the effect layer information
  61288. * @returns a parsed effect Layer
  61289. */
  61290. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61291. }
  61292. }
  61293. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61294. import { Scene } from "babylonjs/scene";
  61295. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61296. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61297. import { AbstractScene } from "babylonjs/abstractScene";
  61298. module "babylonjs/abstractScene" {
  61299. interface AbstractScene {
  61300. /**
  61301. * The list of effect layers (highlights/glow) added to the scene
  61302. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61303. * @see https://doc.babylonjs.com/how_to/glow_layer
  61304. */
  61305. effectLayers: Array<EffectLayer>;
  61306. /**
  61307. * Removes the given effect layer from this scene.
  61308. * @param toRemove defines the effect layer to remove
  61309. * @returns the index of the removed effect layer
  61310. */
  61311. removeEffectLayer(toRemove: EffectLayer): number;
  61312. /**
  61313. * Adds the given effect layer to this scene
  61314. * @param newEffectLayer defines the effect layer to add
  61315. */
  61316. addEffectLayer(newEffectLayer: EffectLayer): void;
  61317. }
  61318. }
  61319. /**
  61320. * Defines the layer scene component responsible to manage any effect layers
  61321. * in a given scene.
  61322. */
  61323. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61324. /**
  61325. * The component name helpfull to identify the component in the list of scene components.
  61326. */
  61327. readonly name: string;
  61328. /**
  61329. * The scene the component belongs to.
  61330. */
  61331. scene: Scene;
  61332. private _engine;
  61333. private _renderEffects;
  61334. private _needStencil;
  61335. private _previousStencilState;
  61336. /**
  61337. * Creates a new instance of the component for the given scene
  61338. * @param scene Defines the scene to register the component in
  61339. */
  61340. constructor(scene: Scene);
  61341. /**
  61342. * Registers the component in a given scene
  61343. */
  61344. register(): void;
  61345. /**
  61346. * Rebuilds the elements related to this component in case of
  61347. * context lost for instance.
  61348. */
  61349. rebuild(): void;
  61350. /**
  61351. * Serializes the component data to the specified json object
  61352. * @param serializationObject The object to serialize to
  61353. */
  61354. serialize(serializationObject: any): void;
  61355. /**
  61356. * Adds all the elements from the container to the scene
  61357. * @param container the container holding the elements
  61358. */
  61359. addFromContainer(container: AbstractScene): void;
  61360. /**
  61361. * Removes all the elements in the container from the scene
  61362. * @param container contains the elements to remove
  61363. * @param dispose if the removed element should be disposed (default: false)
  61364. */
  61365. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61366. /**
  61367. * Disposes the component and the associated ressources.
  61368. */
  61369. dispose(): void;
  61370. private _isReadyForMesh;
  61371. private _renderMainTexture;
  61372. private _setStencil;
  61373. private _setStencilBack;
  61374. private _draw;
  61375. private _drawCamera;
  61376. private _drawRenderingGroup;
  61377. }
  61378. }
  61379. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61380. /** @hidden */
  61381. export var glowMapMergePixelShader: {
  61382. name: string;
  61383. shader: string;
  61384. };
  61385. }
  61386. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61387. /** @hidden */
  61388. export var glowMapMergeVertexShader: {
  61389. name: string;
  61390. shader: string;
  61391. };
  61392. }
  61393. declare module "babylonjs/Layers/glowLayer" {
  61394. import { Nullable } from "babylonjs/types";
  61395. import { Camera } from "babylonjs/Cameras/camera";
  61396. import { Scene } from "babylonjs/scene";
  61397. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61399. import { Mesh } from "babylonjs/Meshes/mesh";
  61400. import { Texture } from "babylonjs/Materials/Textures/texture";
  61401. import { Effect } from "babylonjs/Materials/effect";
  61402. import { Material } from "babylonjs/Materials/material";
  61403. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61404. import { Color4 } from "babylonjs/Maths/math.color";
  61405. import "babylonjs/Shaders/glowMapMerge.fragment";
  61406. import "babylonjs/Shaders/glowMapMerge.vertex";
  61407. import "babylonjs/Layers/effectLayerSceneComponent";
  61408. module "babylonjs/abstractScene" {
  61409. interface AbstractScene {
  61410. /**
  61411. * Return a the first highlight layer of the scene with a given name.
  61412. * @param name The name of the highlight layer to look for.
  61413. * @return The highlight layer if found otherwise null.
  61414. */
  61415. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61416. }
  61417. }
  61418. /**
  61419. * Glow layer options. This helps customizing the behaviour
  61420. * of the glow layer.
  61421. */
  61422. export interface IGlowLayerOptions {
  61423. /**
  61424. * Multiplication factor apply to the canvas size to compute the render target size
  61425. * used to generated the glowing objects (the smaller the faster).
  61426. */
  61427. mainTextureRatio: number;
  61428. /**
  61429. * Enforces a fixed size texture to ensure resize independant blur.
  61430. */
  61431. mainTextureFixedSize?: number;
  61432. /**
  61433. * How big is the kernel of the blur texture.
  61434. */
  61435. blurKernelSize: number;
  61436. /**
  61437. * The camera attached to the layer.
  61438. */
  61439. camera: Nullable<Camera>;
  61440. /**
  61441. * Enable MSAA by chosing the number of samples.
  61442. */
  61443. mainTextureSamples?: number;
  61444. /**
  61445. * The rendering group to draw the layer in.
  61446. */
  61447. renderingGroupId: number;
  61448. }
  61449. /**
  61450. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61451. *
  61452. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61453. *
  61454. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61455. */
  61456. export class GlowLayer extends EffectLayer {
  61457. /**
  61458. * Effect Name of the layer.
  61459. */
  61460. static readonly EffectName: string;
  61461. /**
  61462. * The default blur kernel size used for the glow.
  61463. */
  61464. static DefaultBlurKernelSize: number;
  61465. /**
  61466. * The default texture size ratio used for the glow.
  61467. */
  61468. static DefaultTextureRatio: number;
  61469. /**
  61470. * Sets the kernel size of the blur.
  61471. */
  61472. set blurKernelSize(value: number);
  61473. /**
  61474. * Gets the kernel size of the blur.
  61475. */
  61476. get blurKernelSize(): number;
  61477. /**
  61478. * Sets the glow intensity.
  61479. */
  61480. set intensity(value: number);
  61481. /**
  61482. * Gets the glow intensity.
  61483. */
  61484. get intensity(): number;
  61485. private _options;
  61486. private _intensity;
  61487. private _horizontalBlurPostprocess1;
  61488. private _verticalBlurPostprocess1;
  61489. private _horizontalBlurPostprocess2;
  61490. private _verticalBlurPostprocess2;
  61491. private _blurTexture1;
  61492. private _blurTexture2;
  61493. private _postProcesses1;
  61494. private _postProcesses2;
  61495. private _includedOnlyMeshes;
  61496. private _excludedMeshes;
  61497. private _meshesUsingTheirOwnMaterials;
  61498. /**
  61499. * Callback used to let the user override the color selection on a per mesh basis
  61500. */
  61501. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61502. /**
  61503. * Callback used to let the user override the texture selection on a per mesh basis
  61504. */
  61505. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61506. /**
  61507. * Instantiates a new glow Layer and references it to the scene.
  61508. * @param name The name of the layer
  61509. * @param scene The scene to use the layer in
  61510. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61511. */
  61512. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61513. /**
  61514. * Get the effect name of the layer.
  61515. * @return The effect name
  61516. */
  61517. getEffectName(): string;
  61518. /**
  61519. * Create the merge effect. This is the shader use to blit the information back
  61520. * to the main canvas at the end of the scene rendering.
  61521. */
  61522. protected _createMergeEffect(): Effect;
  61523. /**
  61524. * Creates the render target textures and post processes used in the glow layer.
  61525. */
  61526. protected _createTextureAndPostProcesses(): void;
  61527. /**
  61528. * Checks for the readiness of the element composing the layer.
  61529. * @param subMesh the mesh to check for
  61530. * @param useInstances specify wether or not to use instances to render the mesh
  61531. * @param emissiveTexture the associated emissive texture used to generate the glow
  61532. * @return true if ready otherwise, false
  61533. */
  61534. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61535. /**
  61536. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61537. */
  61538. needStencil(): boolean;
  61539. /**
  61540. * Returns true if the mesh can be rendered, otherwise false.
  61541. * @param mesh The mesh to render
  61542. * @param material The material used on the mesh
  61543. * @returns true if it can be rendered otherwise false
  61544. */
  61545. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61546. /**
  61547. * Implementation specific of rendering the generating effect on the main canvas.
  61548. * @param effect The effect used to render through
  61549. */
  61550. protected _internalRender(effect: Effect): void;
  61551. /**
  61552. * Sets the required values for both the emissive texture and and the main color.
  61553. */
  61554. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61555. /**
  61556. * Returns true if the mesh should render, otherwise false.
  61557. * @param mesh The mesh to render
  61558. * @returns true if it should render otherwise false
  61559. */
  61560. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61561. /**
  61562. * Adds specific effects defines.
  61563. * @param defines The defines to add specifics to.
  61564. */
  61565. protected _addCustomEffectDefines(defines: string[]): void;
  61566. /**
  61567. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61568. * @param mesh The mesh to exclude from the glow layer
  61569. */
  61570. addExcludedMesh(mesh: Mesh): void;
  61571. /**
  61572. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61573. * @param mesh The mesh to remove
  61574. */
  61575. removeExcludedMesh(mesh: Mesh): void;
  61576. /**
  61577. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61578. * @param mesh The mesh to include in the glow layer
  61579. */
  61580. addIncludedOnlyMesh(mesh: Mesh): void;
  61581. /**
  61582. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61583. * @param mesh The mesh to remove
  61584. */
  61585. removeIncludedOnlyMesh(mesh: Mesh): void;
  61586. /**
  61587. * Determine if a given mesh will be used in the glow layer
  61588. * @param mesh The mesh to test
  61589. * @returns true if the mesh will be highlighted by the current glow layer
  61590. */
  61591. hasMesh(mesh: AbstractMesh): boolean;
  61592. /**
  61593. * Defines whether the current material of the mesh should be use to render the effect.
  61594. * @param mesh defines the current mesh to render
  61595. */
  61596. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61597. /**
  61598. * Add a mesh to be rendered through its own material and not with emissive only.
  61599. * @param mesh The mesh for which we need to use its material
  61600. */
  61601. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61602. /**
  61603. * Remove a mesh from being rendered through its own material and not with emissive only.
  61604. * @param mesh The mesh for which we need to not use its material
  61605. */
  61606. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61607. /**
  61608. * Free any resources and references associated to a mesh.
  61609. * Internal use
  61610. * @param mesh The mesh to free.
  61611. * @hidden
  61612. */
  61613. _disposeMesh(mesh: Mesh): void;
  61614. /**
  61615. * Gets the class name of the effect layer
  61616. * @returns the string with the class name of the effect layer
  61617. */
  61618. getClassName(): string;
  61619. /**
  61620. * Serializes this glow layer
  61621. * @returns a serialized glow layer object
  61622. */
  61623. serialize(): any;
  61624. /**
  61625. * Creates a Glow Layer from parsed glow layer data
  61626. * @param parsedGlowLayer defines glow layer data
  61627. * @param scene defines the current scene
  61628. * @param rootUrl defines the root URL containing the glow layer information
  61629. * @returns a parsed Glow Layer
  61630. */
  61631. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61632. }
  61633. }
  61634. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61635. /** @hidden */
  61636. export var glowBlurPostProcessPixelShader: {
  61637. name: string;
  61638. shader: string;
  61639. };
  61640. }
  61641. declare module "babylonjs/Layers/highlightLayer" {
  61642. import { Observable } from "babylonjs/Misc/observable";
  61643. import { Nullable } from "babylonjs/types";
  61644. import { Camera } from "babylonjs/Cameras/camera";
  61645. import { Scene } from "babylonjs/scene";
  61646. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61648. import { Mesh } from "babylonjs/Meshes/mesh";
  61649. import { Effect } from "babylonjs/Materials/effect";
  61650. import { Material } from "babylonjs/Materials/material";
  61651. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61652. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61653. import "babylonjs/Shaders/glowMapMerge.fragment";
  61654. import "babylonjs/Shaders/glowMapMerge.vertex";
  61655. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61656. module "babylonjs/abstractScene" {
  61657. interface AbstractScene {
  61658. /**
  61659. * Return a the first highlight layer of the scene with a given name.
  61660. * @param name The name of the highlight layer to look for.
  61661. * @return The highlight layer if found otherwise null.
  61662. */
  61663. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61664. }
  61665. }
  61666. /**
  61667. * Highlight layer options. This helps customizing the behaviour
  61668. * of the highlight layer.
  61669. */
  61670. export interface IHighlightLayerOptions {
  61671. /**
  61672. * Multiplication factor apply to the canvas size to compute the render target size
  61673. * used to generated the glowing objects (the smaller the faster).
  61674. */
  61675. mainTextureRatio: number;
  61676. /**
  61677. * Enforces a fixed size texture to ensure resize independant blur.
  61678. */
  61679. mainTextureFixedSize?: number;
  61680. /**
  61681. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61682. * of the picture to blur (the smaller the faster).
  61683. */
  61684. blurTextureSizeRatio: number;
  61685. /**
  61686. * How big in texel of the blur texture is the vertical blur.
  61687. */
  61688. blurVerticalSize: number;
  61689. /**
  61690. * How big in texel of the blur texture is the horizontal blur.
  61691. */
  61692. blurHorizontalSize: number;
  61693. /**
  61694. * Alpha blending mode used to apply the blur. Default is combine.
  61695. */
  61696. alphaBlendingMode: number;
  61697. /**
  61698. * The camera attached to the layer.
  61699. */
  61700. camera: Nullable<Camera>;
  61701. /**
  61702. * Should we display highlight as a solid stroke?
  61703. */
  61704. isStroke?: boolean;
  61705. /**
  61706. * The rendering group to draw the layer in.
  61707. */
  61708. renderingGroupId: number;
  61709. }
  61710. /**
  61711. * The highlight layer Helps adding a glow effect around a mesh.
  61712. *
  61713. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61714. * glowy meshes to your scene.
  61715. *
  61716. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61717. */
  61718. export class HighlightLayer extends EffectLayer {
  61719. name: string;
  61720. /**
  61721. * Effect Name of the highlight layer.
  61722. */
  61723. static readonly EffectName: string;
  61724. /**
  61725. * The neutral color used during the preparation of the glow effect.
  61726. * This is black by default as the blend operation is a blend operation.
  61727. */
  61728. static NeutralColor: Color4;
  61729. /**
  61730. * Stencil value used for glowing meshes.
  61731. */
  61732. static GlowingMeshStencilReference: number;
  61733. /**
  61734. * Stencil value used for the other meshes in the scene.
  61735. */
  61736. static NormalMeshStencilReference: number;
  61737. /**
  61738. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61739. */
  61740. innerGlow: boolean;
  61741. /**
  61742. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61743. */
  61744. outerGlow: boolean;
  61745. /**
  61746. * Specifies the horizontal size of the blur.
  61747. */
  61748. set blurHorizontalSize(value: number);
  61749. /**
  61750. * Specifies the vertical size of the blur.
  61751. */
  61752. set blurVerticalSize(value: number);
  61753. /**
  61754. * Gets the horizontal size of the blur.
  61755. */
  61756. get blurHorizontalSize(): number;
  61757. /**
  61758. * Gets the vertical size of the blur.
  61759. */
  61760. get blurVerticalSize(): number;
  61761. /**
  61762. * An event triggered when the highlight layer is being blurred.
  61763. */
  61764. onBeforeBlurObservable: Observable<HighlightLayer>;
  61765. /**
  61766. * An event triggered when the highlight layer has been blurred.
  61767. */
  61768. onAfterBlurObservable: Observable<HighlightLayer>;
  61769. private _instanceGlowingMeshStencilReference;
  61770. private _options;
  61771. private _downSamplePostprocess;
  61772. private _horizontalBlurPostprocess;
  61773. private _verticalBlurPostprocess;
  61774. private _blurTexture;
  61775. private _meshes;
  61776. private _excludedMeshes;
  61777. /**
  61778. * Instantiates a new highlight Layer and references it to the scene..
  61779. * @param name The name of the layer
  61780. * @param scene The scene to use the layer in
  61781. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61782. */
  61783. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61784. /**
  61785. * Get the effect name of the layer.
  61786. * @return The effect name
  61787. */
  61788. getEffectName(): string;
  61789. /**
  61790. * Create the merge effect. This is the shader use to blit the information back
  61791. * to the main canvas at the end of the scene rendering.
  61792. */
  61793. protected _createMergeEffect(): Effect;
  61794. /**
  61795. * Creates the render target textures and post processes used in the highlight layer.
  61796. */
  61797. protected _createTextureAndPostProcesses(): void;
  61798. /**
  61799. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61800. */
  61801. needStencil(): boolean;
  61802. /**
  61803. * Checks for the readiness of the element composing the layer.
  61804. * @param subMesh the mesh to check for
  61805. * @param useInstances specify wether or not to use instances to render the mesh
  61806. * @param emissiveTexture the associated emissive texture used to generate the glow
  61807. * @return true if ready otherwise, false
  61808. */
  61809. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61810. /**
  61811. * Implementation specific of rendering the generating effect on the main canvas.
  61812. * @param effect The effect used to render through
  61813. */
  61814. protected _internalRender(effect: Effect): void;
  61815. /**
  61816. * Returns true if the layer contains information to display, otherwise false.
  61817. */
  61818. shouldRender(): boolean;
  61819. /**
  61820. * Returns true if the mesh should render, otherwise false.
  61821. * @param mesh The mesh to render
  61822. * @returns true if it should render otherwise false
  61823. */
  61824. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61825. /**
  61826. * Returns true if the mesh can be rendered, otherwise false.
  61827. * @param mesh The mesh to render
  61828. * @param material The material used on the mesh
  61829. * @returns true if it can be rendered otherwise false
  61830. */
  61831. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61832. /**
  61833. * Adds specific effects defines.
  61834. * @param defines The defines to add specifics to.
  61835. */
  61836. protected _addCustomEffectDefines(defines: string[]): void;
  61837. /**
  61838. * Sets the required values for both the emissive texture and and the main color.
  61839. */
  61840. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61841. /**
  61842. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61843. * @param mesh The mesh to exclude from the highlight layer
  61844. */
  61845. addExcludedMesh(mesh: Mesh): void;
  61846. /**
  61847. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61848. * @param mesh The mesh to highlight
  61849. */
  61850. removeExcludedMesh(mesh: Mesh): void;
  61851. /**
  61852. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61853. * @param mesh mesh to test
  61854. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61855. */
  61856. hasMesh(mesh: AbstractMesh): boolean;
  61857. /**
  61858. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61859. * @param mesh The mesh to highlight
  61860. * @param color The color of the highlight
  61861. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61862. */
  61863. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61864. /**
  61865. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61866. * @param mesh The mesh to highlight
  61867. */
  61868. removeMesh(mesh: Mesh): void;
  61869. /**
  61870. * Remove all the meshes currently referenced in the highlight layer
  61871. */
  61872. removeAllMeshes(): void;
  61873. /**
  61874. * Force the stencil to the normal expected value for none glowing parts
  61875. */
  61876. private _defaultStencilReference;
  61877. /**
  61878. * Free any resources and references associated to a mesh.
  61879. * Internal use
  61880. * @param mesh The mesh to free.
  61881. * @hidden
  61882. */
  61883. _disposeMesh(mesh: Mesh): void;
  61884. /**
  61885. * Dispose the highlight layer and free resources.
  61886. */
  61887. dispose(): void;
  61888. /**
  61889. * Gets the class name of the effect layer
  61890. * @returns the string with the class name of the effect layer
  61891. */
  61892. getClassName(): string;
  61893. /**
  61894. * Serializes this Highlight layer
  61895. * @returns a serialized Highlight layer object
  61896. */
  61897. serialize(): any;
  61898. /**
  61899. * Creates a Highlight layer from parsed Highlight layer data
  61900. * @param parsedHightlightLayer defines the Highlight layer data
  61901. * @param scene defines the current scene
  61902. * @param rootUrl defines the root URL containing the Highlight layer information
  61903. * @returns a parsed Highlight layer
  61904. */
  61905. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61906. }
  61907. }
  61908. declare module "babylonjs/Layers/layerSceneComponent" {
  61909. import { Scene } from "babylonjs/scene";
  61910. import { ISceneComponent } from "babylonjs/sceneComponent";
  61911. import { Layer } from "babylonjs/Layers/layer";
  61912. import { AbstractScene } from "babylonjs/abstractScene";
  61913. module "babylonjs/abstractScene" {
  61914. interface AbstractScene {
  61915. /**
  61916. * The list of layers (background and foreground) of the scene
  61917. */
  61918. layers: Array<Layer>;
  61919. }
  61920. }
  61921. /**
  61922. * Defines the layer scene component responsible to manage any layers
  61923. * in a given scene.
  61924. */
  61925. export class LayerSceneComponent implements ISceneComponent {
  61926. /**
  61927. * The component name helpfull to identify the component in the list of scene components.
  61928. */
  61929. readonly name: string;
  61930. /**
  61931. * The scene the component belongs to.
  61932. */
  61933. scene: Scene;
  61934. private _engine;
  61935. /**
  61936. * Creates a new instance of the component for the given scene
  61937. * @param scene Defines the scene to register the component in
  61938. */
  61939. constructor(scene: Scene);
  61940. /**
  61941. * Registers the component in a given scene
  61942. */
  61943. register(): void;
  61944. /**
  61945. * Rebuilds the elements related to this component in case of
  61946. * context lost for instance.
  61947. */
  61948. rebuild(): void;
  61949. /**
  61950. * Disposes the component and the associated ressources.
  61951. */
  61952. dispose(): void;
  61953. private _draw;
  61954. private _drawCameraPredicate;
  61955. private _drawCameraBackground;
  61956. private _drawCameraForeground;
  61957. private _drawRenderTargetPredicate;
  61958. private _drawRenderTargetBackground;
  61959. private _drawRenderTargetForeground;
  61960. /**
  61961. * Adds all the elements from the container to the scene
  61962. * @param container the container holding the elements
  61963. */
  61964. addFromContainer(container: AbstractScene): void;
  61965. /**
  61966. * Removes all the elements in the container from the scene
  61967. * @param container contains the elements to remove
  61968. * @param dispose if the removed element should be disposed (default: false)
  61969. */
  61970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61971. }
  61972. }
  61973. declare module "babylonjs/Shaders/layer.fragment" {
  61974. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61975. /** @hidden */
  61976. export var layerPixelShader: {
  61977. name: string;
  61978. shader: string;
  61979. };
  61980. }
  61981. declare module "babylonjs/Shaders/layer.vertex" {
  61982. /** @hidden */
  61983. export var layerVertexShader: {
  61984. name: string;
  61985. shader: string;
  61986. };
  61987. }
  61988. declare module "babylonjs/Layers/layer" {
  61989. import { Observable } from "babylonjs/Misc/observable";
  61990. import { Nullable } from "babylonjs/types";
  61991. import { Scene } from "babylonjs/scene";
  61992. import { Vector2 } from "babylonjs/Maths/math.vector";
  61993. import { Color4 } from "babylonjs/Maths/math.color";
  61994. import { Texture } from "babylonjs/Materials/Textures/texture";
  61995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61996. import "babylonjs/Shaders/layer.fragment";
  61997. import "babylonjs/Shaders/layer.vertex";
  61998. /**
  61999. * This represents a full screen 2d layer.
  62000. * This can be useful to display a picture in the background of your scene for instance.
  62001. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62002. */
  62003. export class Layer {
  62004. /**
  62005. * Define the name of the layer.
  62006. */
  62007. name: string;
  62008. /**
  62009. * Define the texture the layer should display.
  62010. */
  62011. texture: Nullable<Texture>;
  62012. /**
  62013. * Is the layer in background or foreground.
  62014. */
  62015. isBackground: boolean;
  62016. /**
  62017. * Define the color of the layer (instead of texture).
  62018. */
  62019. color: Color4;
  62020. /**
  62021. * Define the scale of the layer in order to zoom in out of the texture.
  62022. */
  62023. scale: Vector2;
  62024. /**
  62025. * Define an offset for the layer in order to shift the texture.
  62026. */
  62027. offset: Vector2;
  62028. /**
  62029. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62030. */
  62031. alphaBlendingMode: number;
  62032. /**
  62033. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62034. * Alpha test will not mix with the background color in case of transparency.
  62035. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62036. */
  62037. alphaTest: boolean;
  62038. /**
  62039. * Define a mask to restrict the layer to only some of the scene cameras.
  62040. */
  62041. layerMask: number;
  62042. /**
  62043. * Define the list of render target the layer is visible into.
  62044. */
  62045. renderTargetTextures: RenderTargetTexture[];
  62046. /**
  62047. * Define if the layer is only used in renderTarget or if it also
  62048. * renders in the main frame buffer of the canvas.
  62049. */
  62050. renderOnlyInRenderTargetTextures: boolean;
  62051. private _scene;
  62052. private _vertexBuffers;
  62053. private _indexBuffer;
  62054. private _effect;
  62055. private _previousDefines;
  62056. /**
  62057. * An event triggered when the layer is disposed.
  62058. */
  62059. onDisposeObservable: Observable<Layer>;
  62060. private _onDisposeObserver;
  62061. /**
  62062. * Back compatibility with callback before the onDisposeObservable existed.
  62063. * The set callback will be triggered when the layer has been disposed.
  62064. */
  62065. set onDispose(callback: () => void);
  62066. /**
  62067. * An event triggered before rendering the scene
  62068. */
  62069. onBeforeRenderObservable: Observable<Layer>;
  62070. private _onBeforeRenderObserver;
  62071. /**
  62072. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62073. * The set callback will be triggered just before rendering the layer.
  62074. */
  62075. set onBeforeRender(callback: () => void);
  62076. /**
  62077. * An event triggered after rendering the scene
  62078. */
  62079. onAfterRenderObservable: Observable<Layer>;
  62080. private _onAfterRenderObserver;
  62081. /**
  62082. * Back compatibility with callback before the onAfterRenderObservable existed.
  62083. * The set callback will be triggered just after rendering the layer.
  62084. */
  62085. set onAfterRender(callback: () => void);
  62086. /**
  62087. * Instantiates a new layer.
  62088. * This represents a full screen 2d layer.
  62089. * This can be useful to display a picture in the background of your scene for instance.
  62090. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62091. * @param name Define the name of the layer in the scene
  62092. * @param imgUrl Define the url of the texture to display in the layer
  62093. * @param scene Define the scene the layer belongs to
  62094. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62095. * @param color Defines a color for the layer
  62096. */
  62097. constructor(
  62098. /**
  62099. * Define the name of the layer.
  62100. */
  62101. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62102. private _createIndexBuffer;
  62103. /** @hidden */
  62104. _rebuild(): void;
  62105. /**
  62106. * Renders the layer in the scene.
  62107. */
  62108. render(): void;
  62109. /**
  62110. * Disposes and releases the associated ressources.
  62111. */
  62112. dispose(): void;
  62113. }
  62114. }
  62115. declare module "babylonjs/Layers/index" {
  62116. export * from "babylonjs/Layers/effectLayer";
  62117. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62118. export * from "babylonjs/Layers/glowLayer";
  62119. export * from "babylonjs/Layers/highlightLayer";
  62120. export * from "babylonjs/Layers/layer";
  62121. export * from "babylonjs/Layers/layerSceneComponent";
  62122. }
  62123. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62124. /** @hidden */
  62125. export var lensFlarePixelShader: {
  62126. name: string;
  62127. shader: string;
  62128. };
  62129. }
  62130. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62131. /** @hidden */
  62132. export var lensFlareVertexShader: {
  62133. name: string;
  62134. shader: string;
  62135. };
  62136. }
  62137. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62138. import { Scene } from "babylonjs/scene";
  62139. import { Vector3 } from "babylonjs/Maths/math.vector";
  62140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62141. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62142. import "babylonjs/Shaders/lensFlare.fragment";
  62143. import "babylonjs/Shaders/lensFlare.vertex";
  62144. import { Viewport } from "babylonjs/Maths/math.viewport";
  62145. /**
  62146. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62147. * It is usually composed of several `lensFlare`.
  62148. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62149. */
  62150. export class LensFlareSystem {
  62151. /**
  62152. * Define the name of the lens flare system
  62153. */
  62154. name: string;
  62155. /**
  62156. * List of lens flares used in this system.
  62157. */
  62158. lensFlares: LensFlare[];
  62159. /**
  62160. * Define a limit from the border the lens flare can be visible.
  62161. */
  62162. borderLimit: number;
  62163. /**
  62164. * Define a viewport border we do not want to see the lens flare in.
  62165. */
  62166. viewportBorder: number;
  62167. /**
  62168. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62169. */
  62170. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62171. /**
  62172. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62173. */
  62174. layerMask: number;
  62175. /**
  62176. * Define the id of the lens flare system in the scene.
  62177. * (equal to name by default)
  62178. */
  62179. id: string;
  62180. private _scene;
  62181. private _emitter;
  62182. private _vertexBuffers;
  62183. private _indexBuffer;
  62184. private _effect;
  62185. private _positionX;
  62186. private _positionY;
  62187. private _isEnabled;
  62188. /** @hidden */
  62189. static _SceneComponentInitialization: (scene: Scene) => void;
  62190. /**
  62191. * Instantiates a lens flare system.
  62192. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62193. * It is usually composed of several `lensFlare`.
  62194. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62195. * @param name Define the name of the lens flare system in the scene
  62196. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62197. * @param scene Define the scene the lens flare system belongs to
  62198. */
  62199. constructor(
  62200. /**
  62201. * Define the name of the lens flare system
  62202. */
  62203. name: string, emitter: any, scene: Scene);
  62204. /**
  62205. * Define if the lens flare system is enabled.
  62206. */
  62207. get isEnabled(): boolean;
  62208. set isEnabled(value: boolean);
  62209. /**
  62210. * Get the scene the effects belongs to.
  62211. * @returns the scene holding the lens flare system
  62212. */
  62213. getScene(): Scene;
  62214. /**
  62215. * Get the emitter of the lens flare system.
  62216. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62217. * @returns the emitter of the lens flare system
  62218. */
  62219. getEmitter(): any;
  62220. /**
  62221. * Set the emitter of the lens flare system.
  62222. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62223. * @param newEmitter Define the new emitter of the system
  62224. */
  62225. setEmitter(newEmitter: any): void;
  62226. /**
  62227. * Get the lens flare system emitter position.
  62228. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62229. * @returns the position
  62230. */
  62231. getEmitterPosition(): Vector3;
  62232. /**
  62233. * @hidden
  62234. */
  62235. computeEffectivePosition(globalViewport: Viewport): boolean;
  62236. /** @hidden */
  62237. _isVisible(): boolean;
  62238. /**
  62239. * @hidden
  62240. */
  62241. render(): boolean;
  62242. /**
  62243. * Dispose and release the lens flare with its associated resources.
  62244. */
  62245. dispose(): void;
  62246. /**
  62247. * Parse a lens flare system from a JSON repressentation
  62248. * @param parsedLensFlareSystem Define the JSON to parse
  62249. * @param scene Define the scene the parsed system should be instantiated in
  62250. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62251. * @returns the parsed system
  62252. */
  62253. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62254. /**
  62255. * Serialize the current Lens Flare System into a JSON representation.
  62256. * @returns the serialized JSON
  62257. */
  62258. serialize(): any;
  62259. }
  62260. }
  62261. declare module "babylonjs/LensFlares/lensFlare" {
  62262. import { Nullable } from "babylonjs/types";
  62263. import { Color3 } from "babylonjs/Maths/math.color";
  62264. import { Texture } from "babylonjs/Materials/Textures/texture";
  62265. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62266. /**
  62267. * This represents one of the lens effect in a `lensFlareSystem`.
  62268. * It controls one of the indiviual texture used in the effect.
  62269. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62270. */
  62271. export class LensFlare {
  62272. /**
  62273. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62274. */
  62275. size: number;
  62276. /**
  62277. * 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.
  62278. */
  62279. position: number;
  62280. /**
  62281. * Define the lens color.
  62282. */
  62283. color: Color3;
  62284. /**
  62285. * Define the lens texture.
  62286. */
  62287. texture: Nullable<Texture>;
  62288. /**
  62289. * Define the alpha mode to render this particular lens.
  62290. */
  62291. alphaMode: number;
  62292. private _system;
  62293. /**
  62294. * Creates a new Lens Flare.
  62295. * This represents one of the lens effect in a `lensFlareSystem`.
  62296. * It controls one of the indiviual texture used in the effect.
  62297. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62298. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62299. * @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.
  62300. * @param color Define the lens color
  62301. * @param imgUrl Define the lens texture url
  62302. * @param system Define the `lensFlareSystem` this flare is part of
  62303. * @returns The newly created Lens Flare
  62304. */
  62305. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62306. /**
  62307. * Instantiates a new Lens Flare.
  62308. * This represents one of the lens effect in a `lensFlareSystem`.
  62309. * It controls one of the indiviual texture used in the effect.
  62310. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62311. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62312. * @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.
  62313. * @param color Define the lens color
  62314. * @param imgUrl Define the lens texture url
  62315. * @param system Define the `lensFlareSystem` this flare is part of
  62316. */
  62317. constructor(
  62318. /**
  62319. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62320. */
  62321. size: number,
  62322. /**
  62323. * 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.
  62324. */
  62325. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62326. /**
  62327. * Dispose and release the lens flare with its associated resources.
  62328. */
  62329. dispose(): void;
  62330. }
  62331. }
  62332. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62333. import { Nullable } from "babylonjs/types";
  62334. import { Scene } from "babylonjs/scene";
  62335. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62336. import { AbstractScene } from "babylonjs/abstractScene";
  62337. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62338. module "babylonjs/abstractScene" {
  62339. interface AbstractScene {
  62340. /**
  62341. * The list of lens flare system added to the scene
  62342. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62343. */
  62344. lensFlareSystems: Array<LensFlareSystem>;
  62345. /**
  62346. * Removes the given lens flare system from this scene.
  62347. * @param toRemove The lens flare system to remove
  62348. * @returns The index of the removed lens flare system
  62349. */
  62350. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62351. /**
  62352. * Adds the given lens flare system to this scene
  62353. * @param newLensFlareSystem The lens flare system to add
  62354. */
  62355. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62356. /**
  62357. * Gets a lens flare system using its name
  62358. * @param name defines the name to look for
  62359. * @returns the lens flare system or null if not found
  62360. */
  62361. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62362. /**
  62363. * Gets a lens flare system using its id
  62364. * @param id defines the id to look for
  62365. * @returns the lens flare system or null if not found
  62366. */
  62367. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62368. }
  62369. }
  62370. /**
  62371. * Defines the lens flare scene component responsible to manage any lens flares
  62372. * in a given scene.
  62373. */
  62374. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62375. /**
  62376. * The component name helpfull to identify the component in the list of scene components.
  62377. */
  62378. readonly name: string;
  62379. /**
  62380. * The scene the component belongs to.
  62381. */
  62382. scene: Scene;
  62383. /**
  62384. * Creates a new instance of the component for the given scene
  62385. * @param scene Defines the scene to register the component in
  62386. */
  62387. constructor(scene: Scene);
  62388. /**
  62389. * Registers the component in a given scene
  62390. */
  62391. register(): void;
  62392. /**
  62393. * Rebuilds the elements related to this component in case of
  62394. * context lost for instance.
  62395. */
  62396. rebuild(): void;
  62397. /**
  62398. * Adds all the elements from the container to the scene
  62399. * @param container the container holding the elements
  62400. */
  62401. addFromContainer(container: AbstractScene): void;
  62402. /**
  62403. * Removes all the elements in the container from the scene
  62404. * @param container contains the elements to remove
  62405. * @param dispose if the removed element should be disposed (default: false)
  62406. */
  62407. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62408. /**
  62409. * Serializes the component data to the specified json object
  62410. * @param serializationObject The object to serialize to
  62411. */
  62412. serialize(serializationObject: any): void;
  62413. /**
  62414. * Disposes the component and the associated ressources.
  62415. */
  62416. dispose(): void;
  62417. private _draw;
  62418. }
  62419. }
  62420. declare module "babylonjs/LensFlares/index" {
  62421. export * from "babylonjs/LensFlares/lensFlare";
  62422. export * from "babylonjs/LensFlares/lensFlareSystem";
  62423. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62424. }
  62425. declare module "babylonjs/Shaders/depth.fragment" {
  62426. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62427. /** @hidden */
  62428. export var depthPixelShader: {
  62429. name: string;
  62430. shader: string;
  62431. };
  62432. }
  62433. declare module "babylonjs/Shaders/depth.vertex" {
  62434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62437. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62439. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62440. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62441. /** @hidden */
  62442. export var depthVertexShader: {
  62443. name: string;
  62444. shader: string;
  62445. };
  62446. }
  62447. declare module "babylonjs/Rendering/depthRenderer" {
  62448. import { Nullable } from "babylonjs/types";
  62449. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62450. import { Scene } from "babylonjs/scene";
  62451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62452. import { Camera } from "babylonjs/Cameras/camera";
  62453. import "babylonjs/Shaders/depth.fragment";
  62454. import "babylonjs/Shaders/depth.vertex";
  62455. /**
  62456. * This represents a depth renderer in Babylon.
  62457. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62458. */
  62459. export class DepthRenderer {
  62460. private _scene;
  62461. private _depthMap;
  62462. private _effect;
  62463. private readonly _storeNonLinearDepth;
  62464. private readonly _clearColor;
  62465. /** Get if the depth renderer is using packed depth or not */
  62466. readonly isPacked: boolean;
  62467. private _cachedDefines;
  62468. private _camera;
  62469. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62470. enabled: boolean;
  62471. /**
  62472. * Specifiess that the depth renderer will only be used within
  62473. * the camera it is created for.
  62474. * This can help forcing its rendering during the camera processing.
  62475. */
  62476. useOnlyInActiveCamera: boolean;
  62477. /** @hidden */
  62478. static _SceneComponentInitialization: (scene: Scene) => void;
  62479. /**
  62480. * Instantiates a depth renderer
  62481. * @param scene The scene the renderer belongs to
  62482. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62483. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62484. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62485. */
  62486. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62487. /**
  62488. * Creates the depth rendering effect and checks if the effect is ready.
  62489. * @param subMesh The submesh to be used to render the depth map of
  62490. * @param useInstances If multiple world instances should be used
  62491. * @returns if the depth renderer is ready to render the depth map
  62492. */
  62493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62494. /**
  62495. * Gets the texture which the depth map will be written to.
  62496. * @returns The depth map texture
  62497. */
  62498. getDepthMap(): RenderTargetTexture;
  62499. /**
  62500. * Disposes of the depth renderer.
  62501. */
  62502. dispose(): void;
  62503. }
  62504. }
  62505. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62506. /** @hidden */
  62507. export var minmaxReduxPixelShader: {
  62508. name: string;
  62509. shader: string;
  62510. };
  62511. }
  62512. declare module "babylonjs/Misc/minMaxReducer" {
  62513. import { Nullable } from "babylonjs/types";
  62514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62515. import { Camera } from "babylonjs/Cameras/camera";
  62516. import { Observer } from "babylonjs/Misc/observable";
  62517. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62518. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62519. import { Observable } from "babylonjs/Misc/observable";
  62520. import "babylonjs/Shaders/minmaxRedux.fragment";
  62521. /**
  62522. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62523. * and maximum values from all values of the texture.
  62524. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62525. * The source values are read from the red channel of the texture.
  62526. */
  62527. export class MinMaxReducer {
  62528. /**
  62529. * Observable triggered when the computation has been performed
  62530. */
  62531. onAfterReductionPerformed: Observable<{
  62532. min: number;
  62533. max: number;
  62534. }>;
  62535. protected _camera: Camera;
  62536. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62537. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62538. protected _postProcessManager: PostProcessManager;
  62539. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62540. protected _forceFullscreenViewport: boolean;
  62541. /**
  62542. * Creates a min/max reducer
  62543. * @param camera The camera to use for the post processes
  62544. */
  62545. constructor(camera: Camera);
  62546. /**
  62547. * Gets the texture used to read the values from.
  62548. */
  62549. get sourceTexture(): Nullable<RenderTargetTexture>;
  62550. /**
  62551. * Sets the source texture to read the values from.
  62552. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62553. * because in such textures '1' value must not be taken into account to compute the maximum
  62554. * as this value is used to clear the texture.
  62555. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62556. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62557. * @param depthRedux Indicates if the texture is a depth texture or not
  62558. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62559. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62560. */
  62561. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62562. /**
  62563. * Defines the refresh rate of the computation.
  62564. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62565. */
  62566. get refreshRate(): number;
  62567. set refreshRate(value: number);
  62568. protected _activated: boolean;
  62569. /**
  62570. * Gets the activation status of the reducer
  62571. */
  62572. get activated(): boolean;
  62573. /**
  62574. * Activates the reduction computation.
  62575. * When activated, the observers registered in onAfterReductionPerformed are
  62576. * called after the compuation is performed
  62577. */
  62578. activate(): void;
  62579. /**
  62580. * Deactivates the reduction computation.
  62581. */
  62582. deactivate(): void;
  62583. /**
  62584. * Disposes the min/max reducer
  62585. * @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.
  62586. */
  62587. dispose(disposeAll?: boolean): void;
  62588. }
  62589. }
  62590. declare module "babylonjs/Misc/depthReducer" {
  62591. import { Nullable } from "babylonjs/types";
  62592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62593. import { Camera } from "babylonjs/Cameras/camera";
  62594. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62595. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62596. /**
  62597. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62598. */
  62599. export class DepthReducer extends MinMaxReducer {
  62600. private _depthRenderer;
  62601. private _depthRendererId;
  62602. /**
  62603. * Gets the depth renderer used for the computation.
  62604. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62605. */
  62606. get depthRenderer(): Nullable<DepthRenderer>;
  62607. /**
  62608. * Creates a depth reducer
  62609. * @param camera The camera used to render the depth texture
  62610. */
  62611. constructor(camera: Camera);
  62612. /**
  62613. * Sets the depth renderer to use to generate the depth map
  62614. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62615. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62616. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62617. */
  62618. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62619. /** @hidden */
  62620. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62621. /**
  62622. * Activates the reduction computation.
  62623. * When activated, the observers registered in onAfterReductionPerformed are
  62624. * called after the compuation is performed
  62625. */
  62626. activate(): void;
  62627. /**
  62628. * Deactivates the reduction computation.
  62629. */
  62630. deactivate(): void;
  62631. /**
  62632. * Disposes the depth reducer
  62633. * @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.
  62634. */
  62635. dispose(disposeAll?: boolean): void;
  62636. }
  62637. }
  62638. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62639. import { Nullable } from "babylonjs/types";
  62640. import { Scene } from "babylonjs/scene";
  62641. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62644. import { Effect } from "babylonjs/Materials/effect";
  62645. import "babylonjs/Shaders/shadowMap.fragment";
  62646. import "babylonjs/Shaders/shadowMap.vertex";
  62647. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62648. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62649. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62650. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62651. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62652. /**
  62653. * A CSM implementation allowing casting shadows on large scenes.
  62654. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62655. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62656. */
  62657. export class CascadedShadowGenerator extends ShadowGenerator {
  62658. private static readonly frustumCornersNDCSpace;
  62659. /**
  62660. * Name of the CSM class
  62661. */
  62662. static CLASSNAME: string;
  62663. /**
  62664. * Defines the default number of cascades used by the CSM.
  62665. */
  62666. static readonly DEFAULT_CASCADES_COUNT: number;
  62667. /**
  62668. * Defines the minimum number of cascades used by the CSM.
  62669. */
  62670. static readonly MIN_CASCADES_COUNT: number;
  62671. /**
  62672. * Defines the maximum number of cascades used by the CSM.
  62673. */
  62674. static readonly MAX_CASCADES_COUNT: number;
  62675. protected _validateFilter(filter: number): number;
  62676. /**
  62677. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62678. */
  62679. penumbraDarkness: number;
  62680. private _numCascades;
  62681. /**
  62682. * Gets or set the number of cascades used by the CSM.
  62683. */
  62684. get numCascades(): number;
  62685. set numCascades(value: number);
  62686. /**
  62687. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62688. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62689. */
  62690. stabilizeCascades: boolean;
  62691. private _freezeShadowCastersBoundingInfo;
  62692. private _freezeShadowCastersBoundingInfoObservable;
  62693. /**
  62694. * Enables or disables the shadow casters bounding info computation.
  62695. * If your shadow casters don't move, you can disable this feature.
  62696. * If it is enabled, the bounding box computation is done every frame.
  62697. */
  62698. get freezeShadowCastersBoundingInfo(): boolean;
  62699. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62700. private _scbiMin;
  62701. private _scbiMax;
  62702. protected _computeShadowCastersBoundingInfo(): void;
  62703. protected _shadowCastersBoundingInfo: BoundingInfo;
  62704. /**
  62705. * Gets or sets the shadow casters bounding info.
  62706. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62707. * so that the system won't overwrite the bounds you provide
  62708. */
  62709. get shadowCastersBoundingInfo(): BoundingInfo;
  62710. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62711. protected _breaksAreDirty: boolean;
  62712. protected _minDistance: number;
  62713. protected _maxDistance: number;
  62714. /**
  62715. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62716. *
  62717. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62718. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62719. * @param min minimal distance for the breaks (default to 0.)
  62720. * @param max maximal distance for the breaks (default to 1.)
  62721. */
  62722. setMinMaxDistance(min: number, max: number): void;
  62723. /** Gets the minimal distance used in the cascade break computation */
  62724. get minDistance(): number;
  62725. /** Gets the maximal distance used in the cascade break computation */
  62726. get maxDistance(): number;
  62727. /**
  62728. * Gets the class name of that object
  62729. * @returns "CascadedShadowGenerator"
  62730. */
  62731. getClassName(): string;
  62732. private _cascadeMinExtents;
  62733. private _cascadeMaxExtents;
  62734. /**
  62735. * Gets a cascade minimum extents
  62736. * @param cascadeIndex index of the cascade
  62737. * @returns the minimum cascade extents
  62738. */
  62739. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62740. /**
  62741. * Gets a cascade maximum extents
  62742. * @param cascadeIndex index of the cascade
  62743. * @returns the maximum cascade extents
  62744. */
  62745. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62746. private _cascades;
  62747. private _currentLayer;
  62748. private _viewSpaceFrustumsZ;
  62749. private _viewMatrices;
  62750. private _projectionMatrices;
  62751. private _transformMatrices;
  62752. private _transformMatricesAsArray;
  62753. private _frustumLengths;
  62754. private _lightSizeUVCorrection;
  62755. private _depthCorrection;
  62756. private _frustumCornersWorldSpace;
  62757. private _frustumCenter;
  62758. private _shadowCameraPos;
  62759. private _shadowMaxZ;
  62760. /**
  62761. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62762. * It defaults to camera.maxZ
  62763. */
  62764. get shadowMaxZ(): number;
  62765. /**
  62766. * Sets the shadow max z distance.
  62767. */
  62768. set shadowMaxZ(value: number);
  62769. protected _debug: boolean;
  62770. /**
  62771. * Gets or sets the debug flag.
  62772. * When enabled, the cascades are materialized by different colors on the screen.
  62773. */
  62774. get debug(): boolean;
  62775. set debug(dbg: boolean);
  62776. private _depthClamp;
  62777. /**
  62778. * Gets or sets the depth clamping value.
  62779. *
  62780. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62781. * to account for the shadow casters far away.
  62782. *
  62783. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62784. */
  62785. get depthClamp(): boolean;
  62786. set depthClamp(value: boolean);
  62787. private _cascadeBlendPercentage;
  62788. /**
  62789. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62790. * It defaults to 0.1 (10% blending).
  62791. */
  62792. get cascadeBlendPercentage(): number;
  62793. set cascadeBlendPercentage(value: number);
  62794. private _lambda;
  62795. /**
  62796. * Gets or set the lambda parameter.
  62797. * This parameter is used to split the camera frustum and create the cascades.
  62798. * 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.
  62799. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62800. */
  62801. get lambda(): number;
  62802. set lambda(value: number);
  62803. /**
  62804. * Gets the view matrix corresponding to a given cascade
  62805. * @param cascadeNum cascade to retrieve the view matrix from
  62806. * @returns the cascade view matrix
  62807. */
  62808. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62809. /**
  62810. * Gets the projection matrix corresponding to a given cascade
  62811. * @param cascadeNum cascade to retrieve the projection matrix from
  62812. * @returns the cascade projection matrix
  62813. */
  62814. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62815. /**
  62816. * Gets the transformation matrix corresponding to a given cascade
  62817. * @param cascadeNum cascade to retrieve the transformation matrix from
  62818. * @returns the cascade transformation matrix
  62819. */
  62820. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62821. private _depthRenderer;
  62822. /**
  62823. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62824. *
  62825. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62826. *
  62827. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62828. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62829. * @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
  62830. */
  62831. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62832. private _depthReducer;
  62833. private _autoCalcDepthBounds;
  62834. /**
  62835. * Gets or sets the autoCalcDepthBounds property.
  62836. *
  62837. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62838. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62839. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62840. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62841. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62842. */
  62843. get autoCalcDepthBounds(): boolean;
  62844. set autoCalcDepthBounds(value: boolean);
  62845. /**
  62846. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62847. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62848. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62849. * for setting the refresh rate on the renderer yourself!
  62850. */
  62851. get autoCalcDepthBoundsRefreshRate(): number;
  62852. set autoCalcDepthBoundsRefreshRate(value: number);
  62853. /**
  62854. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62855. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62856. * you change the camera near/far planes!
  62857. */
  62858. splitFrustum(): void;
  62859. private _splitFrustum;
  62860. private _computeMatrices;
  62861. private _computeFrustumInWorldSpace;
  62862. private _computeCascadeFrustum;
  62863. /**
  62864. * Support test.
  62865. */
  62866. static get IsSupported(): boolean;
  62867. /** @hidden */
  62868. static _SceneComponentInitialization: (scene: Scene) => void;
  62869. /**
  62870. * Creates a Cascaded Shadow Generator object.
  62871. * A ShadowGenerator is the required tool to use the shadows.
  62872. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62873. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62874. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62875. * @param light The directional light object generating the shadows.
  62876. * @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.
  62877. */
  62878. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62879. protected _initializeGenerator(): void;
  62880. protected _createTargetRenderTexture(): void;
  62881. protected _initializeShadowMap(): void;
  62882. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62883. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62884. /**
  62885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62886. * @param defines Defines of the material we want to update
  62887. * @param lightIndex Index of the light in the enabled light list of the material
  62888. */
  62889. prepareDefines(defines: any, lightIndex: number): void;
  62890. /**
  62891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62892. * defined in the generator but impacting the effect).
  62893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62894. * @param effect The effect we are binfing the information for
  62895. */
  62896. bindShadowLight(lightIndex: string, effect: Effect): void;
  62897. /**
  62898. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62899. * (eq to view projection * shadow projection matrices)
  62900. * @returns The transform matrix used to create the shadow map
  62901. */
  62902. getTransformMatrix(): Matrix;
  62903. /**
  62904. * Disposes the ShadowGenerator.
  62905. * Returns nothing.
  62906. */
  62907. dispose(): void;
  62908. /**
  62909. * Serializes the shadow generator setup to a json object.
  62910. * @returns The serialized JSON object
  62911. */
  62912. serialize(): any;
  62913. /**
  62914. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62915. * @param parsedShadowGenerator The JSON object to parse
  62916. * @param scene The scene to create the shadow map for
  62917. * @returns The parsed shadow generator
  62918. */
  62919. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62920. }
  62921. }
  62922. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62923. import { Scene } from "babylonjs/scene";
  62924. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62925. import { AbstractScene } from "babylonjs/abstractScene";
  62926. /**
  62927. * Defines the shadow generator component responsible to manage any shadow generators
  62928. * in a given scene.
  62929. */
  62930. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62931. /**
  62932. * The component name helpfull to identify the component in the list of scene components.
  62933. */
  62934. readonly name: string;
  62935. /**
  62936. * The scene the component belongs to.
  62937. */
  62938. scene: Scene;
  62939. /**
  62940. * Creates a new instance of the component for the given scene
  62941. * @param scene Defines the scene to register the component in
  62942. */
  62943. constructor(scene: Scene);
  62944. /**
  62945. * Registers the component in a given scene
  62946. */
  62947. register(): void;
  62948. /**
  62949. * Rebuilds the elements related to this component in case of
  62950. * context lost for instance.
  62951. */
  62952. rebuild(): void;
  62953. /**
  62954. * Serializes the component data to the specified json object
  62955. * @param serializationObject The object to serialize to
  62956. */
  62957. serialize(serializationObject: any): void;
  62958. /**
  62959. * Adds all the elements from the container to the scene
  62960. * @param container the container holding the elements
  62961. */
  62962. addFromContainer(container: AbstractScene): void;
  62963. /**
  62964. * Removes all the elements in the container from the scene
  62965. * @param container contains the elements to remove
  62966. * @param dispose if the removed element should be disposed (default: false)
  62967. */
  62968. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62969. /**
  62970. * Rebuilds the elements related to this component in case of
  62971. * context lost for instance.
  62972. */
  62973. dispose(): void;
  62974. private _gatherRenderTargets;
  62975. }
  62976. }
  62977. declare module "babylonjs/Lights/Shadows/index" {
  62978. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62979. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62980. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62981. }
  62982. declare module "babylonjs/Lights/pointLight" {
  62983. import { Scene } from "babylonjs/scene";
  62984. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62986. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62987. import { Effect } from "babylonjs/Materials/effect";
  62988. /**
  62989. * A point light is a light defined by an unique point in world space.
  62990. * The light is emitted in every direction from this point.
  62991. * A good example of a point light is a standard light bulb.
  62992. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62993. */
  62994. export class PointLight extends ShadowLight {
  62995. private _shadowAngle;
  62996. /**
  62997. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62998. * This specifies what angle the shadow will use to be created.
  62999. *
  63000. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63001. */
  63002. get shadowAngle(): number;
  63003. /**
  63004. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63005. * This specifies what angle the shadow will use to be created.
  63006. *
  63007. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63008. */
  63009. set shadowAngle(value: number);
  63010. /**
  63011. * Gets the direction if it has been set.
  63012. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63013. */
  63014. get direction(): Vector3;
  63015. /**
  63016. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63017. */
  63018. set direction(value: Vector3);
  63019. /**
  63020. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63021. * A PointLight emits the light in every direction.
  63022. * It can cast shadows.
  63023. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63024. * ```javascript
  63025. * var pointLight = new PointLight("pl", camera.position, scene);
  63026. * ```
  63027. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63028. * @param name The light friendly name
  63029. * @param position The position of the point light in the scene
  63030. * @param scene The scene the lights belongs to
  63031. */
  63032. constructor(name: string, position: Vector3, scene: Scene);
  63033. /**
  63034. * Returns the string "PointLight"
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Returns the integer 0.
  63040. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63041. */
  63042. getTypeID(): number;
  63043. /**
  63044. * Specifies wether or not the shadowmap should be a cube texture.
  63045. * @returns true if the shadowmap needs to be a cube texture.
  63046. */
  63047. needCube(): boolean;
  63048. /**
  63049. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63050. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63051. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63052. */
  63053. getShadowDirection(faceIndex?: number): Vector3;
  63054. /**
  63055. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63056. * - fov = PI / 2
  63057. * - aspect ratio : 1.0
  63058. * - z-near and far equal to the active camera minZ and maxZ.
  63059. * Returns the PointLight.
  63060. */
  63061. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63062. protected _buildUniformLayout(): void;
  63063. /**
  63064. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63065. * @param effect The effect to update
  63066. * @param lightIndex The index of the light in the effect to update
  63067. * @returns The point light
  63068. */
  63069. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63070. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63071. /**
  63072. * Prepares the list of defines specific to the light type.
  63073. * @param defines the list of defines
  63074. * @param lightIndex defines the index of the light for the effect
  63075. */
  63076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63077. }
  63078. }
  63079. declare module "babylonjs/Lights/index" {
  63080. export * from "babylonjs/Lights/light";
  63081. export * from "babylonjs/Lights/shadowLight";
  63082. export * from "babylonjs/Lights/Shadows/index";
  63083. export * from "babylonjs/Lights/directionalLight";
  63084. export * from "babylonjs/Lights/hemisphericLight";
  63085. export * from "babylonjs/Lights/pointLight";
  63086. export * from "babylonjs/Lights/spotLight";
  63087. }
  63088. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63089. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63090. /**
  63091. * Header information of HDR texture files.
  63092. */
  63093. export interface HDRInfo {
  63094. /**
  63095. * The height of the texture in pixels.
  63096. */
  63097. height: number;
  63098. /**
  63099. * The width of the texture in pixels.
  63100. */
  63101. width: number;
  63102. /**
  63103. * The index of the beginning of the data in the binary file.
  63104. */
  63105. dataPosition: number;
  63106. }
  63107. /**
  63108. * This groups tools to convert HDR texture to native colors array.
  63109. */
  63110. export class HDRTools {
  63111. private static Ldexp;
  63112. private static Rgbe2float;
  63113. private static readStringLine;
  63114. /**
  63115. * Reads header information from an RGBE texture stored in a native array.
  63116. * More information on this format are available here:
  63117. * https://en.wikipedia.org/wiki/RGBE_image_format
  63118. *
  63119. * @param uint8array The binary file stored in native array.
  63120. * @return The header information.
  63121. */
  63122. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63123. /**
  63124. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63125. * This RGBE texture needs to store the information as a panorama.
  63126. *
  63127. * More information on this format are available here:
  63128. * https://en.wikipedia.org/wiki/RGBE_image_format
  63129. *
  63130. * @param buffer The binary file stored in an array buffer.
  63131. * @param size The expected size of the extracted cubemap.
  63132. * @return The Cube Map information.
  63133. */
  63134. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63135. /**
  63136. * Returns the pixels data extracted from an RGBE texture.
  63137. * This pixels will be stored left to right up to down in the R G B order in one array.
  63138. *
  63139. * More information on this format are available here:
  63140. * https://en.wikipedia.org/wiki/RGBE_image_format
  63141. *
  63142. * @param uint8array The binary file stored in an array buffer.
  63143. * @param hdrInfo The header information of the file.
  63144. * @return The pixels data in RGB right to left up to down order.
  63145. */
  63146. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63147. private static RGBE_ReadPixels_RLE;
  63148. private static RGBE_ReadPixels_NOT_RLE;
  63149. }
  63150. }
  63151. declare module "babylonjs/Materials/effectRenderer" {
  63152. import { Nullable } from "babylonjs/types";
  63153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63155. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63156. import { Viewport } from "babylonjs/Maths/math.viewport";
  63157. import { Observable } from "babylonjs/Misc/observable";
  63158. import { Effect } from "babylonjs/Materials/effect";
  63159. import "babylonjs/Shaders/postprocess.vertex";
  63160. /**
  63161. * Effect Render Options
  63162. */
  63163. export interface IEffectRendererOptions {
  63164. /**
  63165. * Defines the vertices positions.
  63166. */
  63167. positions?: number[];
  63168. /**
  63169. * Defines the indices.
  63170. */
  63171. indices?: number[];
  63172. }
  63173. /**
  63174. * Helper class to render one or more effects.
  63175. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63176. */
  63177. export class EffectRenderer {
  63178. private engine;
  63179. private static _DefaultOptions;
  63180. private _vertexBuffers;
  63181. private _indexBuffer;
  63182. private _fullscreenViewport;
  63183. /**
  63184. * Creates an effect renderer
  63185. * @param engine the engine to use for rendering
  63186. * @param options defines the options of the effect renderer
  63187. */
  63188. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63189. /**
  63190. * Sets the current viewport in normalized coordinates 0-1
  63191. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63192. */
  63193. setViewport(viewport?: Viewport): void;
  63194. /**
  63195. * Binds the embedded attributes buffer to the effect.
  63196. * @param effect Defines the effect to bind the attributes for
  63197. */
  63198. bindBuffers(effect: Effect): void;
  63199. /**
  63200. * Sets the current effect wrapper to use during draw.
  63201. * The effect needs to be ready before calling this api.
  63202. * This also sets the default full screen position attribute.
  63203. * @param effectWrapper Defines the effect to draw with
  63204. */
  63205. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63206. /**
  63207. * Restores engine states
  63208. */
  63209. restoreStates(): void;
  63210. /**
  63211. * Draws a full screen quad.
  63212. */
  63213. draw(): void;
  63214. private isRenderTargetTexture;
  63215. /**
  63216. * renders one or more effects to a specified texture
  63217. * @param effectWrapper the effect to renderer
  63218. * @param outputTexture texture to draw to, if null it will render to the screen.
  63219. */
  63220. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63221. /**
  63222. * Disposes of the effect renderer
  63223. */
  63224. dispose(): void;
  63225. }
  63226. /**
  63227. * Options to create an EffectWrapper
  63228. */
  63229. interface EffectWrapperCreationOptions {
  63230. /**
  63231. * Engine to use to create the effect
  63232. */
  63233. engine: ThinEngine;
  63234. /**
  63235. * Fragment shader for the effect
  63236. */
  63237. fragmentShader: string;
  63238. /**
  63239. * Use the shader store instead of direct source code
  63240. */
  63241. useShaderStore?: boolean;
  63242. /**
  63243. * Vertex shader for the effect
  63244. */
  63245. vertexShader?: string;
  63246. /**
  63247. * Attributes to use in the shader
  63248. */
  63249. attributeNames?: Array<string>;
  63250. /**
  63251. * Uniforms to use in the shader
  63252. */
  63253. uniformNames?: Array<string>;
  63254. /**
  63255. * Texture sampler names to use in the shader
  63256. */
  63257. samplerNames?: Array<string>;
  63258. /**
  63259. * Defines to use in the shader
  63260. */
  63261. defines?: Array<string>;
  63262. /**
  63263. * Callback when effect is compiled
  63264. */
  63265. onCompiled?: Nullable<(effect: Effect) => void>;
  63266. /**
  63267. * The friendly name of the effect displayed in Spector.
  63268. */
  63269. name?: string;
  63270. }
  63271. /**
  63272. * Wraps an effect to be used for rendering
  63273. */
  63274. export class EffectWrapper {
  63275. /**
  63276. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63277. */
  63278. onApplyObservable: Observable<{}>;
  63279. /**
  63280. * The underlying effect
  63281. */
  63282. effect: Effect;
  63283. /**
  63284. * Creates an effect to be renderer
  63285. * @param creationOptions options to create the effect
  63286. */
  63287. constructor(creationOptions: EffectWrapperCreationOptions);
  63288. /**
  63289. * Disposes of the effect wrapper
  63290. */
  63291. dispose(): void;
  63292. }
  63293. }
  63294. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63295. /** @hidden */
  63296. export var hdrFilteringVertexShader: {
  63297. name: string;
  63298. shader: string;
  63299. };
  63300. }
  63301. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63302. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63303. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63304. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63305. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63306. /** @hidden */
  63307. export var hdrFilteringPixelShader: {
  63308. name: string;
  63309. shader: string;
  63310. };
  63311. }
  63312. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63314. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63315. import { Nullable } from "babylonjs/types";
  63316. import "babylonjs/Shaders/hdrFiltering.vertex";
  63317. import "babylonjs/Shaders/hdrFiltering.fragment";
  63318. /**
  63319. * Options for texture filtering
  63320. */
  63321. interface IHDRFilteringOptions {
  63322. /**
  63323. * Scales pixel intensity for the input HDR map.
  63324. */
  63325. hdrScale?: number;
  63326. /**
  63327. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63328. */
  63329. quality?: number;
  63330. }
  63331. /**
  63332. * Filters HDR maps to get correct renderings of PBR reflections
  63333. */
  63334. export class HDRFiltering {
  63335. private _engine;
  63336. private _effectRenderer;
  63337. private _effectWrapper;
  63338. private _lodGenerationOffset;
  63339. private _lodGenerationScale;
  63340. /**
  63341. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63342. * you care about baking speed.
  63343. */
  63344. quality: number;
  63345. /**
  63346. * Scales pixel intensity for the input HDR map.
  63347. */
  63348. hdrScale: number;
  63349. /**
  63350. * Instantiates HDR filter for reflection maps
  63351. *
  63352. * @param engine Thin engine
  63353. * @param options Options
  63354. */
  63355. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63356. private _createRenderTarget;
  63357. private _prefilterInternal;
  63358. private _createEffect;
  63359. /**
  63360. * Get a value indicating if the filter is ready to be used
  63361. * @param texture Texture to filter
  63362. * @returns true if the filter is ready
  63363. */
  63364. isReady(texture: BaseTexture): boolean;
  63365. /**
  63366. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63367. * Prefiltering will be invoked at the end of next rendering pass.
  63368. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63369. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63370. * @param texture Texture to filter
  63371. * @param onFinished Callback when filtering is done
  63372. * @return Promise called when prefiltering is done
  63373. */
  63374. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63375. }
  63376. }
  63377. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63378. import { Nullable } from "babylonjs/types";
  63379. import { Scene } from "babylonjs/scene";
  63380. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63382. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63383. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63384. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63385. /**
  63386. * This represents a texture coming from an HDR input.
  63387. *
  63388. * The only supported format is currently panorama picture stored in RGBE format.
  63389. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63390. */
  63391. export class HDRCubeTexture extends BaseTexture {
  63392. private static _facesMapping;
  63393. private _generateHarmonics;
  63394. private _noMipmap;
  63395. private _prefilterOnLoad;
  63396. private _textureMatrix;
  63397. private _size;
  63398. private _onLoad;
  63399. private _onError;
  63400. /**
  63401. * The texture URL.
  63402. */
  63403. url: string;
  63404. protected _isBlocking: boolean;
  63405. /**
  63406. * Sets wether or not the texture is blocking during loading.
  63407. */
  63408. set isBlocking(value: boolean);
  63409. /**
  63410. * Gets wether or not the texture is blocking during loading.
  63411. */
  63412. get isBlocking(): boolean;
  63413. protected _rotationY: number;
  63414. /**
  63415. * Sets texture matrix rotation angle around Y axis in radians.
  63416. */
  63417. set rotationY(value: number);
  63418. /**
  63419. * Gets texture matrix rotation angle around Y axis radians.
  63420. */
  63421. get rotationY(): number;
  63422. /**
  63423. * Gets or sets the center of the bounding box associated with the cube texture
  63424. * It must define where the camera used to render the texture was set
  63425. */
  63426. boundingBoxPosition: Vector3;
  63427. private _boundingBoxSize;
  63428. /**
  63429. * Gets or sets the size of the bounding box associated with the cube texture
  63430. * When defined, the cubemap will switch to local mode
  63431. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63432. * @example https://www.babylonjs-playground.com/#RNASML
  63433. */
  63434. set boundingBoxSize(value: Vector3);
  63435. get boundingBoxSize(): Vector3;
  63436. /**
  63437. * Instantiates an HDRTexture from the following parameters.
  63438. *
  63439. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63440. * @param sceneOrEngine The scene or engine the texture will be used in
  63441. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63442. * @param noMipmap Forces to not generate the mipmap if true
  63443. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63444. * @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)
  63445. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63446. */
  63447. 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>);
  63448. /**
  63449. * Get the current class name of the texture useful for serialization or dynamic coding.
  63450. * @returns "HDRCubeTexture"
  63451. */
  63452. getClassName(): string;
  63453. /**
  63454. * Occurs when the file is raw .hdr file.
  63455. */
  63456. private loadTexture;
  63457. clone(): HDRCubeTexture;
  63458. delayLoad(): void;
  63459. /**
  63460. * Get the texture reflection matrix used to rotate/transform the reflection.
  63461. * @returns the reflection matrix
  63462. */
  63463. getReflectionTextureMatrix(): Matrix;
  63464. /**
  63465. * Set the texture reflection matrix used to rotate/transform the reflection.
  63466. * @param value Define the reflection matrix to set
  63467. */
  63468. setReflectionTextureMatrix(value: Matrix): void;
  63469. /**
  63470. * Parses a JSON representation of an HDR Texture in order to create the texture
  63471. * @param parsedTexture Define the JSON representation
  63472. * @param scene Define the scene the texture should be created in
  63473. * @param rootUrl Define the root url in case we need to load relative dependencies
  63474. * @returns the newly created texture after parsing
  63475. */
  63476. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63477. serialize(): any;
  63478. }
  63479. }
  63480. declare module "babylonjs/Physics/physicsEngine" {
  63481. import { Nullable } from "babylonjs/types";
  63482. import { Vector3 } from "babylonjs/Maths/math.vector";
  63483. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63484. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63485. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63486. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63487. /**
  63488. * Class used to control physics engine
  63489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63490. */
  63491. export class PhysicsEngine implements IPhysicsEngine {
  63492. private _physicsPlugin;
  63493. /**
  63494. * Global value used to control the smallest number supported by the simulation
  63495. */
  63496. static Epsilon: number;
  63497. private _impostors;
  63498. private _joints;
  63499. private _subTimeStep;
  63500. /**
  63501. * Gets the gravity vector used by the simulation
  63502. */
  63503. gravity: Vector3;
  63504. /**
  63505. * Factory used to create the default physics plugin.
  63506. * @returns The default physics plugin
  63507. */
  63508. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63509. /**
  63510. * Creates a new Physics Engine
  63511. * @param gravity defines the gravity vector used by the simulation
  63512. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63513. */
  63514. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63515. /**
  63516. * Sets the gravity vector used by the simulation
  63517. * @param gravity defines the gravity vector to use
  63518. */
  63519. setGravity(gravity: Vector3): void;
  63520. /**
  63521. * Set the time step of the physics engine.
  63522. * Default is 1/60.
  63523. * To slow it down, enter 1/600 for example.
  63524. * To speed it up, 1/30
  63525. * @param newTimeStep defines the new timestep to apply to this world.
  63526. */
  63527. setTimeStep(newTimeStep?: number): void;
  63528. /**
  63529. * Get the time step of the physics engine.
  63530. * @returns the current time step
  63531. */
  63532. getTimeStep(): number;
  63533. /**
  63534. * Set the sub time step of the physics engine.
  63535. * Default is 0 meaning there is no sub steps
  63536. * To increase physics resolution precision, set a small value (like 1 ms)
  63537. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63538. */
  63539. setSubTimeStep(subTimeStep?: number): void;
  63540. /**
  63541. * Get the sub time step of the physics engine.
  63542. * @returns the current sub time step
  63543. */
  63544. getSubTimeStep(): number;
  63545. /**
  63546. * Release all resources
  63547. */
  63548. dispose(): void;
  63549. /**
  63550. * Gets the name of the current physics plugin
  63551. * @returns the name of the plugin
  63552. */
  63553. getPhysicsPluginName(): string;
  63554. /**
  63555. * Adding a new impostor for the impostor tracking.
  63556. * This will be done by the impostor itself.
  63557. * @param impostor the impostor to add
  63558. */
  63559. addImpostor(impostor: PhysicsImpostor): void;
  63560. /**
  63561. * Remove an impostor from the engine.
  63562. * This impostor and its mesh will not longer be updated by the physics engine.
  63563. * @param impostor the impostor to remove
  63564. */
  63565. removeImpostor(impostor: PhysicsImpostor): void;
  63566. /**
  63567. * Add a joint to the physics engine
  63568. * @param mainImpostor defines the main impostor to which the joint is added.
  63569. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63570. * @param joint defines the joint that will connect both impostors.
  63571. */
  63572. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63573. /**
  63574. * Removes a joint from the simulation
  63575. * @param mainImpostor defines the impostor used with the joint
  63576. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63577. * @param joint defines the joint to remove
  63578. */
  63579. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63580. /**
  63581. * Called by the scene. No need to call it.
  63582. * @param delta defines the timespam between frames
  63583. */
  63584. _step(delta: number): void;
  63585. /**
  63586. * Gets the current plugin used to run the simulation
  63587. * @returns current plugin
  63588. */
  63589. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63590. /**
  63591. * Gets the list of physic impostors
  63592. * @returns an array of PhysicsImpostor
  63593. */
  63594. getImpostors(): Array<PhysicsImpostor>;
  63595. /**
  63596. * Gets the impostor for a physics enabled object
  63597. * @param object defines the object impersonated by the impostor
  63598. * @returns the PhysicsImpostor or null if not found
  63599. */
  63600. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63601. /**
  63602. * Gets the impostor for a physics body object
  63603. * @param body defines physics body used by the impostor
  63604. * @returns the PhysicsImpostor or null if not found
  63605. */
  63606. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63607. /**
  63608. * Does a raycast in the physics world
  63609. * @param from when should the ray start?
  63610. * @param to when should the ray end?
  63611. * @returns PhysicsRaycastResult
  63612. */
  63613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63614. }
  63615. }
  63616. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63617. import { Nullable } from "babylonjs/types";
  63618. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63620. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63621. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63622. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63623. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63624. /** @hidden */
  63625. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63626. private _useDeltaForWorldStep;
  63627. world: any;
  63628. name: string;
  63629. private _physicsMaterials;
  63630. private _fixedTimeStep;
  63631. private _cannonRaycastResult;
  63632. private _raycastResult;
  63633. private _physicsBodysToRemoveAfterStep;
  63634. private _firstFrame;
  63635. BJSCANNON: any;
  63636. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63637. setGravity(gravity: Vector3): void;
  63638. setTimeStep(timeStep: number): void;
  63639. getTimeStep(): number;
  63640. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63641. private _removeMarkedPhysicsBodiesFromWorld;
  63642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63645. private _processChildMeshes;
  63646. removePhysicsBody(impostor: PhysicsImpostor): void;
  63647. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63648. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63649. private _addMaterial;
  63650. private _checkWithEpsilon;
  63651. private _createShape;
  63652. private _createHeightmap;
  63653. private _minus90X;
  63654. private _plus90X;
  63655. private _tmpPosition;
  63656. private _tmpDeltaPosition;
  63657. private _tmpUnityRotation;
  63658. private _updatePhysicsBodyTransformation;
  63659. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63660. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63661. isSupported(): boolean;
  63662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63667. getBodyMass(impostor: PhysicsImpostor): number;
  63668. getBodyFriction(impostor: PhysicsImpostor): number;
  63669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63670. getBodyRestitution(impostor: PhysicsImpostor): number;
  63671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63672. sleepBody(impostor: PhysicsImpostor): void;
  63673. wakeUpBody(impostor: PhysicsImpostor): void;
  63674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63675. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63677. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63678. getRadius(impostor: PhysicsImpostor): number;
  63679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63680. dispose(): void;
  63681. private _extendNamespace;
  63682. /**
  63683. * Does a raycast in the physics world
  63684. * @param from when should the ray start?
  63685. * @param to when should the ray end?
  63686. * @returns PhysicsRaycastResult
  63687. */
  63688. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63689. }
  63690. }
  63691. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63692. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63693. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63694. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63696. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63697. import { Nullable } from "babylonjs/types";
  63698. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63699. /** @hidden */
  63700. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63701. private _useDeltaForWorldStep;
  63702. world: any;
  63703. name: string;
  63704. BJSOIMO: any;
  63705. private _raycastResult;
  63706. private _fixedTimeStep;
  63707. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63708. setGravity(gravity: Vector3): void;
  63709. setTimeStep(timeStep: number): void;
  63710. getTimeStep(): number;
  63711. private _tmpImpostorsArray;
  63712. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63713. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63714. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63715. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63716. private _tmpPositionVector;
  63717. removePhysicsBody(impostor: PhysicsImpostor): void;
  63718. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63719. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63720. isSupported(): boolean;
  63721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63722. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63723. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63724. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63725. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63726. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63727. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63728. getBodyMass(impostor: PhysicsImpostor): number;
  63729. getBodyFriction(impostor: PhysicsImpostor): number;
  63730. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63731. getBodyRestitution(impostor: PhysicsImpostor): number;
  63732. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63733. sleepBody(impostor: PhysicsImpostor): void;
  63734. wakeUpBody(impostor: PhysicsImpostor): void;
  63735. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63736. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63737. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63738. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63739. getRadius(impostor: PhysicsImpostor): number;
  63740. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63741. dispose(): void;
  63742. /**
  63743. * Does a raycast in the physics world
  63744. * @param from when should the ray start?
  63745. * @param to when should the ray end?
  63746. * @returns PhysicsRaycastResult
  63747. */
  63748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63749. }
  63750. }
  63751. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63752. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63753. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63754. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63755. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63756. import { Nullable } from "babylonjs/types";
  63757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63758. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63759. /**
  63760. * AmmoJS Physics plugin
  63761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63762. * @see https://github.com/kripken/ammo.js/
  63763. */
  63764. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63765. private _useDeltaForWorldStep;
  63766. /**
  63767. * Reference to the Ammo library
  63768. */
  63769. bjsAMMO: any;
  63770. /**
  63771. * Created ammoJS world which physics bodies are added to
  63772. */
  63773. world: any;
  63774. /**
  63775. * Name of the plugin
  63776. */
  63777. name: string;
  63778. private _timeStep;
  63779. private _fixedTimeStep;
  63780. private _maxSteps;
  63781. private _tmpQuaternion;
  63782. private _tmpAmmoTransform;
  63783. private _tmpAmmoQuaternion;
  63784. private _tmpAmmoConcreteContactResultCallback;
  63785. private _collisionConfiguration;
  63786. private _dispatcher;
  63787. private _overlappingPairCache;
  63788. private _solver;
  63789. private _softBodySolver;
  63790. private _tmpAmmoVectorA;
  63791. private _tmpAmmoVectorB;
  63792. private _tmpAmmoVectorC;
  63793. private _tmpAmmoVectorD;
  63794. private _tmpContactCallbackResult;
  63795. private _tmpAmmoVectorRCA;
  63796. private _tmpAmmoVectorRCB;
  63797. private _raycastResult;
  63798. private static readonly DISABLE_COLLISION_FLAG;
  63799. private static readonly KINEMATIC_FLAG;
  63800. private static readonly DISABLE_DEACTIVATION_FLAG;
  63801. /**
  63802. * Initializes the ammoJS plugin
  63803. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63804. * @param ammoInjection can be used to inject your own ammo reference
  63805. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63806. */
  63807. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63808. /**
  63809. * Sets the gravity of the physics world (m/(s^2))
  63810. * @param gravity Gravity to set
  63811. */
  63812. setGravity(gravity: Vector3): void;
  63813. /**
  63814. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63815. * @param timeStep timestep to use in seconds
  63816. */
  63817. setTimeStep(timeStep: number): void;
  63818. /**
  63819. * 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)
  63820. * @param fixedTimeStep fixedTimeStep to use in seconds
  63821. */
  63822. setFixedTimeStep(fixedTimeStep: number): void;
  63823. /**
  63824. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63825. * @param maxSteps the maximum number of steps by the physics engine per frame
  63826. */
  63827. setMaxSteps(maxSteps: number): void;
  63828. /**
  63829. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63830. * @returns the current timestep in seconds
  63831. */
  63832. getTimeStep(): number;
  63833. /**
  63834. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63835. */
  63836. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63837. private _isImpostorInContact;
  63838. private _isImpostorPairInContact;
  63839. private _stepSimulation;
  63840. /**
  63841. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63842. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63843. * After the step the babylon meshes are set to the position of the physics imposters
  63844. * @param delta amount of time to step forward
  63845. * @param impostors array of imposters to update before/after the step
  63846. */
  63847. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63848. /**
  63849. * Update babylon mesh to match physics world object
  63850. * @param impostor imposter to match
  63851. */
  63852. private _afterSoftStep;
  63853. /**
  63854. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63855. * @param impostor imposter to match
  63856. */
  63857. private _ropeStep;
  63858. /**
  63859. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63860. * @param impostor imposter to match
  63861. */
  63862. private _softbodyOrClothStep;
  63863. private _tmpMatrix;
  63864. /**
  63865. * Applies an impulse on the imposter
  63866. * @param impostor imposter to apply impulse to
  63867. * @param force amount of force to be applied to the imposter
  63868. * @param contactPoint the location to apply the impulse on the imposter
  63869. */
  63870. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63871. /**
  63872. * Applies a force on the imposter
  63873. * @param impostor imposter to apply force
  63874. * @param force amount of force to be applied to the imposter
  63875. * @param contactPoint the location to apply the force on the imposter
  63876. */
  63877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63878. /**
  63879. * Creates a physics body using the plugin
  63880. * @param impostor the imposter to create the physics body on
  63881. */
  63882. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63883. /**
  63884. * Removes the physics body from the imposter and disposes of the body's memory
  63885. * @param impostor imposter to remove the physics body from
  63886. */
  63887. removePhysicsBody(impostor: PhysicsImpostor): void;
  63888. /**
  63889. * Generates a joint
  63890. * @param impostorJoint the imposter joint to create the joint with
  63891. */
  63892. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63893. /**
  63894. * Removes a joint
  63895. * @param impostorJoint the imposter joint to remove the joint from
  63896. */
  63897. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63898. private _addMeshVerts;
  63899. /**
  63900. * Initialise the soft body vertices to match its object's (mesh) vertices
  63901. * Softbody vertices (nodes) are in world space and to match this
  63902. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63903. * @param impostor to create the softbody for
  63904. */
  63905. private _softVertexData;
  63906. /**
  63907. * Create an impostor's soft body
  63908. * @param impostor to create the softbody for
  63909. */
  63910. private _createSoftbody;
  63911. /**
  63912. * Create cloth for an impostor
  63913. * @param impostor to create the softbody for
  63914. */
  63915. private _createCloth;
  63916. /**
  63917. * Create rope for an impostor
  63918. * @param impostor to create the softbody for
  63919. */
  63920. private _createRope;
  63921. /**
  63922. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63923. * @param impostor to create the custom physics shape for
  63924. */
  63925. private _createCustom;
  63926. private _addHullVerts;
  63927. private _createShape;
  63928. /**
  63929. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63930. * @param impostor imposter containing the physics body and babylon object
  63931. */
  63932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63933. /**
  63934. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63935. * @param impostor imposter containing the physics body and babylon object
  63936. * @param newPosition new position
  63937. * @param newRotation new rotation
  63938. */
  63939. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63940. /**
  63941. * If this plugin is supported
  63942. * @returns true if its supported
  63943. */
  63944. isSupported(): boolean;
  63945. /**
  63946. * Sets the linear velocity of the physics body
  63947. * @param impostor imposter to set the velocity on
  63948. * @param velocity velocity to set
  63949. */
  63950. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63951. /**
  63952. * Sets the angular velocity of the physics body
  63953. * @param impostor imposter to set the velocity on
  63954. * @param velocity velocity to set
  63955. */
  63956. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63957. /**
  63958. * gets the linear velocity
  63959. * @param impostor imposter to get linear velocity from
  63960. * @returns linear velocity
  63961. */
  63962. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63963. /**
  63964. * gets the angular velocity
  63965. * @param impostor imposter to get angular velocity from
  63966. * @returns angular velocity
  63967. */
  63968. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63969. /**
  63970. * Sets the mass of physics body
  63971. * @param impostor imposter to set the mass on
  63972. * @param mass mass to set
  63973. */
  63974. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63975. /**
  63976. * Gets the mass of the physics body
  63977. * @param impostor imposter to get the mass from
  63978. * @returns mass
  63979. */
  63980. getBodyMass(impostor: PhysicsImpostor): number;
  63981. /**
  63982. * Gets friction of the impostor
  63983. * @param impostor impostor to get friction from
  63984. * @returns friction value
  63985. */
  63986. getBodyFriction(impostor: PhysicsImpostor): number;
  63987. /**
  63988. * Sets friction of the impostor
  63989. * @param impostor impostor to set friction on
  63990. * @param friction friction value
  63991. */
  63992. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63993. /**
  63994. * Gets restitution of the impostor
  63995. * @param impostor impostor to get restitution from
  63996. * @returns restitution value
  63997. */
  63998. getBodyRestitution(impostor: PhysicsImpostor): number;
  63999. /**
  64000. * Sets resitution of the impostor
  64001. * @param impostor impostor to set resitution on
  64002. * @param restitution resitution value
  64003. */
  64004. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64005. /**
  64006. * Gets pressure inside the impostor
  64007. * @param impostor impostor to get pressure from
  64008. * @returns pressure value
  64009. */
  64010. getBodyPressure(impostor: PhysicsImpostor): number;
  64011. /**
  64012. * Sets pressure inside a soft body impostor
  64013. * Cloth and rope must remain 0 pressure
  64014. * @param impostor impostor to set pressure on
  64015. * @param pressure pressure value
  64016. */
  64017. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64018. /**
  64019. * Gets stiffness of the impostor
  64020. * @param impostor impostor to get stiffness from
  64021. * @returns pressure value
  64022. */
  64023. getBodyStiffness(impostor: PhysicsImpostor): number;
  64024. /**
  64025. * Sets stiffness of the impostor
  64026. * @param impostor impostor to set stiffness on
  64027. * @param stiffness stiffness value from 0 to 1
  64028. */
  64029. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64030. /**
  64031. * Gets velocityIterations of the impostor
  64032. * @param impostor impostor to get velocity iterations from
  64033. * @returns velocityIterations value
  64034. */
  64035. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64036. /**
  64037. * Sets velocityIterations of the impostor
  64038. * @param impostor impostor to set velocity iterations on
  64039. * @param velocityIterations velocityIterations value
  64040. */
  64041. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64042. /**
  64043. * Gets positionIterations of the impostor
  64044. * @param impostor impostor to get position iterations from
  64045. * @returns positionIterations value
  64046. */
  64047. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64048. /**
  64049. * Sets positionIterations of the impostor
  64050. * @param impostor impostor to set position on
  64051. * @param positionIterations positionIterations value
  64052. */
  64053. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64054. /**
  64055. * Append an anchor to a cloth object
  64056. * @param impostor is the cloth impostor to add anchor to
  64057. * @param otherImpostor is the rigid impostor to anchor to
  64058. * @param width ratio across width from 0 to 1
  64059. * @param height ratio up height from 0 to 1
  64060. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64061. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64062. */
  64063. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64064. /**
  64065. * Append an hook to a rope object
  64066. * @param impostor is the rope impostor to add hook to
  64067. * @param otherImpostor is the rigid impostor to hook to
  64068. * @param length ratio along the rope from 0 to 1
  64069. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64070. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64071. */
  64072. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64073. /**
  64074. * Sleeps the physics body and stops it from being active
  64075. * @param impostor impostor to sleep
  64076. */
  64077. sleepBody(impostor: PhysicsImpostor): void;
  64078. /**
  64079. * Activates the physics body
  64080. * @param impostor impostor to activate
  64081. */
  64082. wakeUpBody(impostor: PhysicsImpostor): void;
  64083. /**
  64084. * Updates the distance parameters of the joint
  64085. * @param joint joint to update
  64086. * @param maxDistance maximum distance of the joint
  64087. * @param minDistance minimum distance of the joint
  64088. */
  64089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64090. /**
  64091. * Sets a motor on the joint
  64092. * @param joint joint to set motor on
  64093. * @param speed speed of the motor
  64094. * @param maxForce maximum force of the motor
  64095. * @param motorIndex index of the motor
  64096. */
  64097. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64098. /**
  64099. * Sets the motors limit
  64100. * @param joint joint to set limit on
  64101. * @param upperLimit upper limit
  64102. * @param lowerLimit lower limit
  64103. */
  64104. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64105. /**
  64106. * Syncs the position and rotation of a mesh with the impostor
  64107. * @param mesh mesh to sync
  64108. * @param impostor impostor to update the mesh with
  64109. */
  64110. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64111. /**
  64112. * Gets the radius of the impostor
  64113. * @param impostor impostor to get radius from
  64114. * @returns the radius
  64115. */
  64116. getRadius(impostor: PhysicsImpostor): number;
  64117. /**
  64118. * Gets the box size of the impostor
  64119. * @param impostor impostor to get box size from
  64120. * @param result the resulting box size
  64121. */
  64122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64123. /**
  64124. * Disposes of the impostor
  64125. */
  64126. dispose(): void;
  64127. /**
  64128. * Does a raycast in the physics world
  64129. * @param from when should the ray start?
  64130. * @param to when should the ray end?
  64131. * @returns PhysicsRaycastResult
  64132. */
  64133. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64134. }
  64135. }
  64136. declare module "babylonjs/Probes/reflectionProbe" {
  64137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64138. import { Vector3 } from "babylonjs/Maths/math.vector";
  64139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64140. import { Nullable } from "babylonjs/types";
  64141. import { Scene } from "babylonjs/scene";
  64142. module "babylonjs/abstractScene" {
  64143. interface AbstractScene {
  64144. /**
  64145. * The list of reflection probes added to the scene
  64146. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64147. */
  64148. reflectionProbes: Array<ReflectionProbe>;
  64149. /**
  64150. * Removes the given reflection probe from this scene.
  64151. * @param toRemove The reflection probe to remove
  64152. * @returns The index of the removed reflection probe
  64153. */
  64154. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64155. /**
  64156. * Adds the given reflection probe to this scene.
  64157. * @param newReflectionProbe The reflection probe to add
  64158. */
  64159. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64160. }
  64161. }
  64162. /**
  64163. * Class used to generate realtime reflection / refraction cube textures
  64164. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64165. */
  64166. export class ReflectionProbe {
  64167. /** defines the name of the probe */
  64168. name: string;
  64169. private _scene;
  64170. private _renderTargetTexture;
  64171. private _projectionMatrix;
  64172. private _viewMatrix;
  64173. private _target;
  64174. private _add;
  64175. private _attachedMesh;
  64176. private _invertYAxis;
  64177. /** Gets or sets probe position (center of the cube map) */
  64178. position: Vector3;
  64179. /**
  64180. * Creates a new reflection probe
  64181. * @param name defines the name of the probe
  64182. * @param size defines the texture resolution (for each face)
  64183. * @param scene defines the hosting scene
  64184. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64185. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64186. */
  64187. constructor(
  64188. /** defines the name of the probe */
  64189. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64190. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64191. get samples(): number;
  64192. set samples(value: number);
  64193. /** Gets or sets the refresh rate to use (on every frame by default) */
  64194. get refreshRate(): number;
  64195. set refreshRate(value: number);
  64196. /**
  64197. * Gets the hosting scene
  64198. * @returns a Scene
  64199. */
  64200. getScene(): Scene;
  64201. /** Gets the internal CubeTexture used to render to */
  64202. get cubeTexture(): RenderTargetTexture;
  64203. /** Gets the list of meshes to render */
  64204. get renderList(): Nullable<AbstractMesh[]>;
  64205. /**
  64206. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64207. * @param mesh defines the mesh to attach to
  64208. */
  64209. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64210. /**
  64211. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64212. * @param renderingGroupId The rendering group id corresponding to its index
  64213. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64214. */
  64215. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64216. /**
  64217. * Clean all associated resources
  64218. */
  64219. dispose(): void;
  64220. /**
  64221. * Converts the reflection probe information to a readable string for debug purpose.
  64222. * @param fullDetails Supports for multiple levels of logging within scene loading
  64223. * @returns the human readable reflection probe info
  64224. */
  64225. toString(fullDetails?: boolean): string;
  64226. /**
  64227. * Get the class name of the relfection probe.
  64228. * @returns "ReflectionProbe"
  64229. */
  64230. getClassName(): string;
  64231. /**
  64232. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64233. * @returns The JSON representation of the texture
  64234. */
  64235. serialize(): any;
  64236. /**
  64237. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64238. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64239. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64240. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64241. * @returns The parsed reflection probe if successful
  64242. */
  64243. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64244. }
  64245. }
  64246. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64247. /** @hidden */
  64248. export var _BabylonLoaderRegistered: boolean;
  64249. /**
  64250. * Helps setting up some configuration for the babylon file loader.
  64251. */
  64252. export class BabylonFileLoaderConfiguration {
  64253. /**
  64254. * The loader does not allow injecting custom physix engine into the plugins.
  64255. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64256. * So you could set this variable to your engine import to make it work.
  64257. */
  64258. static LoaderInjectedPhysicsEngine: any;
  64259. }
  64260. }
  64261. declare module "babylonjs/Loading/Plugins/index" {
  64262. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64263. }
  64264. declare module "babylonjs/Loading/index" {
  64265. export * from "babylonjs/Loading/loadingScreen";
  64266. export * from "babylonjs/Loading/Plugins/index";
  64267. export * from "babylonjs/Loading/sceneLoader";
  64268. export * from "babylonjs/Loading/sceneLoaderFlags";
  64269. }
  64270. declare module "babylonjs/Materials/Background/index" {
  64271. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64272. }
  64273. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64274. import { Scene } from "babylonjs/scene";
  64275. import { Color3 } from "babylonjs/Maths/math.color";
  64276. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64278. /**
  64279. * The Physically based simple base material of BJS.
  64280. *
  64281. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64282. * It is used as the base class for both the specGloss and metalRough conventions.
  64283. */
  64284. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64285. /**
  64286. * Number of Simultaneous lights allowed on the material.
  64287. */
  64288. maxSimultaneousLights: number;
  64289. /**
  64290. * If sets to true, disables all the lights affecting the material.
  64291. */
  64292. disableLighting: boolean;
  64293. /**
  64294. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64295. */
  64296. environmentTexture: BaseTexture;
  64297. /**
  64298. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64299. */
  64300. invertNormalMapX: boolean;
  64301. /**
  64302. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64303. */
  64304. invertNormalMapY: boolean;
  64305. /**
  64306. * Normal map used in the model.
  64307. */
  64308. normalTexture: BaseTexture;
  64309. /**
  64310. * Emissivie color used to self-illuminate the model.
  64311. */
  64312. emissiveColor: Color3;
  64313. /**
  64314. * Emissivie texture used to self-illuminate the model.
  64315. */
  64316. emissiveTexture: BaseTexture;
  64317. /**
  64318. * Occlusion Channel Strenght.
  64319. */
  64320. occlusionStrength: number;
  64321. /**
  64322. * Occlusion Texture of the material (adding extra occlusion effects).
  64323. */
  64324. occlusionTexture: BaseTexture;
  64325. /**
  64326. * Defines the alpha limits in alpha test mode.
  64327. */
  64328. alphaCutOff: number;
  64329. /**
  64330. * Gets the current double sided mode.
  64331. */
  64332. get doubleSided(): boolean;
  64333. /**
  64334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64335. */
  64336. set doubleSided(value: boolean);
  64337. /**
  64338. * Stores the pre-calculated light information of a mesh in a texture.
  64339. */
  64340. lightmapTexture: BaseTexture;
  64341. /**
  64342. * If true, the light map contains occlusion information instead of lighting info.
  64343. */
  64344. useLightmapAsShadowmap: boolean;
  64345. /**
  64346. * Instantiates a new PBRMaterial instance.
  64347. *
  64348. * @param name The material name
  64349. * @param scene The scene the material will be use in.
  64350. */
  64351. constructor(name: string, scene: Scene);
  64352. getClassName(): string;
  64353. }
  64354. }
  64355. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64356. import { Scene } from "babylonjs/scene";
  64357. import { Color3 } from "babylonjs/Maths/math.color";
  64358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64359. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64360. /**
  64361. * The PBR material of BJS following the metal roughness convention.
  64362. *
  64363. * This fits to the PBR convention in the GLTF definition:
  64364. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64365. */
  64366. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64367. /**
  64368. * The base color has two different interpretations depending on the value of metalness.
  64369. * When the material is a metal, the base color is the specific measured reflectance value
  64370. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64371. * of the material.
  64372. */
  64373. baseColor: Color3;
  64374. /**
  64375. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64376. * well as opacity information in the alpha channel.
  64377. */
  64378. baseTexture: BaseTexture;
  64379. /**
  64380. * Specifies the metallic scalar value of the material.
  64381. * Can also be used to scale the metalness values of the metallic texture.
  64382. */
  64383. metallic: number;
  64384. /**
  64385. * Specifies the roughness scalar value of the material.
  64386. * Can also be used to scale the roughness values of the metallic texture.
  64387. */
  64388. roughness: number;
  64389. /**
  64390. * Texture containing both the metallic value in the B channel and the
  64391. * roughness value in the G channel to keep better precision.
  64392. */
  64393. metallicRoughnessTexture: BaseTexture;
  64394. /**
  64395. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64396. *
  64397. * @param name The material name
  64398. * @param scene The scene the material will be use in.
  64399. */
  64400. constructor(name: string, scene: Scene);
  64401. /**
  64402. * Return the currrent class name of the material.
  64403. */
  64404. getClassName(): string;
  64405. /**
  64406. * Makes a duplicate of the current material.
  64407. * @param name - name to use for the new material.
  64408. */
  64409. clone(name: string): PBRMetallicRoughnessMaterial;
  64410. /**
  64411. * Serialize the material to a parsable JSON object.
  64412. */
  64413. serialize(): any;
  64414. /**
  64415. * Parses a JSON object correponding to the serialize function.
  64416. */
  64417. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64418. }
  64419. }
  64420. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64421. import { Scene } from "babylonjs/scene";
  64422. import { Color3 } from "babylonjs/Maths/math.color";
  64423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64424. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64425. /**
  64426. * The PBR material of BJS following the specular glossiness convention.
  64427. *
  64428. * This fits to the PBR convention in the GLTF definition:
  64429. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64430. */
  64431. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64432. /**
  64433. * Specifies the diffuse color of the material.
  64434. */
  64435. diffuseColor: Color3;
  64436. /**
  64437. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64438. * channel.
  64439. */
  64440. diffuseTexture: BaseTexture;
  64441. /**
  64442. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64443. */
  64444. specularColor: Color3;
  64445. /**
  64446. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64447. */
  64448. glossiness: number;
  64449. /**
  64450. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64451. */
  64452. specularGlossinessTexture: BaseTexture;
  64453. /**
  64454. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64455. *
  64456. * @param name The material name
  64457. * @param scene The scene the material will be use in.
  64458. */
  64459. constructor(name: string, scene: Scene);
  64460. /**
  64461. * Return the currrent class name of the material.
  64462. */
  64463. getClassName(): string;
  64464. /**
  64465. * Makes a duplicate of the current material.
  64466. * @param name - name to use for the new material.
  64467. */
  64468. clone(name: string): PBRSpecularGlossinessMaterial;
  64469. /**
  64470. * Serialize the material to a parsable JSON object.
  64471. */
  64472. serialize(): any;
  64473. /**
  64474. * Parses a JSON object correponding to the serialize function.
  64475. */
  64476. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64477. }
  64478. }
  64479. declare module "babylonjs/Materials/PBR/index" {
  64480. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64481. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64482. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64483. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64484. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64485. }
  64486. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64487. import { Nullable } from "babylonjs/types";
  64488. import { Scene } from "babylonjs/scene";
  64489. import { Matrix } from "babylonjs/Maths/math.vector";
  64490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64491. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64492. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64493. /**
  64494. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64495. * It can help converting any input color in a desired output one. This can then be used to create effects
  64496. * from sepia, black and white to sixties or futuristic rendering...
  64497. *
  64498. * The only supported format is currently 3dl.
  64499. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64500. */
  64501. export class ColorGradingTexture extends BaseTexture {
  64502. /**
  64503. * The texture URL.
  64504. */
  64505. url: string;
  64506. /**
  64507. * Empty line regex stored for GC.
  64508. */
  64509. private static _noneEmptyLineRegex;
  64510. private _textureMatrix;
  64511. private _onLoad;
  64512. /**
  64513. * Instantiates a ColorGradingTexture from the following parameters.
  64514. *
  64515. * @param url The location of the color gradind data (currently only supporting 3dl)
  64516. * @param sceneOrEngine The scene or engine the texture will be used in
  64517. * @param onLoad defines a callback triggered when the texture has been loaded
  64518. */
  64519. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64520. /**
  64521. * Fires the onload event from the constructor if requested.
  64522. */
  64523. private _triggerOnLoad;
  64524. /**
  64525. * Returns the texture matrix used in most of the material.
  64526. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64527. */
  64528. getTextureMatrix(): Matrix;
  64529. /**
  64530. * Occurs when the file being loaded is a .3dl LUT file.
  64531. */
  64532. private load3dlTexture;
  64533. /**
  64534. * Starts the loading process of the texture.
  64535. */
  64536. private loadTexture;
  64537. /**
  64538. * Clones the color gradind texture.
  64539. */
  64540. clone(): ColorGradingTexture;
  64541. /**
  64542. * Called during delayed load for textures.
  64543. */
  64544. delayLoad(): void;
  64545. /**
  64546. * Parses a color grading texture serialized by Babylon.
  64547. * @param parsedTexture The texture information being parsedTexture
  64548. * @param scene The scene to load the texture in
  64549. * @param rootUrl The root url of the data assets to load
  64550. * @return A color gradind texture
  64551. */
  64552. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64553. /**
  64554. * Serializes the LUT texture to json format.
  64555. */
  64556. serialize(): any;
  64557. }
  64558. }
  64559. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64561. import { Scene } from "babylonjs/scene";
  64562. import { Nullable } from "babylonjs/types";
  64563. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64564. /**
  64565. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64566. */
  64567. export class EquiRectangularCubeTexture extends BaseTexture {
  64568. /** The six faces of the cube. */
  64569. private static _FacesMapping;
  64570. private _noMipmap;
  64571. private _onLoad;
  64572. private _onError;
  64573. /** The size of the cubemap. */
  64574. private _size;
  64575. /** The buffer of the image. */
  64576. private _buffer;
  64577. /** The width of the input image. */
  64578. private _width;
  64579. /** The height of the input image. */
  64580. private _height;
  64581. /** The URL to the image. */
  64582. url: string;
  64583. /**
  64584. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64585. * @param url The location of the image
  64586. * @param scene The scene the texture will be used in
  64587. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64588. * @param noMipmap Forces to not generate the mipmap if true
  64589. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64590. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64591. * @param onLoad — defines a callback called when texture is loaded
  64592. * @param onError — defines a callback called if there is an error
  64593. */
  64594. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64595. /**
  64596. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64597. */
  64598. private loadImage;
  64599. /**
  64600. * Convert the image buffer into a cubemap and create a CubeTexture.
  64601. */
  64602. private loadTexture;
  64603. /**
  64604. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64605. * @param buffer The ArrayBuffer that should be converted.
  64606. * @returns The buffer as Float32Array.
  64607. */
  64608. private getFloat32ArrayFromArrayBuffer;
  64609. /**
  64610. * Get the current class name of the texture useful for serialization or dynamic coding.
  64611. * @returns "EquiRectangularCubeTexture"
  64612. */
  64613. getClassName(): string;
  64614. /**
  64615. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64616. * @returns A clone of the current EquiRectangularCubeTexture.
  64617. */
  64618. clone(): EquiRectangularCubeTexture;
  64619. }
  64620. }
  64621. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64622. import { Nullable } from "babylonjs/types";
  64623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64624. import { Matrix } from "babylonjs/Maths/math.vector";
  64625. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64626. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64627. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64628. import { Scene } from "babylonjs/scene";
  64629. /**
  64630. * Defines the options related to the creation of an HtmlElementTexture
  64631. */
  64632. export interface IHtmlElementTextureOptions {
  64633. /**
  64634. * Defines wether mip maps should be created or not.
  64635. */
  64636. generateMipMaps?: boolean;
  64637. /**
  64638. * Defines the sampling mode of the texture.
  64639. */
  64640. samplingMode?: number;
  64641. /**
  64642. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64643. */
  64644. engine: Nullable<ThinEngine>;
  64645. /**
  64646. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64647. */
  64648. scene: Nullable<Scene>;
  64649. }
  64650. /**
  64651. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64652. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64653. * is automatically managed.
  64654. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64655. * in your application.
  64656. *
  64657. * As the update is not automatic, you need to call them manually.
  64658. */
  64659. export class HtmlElementTexture extends BaseTexture {
  64660. /**
  64661. * The texture URL.
  64662. */
  64663. element: HTMLVideoElement | HTMLCanvasElement;
  64664. private static readonly DefaultOptions;
  64665. private _textureMatrix;
  64666. private _isVideo;
  64667. private _generateMipMaps;
  64668. private _samplingMode;
  64669. /**
  64670. * Instantiates a HtmlElementTexture from the following parameters.
  64671. *
  64672. * @param name Defines the name of the texture
  64673. * @param element Defines the video or canvas the texture is filled with
  64674. * @param options Defines the other none mandatory texture creation options
  64675. */
  64676. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64677. private _createInternalTexture;
  64678. /**
  64679. * Returns the texture matrix used in most of the material.
  64680. */
  64681. getTextureMatrix(): Matrix;
  64682. /**
  64683. * Updates the content of the texture.
  64684. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64685. */
  64686. update(invertY?: Nullable<boolean>): void;
  64687. }
  64688. }
  64689. declare module "babylonjs/Misc/tga" {
  64690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64691. /**
  64692. * Based on jsTGALoader - Javascript loader for TGA file
  64693. * By Vincent Thibault
  64694. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64695. */
  64696. export class TGATools {
  64697. private static _TYPE_INDEXED;
  64698. private static _TYPE_RGB;
  64699. private static _TYPE_GREY;
  64700. private static _TYPE_RLE_INDEXED;
  64701. private static _TYPE_RLE_RGB;
  64702. private static _TYPE_RLE_GREY;
  64703. private static _ORIGIN_MASK;
  64704. private static _ORIGIN_SHIFT;
  64705. private static _ORIGIN_BL;
  64706. private static _ORIGIN_BR;
  64707. private static _ORIGIN_UL;
  64708. private static _ORIGIN_UR;
  64709. /**
  64710. * Gets the header of a TGA file
  64711. * @param data defines the TGA data
  64712. * @returns the header
  64713. */
  64714. static GetTGAHeader(data: Uint8Array): any;
  64715. /**
  64716. * Uploads TGA content to a Babylon Texture
  64717. * @hidden
  64718. */
  64719. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64720. /** @hidden */
  64721. 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;
  64722. /** @hidden */
  64723. 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;
  64724. /** @hidden */
  64725. 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;
  64726. /** @hidden */
  64727. 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;
  64728. /** @hidden */
  64729. 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;
  64730. /** @hidden */
  64731. 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;
  64732. }
  64733. }
  64734. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64735. import { Nullable } from "babylonjs/types";
  64736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64738. /**
  64739. * Implementation of the TGA Texture Loader.
  64740. * @hidden
  64741. */
  64742. export class _TGATextureLoader implements IInternalTextureLoader {
  64743. /**
  64744. * Defines wether the loader supports cascade loading the different faces.
  64745. */
  64746. readonly supportCascades: boolean;
  64747. /**
  64748. * This returns if the loader support the current file information.
  64749. * @param extension defines the file extension of the file being loaded
  64750. * @returns true if the loader can load the specified file
  64751. */
  64752. canLoad(extension: string): boolean;
  64753. /**
  64754. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64755. * @param data contains the texture data
  64756. * @param texture defines the BabylonJS internal texture
  64757. * @param createPolynomials will be true if polynomials have been requested
  64758. * @param onLoad defines the callback to trigger once the texture is ready
  64759. * @param onError defines the callback to trigger in case of error
  64760. */
  64761. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64762. /**
  64763. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64764. * @param data contains the texture data
  64765. * @param texture defines the BabylonJS internal texture
  64766. * @param callback defines the method to call once ready to upload
  64767. */
  64768. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64769. }
  64770. }
  64771. declare module "babylonjs/Misc/basis" {
  64772. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64773. /**
  64774. * Info about the .basis files
  64775. */
  64776. class BasisFileInfo {
  64777. /**
  64778. * If the file has alpha
  64779. */
  64780. hasAlpha: boolean;
  64781. /**
  64782. * Info about each image of the basis file
  64783. */
  64784. images: Array<{
  64785. levels: Array<{
  64786. width: number;
  64787. height: number;
  64788. transcodedPixels: ArrayBufferView;
  64789. }>;
  64790. }>;
  64791. }
  64792. /**
  64793. * Result of transcoding a basis file
  64794. */
  64795. class TranscodeResult {
  64796. /**
  64797. * Info about the .basis file
  64798. */
  64799. fileInfo: BasisFileInfo;
  64800. /**
  64801. * Format to use when loading the file
  64802. */
  64803. format: number;
  64804. }
  64805. /**
  64806. * Configuration options for the Basis transcoder
  64807. */
  64808. export class BasisTranscodeConfiguration {
  64809. /**
  64810. * Supported compression formats used to determine the supported output format of the transcoder
  64811. */
  64812. supportedCompressionFormats?: {
  64813. /**
  64814. * etc1 compression format
  64815. */
  64816. etc1?: boolean;
  64817. /**
  64818. * s3tc compression format
  64819. */
  64820. s3tc?: boolean;
  64821. /**
  64822. * pvrtc compression format
  64823. */
  64824. pvrtc?: boolean;
  64825. /**
  64826. * etc2 compression format
  64827. */
  64828. etc2?: boolean;
  64829. };
  64830. /**
  64831. * If mipmap levels should be loaded for transcoded images (Default: true)
  64832. */
  64833. loadMipmapLevels?: boolean;
  64834. /**
  64835. * Index of a single image to load (Default: all images)
  64836. */
  64837. loadSingleImage?: number;
  64838. }
  64839. /**
  64840. * Used to load .Basis files
  64841. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64842. */
  64843. export class BasisTools {
  64844. private static _IgnoreSupportedFormats;
  64845. /**
  64846. * URL to use when loading the basis transcoder
  64847. */
  64848. static JSModuleURL: string;
  64849. /**
  64850. * URL to use when loading the wasm module for the transcoder
  64851. */
  64852. static WasmModuleURL: string;
  64853. /**
  64854. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64855. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64856. * @returns internal format corresponding to the Basis format
  64857. */
  64858. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64859. private static _WorkerPromise;
  64860. private static _Worker;
  64861. private static _actionId;
  64862. private static _CreateWorkerAsync;
  64863. /**
  64864. * Transcodes a loaded image file to compressed pixel data
  64865. * @param data image data to transcode
  64866. * @param config configuration options for the transcoding
  64867. * @returns a promise resulting in the transcoded image
  64868. */
  64869. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64870. /**
  64871. * Loads a texture from the transcode result
  64872. * @param texture texture load to
  64873. * @param transcodeResult the result of transcoding the basis file to load from
  64874. */
  64875. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64876. }
  64877. }
  64878. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64879. import { Nullable } from "babylonjs/types";
  64880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64881. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64882. /**
  64883. * Loader for .basis file format
  64884. */
  64885. export class _BasisTextureLoader implements IInternalTextureLoader {
  64886. /**
  64887. * Defines whether the loader supports cascade loading the different faces.
  64888. */
  64889. readonly supportCascades: boolean;
  64890. /**
  64891. * This returns if the loader support the current file information.
  64892. * @param extension defines the file extension of the file being loaded
  64893. * @returns true if the loader can load the specified file
  64894. */
  64895. canLoad(extension: string): boolean;
  64896. /**
  64897. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64898. * @param data contains the texture data
  64899. * @param texture defines the BabylonJS internal texture
  64900. * @param createPolynomials will be true if polynomials have been requested
  64901. * @param onLoad defines the callback to trigger once the texture is ready
  64902. * @param onError defines the callback to trigger in case of error
  64903. */
  64904. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64905. /**
  64906. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64907. * @param data contains the texture data
  64908. * @param texture defines the BabylonJS internal texture
  64909. * @param callback defines the method to call once ready to upload
  64910. */
  64911. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64912. }
  64913. }
  64914. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64915. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64916. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64917. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64918. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64919. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64920. }
  64921. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64922. import { Vector2 } from "babylonjs/Maths/math.vector";
  64923. /**
  64924. * Defines the basic options interface of a TexturePacker Frame
  64925. */
  64926. export interface ITexturePackerFrame {
  64927. /**
  64928. * The frame ID
  64929. */
  64930. id: number;
  64931. /**
  64932. * The frames Scale
  64933. */
  64934. scale: Vector2;
  64935. /**
  64936. * The Frames offset
  64937. */
  64938. offset: Vector2;
  64939. }
  64940. /**
  64941. * This is a support class for frame Data on texture packer sets.
  64942. */
  64943. export class TexturePackerFrame implements ITexturePackerFrame {
  64944. /**
  64945. * The frame ID
  64946. */
  64947. id: number;
  64948. /**
  64949. * The frames Scale
  64950. */
  64951. scale: Vector2;
  64952. /**
  64953. * The Frames offset
  64954. */
  64955. offset: Vector2;
  64956. /**
  64957. * Initializes a texture package frame.
  64958. * @param id The numerical frame identifier
  64959. * @param scale Scalar Vector2 for UV frame
  64960. * @param offset Vector2 for the frame position in UV units.
  64961. * @returns TexturePackerFrame
  64962. */
  64963. constructor(id: number, scale: Vector2, offset: Vector2);
  64964. }
  64965. }
  64966. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64968. import { Scene } from "babylonjs/scene";
  64969. import { Nullable } from "babylonjs/types";
  64970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64971. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64972. /**
  64973. * Defines the basic options interface of a TexturePacker
  64974. */
  64975. export interface ITexturePackerOptions {
  64976. /**
  64977. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64978. */
  64979. map?: string[];
  64980. /**
  64981. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64982. */
  64983. uvsIn?: string;
  64984. /**
  64985. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64986. */
  64987. uvsOut?: string;
  64988. /**
  64989. * number representing the layout style. Defaults to LAYOUT_STRIP
  64990. */
  64991. layout?: number;
  64992. /**
  64993. * number of columns if using custom column count layout(2). This defaults to 4.
  64994. */
  64995. colnum?: number;
  64996. /**
  64997. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64998. */
  64999. updateInputMeshes?: boolean;
  65000. /**
  65001. * boolean flag to dispose all the source textures. Defaults to true.
  65002. */
  65003. disposeSources?: boolean;
  65004. /**
  65005. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65006. */
  65007. fillBlanks?: boolean;
  65008. /**
  65009. * string value representing the context fill style color. Defaults to 'black'.
  65010. */
  65011. customFillColor?: string;
  65012. /**
  65013. * Width and Height Value of each Frame in the TexturePacker Sets
  65014. */
  65015. frameSize?: number;
  65016. /**
  65017. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65018. */
  65019. paddingRatio?: number;
  65020. /**
  65021. * Number that declares the fill method for the padding gutter.
  65022. */
  65023. paddingMode?: number;
  65024. /**
  65025. * If in SUBUV_COLOR padding mode what color to use.
  65026. */
  65027. paddingColor?: Color3 | Color4;
  65028. }
  65029. /**
  65030. * Defines the basic interface of a TexturePacker JSON File
  65031. */
  65032. export interface ITexturePackerJSON {
  65033. /**
  65034. * The frame ID
  65035. */
  65036. name: string;
  65037. /**
  65038. * The base64 channel data
  65039. */
  65040. sets: any;
  65041. /**
  65042. * The options of the Packer
  65043. */
  65044. options: ITexturePackerOptions;
  65045. /**
  65046. * The frame data of the Packer
  65047. */
  65048. frames: Array<number>;
  65049. }
  65050. /**
  65051. * This is a support class that generates a series of packed texture sets.
  65052. * @see https://doc.babylonjs.com/babylon101/materials
  65053. */
  65054. export class TexturePacker {
  65055. /** Packer Layout Constant 0 */
  65056. static readonly LAYOUT_STRIP: number;
  65057. /** Packer Layout Constant 1 */
  65058. static readonly LAYOUT_POWER2: number;
  65059. /** Packer Layout Constant 2 */
  65060. static readonly LAYOUT_COLNUM: number;
  65061. /** Packer Layout Constant 0 */
  65062. static readonly SUBUV_WRAP: number;
  65063. /** Packer Layout Constant 1 */
  65064. static readonly SUBUV_EXTEND: number;
  65065. /** Packer Layout Constant 2 */
  65066. static readonly SUBUV_COLOR: number;
  65067. /** The Name of the Texture Package */
  65068. name: string;
  65069. /** The scene scope of the TexturePacker */
  65070. scene: Scene;
  65071. /** The Meshes to target */
  65072. meshes: AbstractMesh[];
  65073. /** Arguments passed with the Constructor */
  65074. options: ITexturePackerOptions;
  65075. /** The promise that is started upon initialization */
  65076. promise: Nullable<Promise<TexturePacker | string>>;
  65077. /** The Container object for the channel sets that are generated */
  65078. sets: object;
  65079. /** The Container array for the frames that are generated */
  65080. frames: TexturePackerFrame[];
  65081. /** The expected number of textures the system is parsing. */
  65082. private _expecting;
  65083. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65084. private _paddingValue;
  65085. /**
  65086. * Initializes a texture package series from an array of meshes or a single mesh.
  65087. * @param name The name of the package
  65088. * @param meshes The target meshes to compose the package from
  65089. * @param options The arguments that texture packer should follow while building.
  65090. * @param scene The scene which the textures are scoped to.
  65091. * @returns TexturePacker
  65092. */
  65093. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65094. /**
  65095. * Starts the package process
  65096. * @param resolve The promises resolution function
  65097. * @returns TexturePacker
  65098. */
  65099. private _createFrames;
  65100. /**
  65101. * Calculates the Size of the Channel Sets
  65102. * @returns Vector2
  65103. */
  65104. private _calculateSize;
  65105. /**
  65106. * Calculates the UV data for the frames.
  65107. * @param baseSize the base frameSize
  65108. * @param padding the base frame padding
  65109. * @param dtSize size of the Dynamic Texture for that channel
  65110. * @param dtUnits is 1/dtSize
  65111. * @param update flag to update the input meshes
  65112. */
  65113. private _calculateMeshUVFrames;
  65114. /**
  65115. * Calculates the frames Offset.
  65116. * @param index of the frame
  65117. * @returns Vector2
  65118. */
  65119. private _getFrameOffset;
  65120. /**
  65121. * Updates a Mesh to the frame data
  65122. * @param mesh that is the target
  65123. * @param frameID or the frame index
  65124. */
  65125. private _updateMeshUV;
  65126. /**
  65127. * Updates a Meshes materials to use the texture packer channels
  65128. * @param m is the mesh to target
  65129. * @param force all channels on the packer to be set.
  65130. */
  65131. private _updateTextureReferences;
  65132. /**
  65133. * Public method to set a Mesh to a frame
  65134. * @param m that is the target
  65135. * @param frameID or the frame index
  65136. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65137. */
  65138. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65139. /**
  65140. * Starts the async promise to compile the texture packer.
  65141. * @returns Promise<void>
  65142. */
  65143. processAsync(): Promise<void>;
  65144. /**
  65145. * Disposes all textures associated with this packer
  65146. */
  65147. dispose(): void;
  65148. /**
  65149. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65150. * @param imageType is the image type to use.
  65151. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65152. */
  65153. download(imageType?: string, quality?: number): void;
  65154. /**
  65155. * Public method to load a texturePacker JSON file.
  65156. * @param data of the JSON file in string format.
  65157. */
  65158. updateFromJSON(data: string): void;
  65159. }
  65160. }
  65161. declare module "babylonjs/Materials/Textures/Packer/index" {
  65162. export * from "babylonjs/Materials/Textures/Packer/packer";
  65163. export * from "babylonjs/Materials/Textures/Packer/frame";
  65164. }
  65165. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65166. import { Scene } from "babylonjs/scene";
  65167. import { Texture } from "babylonjs/Materials/Textures/texture";
  65168. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65169. /**
  65170. * 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.
  65171. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65172. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65173. */
  65174. export class CustomProceduralTexture extends ProceduralTexture {
  65175. private _animate;
  65176. private _time;
  65177. private _config;
  65178. private _texturePath;
  65179. /**
  65180. * Instantiates a new Custom Procedural Texture.
  65181. * 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.
  65182. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65183. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65184. * @param name Define the name of the texture
  65185. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65186. * @param size Define the size of the texture to create
  65187. * @param scene Define the scene the texture belongs to
  65188. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65189. * @param generateMipMaps Define if the texture should creates mip maps or not
  65190. */
  65191. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65192. private _loadJson;
  65193. /**
  65194. * Is the texture ready to be used ? (rendered at least once)
  65195. * @returns true if ready, otherwise, false.
  65196. */
  65197. isReady(): boolean;
  65198. /**
  65199. * Render the texture to its associated render target.
  65200. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65201. */
  65202. render(useCameraPostProcess?: boolean): void;
  65203. /**
  65204. * Update the list of dependant textures samplers in the shader.
  65205. */
  65206. updateTextures(): void;
  65207. /**
  65208. * Update the uniform values of the procedural texture in the shader.
  65209. */
  65210. updateShaderUniforms(): void;
  65211. /**
  65212. * Define if the texture animates or not.
  65213. */
  65214. get animate(): boolean;
  65215. set animate(value: boolean);
  65216. }
  65217. }
  65218. declare module "babylonjs/Shaders/noise.fragment" {
  65219. /** @hidden */
  65220. export var noisePixelShader: {
  65221. name: string;
  65222. shader: string;
  65223. };
  65224. }
  65225. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65226. import { Nullable } from "babylonjs/types";
  65227. import { Scene } from "babylonjs/scene";
  65228. import { Texture } from "babylonjs/Materials/Textures/texture";
  65229. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65230. import "babylonjs/Shaders/noise.fragment";
  65231. /**
  65232. * Class used to generate noise procedural textures
  65233. */
  65234. export class NoiseProceduralTexture extends ProceduralTexture {
  65235. /** Gets or sets the start time (default is 0) */
  65236. time: number;
  65237. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65238. brightness: number;
  65239. /** Defines the number of octaves to process */
  65240. octaves: number;
  65241. /** Defines the level of persistence (0.8 by default) */
  65242. persistence: number;
  65243. /** Gets or sets animation speed factor (default is 1) */
  65244. animationSpeedFactor: number;
  65245. /**
  65246. * Creates a new NoiseProceduralTexture
  65247. * @param name defines the name fo the texture
  65248. * @param size defines the size of the texture (default is 256)
  65249. * @param scene defines the hosting scene
  65250. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65251. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65252. */
  65253. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65254. private _updateShaderUniforms;
  65255. protected _getDefines(): string;
  65256. /** Generate the current state of the procedural texture */
  65257. render(useCameraPostProcess?: boolean): void;
  65258. /**
  65259. * Serializes this noise procedural texture
  65260. * @returns a serialized noise procedural texture object
  65261. */
  65262. serialize(): any;
  65263. /**
  65264. * Clone the texture.
  65265. * @returns the cloned texture
  65266. */
  65267. clone(): NoiseProceduralTexture;
  65268. /**
  65269. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65270. * @param parsedTexture defines parsed texture data
  65271. * @param scene defines the current scene
  65272. * @param rootUrl defines the root URL containing noise procedural texture information
  65273. * @returns a parsed NoiseProceduralTexture
  65274. */
  65275. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65276. }
  65277. }
  65278. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65279. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65280. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65281. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65282. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65283. }
  65284. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65285. import { Nullable } from "babylonjs/types";
  65286. import { Scene } from "babylonjs/scene";
  65287. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65289. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65290. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65291. /**
  65292. * Raw cube texture where the raw buffers are passed in
  65293. */
  65294. export class RawCubeTexture extends CubeTexture {
  65295. /**
  65296. * Creates a cube texture where the raw buffers are passed in.
  65297. * @param scene defines the scene the texture is attached to
  65298. * @param data defines the array of data to use to create each face
  65299. * @param size defines the size of the textures
  65300. * @param format defines the format of the data
  65301. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65302. * @param generateMipMaps defines if the engine should generate the mip levels
  65303. * @param invertY defines if data must be stored with Y axis inverted
  65304. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65305. * @param compression defines the compression used (null by default)
  65306. */
  65307. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65308. /**
  65309. * Updates the raw cube texture.
  65310. * @param data defines the data to store
  65311. * @param format defines the data format
  65312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65313. * @param invertY defines if data must be stored with Y axis inverted
  65314. * @param compression defines the compression used (null by default)
  65315. * @param level defines which level of the texture to update
  65316. */
  65317. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65318. /**
  65319. * Updates a raw cube texture with RGBD encoded data.
  65320. * @param data defines the array of data [mipmap][face] to use to create each face
  65321. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65322. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65323. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65324. * @returns a promsie that resolves when the operation is complete
  65325. */
  65326. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65327. /**
  65328. * Clones the raw cube texture.
  65329. * @return a new cube texture
  65330. */
  65331. clone(): CubeTexture;
  65332. /** @hidden */
  65333. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65334. }
  65335. }
  65336. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65337. import { Scene } from "babylonjs/scene";
  65338. import { Texture } from "babylonjs/Materials/Textures/texture";
  65339. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65340. /**
  65341. * Class used to store 2D array textures containing user data
  65342. */
  65343. export class RawTexture2DArray extends Texture {
  65344. /** Gets or sets the texture format to use */
  65345. format: number;
  65346. /**
  65347. * Create a new RawTexture2DArray
  65348. * @param data defines the data of the texture
  65349. * @param width defines the width of the texture
  65350. * @param height defines the height of the texture
  65351. * @param depth defines the number of layers of the texture
  65352. * @param format defines the texture format to use
  65353. * @param scene defines the hosting scene
  65354. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65355. * @param invertY defines if texture must be stored with Y axis inverted
  65356. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65357. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65358. */
  65359. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65360. /** Gets or sets the texture format to use */
  65361. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65362. /**
  65363. * Update the texture with new data
  65364. * @param data defines the data to store in the texture
  65365. */
  65366. update(data: ArrayBufferView): void;
  65367. }
  65368. }
  65369. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65370. import { Scene } from "babylonjs/scene";
  65371. import { Texture } from "babylonjs/Materials/Textures/texture";
  65372. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65373. /**
  65374. * Class used to store 3D textures containing user data
  65375. */
  65376. export class RawTexture3D extends Texture {
  65377. /** Gets or sets the texture format to use */
  65378. format: number;
  65379. /**
  65380. * Create a new RawTexture3D
  65381. * @param data defines the data of the texture
  65382. * @param width defines the width of the texture
  65383. * @param height defines the height of the texture
  65384. * @param depth defines the depth of the texture
  65385. * @param format defines the texture format to use
  65386. * @param scene defines the hosting scene
  65387. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65388. * @param invertY defines if texture must be stored with Y axis inverted
  65389. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65390. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65391. */
  65392. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65393. /** Gets or sets the texture format to use */
  65394. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65395. /**
  65396. * Update the texture with new data
  65397. * @param data defines the data to store in the texture
  65398. */
  65399. update(data: ArrayBufferView): void;
  65400. }
  65401. }
  65402. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65403. import { Scene } from "babylonjs/scene";
  65404. import { Plane } from "babylonjs/Maths/math.plane";
  65405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65406. /**
  65407. * Creates a refraction texture used by refraction channel of the standard material.
  65408. * It is like a mirror but to see through a material.
  65409. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65410. */
  65411. export class RefractionTexture extends RenderTargetTexture {
  65412. /**
  65413. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65414. * 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.
  65415. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65416. */
  65417. refractionPlane: Plane;
  65418. /**
  65419. * Define how deep under the surface we should see.
  65420. */
  65421. depth: number;
  65422. /**
  65423. * Creates a refraction texture used by refraction channel of the standard material.
  65424. * It is like a mirror but to see through a material.
  65425. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65426. * @param name Define the texture name
  65427. * @param size Define the size of the underlying texture
  65428. * @param scene Define the scene the refraction belongs to
  65429. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65430. */
  65431. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65432. /**
  65433. * Clone the refraction texture.
  65434. * @returns the cloned texture
  65435. */
  65436. clone(): RefractionTexture;
  65437. /**
  65438. * Serialize the texture to a JSON representation you could use in Parse later on
  65439. * @returns the serialized JSON representation
  65440. */
  65441. serialize(): any;
  65442. }
  65443. }
  65444. declare module "babylonjs/Materials/Textures/index" {
  65445. export * from "babylonjs/Materials/Textures/baseTexture";
  65446. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65447. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65448. export * from "babylonjs/Materials/Textures/cubeTexture";
  65449. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65450. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65451. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65452. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65453. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65454. export * from "babylonjs/Materials/Textures/internalTexture";
  65455. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65456. export * from "babylonjs/Materials/Textures/Loaders/index";
  65457. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65458. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65459. export * from "babylonjs/Materials/Textures/Packer/index";
  65460. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65461. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65462. export * from "babylonjs/Materials/Textures/rawTexture";
  65463. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65464. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65465. export * from "babylonjs/Materials/Textures/refractionTexture";
  65466. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65467. export * from "babylonjs/Materials/Textures/texture";
  65468. export * from "babylonjs/Materials/Textures/videoTexture";
  65469. }
  65470. declare module "babylonjs/Materials/Node/Enums/index" {
  65471. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65472. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65473. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65474. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65475. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65476. }
  65477. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65481. import { Mesh } from "babylonjs/Meshes/mesh";
  65482. import { Effect } from "babylonjs/Materials/effect";
  65483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65486. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65487. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65488. /**
  65489. * Block used to add support for vertex skinning (bones)
  65490. */
  65491. export class BonesBlock extends NodeMaterialBlock {
  65492. /**
  65493. * Creates a new BonesBlock
  65494. * @param name defines the block name
  65495. */
  65496. constructor(name: string);
  65497. /**
  65498. * Initialize the block and prepare the context for build
  65499. * @param state defines the state that will be used for the build
  65500. */
  65501. initialize(state: NodeMaterialBuildState): void;
  65502. /**
  65503. * Gets the current class name
  65504. * @returns the class name
  65505. */
  65506. getClassName(): string;
  65507. /**
  65508. * Gets the matrix indices input component
  65509. */
  65510. get matricesIndices(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the matrix weights input component
  65513. */
  65514. get matricesWeights(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the extra matrix indices input component
  65517. */
  65518. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65519. /**
  65520. * Gets the extra matrix weights input component
  65521. */
  65522. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the world input component
  65525. */
  65526. get world(): NodeMaterialConnectionPoint;
  65527. /**
  65528. * Gets the output component
  65529. */
  65530. get output(): NodeMaterialConnectionPoint;
  65531. autoConfigure(material: NodeMaterial): void;
  65532. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65533. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65535. protected _buildBlock(state: NodeMaterialBuildState): this;
  65536. }
  65537. }
  65538. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65543. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65545. /**
  65546. * Block used to add support for instances
  65547. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65548. */
  65549. export class InstancesBlock extends NodeMaterialBlock {
  65550. /**
  65551. * Creates a new InstancesBlock
  65552. * @param name defines the block name
  65553. */
  65554. constructor(name: string);
  65555. /**
  65556. * Gets the current class name
  65557. * @returns the class name
  65558. */
  65559. getClassName(): string;
  65560. /**
  65561. * Gets the first world row input component
  65562. */
  65563. get world0(): NodeMaterialConnectionPoint;
  65564. /**
  65565. * Gets the second world row input component
  65566. */
  65567. get world1(): NodeMaterialConnectionPoint;
  65568. /**
  65569. * Gets the third world row input component
  65570. */
  65571. get world2(): NodeMaterialConnectionPoint;
  65572. /**
  65573. * Gets the forth world row input component
  65574. */
  65575. get world3(): NodeMaterialConnectionPoint;
  65576. /**
  65577. * Gets the world input component
  65578. */
  65579. get world(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the output component
  65582. */
  65583. get output(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the isntanceID component
  65586. */
  65587. get instanceID(): NodeMaterialConnectionPoint;
  65588. autoConfigure(material: NodeMaterial): void;
  65589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65590. protected _buildBlock(state: NodeMaterialBuildState): this;
  65591. }
  65592. }
  65593. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  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. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65598. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65599. import { Effect } from "babylonjs/Materials/effect";
  65600. import { Mesh } from "babylonjs/Meshes/mesh";
  65601. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65603. /**
  65604. * Block used to add morph targets support to vertex shader
  65605. */
  65606. export class MorphTargetsBlock extends NodeMaterialBlock {
  65607. private _repeatableContentAnchor;
  65608. /**
  65609. * Create a new MorphTargetsBlock
  65610. * @param name defines the block name
  65611. */
  65612. constructor(name: string);
  65613. /**
  65614. * Gets the current class name
  65615. * @returns the class name
  65616. */
  65617. getClassName(): string;
  65618. /**
  65619. * Gets the position input component
  65620. */
  65621. get position(): NodeMaterialConnectionPoint;
  65622. /**
  65623. * Gets the normal input component
  65624. */
  65625. get normal(): NodeMaterialConnectionPoint;
  65626. /**
  65627. * Gets the tangent input component
  65628. */
  65629. get tangent(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the tangent input component
  65632. */
  65633. get uv(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the position output component
  65636. */
  65637. get positionOutput(): NodeMaterialConnectionPoint;
  65638. /**
  65639. * Gets the normal output component
  65640. */
  65641. get normalOutput(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the tangent output component
  65644. */
  65645. get tangentOutput(): NodeMaterialConnectionPoint;
  65646. /**
  65647. * Gets the tangent output component
  65648. */
  65649. get uvOutput(): NodeMaterialConnectionPoint;
  65650. initialize(state: NodeMaterialBuildState): void;
  65651. autoConfigure(material: NodeMaterial): void;
  65652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65654. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65655. protected _buildBlock(state: NodeMaterialBuildState): this;
  65656. }
  65657. }
  65658. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65662. import { Nullable } from "babylonjs/types";
  65663. import { Scene } from "babylonjs/scene";
  65664. import { Effect } from "babylonjs/Materials/effect";
  65665. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65666. import { Mesh } from "babylonjs/Meshes/mesh";
  65667. import { Light } from "babylonjs/Lights/light";
  65668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65669. /**
  65670. * Block used to get data information from a light
  65671. */
  65672. export class LightInformationBlock extends NodeMaterialBlock {
  65673. private _lightDataUniformName;
  65674. private _lightColorUniformName;
  65675. private _lightTypeDefineName;
  65676. /**
  65677. * Gets or sets the light associated with this block
  65678. */
  65679. light: Nullable<Light>;
  65680. /**
  65681. * Creates a new LightInformationBlock
  65682. * @param name defines the block name
  65683. */
  65684. constructor(name: string);
  65685. /**
  65686. * Gets the current class name
  65687. * @returns the class name
  65688. */
  65689. getClassName(): string;
  65690. /**
  65691. * Gets the world position input component
  65692. */
  65693. get worldPosition(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the direction output component
  65696. */
  65697. get direction(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the direction output component
  65700. */
  65701. get color(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the direction output component
  65704. */
  65705. get intensity(): NodeMaterialConnectionPoint;
  65706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65708. protected _buildBlock(state: NodeMaterialBuildState): this;
  65709. serialize(): any;
  65710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65711. }
  65712. }
  65713. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65714. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65715. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65716. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65717. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65718. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65719. }
  65720. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65725. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65726. import { Effect } from "babylonjs/Materials/effect";
  65727. import { Mesh } from "babylonjs/Meshes/mesh";
  65728. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65729. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65730. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65731. /**
  65732. * Block used to add image processing support to fragment shader
  65733. */
  65734. export class ImageProcessingBlock extends NodeMaterialBlock {
  65735. /**
  65736. * Create a new ImageProcessingBlock
  65737. * @param name defines the block name
  65738. */
  65739. constructor(name: string);
  65740. /**
  65741. * Gets the current class name
  65742. * @returns the class name
  65743. */
  65744. getClassName(): string;
  65745. /**
  65746. * Gets the color input component
  65747. */
  65748. get color(): NodeMaterialConnectionPoint;
  65749. /**
  65750. * Gets the output component
  65751. */
  65752. get output(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Initialize the block and prepare the context for build
  65755. * @param state defines the state that will be used for the build
  65756. */
  65757. initialize(state: NodeMaterialBuildState): void;
  65758. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65760. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65761. protected _buildBlock(state: NodeMaterialBuildState): this;
  65762. }
  65763. }
  65764. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65768. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65770. import { Effect } from "babylonjs/Materials/effect";
  65771. import { Mesh } from "babylonjs/Meshes/mesh";
  65772. import { Scene } from "babylonjs/scene";
  65773. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65774. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65775. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65776. /**
  65777. * Block used to pertub normals based on a normal map
  65778. */
  65779. export class PerturbNormalBlock extends NodeMaterialBlock {
  65780. private _tangentSpaceParameterName;
  65781. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65782. invertX: boolean;
  65783. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65784. invertY: boolean;
  65785. /**
  65786. * Create a new PerturbNormalBlock
  65787. * @param name defines the block name
  65788. */
  65789. constructor(name: string);
  65790. /**
  65791. * Gets the current class name
  65792. * @returns the class name
  65793. */
  65794. getClassName(): string;
  65795. /**
  65796. * Gets the world position input component
  65797. */
  65798. get worldPosition(): NodeMaterialConnectionPoint;
  65799. /**
  65800. * Gets the world normal input component
  65801. */
  65802. get worldNormal(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the world tangent input component
  65805. */
  65806. get worldTangent(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the uv input component
  65809. */
  65810. get uv(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the normal map color input component
  65813. */
  65814. get normalMapColor(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the strength input component
  65817. */
  65818. get strength(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the output component
  65821. */
  65822. get output(): NodeMaterialConnectionPoint;
  65823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65825. autoConfigure(material: NodeMaterial): void;
  65826. protected _buildBlock(state: NodeMaterialBuildState): this;
  65827. protected _dumpPropertiesCode(): string;
  65828. serialize(): any;
  65829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65830. }
  65831. }
  65832. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65836. /**
  65837. * Block used to discard a pixel if a value is smaller than a cutoff
  65838. */
  65839. export class DiscardBlock extends NodeMaterialBlock {
  65840. /**
  65841. * Create a new DiscardBlock
  65842. * @param name defines the block name
  65843. */
  65844. constructor(name: string);
  65845. /**
  65846. * Gets the current class name
  65847. * @returns the class name
  65848. */
  65849. getClassName(): string;
  65850. /**
  65851. * Gets the color input component
  65852. */
  65853. get value(): NodeMaterialConnectionPoint;
  65854. /**
  65855. * Gets the cutoff input component
  65856. */
  65857. get cutoff(): NodeMaterialConnectionPoint;
  65858. protected _buildBlock(state: NodeMaterialBuildState): this;
  65859. }
  65860. }
  65861. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65865. /**
  65866. * Block used to test if the fragment shader is front facing
  65867. */
  65868. export class FrontFacingBlock extends NodeMaterialBlock {
  65869. /**
  65870. * Creates a new FrontFacingBlock
  65871. * @param name defines the block name
  65872. */
  65873. constructor(name: string);
  65874. /**
  65875. * Gets the current class name
  65876. * @returns the class name
  65877. */
  65878. getClassName(): string;
  65879. /**
  65880. * Gets the output component
  65881. */
  65882. get output(): NodeMaterialConnectionPoint;
  65883. protected _buildBlock(state: NodeMaterialBuildState): this;
  65884. }
  65885. }
  65886. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65890. /**
  65891. * Block used to get the derivative value on x and y of a given input
  65892. */
  65893. export class DerivativeBlock extends NodeMaterialBlock {
  65894. /**
  65895. * Create a new DerivativeBlock
  65896. * @param name defines the block name
  65897. */
  65898. constructor(name: string);
  65899. /**
  65900. * Gets the current class name
  65901. * @returns the class name
  65902. */
  65903. getClassName(): string;
  65904. /**
  65905. * Gets the input component
  65906. */
  65907. get input(): NodeMaterialConnectionPoint;
  65908. /**
  65909. * Gets the derivative output on x
  65910. */
  65911. get dx(): NodeMaterialConnectionPoint;
  65912. /**
  65913. * Gets the derivative output on y
  65914. */
  65915. get dy(): NodeMaterialConnectionPoint;
  65916. protected _buildBlock(state: NodeMaterialBuildState): this;
  65917. }
  65918. }
  65919. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65923. /**
  65924. * Block used to make gl_FragCoord available
  65925. */
  65926. export class FragCoordBlock extends NodeMaterialBlock {
  65927. /**
  65928. * Creates a new FragCoordBlock
  65929. * @param name defines the block name
  65930. */
  65931. constructor(name: string);
  65932. /**
  65933. * Gets the current class name
  65934. * @returns the class name
  65935. */
  65936. getClassName(): string;
  65937. /**
  65938. * Gets the xy component
  65939. */
  65940. get xy(): NodeMaterialConnectionPoint;
  65941. /**
  65942. * Gets the xyz component
  65943. */
  65944. get xyz(): NodeMaterialConnectionPoint;
  65945. /**
  65946. * Gets the xyzw component
  65947. */
  65948. get xyzw(): NodeMaterialConnectionPoint;
  65949. /**
  65950. * Gets the x component
  65951. */
  65952. get x(): NodeMaterialConnectionPoint;
  65953. /**
  65954. * Gets the y component
  65955. */
  65956. get y(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the z component
  65959. */
  65960. get z(): NodeMaterialConnectionPoint;
  65961. /**
  65962. * Gets the w component
  65963. */
  65964. get output(): NodeMaterialConnectionPoint;
  65965. protected writeOutputs(state: NodeMaterialBuildState): string;
  65966. protected _buildBlock(state: NodeMaterialBuildState): this;
  65967. }
  65968. }
  65969. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65973. import { Effect } from "babylonjs/Materials/effect";
  65974. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65975. import { Mesh } from "babylonjs/Meshes/mesh";
  65976. /**
  65977. * Block used to get the screen sizes
  65978. */
  65979. export class ScreenSizeBlock extends NodeMaterialBlock {
  65980. private _varName;
  65981. private _scene;
  65982. /**
  65983. * Creates a new ScreenSizeBlock
  65984. * @param name defines the block name
  65985. */
  65986. constructor(name: string);
  65987. /**
  65988. * Gets the current class name
  65989. * @returns the class name
  65990. */
  65991. getClassName(): string;
  65992. /**
  65993. * Gets the xy component
  65994. */
  65995. get xy(): NodeMaterialConnectionPoint;
  65996. /**
  65997. * Gets the x component
  65998. */
  65999. get x(): NodeMaterialConnectionPoint;
  66000. /**
  66001. * Gets the y component
  66002. */
  66003. get y(): NodeMaterialConnectionPoint;
  66004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66005. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66006. protected _buildBlock(state: NodeMaterialBuildState): this;
  66007. }
  66008. }
  66009. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66010. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66011. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66012. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66013. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66014. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66015. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66016. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66017. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66018. }
  66019. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66022. import { Mesh } from "babylonjs/Meshes/mesh";
  66023. import { Effect } from "babylonjs/Materials/effect";
  66024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66026. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66028. /**
  66029. * Block used to add support for scene fog
  66030. */
  66031. export class FogBlock extends NodeMaterialBlock {
  66032. private _fogDistanceName;
  66033. private _fogParameters;
  66034. /**
  66035. * Create a new FogBlock
  66036. * @param name defines the block name
  66037. */
  66038. constructor(name: string);
  66039. /**
  66040. * Gets the current class name
  66041. * @returns the class name
  66042. */
  66043. getClassName(): string;
  66044. /**
  66045. * Gets the world position input component
  66046. */
  66047. get worldPosition(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the view input component
  66050. */
  66051. get view(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the color input component
  66054. */
  66055. get input(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the fog color input component
  66058. */
  66059. get fogColor(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the output component
  66062. */
  66063. get output(): NodeMaterialConnectionPoint;
  66064. autoConfigure(material: NodeMaterial): void;
  66065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66066. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66067. protected _buildBlock(state: NodeMaterialBuildState): this;
  66068. }
  66069. }
  66070. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66075. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66076. import { Effect } from "babylonjs/Materials/effect";
  66077. import { Mesh } from "babylonjs/Meshes/mesh";
  66078. import { Light } from "babylonjs/Lights/light";
  66079. import { Nullable } from "babylonjs/types";
  66080. import { Scene } from "babylonjs/scene";
  66081. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66082. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66083. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66085. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66086. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66087. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66088. /**
  66089. * Block used to add light in the fragment shader
  66090. */
  66091. export class LightBlock extends NodeMaterialBlock {
  66092. private _lightId;
  66093. /**
  66094. * Gets or sets the light associated with this block
  66095. */
  66096. light: Nullable<Light>;
  66097. /**
  66098. * Create a new LightBlock
  66099. * @param name defines the block name
  66100. */
  66101. constructor(name: string);
  66102. /**
  66103. * Gets the current class name
  66104. * @returns the class name
  66105. */
  66106. getClassName(): string;
  66107. /**
  66108. * Gets the world position input component
  66109. */
  66110. get worldPosition(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the world normal input component
  66113. */
  66114. get worldNormal(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the camera (or eye) position component
  66117. */
  66118. get cameraPosition(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the glossiness component
  66121. */
  66122. get glossiness(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the glossinness power component
  66125. */
  66126. get glossPower(): NodeMaterialConnectionPoint;
  66127. /**
  66128. * Gets the diffuse color component
  66129. */
  66130. get diffuseColor(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the specular color component
  66133. */
  66134. get specularColor(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the diffuse output component
  66137. */
  66138. get diffuseOutput(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the specular output component
  66141. */
  66142. get specularOutput(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the shadow output component
  66145. */
  66146. get shadow(): NodeMaterialConnectionPoint;
  66147. autoConfigure(material: NodeMaterial): void;
  66148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66149. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66150. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66151. private _injectVertexCode;
  66152. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66153. serialize(): any;
  66154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66155. }
  66156. }
  66157. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66160. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66161. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66162. /**
  66163. * Block used to read a reflection texture from a sampler
  66164. */
  66165. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66166. /**
  66167. * Create a new ReflectionTextureBlock
  66168. * @param name defines the block name
  66169. */
  66170. constructor(name: string);
  66171. /**
  66172. * Gets the current class name
  66173. * @returns the class name
  66174. */
  66175. getClassName(): string;
  66176. /**
  66177. * Gets the world position input component
  66178. */
  66179. get position(): NodeMaterialConnectionPoint;
  66180. /**
  66181. * Gets the world position input component
  66182. */
  66183. get worldPosition(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the world normal input component
  66186. */
  66187. get worldNormal(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the world input component
  66190. */
  66191. get world(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the camera (or eye) position component
  66194. */
  66195. get cameraPosition(): NodeMaterialConnectionPoint;
  66196. /**
  66197. * Gets the view input component
  66198. */
  66199. get view(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the rgb output component
  66202. */
  66203. get rgb(): NodeMaterialConnectionPoint;
  66204. /**
  66205. * Gets the rgba output component
  66206. */
  66207. get rgba(): NodeMaterialConnectionPoint;
  66208. /**
  66209. * Gets the r output component
  66210. */
  66211. get r(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the g output component
  66214. */
  66215. get g(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the b output component
  66218. */
  66219. get b(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the a output component
  66222. */
  66223. get a(): NodeMaterialConnectionPoint;
  66224. autoConfigure(material: NodeMaterial): void;
  66225. protected _buildBlock(state: NodeMaterialBuildState): this;
  66226. }
  66227. }
  66228. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66229. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66230. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66231. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66232. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66233. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66234. }
  66235. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66236. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66237. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66238. }
  66239. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66243. /**
  66244. * Block used to add 2 vectors
  66245. */
  66246. export class AddBlock extends NodeMaterialBlock {
  66247. /**
  66248. * Creates a new AddBlock
  66249. * @param name defines the block name
  66250. */
  66251. constructor(name: string);
  66252. /**
  66253. * Gets the current class name
  66254. * @returns the class name
  66255. */
  66256. getClassName(): string;
  66257. /**
  66258. * Gets the left operand input component
  66259. */
  66260. get left(): NodeMaterialConnectionPoint;
  66261. /**
  66262. * Gets the right operand input component
  66263. */
  66264. get right(): NodeMaterialConnectionPoint;
  66265. /**
  66266. * Gets the output component
  66267. */
  66268. get output(): NodeMaterialConnectionPoint;
  66269. protected _buildBlock(state: NodeMaterialBuildState): this;
  66270. }
  66271. }
  66272. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66274. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66276. /**
  66277. * Block used to scale a vector by a float
  66278. */
  66279. export class ScaleBlock extends NodeMaterialBlock {
  66280. /**
  66281. * Creates a new ScaleBlock
  66282. * @param name defines the block name
  66283. */
  66284. constructor(name: string);
  66285. /**
  66286. * Gets the current class name
  66287. * @returns the class name
  66288. */
  66289. getClassName(): string;
  66290. /**
  66291. * Gets the input component
  66292. */
  66293. get input(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the factor input component
  66296. */
  66297. get factor(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the output component
  66300. */
  66301. get output(): NodeMaterialConnectionPoint;
  66302. protected _buildBlock(state: NodeMaterialBuildState): this;
  66303. }
  66304. }
  66305. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66309. import { Scene } from "babylonjs/scene";
  66310. /**
  66311. * Block used to clamp a float
  66312. */
  66313. export class ClampBlock extends NodeMaterialBlock {
  66314. /** Gets or sets the minimum range */
  66315. minimum: number;
  66316. /** Gets or sets the maximum range */
  66317. maximum: number;
  66318. /**
  66319. * Creates a new ClampBlock
  66320. * @param name defines the block name
  66321. */
  66322. constructor(name: string);
  66323. /**
  66324. * Gets the current class name
  66325. * @returns the class name
  66326. */
  66327. getClassName(): string;
  66328. /**
  66329. * Gets the value input component
  66330. */
  66331. get value(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the output component
  66334. */
  66335. get output(): NodeMaterialConnectionPoint;
  66336. protected _buildBlock(state: NodeMaterialBuildState): this;
  66337. protected _dumpPropertiesCode(): string;
  66338. serialize(): any;
  66339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66340. }
  66341. }
  66342. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66346. /**
  66347. * Block used to apply a cross product between 2 vectors
  66348. */
  66349. export class CrossBlock extends NodeMaterialBlock {
  66350. /**
  66351. * Creates a new CrossBlock
  66352. * @param name defines the block name
  66353. */
  66354. constructor(name: string);
  66355. /**
  66356. * Gets the current class name
  66357. * @returns the class name
  66358. */
  66359. getClassName(): string;
  66360. /**
  66361. * Gets the left operand input component
  66362. */
  66363. get left(): NodeMaterialConnectionPoint;
  66364. /**
  66365. * Gets the right operand input component
  66366. */
  66367. get right(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the output component
  66370. */
  66371. get output(): NodeMaterialConnectionPoint;
  66372. protected _buildBlock(state: NodeMaterialBuildState): this;
  66373. }
  66374. }
  66375. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66379. /**
  66380. * Block used to apply a dot product between 2 vectors
  66381. */
  66382. export class DotBlock extends NodeMaterialBlock {
  66383. /**
  66384. * Creates a new DotBlock
  66385. * @param name defines the block name
  66386. */
  66387. constructor(name: string);
  66388. /**
  66389. * Gets the current class name
  66390. * @returns the class name
  66391. */
  66392. getClassName(): string;
  66393. /**
  66394. * Gets the left operand input component
  66395. */
  66396. get left(): NodeMaterialConnectionPoint;
  66397. /**
  66398. * Gets the right operand input component
  66399. */
  66400. get right(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Gets the output component
  66403. */
  66404. get output(): NodeMaterialConnectionPoint;
  66405. protected _buildBlock(state: NodeMaterialBuildState): this;
  66406. }
  66407. }
  66408. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66412. /**
  66413. * Block used to normalize a vector
  66414. */
  66415. export class NormalizeBlock extends NodeMaterialBlock {
  66416. /**
  66417. * Creates a new NormalizeBlock
  66418. * @param name defines the block name
  66419. */
  66420. constructor(name: string);
  66421. /**
  66422. * Gets the current class name
  66423. * @returns the class name
  66424. */
  66425. getClassName(): string;
  66426. /**
  66427. * Gets the input component
  66428. */
  66429. get input(): NodeMaterialConnectionPoint;
  66430. /**
  66431. * Gets the output component
  66432. */
  66433. get output(): NodeMaterialConnectionPoint;
  66434. protected _buildBlock(state: NodeMaterialBuildState): this;
  66435. }
  66436. }
  66437. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66441. /**
  66442. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66443. */
  66444. export class ColorMergerBlock extends NodeMaterialBlock {
  66445. /**
  66446. * Create a new ColorMergerBlock
  66447. * @param name defines the block name
  66448. */
  66449. constructor(name: string);
  66450. /**
  66451. * Gets the current class name
  66452. * @returns the class name
  66453. */
  66454. getClassName(): string;
  66455. /**
  66456. * Gets the rgb component (input)
  66457. */
  66458. get rgbIn(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the r component (input)
  66461. */
  66462. get r(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the g component (input)
  66465. */
  66466. get g(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the b component (input)
  66469. */
  66470. get b(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the a component (input)
  66473. */
  66474. get a(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the rgba component (output)
  66477. */
  66478. get rgba(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the rgb component (output)
  66481. */
  66482. get rgbOut(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the rgb component (output)
  66485. * @deprecated Please use rgbOut instead.
  66486. */
  66487. get rgb(): NodeMaterialConnectionPoint;
  66488. protected _buildBlock(state: NodeMaterialBuildState): this;
  66489. }
  66490. }
  66491. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66495. /**
  66496. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66497. */
  66498. export class VectorSplitterBlock extends NodeMaterialBlock {
  66499. /**
  66500. * Create a new VectorSplitterBlock
  66501. * @param name defines the block name
  66502. */
  66503. constructor(name: string);
  66504. /**
  66505. * Gets the current class name
  66506. * @returns the class name
  66507. */
  66508. getClassName(): string;
  66509. /**
  66510. * Gets the xyzw component (input)
  66511. */
  66512. get xyzw(): NodeMaterialConnectionPoint;
  66513. /**
  66514. * Gets the xyz component (input)
  66515. */
  66516. get xyzIn(): NodeMaterialConnectionPoint;
  66517. /**
  66518. * Gets the xy component (input)
  66519. */
  66520. get xyIn(): NodeMaterialConnectionPoint;
  66521. /**
  66522. * Gets the xyz component (output)
  66523. */
  66524. get xyzOut(): NodeMaterialConnectionPoint;
  66525. /**
  66526. * Gets the xy component (output)
  66527. */
  66528. get xyOut(): NodeMaterialConnectionPoint;
  66529. /**
  66530. * Gets the x component (output)
  66531. */
  66532. get x(): NodeMaterialConnectionPoint;
  66533. /**
  66534. * Gets the y component (output)
  66535. */
  66536. get y(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the z component (output)
  66539. */
  66540. get z(): NodeMaterialConnectionPoint;
  66541. /**
  66542. * Gets the w component (output)
  66543. */
  66544. get w(): NodeMaterialConnectionPoint;
  66545. protected _inputRename(name: string): string;
  66546. protected _outputRename(name: string): string;
  66547. protected _buildBlock(state: NodeMaterialBuildState): this;
  66548. }
  66549. }
  66550. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66554. /**
  66555. * Block used to lerp between 2 values
  66556. */
  66557. export class LerpBlock extends NodeMaterialBlock {
  66558. /**
  66559. * Creates a new LerpBlock
  66560. * @param name defines the block name
  66561. */
  66562. constructor(name: string);
  66563. /**
  66564. * Gets the current class name
  66565. * @returns the class name
  66566. */
  66567. getClassName(): string;
  66568. /**
  66569. * Gets the left operand input component
  66570. */
  66571. get left(): NodeMaterialConnectionPoint;
  66572. /**
  66573. * Gets the right operand input component
  66574. */
  66575. get right(): NodeMaterialConnectionPoint;
  66576. /**
  66577. * Gets the gradient operand input component
  66578. */
  66579. get gradient(): NodeMaterialConnectionPoint;
  66580. /**
  66581. * Gets the output component
  66582. */
  66583. get output(): NodeMaterialConnectionPoint;
  66584. protected _buildBlock(state: NodeMaterialBuildState): this;
  66585. }
  66586. }
  66587. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66591. /**
  66592. * Block used to divide 2 vectors
  66593. */
  66594. export class DivideBlock extends NodeMaterialBlock {
  66595. /**
  66596. * Creates a new DivideBlock
  66597. * @param name defines the block name
  66598. */
  66599. constructor(name: string);
  66600. /**
  66601. * Gets the current class name
  66602. * @returns the class name
  66603. */
  66604. getClassName(): string;
  66605. /**
  66606. * Gets the left operand input component
  66607. */
  66608. get left(): NodeMaterialConnectionPoint;
  66609. /**
  66610. * Gets the right operand input component
  66611. */
  66612. get right(): NodeMaterialConnectionPoint;
  66613. /**
  66614. * Gets the output component
  66615. */
  66616. get output(): NodeMaterialConnectionPoint;
  66617. protected _buildBlock(state: NodeMaterialBuildState): this;
  66618. }
  66619. }
  66620. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66624. /**
  66625. * Block used to subtract 2 vectors
  66626. */
  66627. export class SubtractBlock extends NodeMaterialBlock {
  66628. /**
  66629. * Creates a new SubtractBlock
  66630. * @param name defines the block name
  66631. */
  66632. constructor(name: string);
  66633. /**
  66634. * Gets the current class name
  66635. * @returns the class name
  66636. */
  66637. getClassName(): string;
  66638. /**
  66639. * Gets the left operand input component
  66640. */
  66641. get left(): NodeMaterialConnectionPoint;
  66642. /**
  66643. * Gets the right operand input component
  66644. */
  66645. get right(): NodeMaterialConnectionPoint;
  66646. /**
  66647. * Gets the output component
  66648. */
  66649. get output(): NodeMaterialConnectionPoint;
  66650. protected _buildBlock(state: NodeMaterialBuildState): this;
  66651. }
  66652. }
  66653. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66657. /**
  66658. * Block used to step a value
  66659. */
  66660. export class StepBlock extends NodeMaterialBlock {
  66661. /**
  66662. * Creates a new StepBlock
  66663. * @param name defines the block name
  66664. */
  66665. constructor(name: string);
  66666. /**
  66667. * Gets the current class name
  66668. * @returns the class name
  66669. */
  66670. getClassName(): string;
  66671. /**
  66672. * Gets the value operand input component
  66673. */
  66674. get value(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the edge operand input component
  66677. */
  66678. get edge(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the output component
  66681. */
  66682. get output(): NodeMaterialConnectionPoint;
  66683. protected _buildBlock(state: NodeMaterialBuildState): this;
  66684. }
  66685. }
  66686. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66690. /**
  66691. * Block used to get the opposite (1 - x) of a value
  66692. */
  66693. export class OneMinusBlock extends NodeMaterialBlock {
  66694. /**
  66695. * Creates a new OneMinusBlock
  66696. * @param name defines the block name
  66697. */
  66698. constructor(name: string);
  66699. /**
  66700. * Gets the current class name
  66701. * @returns the class name
  66702. */
  66703. getClassName(): string;
  66704. /**
  66705. * Gets the input component
  66706. */
  66707. get input(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the output component
  66710. */
  66711. get output(): NodeMaterialConnectionPoint;
  66712. protected _buildBlock(state: NodeMaterialBuildState): this;
  66713. }
  66714. }
  66715. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66719. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66720. /**
  66721. * Block used to get the view direction
  66722. */
  66723. export class ViewDirectionBlock extends NodeMaterialBlock {
  66724. /**
  66725. * Creates a new ViewDirectionBlock
  66726. * @param name defines the block name
  66727. */
  66728. constructor(name: string);
  66729. /**
  66730. * Gets the current class name
  66731. * @returns the class name
  66732. */
  66733. getClassName(): string;
  66734. /**
  66735. * Gets the world position component
  66736. */
  66737. get worldPosition(): NodeMaterialConnectionPoint;
  66738. /**
  66739. * Gets the camera position component
  66740. */
  66741. get cameraPosition(): NodeMaterialConnectionPoint;
  66742. /**
  66743. * Gets the output component
  66744. */
  66745. get output(): NodeMaterialConnectionPoint;
  66746. autoConfigure(material: NodeMaterial): void;
  66747. protected _buildBlock(state: NodeMaterialBuildState): this;
  66748. }
  66749. }
  66750. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66754. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66755. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66756. /**
  66757. * Block used to compute fresnel value
  66758. */
  66759. export class FresnelBlock extends NodeMaterialBlock {
  66760. /**
  66761. * Create a new FresnelBlock
  66762. * @param name defines the block name
  66763. */
  66764. constructor(name: string);
  66765. /**
  66766. * Gets the current class name
  66767. * @returns the class name
  66768. */
  66769. getClassName(): string;
  66770. /**
  66771. * Gets the world normal input component
  66772. */
  66773. get worldNormal(): NodeMaterialConnectionPoint;
  66774. /**
  66775. * Gets the view direction input component
  66776. */
  66777. get viewDirection(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the bias input component
  66780. */
  66781. get bias(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the camera (or eye) position component
  66784. */
  66785. get power(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the fresnel output component
  66788. */
  66789. get fresnel(): NodeMaterialConnectionPoint;
  66790. autoConfigure(material: NodeMaterial): void;
  66791. protected _buildBlock(state: NodeMaterialBuildState): this;
  66792. }
  66793. }
  66794. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66798. /**
  66799. * Block used to get the max of 2 values
  66800. */
  66801. export class MaxBlock extends NodeMaterialBlock {
  66802. /**
  66803. * Creates a new MaxBlock
  66804. * @param name defines the block name
  66805. */
  66806. constructor(name: string);
  66807. /**
  66808. * Gets the current class name
  66809. * @returns the class name
  66810. */
  66811. getClassName(): string;
  66812. /**
  66813. * Gets the left operand input component
  66814. */
  66815. get left(): NodeMaterialConnectionPoint;
  66816. /**
  66817. * Gets the right operand input component
  66818. */
  66819. get right(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the output component
  66822. */
  66823. get output(): NodeMaterialConnectionPoint;
  66824. protected _buildBlock(state: NodeMaterialBuildState): this;
  66825. }
  66826. }
  66827. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  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. /**
  66832. * Block used to get the min of 2 values
  66833. */
  66834. export class MinBlock extends NodeMaterialBlock {
  66835. /**
  66836. * Creates a new MinBlock
  66837. * @param name defines the block name
  66838. */
  66839. constructor(name: string);
  66840. /**
  66841. * Gets the current class name
  66842. * @returns the class name
  66843. */
  66844. getClassName(): string;
  66845. /**
  66846. * Gets the left operand input component
  66847. */
  66848. get left(): NodeMaterialConnectionPoint;
  66849. /**
  66850. * Gets the right operand input component
  66851. */
  66852. get right(): NodeMaterialConnectionPoint;
  66853. /**
  66854. * Gets the output component
  66855. */
  66856. get output(): NodeMaterialConnectionPoint;
  66857. protected _buildBlock(state: NodeMaterialBuildState): this;
  66858. }
  66859. }
  66860. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66864. /**
  66865. * Block used to get the distance between 2 values
  66866. */
  66867. export class DistanceBlock extends NodeMaterialBlock {
  66868. /**
  66869. * Creates a new DistanceBlock
  66870. * @param name defines the block name
  66871. */
  66872. constructor(name: string);
  66873. /**
  66874. * Gets the current class name
  66875. * @returns the class name
  66876. */
  66877. getClassName(): string;
  66878. /**
  66879. * Gets the left operand input component
  66880. */
  66881. get left(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the right operand input component
  66884. */
  66885. get right(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the output component
  66888. */
  66889. get output(): NodeMaterialConnectionPoint;
  66890. protected _buildBlock(state: NodeMaterialBuildState): this;
  66891. }
  66892. }
  66893. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66897. /**
  66898. * Block used to get the length of a vector
  66899. */
  66900. export class LengthBlock extends NodeMaterialBlock {
  66901. /**
  66902. * Creates a new LengthBlock
  66903. * @param name defines the block name
  66904. */
  66905. constructor(name: string);
  66906. /**
  66907. * Gets the current class name
  66908. * @returns the class name
  66909. */
  66910. getClassName(): string;
  66911. /**
  66912. * Gets the value input component
  66913. */
  66914. get value(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the output component
  66917. */
  66918. get output(): NodeMaterialConnectionPoint;
  66919. protected _buildBlock(state: NodeMaterialBuildState): this;
  66920. }
  66921. }
  66922. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66926. /**
  66927. * Block used to get negative version of a value (i.e. x * -1)
  66928. */
  66929. export class NegateBlock extends NodeMaterialBlock {
  66930. /**
  66931. * Creates a new NegateBlock
  66932. * @param name defines the block name
  66933. */
  66934. constructor(name: string);
  66935. /**
  66936. * Gets the current class name
  66937. * @returns the class name
  66938. */
  66939. getClassName(): string;
  66940. /**
  66941. * Gets the value input component
  66942. */
  66943. get value(): NodeMaterialConnectionPoint;
  66944. /**
  66945. * Gets the output component
  66946. */
  66947. get output(): NodeMaterialConnectionPoint;
  66948. protected _buildBlock(state: NodeMaterialBuildState): this;
  66949. }
  66950. }
  66951. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66955. /**
  66956. * Block used to get the value of the first parameter raised to the power of the second
  66957. */
  66958. export class PowBlock extends NodeMaterialBlock {
  66959. /**
  66960. * Creates a new PowBlock
  66961. * @param name defines the block name
  66962. */
  66963. constructor(name: string);
  66964. /**
  66965. * Gets the current class name
  66966. * @returns the class name
  66967. */
  66968. getClassName(): string;
  66969. /**
  66970. * Gets the value operand input component
  66971. */
  66972. get value(): NodeMaterialConnectionPoint;
  66973. /**
  66974. * Gets the power operand input component
  66975. */
  66976. get power(): NodeMaterialConnectionPoint;
  66977. /**
  66978. * Gets the output component
  66979. */
  66980. get output(): NodeMaterialConnectionPoint;
  66981. protected _buildBlock(state: NodeMaterialBuildState): this;
  66982. }
  66983. }
  66984. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66988. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66989. /**
  66990. * Block used to get a random number
  66991. */
  66992. export class RandomNumberBlock extends NodeMaterialBlock {
  66993. /**
  66994. * Creates a new RandomNumberBlock
  66995. * @param name defines the block name
  66996. */
  66997. constructor(name: string);
  66998. /**
  66999. * Gets the current class name
  67000. * @returns the class name
  67001. */
  67002. getClassName(): string;
  67003. /**
  67004. * Gets the seed input component
  67005. */
  67006. get seed(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the output component
  67009. */
  67010. get output(): NodeMaterialConnectionPoint;
  67011. protected _buildBlock(state: NodeMaterialBuildState): this;
  67012. }
  67013. }
  67014. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67018. /**
  67019. * Block used to compute arc tangent of 2 values
  67020. */
  67021. export class ArcTan2Block extends NodeMaterialBlock {
  67022. /**
  67023. * Creates a new ArcTan2Block
  67024. * @param name defines the block name
  67025. */
  67026. constructor(name: string);
  67027. /**
  67028. * Gets the current class name
  67029. * @returns the class name
  67030. */
  67031. getClassName(): string;
  67032. /**
  67033. * Gets the x operand input component
  67034. */
  67035. get x(): NodeMaterialConnectionPoint;
  67036. /**
  67037. * Gets the y operand input component
  67038. */
  67039. get y(): NodeMaterialConnectionPoint;
  67040. /**
  67041. * Gets the output component
  67042. */
  67043. get output(): NodeMaterialConnectionPoint;
  67044. protected _buildBlock(state: NodeMaterialBuildState): this;
  67045. }
  67046. }
  67047. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67051. /**
  67052. * Block used to smooth step a value
  67053. */
  67054. export class SmoothStepBlock extends NodeMaterialBlock {
  67055. /**
  67056. * Creates a new SmoothStepBlock
  67057. * @param name defines the block name
  67058. */
  67059. constructor(name: string);
  67060. /**
  67061. * Gets the current class name
  67062. * @returns the class name
  67063. */
  67064. getClassName(): string;
  67065. /**
  67066. * Gets the value operand input component
  67067. */
  67068. get value(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the first edge operand input component
  67071. */
  67072. get edge0(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the second edge operand input component
  67075. */
  67076. get edge1(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the output component
  67079. */
  67080. get output(): NodeMaterialConnectionPoint;
  67081. protected _buildBlock(state: NodeMaterialBuildState): this;
  67082. }
  67083. }
  67084. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67088. /**
  67089. * Block used to get the reciprocal (1 / x) of a value
  67090. */
  67091. export class ReciprocalBlock extends NodeMaterialBlock {
  67092. /**
  67093. * Creates a new ReciprocalBlock
  67094. * @param name defines the block name
  67095. */
  67096. constructor(name: string);
  67097. /**
  67098. * Gets the current class name
  67099. * @returns the class name
  67100. */
  67101. getClassName(): string;
  67102. /**
  67103. * Gets the input component
  67104. */
  67105. get input(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the output component
  67108. */
  67109. get output(): NodeMaterialConnectionPoint;
  67110. protected _buildBlock(state: NodeMaterialBuildState): this;
  67111. }
  67112. }
  67113. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67117. /**
  67118. * Block used to replace a color by another one
  67119. */
  67120. export class ReplaceColorBlock extends NodeMaterialBlock {
  67121. /**
  67122. * Creates a new ReplaceColorBlock
  67123. * @param name defines the block name
  67124. */
  67125. constructor(name: string);
  67126. /**
  67127. * Gets the current class name
  67128. * @returns the class name
  67129. */
  67130. getClassName(): string;
  67131. /**
  67132. * Gets the value input component
  67133. */
  67134. get value(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the reference input component
  67137. */
  67138. get reference(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Gets the distance input component
  67141. */
  67142. get distance(): NodeMaterialConnectionPoint;
  67143. /**
  67144. * Gets the replacement input component
  67145. */
  67146. get replacement(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the output component
  67149. */
  67150. get output(): NodeMaterialConnectionPoint;
  67151. protected _buildBlock(state: NodeMaterialBuildState): this;
  67152. }
  67153. }
  67154. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67158. /**
  67159. * Block used to posterize a value
  67160. * @see https://en.wikipedia.org/wiki/Posterization
  67161. */
  67162. export class PosterizeBlock extends NodeMaterialBlock {
  67163. /**
  67164. * Creates a new PosterizeBlock
  67165. * @param name defines the block name
  67166. */
  67167. constructor(name: string);
  67168. /**
  67169. * Gets the current class name
  67170. * @returns the class name
  67171. */
  67172. getClassName(): string;
  67173. /**
  67174. * Gets the value input component
  67175. */
  67176. get value(): NodeMaterialConnectionPoint;
  67177. /**
  67178. * Gets the steps input component
  67179. */
  67180. get steps(): NodeMaterialConnectionPoint;
  67181. /**
  67182. * Gets the output component
  67183. */
  67184. get output(): NodeMaterialConnectionPoint;
  67185. protected _buildBlock(state: NodeMaterialBuildState): this;
  67186. }
  67187. }
  67188. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67192. import { Scene } from "babylonjs/scene";
  67193. /**
  67194. * Operations supported by the Wave block
  67195. */
  67196. export enum WaveBlockKind {
  67197. /** SawTooth */
  67198. SawTooth = 0,
  67199. /** Square */
  67200. Square = 1,
  67201. /** Triangle */
  67202. Triangle = 2
  67203. }
  67204. /**
  67205. * Block used to apply wave operation to floats
  67206. */
  67207. export class WaveBlock extends NodeMaterialBlock {
  67208. /**
  67209. * Gets or sets the kibnd of wave to be applied by the block
  67210. */
  67211. kind: WaveBlockKind;
  67212. /**
  67213. * Creates a new WaveBlock
  67214. * @param name defines the block name
  67215. */
  67216. constructor(name: string);
  67217. /**
  67218. * Gets the current class name
  67219. * @returns the class name
  67220. */
  67221. getClassName(): string;
  67222. /**
  67223. * Gets the input component
  67224. */
  67225. get input(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the output component
  67228. */
  67229. get output(): NodeMaterialConnectionPoint;
  67230. protected _buildBlock(state: NodeMaterialBuildState): this;
  67231. serialize(): any;
  67232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67233. }
  67234. }
  67235. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67239. import { Color3 } from "babylonjs/Maths/math.color";
  67240. import { Scene } from "babylonjs/scene";
  67241. import { Observable } from "babylonjs/Misc/observable";
  67242. /**
  67243. * Class used to store a color step for the GradientBlock
  67244. */
  67245. export class GradientBlockColorStep {
  67246. private _step;
  67247. /**
  67248. * Gets value indicating which step this color is associated with (between 0 and 1)
  67249. */
  67250. get step(): number;
  67251. /**
  67252. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67253. */
  67254. set step(val: number);
  67255. private _color;
  67256. /**
  67257. * Gets the color associated with this step
  67258. */
  67259. get color(): Color3;
  67260. /**
  67261. * Sets the color associated with this step
  67262. */
  67263. set color(val: Color3);
  67264. /**
  67265. * Creates a new GradientBlockColorStep
  67266. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67267. * @param color defines the color associated with this step
  67268. */
  67269. constructor(step: number, color: Color3);
  67270. }
  67271. /**
  67272. * Block used to return a color from a gradient based on an input value between 0 and 1
  67273. */
  67274. export class GradientBlock extends NodeMaterialBlock {
  67275. /**
  67276. * Gets or sets the list of color steps
  67277. */
  67278. colorSteps: GradientBlockColorStep[];
  67279. /** Gets an observable raised when the value is changed */
  67280. onValueChangedObservable: Observable<GradientBlock>;
  67281. /** calls observable when the value is changed*/
  67282. colorStepsUpdated(): void;
  67283. /**
  67284. * Creates a new GradientBlock
  67285. * @param name defines the block name
  67286. */
  67287. constructor(name: string);
  67288. /**
  67289. * Gets the current class name
  67290. * @returns the class name
  67291. */
  67292. getClassName(): string;
  67293. /**
  67294. * Gets the gradient input component
  67295. */
  67296. get gradient(): NodeMaterialConnectionPoint;
  67297. /**
  67298. * Gets the output component
  67299. */
  67300. get output(): NodeMaterialConnectionPoint;
  67301. private _writeColorConstant;
  67302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67303. serialize(): any;
  67304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67305. protected _dumpPropertiesCode(): string;
  67306. }
  67307. }
  67308. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67312. /**
  67313. * Block used to normalize lerp between 2 values
  67314. */
  67315. export class NLerpBlock extends NodeMaterialBlock {
  67316. /**
  67317. * Creates a new NLerpBlock
  67318. * @param name defines the block name
  67319. */
  67320. constructor(name: string);
  67321. /**
  67322. * Gets the current class name
  67323. * @returns the class name
  67324. */
  67325. getClassName(): string;
  67326. /**
  67327. * Gets the left operand input component
  67328. */
  67329. get left(): NodeMaterialConnectionPoint;
  67330. /**
  67331. * Gets the right operand input component
  67332. */
  67333. get right(): NodeMaterialConnectionPoint;
  67334. /**
  67335. * Gets the gradient operand input component
  67336. */
  67337. get gradient(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the output component
  67340. */
  67341. get output(): NodeMaterialConnectionPoint;
  67342. protected _buildBlock(state: NodeMaterialBuildState): this;
  67343. }
  67344. }
  67345. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67349. import { Scene } from "babylonjs/scene";
  67350. /**
  67351. * block used to Generate a Worley Noise 3D Noise Pattern
  67352. */
  67353. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67354. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67355. manhattanDistance: boolean;
  67356. /**
  67357. * Creates a new WorleyNoise3DBlock
  67358. * @param name defines the block name
  67359. */
  67360. constructor(name: string);
  67361. /**
  67362. * Gets the current class name
  67363. * @returns the class name
  67364. */
  67365. getClassName(): string;
  67366. /**
  67367. * Gets the seed input component
  67368. */
  67369. get seed(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the jitter input component
  67372. */
  67373. get jitter(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the output component
  67376. */
  67377. get output(): NodeMaterialConnectionPoint;
  67378. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67379. /**
  67380. * Exposes the properties to the UI?
  67381. */
  67382. protected _dumpPropertiesCode(): string;
  67383. /**
  67384. * Exposes the properties to the Seralize?
  67385. */
  67386. serialize(): any;
  67387. /**
  67388. * Exposes the properties to the deseralize?
  67389. */
  67390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67391. }
  67392. }
  67393. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67397. /**
  67398. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67399. */
  67400. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67401. /**
  67402. * Creates a new SimplexPerlin3DBlock
  67403. * @param name defines the block name
  67404. */
  67405. constructor(name: string);
  67406. /**
  67407. * Gets the current class name
  67408. * @returns the class name
  67409. */
  67410. getClassName(): string;
  67411. /**
  67412. * Gets the seed operand input component
  67413. */
  67414. get seed(): NodeMaterialConnectionPoint;
  67415. /**
  67416. * Gets the output component
  67417. */
  67418. get output(): NodeMaterialConnectionPoint;
  67419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67420. }
  67421. }
  67422. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67426. /**
  67427. * Block used to blend normals
  67428. */
  67429. export class NormalBlendBlock extends NodeMaterialBlock {
  67430. /**
  67431. * Creates a new NormalBlendBlock
  67432. * @param name defines the block name
  67433. */
  67434. constructor(name: string);
  67435. /**
  67436. * Gets the current class name
  67437. * @returns the class name
  67438. */
  67439. getClassName(): string;
  67440. /**
  67441. * Gets the first input component
  67442. */
  67443. get normalMap0(): NodeMaterialConnectionPoint;
  67444. /**
  67445. * Gets the second input component
  67446. */
  67447. get normalMap1(): NodeMaterialConnectionPoint;
  67448. /**
  67449. * Gets the output component
  67450. */
  67451. get output(): NodeMaterialConnectionPoint;
  67452. protected _buildBlock(state: NodeMaterialBuildState): this;
  67453. }
  67454. }
  67455. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67459. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67460. /**
  67461. * Block used to rotate a 2d vector by a given angle
  67462. */
  67463. export class Rotate2dBlock extends NodeMaterialBlock {
  67464. /**
  67465. * Creates a new Rotate2dBlock
  67466. * @param name defines the block name
  67467. */
  67468. constructor(name: string);
  67469. /**
  67470. * Gets the current class name
  67471. * @returns the class name
  67472. */
  67473. getClassName(): string;
  67474. /**
  67475. * Gets the input vector
  67476. */
  67477. get input(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the input angle
  67480. */
  67481. get angle(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the output component
  67484. */
  67485. get output(): NodeMaterialConnectionPoint;
  67486. autoConfigure(material: NodeMaterial): void;
  67487. protected _buildBlock(state: NodeMaterialBuildState): this;
  67488. }
  67489. }
  67490. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67494. /**
  67495. * Block used to get the reflected vector from a direction and a normal
  67496. */
  67497. export class ReflectBlock extends NodeMaterialBlock {
  67498. /**
  67499. * Creates a new ReflectBlock
  67500. * @param name defines the block name
  67501. */
  67502. constructor(name: string);
  67503. /**
  67504. * Gets the current class name
  67505. * @returns the class name
  67506. */
  67507. getClassName(): string;
  67508. /**
  67509. * Gets the incident component
  67510. */
  67511. get incident(): NodeMaterialConnectionPoint;
  67512. /**
  67513. * Gets the normal component
  67514. */
  67515. get normal(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the output component
  67518. */
  67519. get output(): NodeMaterialConnectionPoint;
  67520. protected _buildBlock(state: NodeMaterialBuildState): this;
  67521. }
  67522. }
  67523. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67527. /**
  67528. * Block used to get the refracted vector from a direction and a normal
  67529. */
  67530. export class RefractBlock extends NodeMaterialBlock {
  67531. /**
  67532. * Creates a new RefractBlock
  67533. * @param name defines the block name
  67534. */
  67535. constructor(name: string);
  67536. /**
  67537. * Gets the current class name
  67538. * @returns the class name
  67539. */
  67540. getClassName(): string;
  67541. /**
  67542. * Gets the incident component
  67543. */
  67544. get incident(): NodeMaterialConnectionPoint;
  67545. /**
  67546. * Gets the normal component
  67547. */
  67548. get normal(): NodeMaterialConnectionPoint;
  67549. /**
  67550. * Gets the index of refraction component
  67551. */
  67552. get ior(): NodeMaterialConnectionPoint;
  67553. /**
  67554. * Gets the output component
  67555. */
  67556. get output(): NodeMaterialConnectionPoint;
  67557. protected _buildBlock(state: NodeMaterialBuildState): this;
  67558. }
  67559. }
  67560. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67564. /**
  67565. * Block used to desaturate a color
  67566. */
  67567. export class DesaturateBlock extends NodeMaterialBlock {
  67568. /**
  67569. * Creates a new DesaturateBlock
  67570. * @param name defines the block name
  67571. */
  67572. constructor(name: string);
  67573. /**
  67574. * Gets the current class name
  67575. * @returns the class name
  67576. */
  67577. getClassName(): string;
  67578. /**
  67579. * Gets the color operand input component
  67580. */
  67581. get color(): NodeMaterialConnectionPoint;
  67582. /**
  67583. * Gets the level operand input component
  67584. */
  67585. get level(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the output component
  67588. */
  67589. get output(): NodeMaterialConnectionPoint;
  67590. protected _buildBlock(state: NodeMaterialBuildState): this;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67597. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67598. import { Nullable } from "babylonjs/types";
  67599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67600. import { Scene } from "babylonjs/scene";
  67601. /**
  67602. * Block used to implement the ambient occlusion module of the PBR material
  67603. */
  67604. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67605. /**
  67606. * Create a new AmbientOcclusionBlock
  67607. * @param name defines the block name
  67608. */
  67609. constructor(name: string);
  67610. /**
  67611. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67612. */
  67613. useAmbientInGrayScale: boolean;
  67614. /**
  67615. * Initialize the block and prepare the context for build
  67616. * @param state defines the state that will be used for the build
  67617. */
  67618. initialize(state: NodeMaterialBuildState): void;
  67619. /**
  67620. * Gets the current class name
  67621. * @returns the class name
  67622. */
  67623. getClassName(): string;
  67624. /**
  67625. * Gets the texture input component
  67626. */
  67627. get texture(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the texture intensity component
  67630. */
  67631. get intensity(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the direct light intensity input component
  67634. */
  67635. get directLightIntensity(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the ambient occlusion object output component
  67638. */
  67639. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the main code of the block (fragment side)
  67642. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67643. * @returns the shader code
  67644. */
  67645. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67647. protected _buildBlock(state: NodeMaterialBuildState): this;
  67648. protected _dumpPropertiesCode(): string;
  67649. serialize(): any;
  67650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67651. }
  67652. }
  67653. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67656. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67657. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67659. import { Nullable } from "babylonjs/types";
  67660. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67661. import { Mesh } from "babylonjs/Meshes/mesh";
  67662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67663. import { Effect } from "babylonjs/Materials/effect";
  67664. import { Scene } from "babylonjs/scene";
  67665. /**
  67666. * Block used to implement the reflection module of the PBR material
  67667. */
  67668. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67669. /** @hidden */
  67670. _defineLODReflectionAlpha: string;
  67671. /** @hidden */
  67672. _defineLinearSpecularReflection: string;
  67673. private _vEnvironmentIrradianceName;
  67674. /** @hidden */
  67675. _vReflectionMicrosurfaceInfosName: string;
  67676. /** @hidden */
  67677. _vReflectionInfosName: string;
  67678. /** @hidden */
  67679. _vReflectionFilteringInfoName: string;
  67680. private _scene;
  67681. /**
  67682. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67683. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67684. * It's less burden on the user side in the editor part.
  67685. */
  67686. /** @hidden */
  67687. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67688. /** @hidden */
  67689. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67690. /** @hidden */
  67691. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67692. /**
  67693. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67694. * diffuse part of the IBL.
  67695. */
  67696. useSphericalHarmonics: boolean;
  67697. /**
  67698. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67699. */
  67700. forceIrradianceInFragment: boolean;
  67701. /**
  67702. * Create a new ReflectionBlock
  67703. * @param name defines the block name
  67704. */
  67705. constructor(name: string);
  67706. /**
  67707. * Gets the current class name
  67708. * @returns the class name
  67709. */
  67710. getClassName(): string;
  67711. /**
  67712. * Gets the position input component
  67713. */
  67714. get position(): NodeMaterialConnectionPoint;
  67715. /**
  67716. * Gets the world position input component
  67717. */
  67718. get worldPosition(): NodeMaterialConnectionPoint;
  67719. /**
  67720. * Gets the world normal input component
  67721. */
  67722. get worldNormal(): NodeMaterialConnectionPoint;
  67723. /**
  67724. * Gets the world input component
  67725. */
  67726. get world(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the camera (or eye) position component
  67729. */
  67730. get cameraPosition(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the view input component
  67733. */
  67734. get view(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the color input component
  67737. */
  67738. get color(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the reflection object output component
  67741. */
  67742. get reflection(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67745. */
  67746. get hasTexture(): boolean;
  67747. /**
  67748. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67749. */
  67750. get reflectionColor(): string;
  67751. protected _getTexture(): Nullable<BaseTexture>;
  67752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67754. /**
  67755. * Gets the code to inject in the vertex shader
  67756. * @param state current state of the node material building
  67757. * @returns the shader code
  67758. */
  67759. handleVertexSide(state: NodeMaterialBuildState): string;
  67760. /**
  67761. * Gets the main code of the block (fragment side)
  67762. * @param state current state of the node material building
  67763. * @param normalVarName name of the existing variable corresponding to the normal
  67764. * @returns the shader code
  67765. */
  67766. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67767. protected _buildBlock(state: NodeMaterialBuildState): this;
  67768. protected _dumpPropertiesCode(): string;
  67769. serialize(): any;
  67770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67771. }
  67772. }
  67773. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67779. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67780. import { Scene } from "babylonjs/scene";
  67781. import { Nullable } from "babylonjs/types";
  67782. /**
  67783. * Block used to implement the sheen module of the PBR material
  67784. */
  67785. export class SheenBlock extends NodeMaterialBlock {
  67786. /**
  67787. * Create a new SheenBlock
  67788. * @param name defines the block name
  67789. */
  67790. constructor(name: string);
  67791. /**
  67792. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67793. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67794. * making it easier to setup and tweak the effect
  67795. */
  67796. albedoScaling: boolean;
  67797. /**
  67798. * Defines if the sheen is linked to the sheen color.
  67799. */
  67800. linkSheenWithAlbedo: boolean;
  67801. /**
  67802. * Initialize the block and prepare the context for build
  67803. * @param state defines the state that will be used for the build
  67804. */
  67805. initialize(state: NodeMaterialBuildState): void;
  67806. /**
  67807. * Gets the current class name
  67808. * @returns the class name
  67809. */
  67810. getClassName(): string;
  67811. /**
  67812. * Gets the intensity input component
  67813. */
  67814. get intensity(): NodeMaterialConnectionPoint;
  67815. /**
  67816. * Gets the color input component
  67817. */
  67818. get color(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the roughness input component
  67821. */
  67822. get roughness(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the sheen object output component
  67825. */
  67826. get sheen(): NodeMaterialConnectionPoint;
  67827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67828. /**
  67829. * Gets the main code of the block (fragment side)
  67830. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67831. * @returns the shader code
  67832. */
  67833. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67834. protected _buildBlock(state: NodeMaterialBuildState): this;
  67835. protected _dumpPropertiesCode(): string;
  67836. serialize(): any;
  67837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67838. }
  67839. }
  67840. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67841. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67846. import { Scene } from "babylonjs/scene";
  67847. import { Nullable } from "babylonjs/types";
  67848. import { Mesh } from "babylonjs/Meshes/mesh";
  67849. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67850. import { Effect } from "babylonjs/Materials/effect";
  67851. /**
  67852. * Block used to implement the reflectivity module of the PBR material
  67853. */
  67854. export class ReflectivityBlock extends NodeMaterialBlock {
  67855. private _metallicReflectanceColor;
  67856. private _metallicF0Factor;
  67857. /** @hidden */
  67858. _vMetallicReflectanceFactorsName: string;
  67859. /**
  67860. * The property below is set by the main PBR block prior to calling methods of this class.
  67861. */
  67862. /** @hidden */
  67863. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67864. /**
  67865. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67866. */
  67867. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67868. /**
  67869. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67870. */
  67871. useMetallnessFromMetallicTextureBlue: boolean;
  67872. /**
  67873. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67874. */
  67875. useRoughnessFromMetallicTextureAlpha: boolean;
  67876. /**
  67877. * Specifies if the metallic texture contains the roughness information in its green channel.
  67878. */
  67879. useRoughnessFromMetallicTextureGreen: boolean;
  67880. /**
  67881. * Create a new ReflectivityBlock
  67882. * @param name defines the block name
  67883. */
  67884. constructor(name: string);
  67885. /**
  67886. * Initialize the block and prepare the context for build
  67887. * @param state defines the state that will be used for the build
  67888. */
  67889. initialize(state: NodeMaterialBuildState): void;
  67890. /**
  67891. * Gets the current class name
  67892. * @returns the class name
  67893. */
  67894. getClassName(): string;
  67895. /**
  67896. * Gets the metallic input component
  67897. */
  67898. get metallic(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the roughness input component
  67901. */
  67902. get roughness(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the texture input component
  67905. */
  67906. get texture(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the reflectivity object output component
  67909. */
  67910. get reflectivity(): NodeMaterialConnectionPoint;
  67911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67912. /**
  67913. * Gets the main code of the block (fragment side)
  67914. * @param state current state of the node material building
  67915. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67916. * @returns the shader code
  67917. */
  67918. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67920. protected _buildBlock(state: NodeMaterialBuildState): this;
  67921. protected _dumpPropertiesCode(): string;
  67922. serialize(): any;
  67923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67924. }
  67925. }
  67926. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67927. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67932. /**
  67933. * Block used to implement the anisotropy module of the PBR material
  67934. */
  67935. export class AnisotropyBlock extends NodeMaterialBlock {
  67936. /**
  67937. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67938. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67939. * It's less burden on the user side in the editor part.
  67940. */
  67941. /** @hidden */
  67942. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67943. /** @hidden */
  67944. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67945. /**
  67946. * Create a new AnisotropyBlock
  67947. * @param name defines the block name
  67948. */
  67949. constructor(name: string);
  67950. /**
  67951. * Initialize the block and prepare the context for build
  67952. * @param state defines the state that will be used for the build
  67953. */
  67954. initialize(state: NodeMaterialBuildState): void;
  67955. /**
  67956. * Gets the current class name
  67957. * @returns the class name
  67958. */
  67959. getClassName(): string;
  67960. /**
  67961. * Gets the intensity input component
  67962. */
  67963. get intensity(): NodeMaterialConnectionPoint;
  67964. /**
  67965. * Gets the direction input component
  67966. */
  67967. get direction(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the texture input component
  67970. */
  67971. get texture(): NodeMaterialConnectionPoint;
  67972. /**
  67973. * Gets the uv input component
  67974. */
  67975. get uv(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the worldTangent input component
  67978. */
  67979. get worldTangent(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the anisotropy object output component
  67982. */
  67983. get anisotropy(): NodeMaterialConnectionPoint;
  67984. private _generateTBNSpace;
  67985. /**
  67986. * Gets the main code of the block (fragment side)
  67987. * @param state current state of the node material building
  67988. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67989. * @returns the shader code
  67990. */
  67991. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67993. protected _buildBlock(state: NodeMaterialBuildState): this;
  67994. }
  67995. }
  67996. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68000. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68002. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68003. import { Nullable } from "babylonjs/types";
  68004. import { Mesh } from "babylonjs/Meshes/mesh";
  68005. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68006. import { Effect } from "babylonjs/Materials/effect";
  68007. /**
  68008. * Block used to implement the clear coat module of the PBR material
  68009. */
  68010. export class ClearCoatBlock extends NodeMaterialBlock {
  68011. private _scene;
  68012. /**
  68013. * Create a new ClearCoatBlock
  68014. * @param name defines the block name
  68015. */
  68016. constructor(name: string);
  68017. /**
  68018. * Initialize the block and prepare the context for build
  68019. * @param state defines the state that will be used for the build
  68020. */
  68021. initialize(state: NodeMaterialBuildState): void;
  68022. /**
  68023. * Gets the current class name
  68024. * @returns the class name
  68025. */
  68026. getClassName(): string;
  68027. /**
  68028. * Gets the intensity input component
  68029. */
  68030. get intensity(): NodeMaterialConnectionPoint;
  68031. /**
  68032. * Gets the roughness input component
  68033. */
  68034. get roughness(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the ior input component
  68037. */
  68038. get ior(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the texture input component
  68041. */
  68042. get texture(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the bump texture input component
  68045. */
  68046. get bumpTexture(): NodeMaterialConnectionPoint;
  68047. /**
  68048. * Gets the uv input component
  68049. */
  68050. get uv(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the tint color input component
  68053. */
  68054. get tintColor(): NodeMaterialConnectionPoint;
  68055. /**
  68056. * Gets the tint "at distance" input component
  68057. */
  68058. get tintAtDistance(): NodeMaterialConnectionPoint;
  68059. /**
  68060. * Gets the tint thickness input component
  68061. */
  68062. get tintThickness(): NodeMaterialConnectionPoint;
  68063. /**
  68064. * Gets the world tangent input component
  68065. */
  68066. get worldTangent(): NodeMaterialConnectionPoint;
  68067. /**
  68068. * Gets the clear coat object output component
  68069. */
  68070. get clearcoat(): NodeMaterialConnectionPoint;
  68071. autoConfigure(material: NodeMaterial): void;
  68072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68074. private _generateTBNSpace;
  68075. /**
  68076. * Gets the main code of the block (fragment side)
  68077. * @param state current state of the node material building
  68078. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68079. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68080. * @param worldPosVarName name of the variable holding the world position
  68081. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68082. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68083. * @param worldNormalVarName name of the variable holding the world normal
  68084. * @returns the shader code
  68085. */
  68086. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68087. protected _buildBlock(state: NodeMaterialBuildState): this;
  68088. }
  68089. }
  68090. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68094. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68096. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68097. import { Nullable } from "babylonjs/types";
  68098. /**
  68099. * Block used to implement the sub surface module of the PBR material
  68100. */
  68101. export class SubSurfaceBlock extends NodeMaterialBlock {
  68102. /**
  68103. * Create a new SubSurfaceBlock
  68104. * @param name defines the block name
  68105. */
  68106. constructor(name: string);
  68107. /**
  68108. * Stores the intensity of the different subsurface effects in the thickness texture.
  68109. * * the green channel is the translucency intensity.
  68110. * * the blue channel is the scattering intensity.
  68111. * * the alpha channel is the refraction intensity.
  68112. */
  68113. useMaskFromThicknessTexture: boolean;
  68114. /**
  68115. * Initialize the block and prepare the context for build
  68116. * @param state defines the state that will be used for the build
  68117. */
  68118. initialize(state: NodeMaterialBuildState): void;
  68119. /**
  68120. * Gets the current class name
  68121. * @returns the class name
  68122. */
  68123. getClassName(): string;
  68124. /**
  68125. * Gets the min thickness input component
  68126. */
  68127. get minThickness(): NodeMaterialConnectionPoint;
  68128. /**
  68129. * Gets the max thickness input component
  68130. */
  68131. get maxThickness(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the thickness texture component
  68134. */
  68135. get thicknessTexture(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the tint color input component
  68138. */
  68139. get tintColor(): NodeMaterialConnectionPoint;
  68140. /**
  68141. * Gets the translucency intensity input component
  68142. */
  68143. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68144. /**
  68145. * Gets the translucency diffusion distance input component
  68146. */
  68147. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68148. /**
  68149. * Gets the refraction object parameters
  68150. */
  68151. get refraction(): NodeMaterialConnectionPoint;
  68152. /**
  68153. * Gets the sub surface object output component
  68154. */
  68155. get subsurface(): NodeMaterialConnectionPoint;
  68156. autoConfigure(material: NodeMaterial): void;
  68157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68158. /**
  68159. * Gets the main code of the block (fragment side)
  68160. * @param state current state of the node material building
  68161. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68162. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68163. * @param worldPosVarName name of the variable holding the world position
  68164. * @returns the shader code
  68165. */
  68166. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68167. protected _buildBlock(state: NodeMaterialBuildState): this;
  68168. }
  68169. }
  68170. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68174. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68175. import { Light } from "babylonjs/Lights/light";
  68176. import { Nullable } from "babylonjs/types";
  68177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68178. import { Effect } from "babylonjs/Materials/effect";
  68179. import { Mesh } from "babylonjs/Meshes/mesh";
  68180. import { Scene } from "babylonjs/scene";
  68181. /**
  68182. * Block used to implement the PBR metallic/roughness model
  68183. */
  68184. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68185. /**
  68186. * Gets or sets the light associated with this block
  68187. */
  68188. light: Nullable<Light>;
  68189. private _lightId;
  68190. private _scene;
  68191. private _environmentBRDFTexture;
  68192. private _environmentBrdfSamplerName;
  68193. private _vNormalWName;
  68194. private _invertNormalName;
  68195. /**
  68196. * Create a new ReflectionBlock
  68197. * @param name defines the block name
  68198. */
  68199. constructor(name: string);
  68200. /**
  68201. * Intensity of the direct lights e.g. the four lights available in your scene.
  68202. * This impacts both the direct diffuse and specular highlights.
  68203. */
  68204. directIntensity: number;
  68205. /**
  68206. * Intensity of the environment e.g. how much the environment will light the object
  68207. * either through harmonics for rough material or through the refelction for shiny ones.
  68208. */
  68209. environmentIntensity: number;
  68210. /**
  68211. * This is a special control allowing the reduction of the specular highlights coming from the
  68212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68213. */
  68214. specularIntensity: number;
  68215. /**
  68216. * Defines the falloff type used in this material.
  68217. * It by default is Physical.
  68218. */
  68219. lightFalloff: number;
  68220. /**
  68221. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68222. */
  68223. useAlphaFromAlbedoTexture: boolean;
  68224. /**
  68225. * Specifies that alpha test should be used
  68226. */
  68227. useAlphaTest: boolean;
  68228. /**
  68229. * Defines the alpha limits in alpha test mode.
  68230. */
  68231. alphaTestCutoff: number;
  68232. /**
  68233. * Specifies that alpha blending should be used
  68234. */
  68235. useAlphaBlending: boolean;
  68236. /**
  68237. * Defines if the alpha value should be determined via the rgb values.
  68238. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68239. */
  68240. opacityRGB: boolean;
  68241. /**
  68242. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68243. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68244. */
  68245. useRadianceOverAlpha: boolean;
  68246. /**
  68247. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68248. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68249. */
  68250. useSpecularOverAlpha: boolean;
  68251. /**
  68252. * Enables specular anti aliasing in the PBR shader.
  68253. * It will both interacts on the Geometry for analytical and IBL lighting.
  68254. * It also prefilter the roughness map based on the bump values.
  68255. */
  68256. enableSpecularAntiAliasing: boolean;
  68257. /**
  68258. * Enables realtime filtering on the texture.
  68259. */
  68260. realTimeFiltering: boolean;
  68261. /**
  68262. * Quality switch for realtime filtering
  68263. */
  68264. realTimeFilteringQuality: number;
  68265. /**
  68266. * Defines if the material uses energy conservation.
  68267. */
  68268. useEnergyConservation: boolean;
  68269. /**
  68270. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68271. * too much the area relying on ambient texture to define their ambient occlusion.
  68272. */
  68273. useRadianceOcclusion: boolean;
  68274. /**
  68275. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68276. * makes the reflect vector face the model (under horizon).
  68277. */
  68278. useHorizonOcclusion: boolean;
  68279. /**
  68280. * If set to true, no lighting calculations will be applied.
  68281. */
  68282. unlit: boolean;
  68283. /**
  68284. * Force normal to face away from face.
  68285. */
  68286. forceNormalForward: boolean;
  68287. /**
  68288. * Defines the material debug mode.
  68289. * It helps seeing only some components of the material while troubleshooting.
  68290. */
  68291. debugMode: number;
  68292. /**
  68293. * Specify from where on screen the debug mode should start.
  68294. * The value goes from -1 (full screen) to 1 (not visible)
  68295. * It helps with side by side comparison against the final render
  68296. * This defaults to 0
  68297. */
  68298. debugLimit: number;
  68299. /**
  68300. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68301. * You can use the factor to better multiply the final value.
  68302. */
  68303. debugFactor: number;
  68304. /**
  68305. * Initialize the block and prepare the context for build
  68306. * @param state defines the state that will be used for the build
  68307. */
  68308. initialize(state: NodeMaterialBuildState): void;
  68309. /**
  68310. * Gets the current class name
  68311. * @returns the class name
  68312. */
  68313. getClassName(): string;
  68314. /**
  68315. * Gets the world position input component
  68316. */
  68317. get worldPosition(): NodeMaterialConnectionPoint;
  68318. /**
  68319. * Gets the world normal input component
  68320. */
  68321. get worldNormal(): NodeMaterialConnectionPoint;
  68322. /**
  68323. * Gets the perturbed normal input component
  68324. */
  68325. get perturbedNormal(): NodeMaterialConnectionPoint;
  68326. /**
  68327. * Gets the camera position input component
  68328. */
  68329. get cameraPosition(): NodeMaterialConnectionPoint;
  68330. /**
  68331. * Gets the base color input component
  68332. */
  68333. get baseColor(): NodeMaterialConnectionPoint;
  68334. /**
  68335. * Gets the opacity texture input component
  68336. */
  68337. get opacityTexture(): NodeMaterialConnectionPoint;
  68338. /**
  68339. * Gets the ambient color input component
  68340. */
  68341. get ambientColor(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the reflectivity object parameters
  68344. */
  68345. get reflectivity(): NodeMaterialConnectionPoint;
  68346. /**
  68347. * Gets the ambient occlusion object parameters
  68348. */
  68349. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68350. /**
  68351. * Gets the reflection object parameters
  68352. */
  68353. get reflection(): NodeMaterialConnectionPoint;
  68354. /**
  68355. * Gets the sheen object parameters
  68356. */
  68357. get sheen(): NodeMaterialConnectionPoint;
  68358. /**
  68359. * Gets the clear coat object parameters
  68360. */
  68361. get clearcoat(): NodeMaterialConnectionPoint;
  68362. /**
  68363. * Gets the sub surface object parameters
  68364. */
  68365. get subsurface(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the anisotropy object parameters
  68368. */
  68369. get anisotropy(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the ambient output component
  68372. */
  68373. get ambient(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the diffuse output component
  68376. */
  68377. get diffuse(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the specular output component
  68380. */
  68381. get specular(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the sheen output component
  68384. */
  68385. get sheenDir(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the clear coat output component
  68388. */
  68389. get clearcoatDir(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the indirect diffuse output component
  68392. */
  68393. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the indirect specular output component
  68396. */
  68397. get specularIndirect(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the indirect sheen output component
  68400. */
  68401. get sheenIndirect(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the indirect clear coat output component
  68404. */
  68405. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the refraction output component
  68408. */
  68409. get refraction(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the global lighting output component
  68412. */
  68413. get lighting(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the shadow output component
  68416. */
  68417. get shadow(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the alpha output component
  68420. */
  68421. get alpha(): NodeMaterialConnectionPoint;
  68422. autoConfigure(material: NodeMaterial): void;
  68423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68424. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68426. private _injectVertexCode;
  68427. /**
  68428. * Gets the code corresponding to the albedo/opacity module
  68429. * @returns the shader code
  68430. */
  68431. getAlbedoOpacityCode(): string;
  68432. protected _buildBlock(state: NodeMaterialBuildState): this;
  68433. protected _dumpPropertiesCode(): string;
  68434. serialize(): any;
  68435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68436. }
  68437. }
  68438. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68439. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68440. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68441. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68442. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68443. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68444. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68445. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68446. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68447. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68448. }
  68449. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68450. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68452. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68453. }
  68454. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68458. /**
  68459. * Block used to compute value of one parameter modulo another
  68460. */
  68461. export class ModBlock extends NodeMaterialBlock {
  68462. /**
  68463. * Creates a new ModBlock
  68464. * @param name defines the block name
  68465. */
  68466. constructor(name: string);
  68467. /**
  68468. * Gets the current class name
  68469. * @returns the class name
  68470. */
  68471. getClassName(): string;
  68472. /**
  68473. * Gets the left operand input component
  68474. */
  68475. get left(): NodeMaterialConnectionPoint;
  68476. /**
  68477. * Gets the right operand input component
  68478. */
  68479. get right(): NodeMaterialConnectionPoint;
  68480. /**
  68481. * Gets the output component
  68482. */
  68483. get output(): NodeMaterialConnectionPoint;
  68484. protected _buildBlock(state: NodeMaterialBuildState): this;
  68485. }
  68486. }
  68487. declare module "babylonjs/Materials/Node/Blocks/index" {
  68488. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68489. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68490. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68491. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68492. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68493. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68494. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68495. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68496. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68497. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68512. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68519. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68520. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68521. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68522. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68523. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68524. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68525. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68526. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68527. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68528. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68529. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68530. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68531. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68532. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68533. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68534. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68535. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68536. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68537. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68538. }
  68539. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68540. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68541. }
  68542. declare module "babylonjs/Materials/Node/index" {
  68543. export * from "babylonjs/Materials/Node/Enums/index";
  68544. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68545. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68546. export * from "babylonjs/Materials/Node/nodeMaterial";
  68547. export * from "babylonjs/Materials/Node/Blocks/index";
  68548. export * from "babylonjs/Materials/Node/Optimizers/index";
  68549. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68550. }
  68551. declare module "babylonjs/Materials/index" {
  68552. export * from "babylonjs/Materials/Background/index";
  68553. export * from "babylonjs/Materials/colorCurves";
  68554. export * from "babylonjs/Materials/iEffectFallbacks";
  68555. export * from "babylonjs/Materials/effectFallbacks";
  68556. export * from "babylonjs/Materials/effect";
  68557. export * from "babylonjs/Materials/fresnelParameters";
  68558. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68559. export * from "babylonjs/Materials/material";
  68560. export * from "babylonjs/Materials/materialDefines";
  68561. export * from "babylonjs/Materials/thinMaterialHelper";
  68562. export * from "babylonjs/Materials/materialHelper";
  68563. export * from "babylonjs/Materials/multiMaterial";
  68564. export * from "babylonjs/Materials/PBR/index";
  68565. export * from "babylonjs/Materials/pushMaterial";
  68566. export * from "babylonjs/Materials/shaderMaterial";
  68567. export * from "babylonjs/Materials/standardMaterial";
  68568. export * from "babylonjs/Materials/Textures/index";
  68569. export * from "babylonjs/Materials/uniformBuffer";
  68570. export * from "babylonjs/Materials/materialFlags";
  68571. export * from "babylonjs/Materials/Node/index";
  68572. export * from "babylonjs/Materials/effectRenderer";
  68573. export * from "babylonjs/Materials/shadowDepthWrapper";
  68574. }
  68575. declare module "babylonjs/Maths/index" {
  68576. export * from "babylonjs/Maths/math.scalar";
  68577. export * from "babylonjs/Maths/math";
  68578. export * from "babylonjs/Maths/sphericalPolynomial";
  68579. }
  68580. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68581. import { IDisposable } from "babylonjs/scene";
  68582. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68583. /**
  68584. * Configuration for Draco compression
  68585. */
  68586. export interface IDracoCompressionConfiguration {
  68587. /**
  68588. * Configuration for the decoder.
  68589. */
  68590. decoder: {
  68591. /**
  68592. * The url to the WebAssembly module.
  68593. */
  68594. wasmUrl?: string;
  68595. /**
  68596. * The url to the WebAssembly binary.
  68597. */
  68598. wasmBinaryUrl?: string;
  68599. /**
  68600. * The url to the fallback JavaScript module.
  68601. */
  68602. fallbackUrl?: string;
  68603. };
  68604. }
  68605. /**
  68606. * Draco compression (https://google.github.io/draco/)
  68607. *
  68608. * This class wraps the Draco module.
  68609. *
  68610. * **Encoder**
  68611. *
  68612. * The encoder is not currently implemented.
  68613. *
  68614. * **Decoder**
  68615. *
  68616. * 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.
  68617. *
  68618. * To update the configuration, use the following code:
  68619. * ```javascript
  68620. * DracoCompression.Configuration = {
  68621. * decoder: {
  68622. * wasmUrl: "<url to the WebAssembly library>",
  68623. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68624. * fallbackUrl: "<url to the fallback JavaScript library>",
  68625. * }
  68626. * };
  68627. * ```
  68628. *
  68629. * 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.
  68630. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68631. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68632. *
  68633. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68634. * ```javascript
  68635. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68636. * ```
  68637. *
  68638. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68639. */
  68640. export class DracoCompression implements IDisposable {
  68641. private _workerPoolPromise?;
  68642. private _decoderModulePromise?;
  68643. /**
  68644. * The configuration. Defaults to the following urls:
  68645. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68646. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68647. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68648. */
  68649. static Configuration: IDracoCompressionConfiguration;
  68650. /**
  68651. * Returns true if the decoder configuration is available.
  68652. */
  68653. static get DecoderAvailable(): boolean;
  68654. /**
  68655. * Default number of workers to create when creating the draco compression object.
  68656. */
  68657. static DefaultNumWorkers: number;
  68658. private static GetDefaultNumWorkers;
  68659. private static _Default;
  68660. /**
  68661. * Default instance for the draco compression object.
  68662. */
  68663. static get Default(): DracoCompression;
  68664. /**
  68665. * Constructor
  68666. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68667. */
  68668. constructor(numWorkers?: number);
  68669. /**
  68670. * Stop all async operations and release resources.
  68671. */
  68672. dispose(): void;
  68673. /**
  68674. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68675. * @returns a promise that resolves when ready
  68676. */
  68677. whenReadyAsync(): Promise<void>;
  68678. /**
  68679. * Decode Draco compressed mesh data to vertex data.
  68680. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68681. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68682. * @returns A promise that resolves with the decoded vertex data
  68683. */
  68684. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68685. [kind: string]: number;
  68686. }): Promise<VertexData>;
  68687. }
  68688. }
  68689. declare module "babylonjs/Meshes/Compression/index" {
  68690. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68691. }
  68692. declare module "babylonjs/Meshes/csg" {
  68693. import { Nullable } from "babylonjs/types";
  68694. import { Scene } from "babylonjs/scene";
  68695. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68696. import { Mesh } from "babylonjs/Meshes/mesh";
  68697. import { Material } from "babylonjs/Materials/material";
  68698. /**
  68699. * Class for building Constructive Solid Geometry
  68700. */
  68701. export class CSG {
  68702. private polygons;
  68703. /**
  68704. * The world matrix
  68705. */
  68706. matrix: Matrix;
  68707. /**
  68708. * Stores the position
  68709. */
  68710. position: Vector3;
  68711. /**
  68712. * Stores the rotation
  68713. */
  68714. rotation: Vector3;
  68715. /**
  68716. * Stores the rotation quaternion
  68717. */
  68718. rotationQuaternion: Nullable<Quaternion>;
  68719. /**
  68720. * Stores the scaling vector
  68721. */
  68722. scaling: Vector3;
  68723. /**
  68724. * Convert the Mesh to CSG
  68725. * @param mesh The Mesh to convert to CSG
  68726. * @returns A new CSG from the Mesh
  68727. */
  68728. static FromMesh(mesh: Mesh): CSG;
  68729. /**
  68730. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68731. * @param polygons Polygons used to construct a CSG solid
  68732. */
  68733. private static FromPolygons;
  68734. /**
  68735. * Clones, or makes a deep copy, of the CSG
  68736. * @returns A new CSG
  68737. */
  68738. clone(): CSG;
  68739. /**
  68740. * Unions this CSG with another CSG
  68741. * @param csg The CSG to union against this CSG
  68742. * @returns The unioned CSG
  68743. */
  68744. union(csg: CSG): CSG;
  68745. /**
  68746. * Unions this CSG with another CSG in place
  68747. * @param csg The CSG to union against this CSG
  68748. */
  68749. unionInPlace(csg: CSG): void;
  68750. /**
  68751. * Subtracts this CSG with another CSG
  68752. * @param csg The CSG to subtract against this CSG
  68753. * @returns A new CSG
  68754. */
  68755. subtract(csg: CSG): CSG;
  68756. /**
  68757. * Subtracts this CSG with another CSG in place
  68758. * @param csg The CSG to subtact against this CSG
  68759. */
  68760. subtractInPlace(csg: CSG): void;
  68761. /**
  68762. * Intersect this CSG with another CSG
  68763. * @param csg The CSG to intersect against this CSG
  68764. * @returns A new CSG
  68765. */
  68766. intersect(csg: CSG): CSG;
  68767. /**
  68768. * Intersects this CSG with another CSG in place
  68769. * @param csg The CSG to intersect against this CSG
  68770. */
  68771. intersectInPlace(csg: CSG): void;
  68772. /**
  68773. * Return a new CSG solid with solid and empty space switched. This solid is
  68774. * not modified.
  68775. * @returns A new CSG solid with solid and empty space switched
  68776. */
  68777. inverse(): CSG;
  68778. /**
  68779. * Inverses the CSG in place
  68780. */
  68781. inverseInPlace(): void;
  68782. /**
  68783. * This is used to keep meshes transformations so they can be restored
  68784. * when we build back a Babylon Mesh
  68785. * NB : All CSG operations are performed in world coordinates
  68786. * @param csg The CSG to copy the transform attributes from
  68787. * @returns This CSG
  68788. */
  68789. copyTransformAttributes(csg: CSG): CSG;
  68790. /**
  68791. * Build Raw mesh from CSG
  68792. * Coordinates here are in world space
  68793. * @param name The name of the mesh geometry
  68794. * @param scene The Scene
  68795. * @param keepSubMeshes Specifies if the submeshes should be kept
  68796. * @returns A new Mesh
  68797. */
  68798. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68799. /**
  68800. * Build Mesh from CSG taking material and transforms into account
  68801. * @param name The name of the Mesh
  68802. * @param material The material of the Mesh
  68803. * @param scene The Scene
  68804. * @param keepSubMeshes Specifies if submeshes should be kept
  68805. * @returns The new Mesh
  68806. */
  68807. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68808. }
  68809. }
  68810. declare module "babylonjs/Meshes/trailMesh" {
  68811. import { Mesh } from "babylonjs/Meshes/mesh";
  68812. import { Scene } from "babylonjs/scene";
  68813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68814. /**
  68815. * Class used to create a trail following a mesh
  68816. */
  68817. export class TrailMesh extends Mesh {
  68818. private _generator;
  68819. private _autoStart;
  68820. private _running;
  68821. private _diameter;
  68822. private _length;
  68823. private _sectionPolygonPointsCount;
  68824. private _sectionVectors;
  68825. private _sectionNormalVectors;
  68826. private _beforeRenderObserver;
  68827. /**
  68828. * @constructor
  68829. * @param name The value used by scene.getMeshByName() to do a lookup.
  68830. * @param generator The mesh or transform node to generate a trail.
  68831. * @param scene The scene to add this mesh to.
  68832. * @param diameter Diameter of trailing mesh. Default is 1.
  68833. * @param length Length of trailing mesh. Default is 60.
  68834. * @param autoStart Automatically start trailing mesh. Default true.
  68835. */
  68836. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68837. /**
  68838. * "TrailMesh"
  68839. * @returns "TrailMesh"
  68840. */
  68841. getClassName(): string;
  68842. private _createMesh;
  68843. /**
  68844. * Start trailing mesh.
  68845. */
  68846. start(): void;
  68847. /**
  68848. * Stop trailing mesh.
  68849. */
  68850. stop(): void;
  68851. /**
  68852. * Update trailing mesh geometry.
  68853. */
  68854. update(): void;
  68855. /**
  68856. * Returns a new TrailMesh object.
  68857. * @param name is a string, the name given to the new mesh
  68858. * @param newGenerator use new generator object for cloned trail mesh
  68859. * @returns a new mesh
  68860. */
  68861. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68862. /**
  68863. * Serializes this trail mesh
  68864. * @param serializationObject object to write serialization to
  68865. */
  68866. serialize(serializationObject: any): void;
  68867. /**
  68868. * Parses a serialized trail mesh
  68869. * @param parsedMesh the serialized mesh
  68870. * @param scene the scene to create the trail mesh in
  68871. * @returns the created trail mesh
  68872. */
  68873. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68874. }
  68875. }
  68876. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68877. import { Nullable } from "babylonjs/types";
  68878. import { Scene } from "babylonjs/scene";
  68879. import { Vector4 } from "babylonjs/Maths/math.vector";
  68880. import { Color4 } from "babylonjs/Maths/math.color";
  68881. import { Mesh } from "babylonjs/Meshes/mesh";
  68882. /**
  68883. * Class containing static functions to help procedurally build meshes
  68884. */
  68885. export class TiledBoxBuilder {
  68886. /**
  68887. * Creates a box mesh
  68888. * 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)
  68889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68893. * @param name defines the name of the mesh
  68894. * @param options defines the options used to create the mesh
  68895. * @param scene defines the hosting scene
  68896. * @returns the box mesh
  68897. */
  68898. static CreateTiledBox(name: string, options: {
  68899. pattern?: number;
  68900. width?: number;
  68901. height?: number;
  68902. depth?: number;
  68903. tileSize?: number;
  68904. tileWidth?: number;
  68905. tileHeight?: number;
  68906. alignHorizontal?: number;
  68907. alignVertical?: number;
  68908. faceUV?: Vector4[];
  68909. faceColors?: Color4[];
  68910. sideOrientation?: number;
  68911. updatable?: boolean;
  68912. }, scene?: Nullable<Scene>): Mesh;
  68913. }
  68914. }
  68915. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68916. import { Vector4 } from "babylonjs/Maths/math.vector";
  68917. import { Mesh } from "babylonjs/Meshes/mesh";
  68918. /**
  68919. * Class containing static functions to help procedurally build meshes
  68920. */
  68921. export class TorusKnotBuilder {
  68922. /**
  68923. * Creates a torus knot mesh
  68924. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68925. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68926. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68927. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68931. * @param name defines the name of the mesh
  68932. * @param options defines the options used to create the mesh
  68933. * @param scene defines the hosting scene
  68934. * @returns the torus knot mesh
  68935. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68936. */
  68937. static CreateTorusKnot(name: string, options: {
  68938. radius?: number;
  68939. tube?: number;
  68940. radialSegments?: number;
  68941. tubularSegments?: number;
  68942. p?: number;
  68943. q?: number;
  68944. updatable?: boolean;
  68945. sideOrientation?: number;
  68946. frontUVs?: Vector4;
  68947. backUVs?: Vector4;
  68948. }, scene: any): Mesh;
  68949. }
  68950. }
  68951. declare module "babylonjs/Meshes/polygonMesh" {
  68952. import { Scene } from "babylonjs/scene";
  68953. import { Vector2 } from "babylonjs/Maths/math.vector";
  68954. import { Mesh } from "babylonjs/Meshes/mesh";
  68955. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68956. import { Path2 } from "babylonjs/Maths/math.path";
  68957. /**
  68958. * Polygon
  68959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68960. */
  68961. export class Polygon {
  68962. /**
  68963. * Creates a rectangle
  68964. * @param xmin bottom X coord
  68965. * @param ymin bottom Y coord
  68966. * @param xmax top X coord
  68967. * @param ymax top Y coord
  68968. * @returns points that make the resulting rectation
  68969. */
  68970. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68971. /**
  68972. * Creates a circle
  68973. * @param radius radius of circle
  68974. * @param cx scale in x
  68975. * @param cy scale in y
  68976. * @param numberOfSides number of sides that make up the circle
  68977. * @returns points that make the resulting circle
  68978. */
  68979. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68980. /**
  68981. * Creates a polygon from input string
  68982. * @param input Input polygon data
  68983. * @returns the parsed points
  68984. */
  68985. static Parse(input: string): Vector2[];
  68986. /**
  68987. * Starts building a polygon from x and y coordinates
  68988. * @param x x coordinate
  68989. * @param y y coordinate
  68990. * @returns the started path2
  68991. */
  68992. static StartingAt(x: number, y: number): Path2;
  68993. }
  68994. /**
  68995. * Builds a polygon
  68996. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68997. */
  68998. export class PolygonMeshBuilder {
  68999. private _points;
  69000. private _outlinepoints;
  69001. private _holes;
  69002. private _name;
  69003. private _scene;
  69004. private _epoints;
  69005. private _eholes;
  69006. private _addToepoint;
  69007. /**
  69008. * Babylon reference to the earcut plugin.
  69009. */
  69010. bjsEarcut: any;
  69011. /**
  69012. * Creates a PolygonMeshBuilder
  69013. * @param name name of the builder
  69014. * @param contours Path of the polygon
  69015. * @param scene scene to add to when creating the mesh
  69016. * @param earcutInjection can be used to inject your own earcut reference
  69017. */
  69018. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69019. /**
  69020. * Adds a whole within the polygon
  69021. * @param hole Array of points defining the hole
  69022. * @returns this
  69023. */
  69024. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69025. /**
  69026. * Creates the polygon
  69027. * @param updatable If the mesh should be updatable
  69028. * @param depth The depth of the mesh created
  69029. * @returns the created mesh
  69030. */
  69031. build(updatable?: boolean, depth?: number): Mesh;
  69032. /**
  69033. * Creates the polygon
  69034. * @param depth The depth of the mesh created
  69035. * @returns the created VertexData
  69036. */
  69037. buildVertexData(depth?: number): VertexData;
  69038. /**
  69039. * Adds a side to the polygon
  69040. * @param positions points that make the polygon
  69041. * @param normals normals of the polygon
  69042. * @param uvs uvs of the polygon
  69043. * @param indices indices of the polygon
  69044. * @param bounds bounds of the polygon
  69045. * @param points points of the polygon
  69046. * @param depth depth of the polygon
  69047. * @param flip flip of the polygon
  69048. */
  69049. private addSide;
  69050. }
  69051. }
  69052. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69053. import { Scene } from "babylonjs/scene";
  69054. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69055. import { Color4 } from "babylonjs/Maths/math.color";
  69056. import { Mesh } from "babylonjs/Meshes/mesh";
  69057. import { Nullable } from "babylonjs/types";
  69058. /**
  69059. * Class containing static functions to help procedurally build meshes
  69060. */
  69061. export class PolygonBuilder {
  69062. /**
  69063. * Creates a polygon mesh
  69064. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69065. * * 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
  69066. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69069. * * Remember you can only change the shape positions, not their number when updating a polygon
  69070. * @param name defines the name of the mesh
  69071. * @param options defines the options used to create the mesh
  69072. * @param scene defines the hosting scene
  69073. * @param earcutInjection can be used to inject your own earcut reference
  69074. * @returns the polygon mesh
  69075. */
  69076. static CreatePolygon(name: string, options: {
  69077. shape: Vector3[];
  69078. holes?: Vector3[][];
  69079. depth?: number;
  69080. faceUV?: Vector4[];
  69081. faceColors?: Color4[];
  69082. updatable?: boolean;
  69083. sideOrientation?: number;
  69084. frontUVs?: Vector4;
  69085. backUVs?: Vector4;
  69086. wrap?: boolean;
  69087. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69088. /**
  69089. * Creates an extruded polygon mesh, with depth in the Y direction.
  69090. * * 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)
  69091. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69092. * @param name defines the name of the mesh
  69093. * @param options defines the options used to create the mesh
  69094. * @param scene defines the hosting scene
  69095. * @param earcutInjection can be used to inject your own earcut reference
  69096. * @returns the polygon mesh
  69097. */
  69098. static ExtrudePolygon(name: string, options: {
  69099. shape: Vector3[];
  69100. holes?: Vector3[][];
  69101. depth?: number;
  69102. faceUV?: Vector4[];
  69103. faceColors?: Color4[];
  69104. updatable?: boolean;
  69105. sideOrientation?: number;
  69106. frontUVs?: Vector4;
  69107. backUVs?: Vector4;
  69108. wrap?: boolean;
  69109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69110. }
  69111. }
  69112. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69113. import { Scene } from "babylonjs/scene";
  69114. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69115. import { Mesh } from "babylonjs/Meshes/mesh";
  69116. import { Nullable } from "babylonjs/types";
  69117. /**
  69118. * Class containing static functions to help procedurally build meshes
  69119. */
  69120. export class LatheBuilder {
  69121. /**
  69122. * Creates lathe mesh.
  69123. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69124. * * 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
  69125. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69126. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69127. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69128. * * 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
  69129. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69130. * * 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
  69131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69135. * @param name defines the name of the mesh
  69136. * @param options defines the options used to create the mesh
  69137. * @param scene defines the hosting scene
  69138. * @returns the lathe mesh
  69139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69140. */
  69141. static CreateLathe(name: string, options: {
  69142. shape: Vector3[];
  69143. radius?: number;
  69144. tessellation?: number;
  69145. clip?: number;
  69146. arc?: number;
  69147. closed?: boolean;
  69148. updatable?: boolean;
  69149. sideOrientation?: number;
  69150. frontUVs?: Vector4;
  69151. backUVs?: Vector4;
  69152. cap?: number;
  69153. invertUV?: boolean;
  69154. }, scene?: Nullable<Scene>): Mesh;
  69155. }
  69156. }
  69157. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69158. import { Nullable } from "babylonjs/types";
  69159. import { Scene } from "babylonjs/scene";
  69160. import { Vector4 } from "babylonjs/Maths/math.vector";
  69161. import { Mesh } from "babylonjs/Meshes/mesh";
  69162. /**
  69163. * Class containing static functions to help procedurally build meshes
  69164. */
  69165. export class TiledPlaneBuilder {
  69166. /**
  69167. * Creates a tiled plane mesh
  69168. * * The parameter `pattern` will, depending on value, do nothing or
  69169. * * * flip (reflect about central vertical) alternate tiles across and up
  69170. * * * flip every tile on alternate rows
  69171. * * * rotate (180 degs) alternate tiles across and up
  69172. * * * rotate every tile on alternate rows
  69173. * * * flip and rotate alternate tiles across and up
  69174. * * * flip and rotate every tile on alternate rows
  69175. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69176. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69179. * * 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)
  69180. * * 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)
  69181. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69182. * @param name defines the name of the mesh
  69183. * @param options defines the options used to create the mesh
  69184. * @param scene defines the hosting scene
  69185. * @returns the box mesh
  69186. */
  69187. static CreateTiledPlane(name: string, options: {
  69188. pattern?: number;
  69189. tileSize?: number;
  69190. tileWidth?: number;
  69191. tileHeight?: number;
  69192. size?: number;
  69193. width?: number;
  69194. height?: number;
  69195. alignHorizontal?: number;
  69196. alignVertical?: number;
  69197. sideOrientation?: number;
  69198. frontUVs?: Vector4;
  69199. backUVs?: Vector4;
  69200. updatable?: boolean;
  69201. }, scene?: Nullable<Scene>): Mesh;
  69202. }
  69203. }
  69204. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69205. import { Nullable } from "babylonjs/types";
  69206. import { Scene } from "babylonjs/scene";
  69207. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69208. import { Mesh } from "babylonjs/Meshes/mesh";
  69209. /**
  69210. * Class containing static functions to help procedurally build meshes
  69211. */
  69212. export class TubeBuilder {
  69213. /**
  69214. * Creates a tube mesh.
  69215. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69216. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69217. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69218. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69219. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69220. * * 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)
  69221. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69222. * * 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
  69223. * * 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
  69224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69228. * @param name defines the name of the mesh
  69229. * @param options defines the options used to create the mesh
  69230. * @param scene defines the hosting scene
  69231. * @returns the tube mesh
  69232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69233. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69234. */
  69235. static CreateTube(name: string, options: {
  69236. path: Vector3[];
  69237. radius?: number;
  69238. tessellation?: number;
  69239. radiusFunction?: {
  69240. (i: number, distance: number): number;
  69241. };
  69242. cap?: number;
  69243. arc?: number;
  69244. updatable?: boolean;
  69245. sideOrientation?: number;
  69246. frontUVs?: Vector4;
  69247. backUVs?: Vector4;
  69248. instance?: Mesh;
  69249. invertUV?: boolean;
  69250. }, scene?: Nullable<Scene>): Mesh;
  69251. }
  69252. }
  69253. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69254. import { Scene } from "babylonjs/scene";
  69255. import { Vector4 } from "babylonjs/Maths/math.vector";
  69256. import { Mesh } from "babylonjs/Meshes/mesh";
  69257. import { Nullable } from "babylonjs/types";
  69258. /**
  69259. * Class containing static functions to help procedurally build meshes
  69260. */
  69261. export class IcoSphereBuilder {
  69262. /**
  69263. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69264. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69265. * * 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`)
  69266. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69267. * * 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
  69268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69271. * @param name defines the name of the mesh
  69272. * @param options defines the options used to create the mesh
  69273. * @param scene defines the hosting scene
  69274. * @returns the icosahedron mesh
  69275. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69276. */
  69277. static CreateIcoSphere(name: string, options: {
  69278. radius?: number;
  69279. radiusX?: number;
  69280. radiusY?: number;
  69281. radiusZ?: number;
  69282. flat?: boolean;
  69283. subdivisions?: number;
  69284. sideOrientation?: number;
  69285. frontUVs?: Vector4;
  69286. backUVs?: Vector4;
  69287. updatable?: boolean;
  69288. }, scene?: Nullable<Scene>): Mesh;
  69289. }
  69290. }
  69291. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69292. import { Vector3 } from "babylonjs/Maths/math.vector";
  69293. import { Mesh } from "babylonjs/Meshes/mesh";
  69294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69295. /**
  69296. * Class containing static functions to help procedurally build meshes
  69297. */
  69298. export class DecalBuilder {
  69299. /**
  69300. * Creates a decal mesh.
  69301. * 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
  69302. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69303. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69304. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69305. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69306. * @param name defines the name of the mesh
  69307. * @param sourceMesh defines the mesh where the decal must be applied
  69308. * @param options defines the options used to create the mesh
  69309. * @param scene defines the hosting scene
  69310. * @returns the decal mesh
  69311. * @see https://doc.babylonjs.com/how_to/decals
  69312. */
  69313. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69314. position?: Vector3;
  69315. normal?: Vector3;
  69316. size?: Vector3;
  69317. angle?: number;
  69318. }): Mesh;
  69319. }
  69320. }
  69321. declare module "babylonjs/Meshes/meshBuilder" {
  69322. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69323. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69324. import { Nullable } from "babylonjs/types";
  69325. import { Scene } from "babylonjs/scene";
  69326. import { Mesh } from "babylonjs/Meshes/mesh";
  69327. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69328. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69331. import { Plane } from "babylonjs/Maths/math.plane";
  69332. /**
  69333. * Class containing static functions to help procedurally build meshes
  69334. */
  69335. export class MeshBuilder {
  69336. /**
  69337. * Creates a box mesh
  69338. * * The parameter `size` sets the size (float) of each box side (default 1)
  69339. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69340. * * 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)
  69341. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69345. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69346. * @param name defines the name of the mesh
  69347. * @param options defines the options used to create the mesh
  69348. * @param scene defines the hosting scene
  69349. * @returns the box mesh
  69350. */
  69351. static CreateBox(name: string, options: {
  69352. size?: number;
  69353. width?: number;
  69354. height?: number;
  69355. depth?: number;
  69356. faceUV?: Vector4[];
  69357. faceColors?: Color4[];
  69358. sideOrientation?: number;
  69359. frontUVs?: Vector4;
  69360. backUVs?: Vector4;
  69361. wrap?: boolean;
  69362. topBaseAt?: number;
  69363. bottomBaseAt?: number;
  69364. updatable?: boolean;
  69365. }, scene?: Nullable<Scene>): Mesh;
  69366. /**
  69367. * Creates a tiled box mesh
  69368. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69370. * @param name defines the name of the mesh
  69371. * @param options defines the options used to create the mesh
  69372. * @param scene defines the hosting scene
  69373. * @returns the tiled box mesh
  69374. */
  69375. static CreateTiledBox(name: string, options: {
  69376. pattern?: number;
  69377. size?: number;
  69378. width?: number;
  69379. height?: number;
  69380. depth: number;
  69381. tileSize?: number;
  69382. tileWidth?: number;
  69383. tileHeight?: number;
  69384. faceUV?: Vector4[];
  69385. faceColors?: Color4[];
  69386. alignHorizontal?: number;
  69387. alignVertical?: number;
  69388. sideOrientation?: number;
  69389. updatable?: boolean;
  69390. }, scene?: Nullable<Scene>): Mesh;
  69391. /**
  69392. * Creates a sphere mesh
  69393. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69394. * * 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`)
  69395. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69396. * * 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
  69397. * * 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)
  69398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69401. * @param name defines the name of the mesh
  69402. * @param options defines the options used to create the mesh
  69403. * @param scene defines the hosting scene
  69404. * @returns the sphere mesh
  69405. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69406. */
  69407. static CreateSphere(name: string, options: {
  69408. segments?: number;
  69409. diameter?: number;
  69410. diameterX?: number;
  69411. diameterY?: number;
  69412. diameterZ?: number;
  69413. arc?: number;
  69414. slice?: number;
  69415. sideOrientation?: number;
  69416. frontUVs?: Vector4;
  69417. backUVs?: Vector4;
  69418. updatable?: boolean;
  69419. }, scene?: Nullable<Scene>): Mesh;
  69420. /**
  69421. * Creates a plane polygonal mesh. By default, this is a disc
  69422. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69423. * * 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
  69424. * * 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
  69425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69428. * @param name defines the name of the mesh
  69429. * @param options defines the options used to create the mesh
  69430. * @param scene defines the hosting scene
  69431. * @returns the plane polygonal mesh
  69432. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69433. */
  69434. static CreateDisc(name: string, options: {
  69435. radius?: number;
  69436. tessellation?: number;
  69437. arc?: number;
  69438. updatable?: boolean;
  69439. sideOrientation?: number;
  69440. frontUVs?: Vector4;
  69441. backUVs?: Vector4;
  69442. }, scene?: Nullable<Scene>): Mesh;
  69443. /**
  69444. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69445. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69446. * * 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`)
  69447. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69448. * * 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
  69449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69452. * @param name defines the name of the mesh
  69453. * @param options defines the options used to create the mesh
  69454. * @param scene defines the hosting scene
  69455. * @returns the icosahedron mesh
  69456. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69457. */
  69458. static CreateIcoSphere(name: string, options: {
  69459. radius?: number;
  69460. radiusX?: number;
  69461. radiusY?: number;
  69462. radiusZ?: number;
  69463. flat?: boolean;
  69464. subdivisions?: number;
  69465. sideOrientation?: number;
  69466. frontUVs?: Vector4;
  69467. backUVs?: Vector4;
  69468. updatable?: boolean;
  69469. }, scene?: Nullable<Scene>): Mesh;
  69470. /**
  69471. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69472. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69473. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69474. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69475. * * 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
  69476. * * 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
  69477. * * 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
  69478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69481. * * 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
  69482. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69483. * * 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
  69484. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69486. * @param name defines the name of the mesh
  69487. * @param options defines the options used to create the mesh
  69488. * @param scene defines the hosting scene
  69489. * @returns the ribbon mesh
  69490. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69492. */
  69493. static CreateRibbon(name: string, options: {
  69494. pathArray: Vector3[][];
  69495. closeArray?: boolean;
  69496. closePath?: boolean;
  69497. offset?: number;
  69498. updatable?: boolean;
  69499. sideOrientation?: number;
  69500. frontUVs?: Vector4;
  69501. backUVs?: Vector4;
  69502. instance?: Mesh;
  69503. invertUV?: boolean;
  69504. uvs?: Vector2[];
  69505. colors?: Color4[];
  69506. }, scene?: Nullable<Scene>): Mesh;
  69507. /**
  69508. * Creates a cylinder or a cone mesh
  69509. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69510. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69511. * * 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.
  69512. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69513. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69514. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69515. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69516. * * 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).
  69517. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69518. * * 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).
  69519. * * 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
  69520. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69521. * * 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
  69522. * * 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.
  69523. * * If `enclose` is false, a ring surface is one element.
  69524. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69525. * * 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
  69526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69529. * @param name defines the name of the mesh
  69530. * @param options defines the options used to create the mesh
  69531. * @param scene defines the hosting scene
  69532. * @returns the cylinder mesh
  69533. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69534. */
  69535. static CreateCylinder(name: string, options: {
  69536. height?: number;
  69537. diameterTop?: number;
  69538. diameterBottom?: number;
  69539. diameter?: number;
  69540. tessellation?: number;
  69541. subdivisions?: number;
  69542. arc?: number;
  69543. faceColors?: Color4[];
  69544. faceUV?: Vector4[];
  69545. updatable?: boolean;
  69546. hasRings?: boolean;
  69547. enclose?: boolean;
  69548. cap?: number;
  69549. sideOrientation?: number;
  69550. frontUVs?: Vector4;
  69551. backUVs?: Vector4;
  69552. }, scene?: Nullable<Scene>): Mesh;
  69553. /**
  69554. * Creates a torus mesh
  69555. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69556. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69557. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69561. * @param name defines the name of the mesh
  69562. * @param options defines the options used to create the mesh
  69563. * @param scene defines the hosting scene
  69564. * @returns the torus mesh
  69565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69566. */
  69567. static CreateTorus(name: string, options: {
  69568. diameter?: number;
  69569. thickness?: number;
  69570. tessellation?: number;
  69571. updatable?: boolean;
  69572. sideOrientation?: number;
  69573. frontUVs?: Vector4;
  69574. backUVs?: Vector4;
  69575. }, scene?: Nullable<Scene>): Mesh;
  69576. /**
  69577. * Creates a torus knot mesh
  69578. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69579. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69580. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69581. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69585. * @param name defines the name of the mesh
  69586. * @param options defines the options used to create the mesh
  69587. * @param scene defines the hosting scene
  69588. * @returns the torus knot mesh
  69589. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69590. */
  69591. static CreateTorusKnot(name: string, options: {
  69592. radius?: number;
  69593. tube?: number;
  69594. radialSegments?: number;
  69595. tubularSegments?: number;
  69596. p?: number;
  69597. q?: number;
  69598. updatable?: boolean;
  69599. sideOrientation?: number;
  69600. frontUVs?: Vector4;
  69601. backUVs?: Vector4;
  69602. }, scene?: Nullable<Scene>): Mesh;
  69603. /**
  69604. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69605. * * 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
  69606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69607. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69608. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69609. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69611. * * 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
  69612. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69615. * @param name defines the name of the new line system
  69616. * @param options defines the options used to create the line system
  69617. * @param scene defines the hosting scene
  69618. * @returns a new line system mesh
  69619. */
  69620. static CreateLineSystem(name: string, options: {
  69621. lines: Vector3[][];
  69622. updatable?: boolean;
  69623. instance?: Nullable<LinesMesh>;
  69624. colors?: Nullable<Color4[][]>;
  69625. useVertexAlpha?: boolean;
  69626. }, scene: Nullable<Scene>): LinesMesh;
  69627. /**
  69628. * Creates a line mesh
  69629. * 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
  69630. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69631. * * The parameter `points` is an array successive Vector3
  69632. * * 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
  69633. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69634. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69635. * * When updating an instance, remember that only point positions can change, not the number of points
  69636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69638. * @param name defines the name of the new line system
  69639. * @param options defines the options used to create the line system
  69640. * @param scene defines the hosting scene
  69641. * @returns a new line mesh
  69642. */
  69643. static CreateLines(name: string, options: {
  69644. points: Vector3[];
  69645. updatable?: boolean;
  69646. instance?: Nullable<LinesMesh>;
  69647. colors?: Color4[];
  69648. useVertexAlpha?: boolean;
  69649. }, scene?: Nullable<Scene>): LinesMesh;
  69650. /**
  69651. * Creates a dashed line mesh
  69652. * * 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
  69653. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69654. * * The parameter `points` is an array successive Vector3
  69655. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69656. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69657. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69658. * * 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
  69659. * * When updating an instance, remember that only point positions can change, not the number of points
  69660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69661. * @param name defines the name of the mesh
  69662. * @param options defines the options used to create the mesh
  69663. * @param scene defines the hosting scene
  69664. * @returns the dashed line mesh
  69665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69666. */
  69667. static CreateDashedLines(name: string, options: {
  69668. points: Vector3[];
  69669. dashSize?: number;
  69670. gapSize?: number;
  69671. dashNb?: number;
  69672. updatable?: boolean;
  69673. instance?: LinesMesh;
  69674. }, scene?: Nullable<Scene>): LinesMesh;
  69675. /**
  69676. * 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.
  69677. * * 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.
  69678. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69679. * * 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.
  69680. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69681. * * 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
  69682. * * 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
  69683. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69688. * @param name defines the name of the mesh
  69689. * @param options defines the options used to create the mesh
  69690. * @param scene defines the hosting scene
  69691. * @returns the extruded shape mesh
  69692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69694. */
  69695. static ExtrudeShape(name: string, options: {
  69696. shape: Vector3[];
  69697. path: Vector3[];
  69698. scale?: number;
  69699. rotation?: number;
  69700. cap?: number;
  69701. updatable?: boolean;
  69702. sideOrientation?: number;
  69703. frontUVs?: Vector4;
  69704. backUVs?: Vector4;
  69705. instance?: Mesh;
  69706. invertUV?: boolean;
  69707. }, scene?: Nullable<Scene>): Mesh;
  69708. /**
  69709. * Creates an custom extruded shape mesh.
  69710. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69711. * * 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.
  69712. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69713. * * 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
  69714. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69715. * * 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
  69716. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69717. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69718. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69719. * * 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
  69720. * * 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
  69721. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69726. * @param name defines the name of the mesh
  69727. * @param options defines the options used to create the mesh
  69728. * @param scene defines the hosting scene
  69729. * @returns the custom extruded shape mesh
  69730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69731. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69733. */
  69734. static ExtrudeShapeCustom(name: string, options: {
  69735. shape: Vector3[];
  69736. path: Vector3[];
  69737. scaleFunction?: any;
  69738. rotationFunction?: any;
  69739. ribbonCloseArray?: boolean;
  69740. ribbonClosePath?: boolean;
  69741. cap?: number;
  69742. updatable?: boolean;
  69743. sideOrientation?: number;
  69744. frontUVs?: Vector4;
  69745. backUVs?: Vector4;
  69746. instance?: Mesh;
  69747. invertUV?: boolean;
  69748. }, scene?: Nullable<Scene>): Mesh;
  69749. /**
  69750. * Creates lathe mesh.
  69751. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69752. * * 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
  69753. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69754. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69755. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69756. * * 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
  69757. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69758. * * 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
  69759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69763. * @param name defines the name of the mesh
  69764. * @param options defines the options used to create the mesh
  69765. * @param scene defines the hosting scene
  69766. * @returns the lathe mesh
  69767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69768. */
  69769. static CreateLathe(name: string, options: {
  69770. shape: Vector3[];
  69771. radius?: number;
  69772. tessellation?: number;
  69773. clip?: number;
  69774. arc?: number;
  69775. closed?: boolean;
  69776. updatable?: boolean;
  69777. sideOrientation?: number;
  69778. frontUVs?: Vector4;
  69779. backUVs?: Vector4;
  69780. cap?: number;
  69781. invertUV?: boolean;
  69782. }, scene?: Nullable<Scene>): Mesh;
  69783. /**
  69784. * Creates a tiled plane mesh
  69785. * * You can set a limited pattern arrangement with the tiles
  69786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69789. * @param name defines the name of the mesh
  69790. * @param options defines the options used to create the mesh
  69791. * @param scene defines the hosting scene
  69792. * @returns the plane mesh
  69793. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69794. */
  69795. static CreateTiledPlane(name: string, options: {
  69796. pattern?: number;
  69797. tileSize?: number;
  69798. tileWidth?: number;
  69799. tileHeight?: number;
  69800. size?: number;
  69801. width?: number;
  69802. height?: number;
  69803. alignHorizontal?: number;
  69804. alignVertical?: number;
  69805. sideOrientation?: number;
  69806. frontUVs?: Vector4;
  69807. backUVs?: Vector4;
  69808. updatable?: boolean;
  69809. }, scene?: Nullable<Scene>): Mesh;
  69810. /**
  69811. * Creates a plane mesh
  69812. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69813. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69814. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69818. * @param name defines the name of the mesh
  69819. * @param options defines the options used to create the mesh
  69820. * @param scene defines the hosting scene
  69821. * @returns the plane mesh
  69822. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69823. */
  69824. static CreatePlane(name: string, options: {
  69825. size?: number;
  69826. width?: number;
  69827. height?: number;
  69828. sideOrientation?: number;
  69829. frontUVs?: Vector4;
  69830. backUVs?: Vector4;
  69831. updatable?: boolean;
  69832. sourcePlane?: Plane;
  69833. }, scene?: Nullable<Scene>): Mesh;
  69834. /**
  69835. * Creates a ground mesh
  69836. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69837. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69839. * @param name defines the name of the mesh
  69840. * @param options defines the options used to create the mesh
  69841. * @param scene defines the hosting scene
  69842. * @returns the ground mesh
  69843. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69844. */
  69845. static CreateGround(name: string, options: {
  69846. width?: number;
  69847. height?: number;
  69848. subdivisions?: number;
  69849. subdivisionsX?: number;
  69850. subdivisionsY?: number;
  69851. updatable?: boolean;
  69852. }, scene?: Nullable<Scene>): Mesh;
  69853. /**
  69854. * Creates a tiled ground mesh
  69855. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69856. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69857. * * 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
  69858. * * 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
  69859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69860. * @param name defines the name of the mesh
  69861. * @param options defines the options used to create the mesh
  69862. * @param scene defines the hosting scene
  69863. * @returns the tiled ground mesh
  69864. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69865. */
  69866. static CreateTiledGround(name: string, options: {
  69867. xmin: number;
  69868. zmin: number;
  69869. xmax: number;
  69870. zmax: number;
  69871. subdivisions?: {
  69872. w: number;
  69873. h: number;
  69874. };
  69875. precision?: {
  69876. w: number;
  69877. h: number;
  69878. };
  69879. updatable?: boolean;
  69880. }, scene?: Nullable<Scene>): Mesh;
  69881. /**
  69882. * Creates a ground mesh from a height map
  69883. * * The parameter `url` sets the URL of the height map image resource.
  69884. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69885. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69886. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69887. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69888. * * 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.
  69889. * * 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).
  69890. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69892. * @param name defines the name of the mesh
  69893. * @param url defines the url to the height map
  69894. * @param options defines the options used to create the mesh
  69895. * @param scene defines the hosting scene
  69896. * @returns the ground mesh
  69897. * @see https://doc.babylonjs.com/babylon101/height_map
  69898. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69899. */
  69900. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69901. width?: number;
  69902. height?: number;
  69903. subdivisions?: number;
  69904. minHeight?: number;
  69905. maxHeight?: number;
  69906. colorFilter?: Color3;
  69907. alphaFilter?: number;
  69908. updatable?: boolean;
  69909. onReady?: (mesh: GroundMesh) => void;
  69910. }, scene?: Nullable<Scene>): GroundMesh;
  69911. /**
  69912. * Creates a polygon mesh
  69913. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69914. * * 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
  69915. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69918. * * Remember you can only change the shape positions, not their number when updating a polygon
  69919. * @param name defines the name of the mesh
  69920. * @param options defines the options used to create the mesh
  69921. * @param scene defines the hosting scene
  69922. * @param earcutInjection can be used to inject your own earcut reference
  69923. * @returns the polygon mesh
  69924. */
  69925. static CreatePolygon(name: string, options: {
  69926. shape: Vector3[];
  69927. holes?: Vector3[][];
  69928. depth?: number;
  69929. faceUV?: Vector4[];
  69930. faceColors?: Color4[];
  69931. updatable?: boolean;
  69932. sideOrientation?: number;
  69933. frontUVs?: Vector4;
  69934. backUVs?: Vector4;
  69935. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69936. /**
  69937. * Creates an extruded polygon mesh, with depth in the Y direction.
  69938. * * 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)
  69939. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69940. * @param name defines the name of the mesh
  69941. * @param options defines the options used to create the mesh
  69942. * @param scene defines the hosting scene
  69943. * @param earcutInjection can be used to inject your own earcut reference
  69944. * @returns the polygon mesh
  69945. */
  69946. static ExtrudePolygon(name: string, options: {
  69947. shape: Vector3[];
  69948. holes?: Vector3[][];
  69949. depth?: number;
  69950. faceUV?: Vector4[];
  69951. faceColors?: Color4[];
  69952. updatable?: boolean;
  69953. sideOrientation?: number;
  69954. frontUVs?: Vector4;
  69955. backUVs?: Vector4;
  69956. wrap?: boolean;
  69957. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69958. /**
  69959. * Creates a tube mesh.
  69960. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69961. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69962. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69963. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69964. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69965. * * 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)
  69966. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69967. * * 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
  69968. * * 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
  69969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69973. * @param name defines the name of the mesh
  69974. * @param options defines the options used to create the mesh
  69975. * @param scene defines the hosting scene
  69976. * @returns the tube mesh
  69977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69978. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69979. */
  69980. static CreateTube(name: string, options: {
  69981. path: Vector3[];
  69982. radius?: number;
  69983. tessellation?: number;
  69984. radiusFunction?: {
  69985. (i: number, distance: number): number;
  69986. };
  69987. cap?: number;
  69988. arc?: number;
  69989. updatable?: boolean;
  69990. sideOrientation?: number;
  69991. frontUVs?: Vector4;
  69992. backUVs?: Vector4;
  69993. instance?: Mesh;
  69994. invertUV?: boolean;
  69995. }, scene?: Nullable<Scene>): Mesh;
  69996. /**
  69997. * Creates a polyhedron mesh
  69998. * * 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
  69999. * * The parameter `size` (positive float, default 1) sets the polygon size
  70000. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70001. * * 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`
  70002. * * 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
  70003. * * 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)`)
  70004. * * 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
  70005. * * 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
  70006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70009. * @param name defines the name of the mesh
  70010. * @param options defines the options used to create the mesh
  70011. * @param scene defines the hosting scene
  70012. * @returns the polyhedron mesh
  70013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70014. */
  70015. static CreatePolyhedron(name: string, options: {
  70016. type?: number;
  70017. size?: number;
  70018. sizeX?: number;
  70019. sizeY?: number;
  70020. sizeZ?: number;
  70021. custom?: any;
  70022. faceUV?: Vector4[];
  70023. faceColors?: Color4[];
  70024. flat?: boolean;
  70025. updatable?: boolean;
  70026. sideOrientation?: number;
  70027. frontUVs?: Vector4;
  70028. backUVs?: Vector4;
  70029. }, scene?: Nullable<Scene>): Mesh;
  70030. /**
  70031. * Creates a decal mesh.
  70032. * 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
  70033. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70034. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70035. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70036. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70037. * @param name defines the name of the mesh
  70038. * @param sourceMesh defines the mesh where the decal must be applied
  70039. * @param options defines the options used to create the mesh
  70040. * @param scene defines the hosting scene
  70041. * @returns the decal mesh
  70042. * @see https://doc.babylonjs.com/how_to/decals
  70043. */
  70044. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70045. position?: Vector3;
  70046. normal?: Vector3;
  70047. size?: Vector3;
  70048. angle?: number;
  70049. }): Mesh;
  70050. /**
  70051. * Creates a Capsule Mesh
  70052. * @param name defines the name of the mesh.
  70053. * @param options the constructors options used to shape the mesh.
  70054. * @param scene defines the scene the mesh is scoped to.
  70055. * @returns the capsule mesh
  70056. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70057. */
  70058. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70059. }
  70060. }
  70061. declare module "babylonjs/Meshes/meshSimplification" {
  70062. import { Mesh } from "babylonjs/Meshes/mesh";
  70063. /**
  70064. * A simplifier interface for future simplification implementations
  70065. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70066. */
  70067. export interface ISimplifier {
  70068. /**
  70069. * Simplification of a given mesh according to the given settings.
  70070. * Since this requires computation, it is assumed that the function runs async.
  70071. * @param settings The settings of the simplification, including quality and distance
  70072. * @param successCallback A callback that will be called after the mesh was simplified.
  70073. * @param errorCallback in case of an error, this callback will be called. optional.
  70074. */
  70075. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70076. }
  70077. /**
  70078. * Expected simplification settings.
  70079. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70080. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70081. */
  70082. export interface ISimplificationSettings {
  70083. /**
  70084. * Gets or sets the expected quality
  70085. */
  70086. quality: number;
  70087. /**
  70088. * Gets or sets the distance when this optimized version should be used
  70089. */
  70090. distance: number;
  70091. /**
  70092. * Gets an already optimized mesh
  70093. */
  70094. optimizeMesh?: boolean;
  70095. }
  70096. /**
  70097. * Class used to specify simplification options
  70098. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70099. */
  70100. export class SimplificationSettings implements ISimplificationSettings {
  70101. /** expected quality */
  70102. quality: number;
  70103. /** distance when this optimized version should be used */
  70104. distance: number;
  70105. /** already optimized mesh */
  70106. optimizeMesh?: boolean | undefined;
  70107. /**
  70108. * Creates a SimplificationSettings
  70109. * @param quality expected quality
  70110. * @param distance distance when this optimized version should be used
  70111. * @param optimizeMesh already optimized mesh
  70112. */
  70113. constructor(
  70114. /** expected quality */
  70115. quality: number,
  70116. /** distance when this optimized version should be used */
  70117. distance: number,
  70118. /** already optimized mesh */
  70119. optimizeMesh?: boolean | undefined);
  70120. }
  70121. /**
  70122. * Interface used to define a simplification task
  70123. */
  70124. export interface ISimplificationTask {
  70125. /**
  70126. * Array of settings
  70127. */
  70128. settings: Array<ISimplificationSettings>;
  70129. /**
  70130. * Simplification type
  70131. */
  70132. simplificationType: SimplificationType;
  70133. /**
  70134. * Mesh to simplify
  70135. */
  70136. mesh: Mesh;
  70137. /**
  70138. * Callback called on success
  70139. */
  70140. successCallback?: () => void;
  70141. /**
  70142. * Defines if parallel processing can be used
  70143. */
  70144. parallelProcessing: boolean;
  70145. }
  70146. /**
  70147. * Queue used to order the simplification tasks
  70148. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70149. */
  70150. export class SimplificationQueue {
  70151. private _simplificationArray;
  70152. /**
  70153. * Gets a boolean indicating that the process is still running
  70154. */
  70155. running: boolean;
  70156. /**
  70157. * Creates a new queue
  70158. */
  70159. constructor();
  70160. /**
  70161. * Adds a new simplification task
  70162. * @param task defines a task to add
  70163. */
  70164. addTask(task: ISimplificationTask): void;
  70165. /**
  70166. * Execute next task
  70167. */
  70168. executeNext(): void;
  70169. /**
  70170. * Execute a simplification task
  70171. * @param task defines the task to run
  70172. */
  70173. runSimplification(task: ISimplificationTask): void;
  70174. private getSimplifier;
  70175. }
  70176. /**
  70177. * The implemented types of simplification
  70178. * At the moment only Quadratic Error Decimation is implemented
  70179. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70180. */
  70181. export enum SimplificationType {
  70182. /** Quadratic error decimation */
  70183. QUADRATIC = 0
  70184. }
  70185. /**
  70186. * An implementation of the Quadratic Error simplification algorithm.
  70187. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70188. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70189. * @author RaananW
  70190. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70191. */
  70192. export class QuadraticErrorSimplification implements ISimplifier {
  70193. private _mesh;
  70194. private triangles;
  70195. private vertices;
  70196. private references;
  70197. private _reconstructedMesh;
  70198. /** Gets or sets the number pf sync interations */
  70199. syncIterations: number;
  70200. /** Gets or sets the aggressiveness of the simplifier */
  70201. aggressiveness: number;
  70202. /** Gets or sets the number of allowed iterations for decimation */
  70203. decimationIterations: number;
  70204. /** Gets or sets the espilon to use for bounding box computation */
  70205. boundingBoxEpsilon: number;
  70206. /**
  70207. * Creates a new QuadraticErrorSimplification
  70208. * @param _mesh defines the target mesh
  70209. */
  70210. constructor(_mesh: Mesh);
  70211. /**
  70212. * Simplification of a given mesh according to the given settings.
  70213. * Since this requires computation, it is assumed that the function runs async.
  70214. * @param settings The settings of the simplification, including quality and distance
  70215. * @param successCallback A callback that will be called after the mesh was simplified.
  70216. */
  70217. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70218. private runDecimation;
  70219. private initWithMesh;
  70220. private init;
  70221. private reconstructMesh;
  70222. private initDecimatedMesh;
  70223. private isFlipped;
  70224. private updateTriangles;
  70225. private identifyBorder;
  70226. private updateMesh;
  70227. private vertexError;
  70228. private calculateError;
  70229. }
  70230. }
  70231. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70232. import { Scene } from "babylonjs/scene";
  70233. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70234. import { ISceneComponent } from "babylonjs/sceneComponent";
  70235. module "babylonjs/scene" {
  70236. interface Scene {
  70237. /** @hidden (Backing field) */
  70238. _simplificationQueue: SimplificationQueue;
  70239. /**
  70240. * Gets or sets the simplification queue attached to the scene
  70241. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70242. */
  70243. simplificationQueue: SimplificationQueue;
  70244. }
  70245. }
  70246. module "babylonjs/Meshes/mesh" {
  70247. interface Mesh {
  70248. /**
  70249. * Simplify the mesh according to the given array of settings.
  70250. * Function will return immediately and will simplify async
  70251. * @param settings a collection of simplification settings
  70252. * @param parallelProcessing should all levels calculate parallel or one after the other
  70253. * @param simplificationType the type of simplification to run
  70254. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70255. * @returns the current mesh
  70256. */
  70257. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70258. }
  70259. }
  70260. /**
  70261. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70262. * created in a scene
  70263. */
  70264. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70265. /**
  70266. * The component name helpfull to identify the component in the list of scene components.
  70267. */
  70268. readonly name: string;
  70269. /**
  70270. * The scene the component belongs to.
  70271. */
  70272. scene: Scene;
  70273. /**
  70274. * Creates a new instance of the component for the given scene
  70275. * @param scene Defines the scene to register the component in
  70276. */
  70277. constructor(scene: Scene);
  70278. /**
  70279. * Registers the component in a given scene
  70280. */
  70281. register(): void;
  70282. /**
  70283. * Rebuilds the elements related to this component in case of
  70284. * context lost for instance.
  70285. */
  70286. rebuild(): void;
  70287. /**
  70288. * Disposes the component and the associated ressources
  70289. */
  70290. dispose(): void;
  70291. private _beforeCameraUpdate;
  70292. }
  70293. }
  70294. declare module "babylonjs/Meshes/Builders/index" {
  70295. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70296. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70297. export * from "babylonjs/Meshes/Builders/discBuilder";
  70298. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70299. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70300. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70301. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70302. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70303. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70304. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70305. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70306. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70307. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70308. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70309. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70310. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70311. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70312. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70313. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70314. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70315. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70316. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70317. }
  70318. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70319. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70320. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70321. import { Matrix } from "babylonjs/Maths/math.vector";
  70322. module "babylonjs/Meshes/mesh" {
  70323. interface Mesh {
  70324. /**
  70325. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70326. */
  70327. thinInstanceEnablePicking: boolean;
  70328. /**
  70329. * Creates a new thin instance
  70330. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70331. * @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
  70332. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70333. */
  70334. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70335. /**
  70336. * Adds the transformation (matrix) of the current mesh as a thin instance
  70337. * @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
  70338. * @returns the thin instance index number
  70339. */
  70340. thinInstanceAddSelf(refresh: boolean): number;
  70341. /**
  70342. * Registers a custom attribute to be used with thin instances
  70343. * @param kind name of the attribute
  70344. * @param stride size in floats of the attribute
  70345. */
  70346. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70347. /**
  70348. * Sets the matrix of a thin instance
  70349. * @param index index of the thin instance
  70350. * @param matrix matrix to set
  70351. * @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
  70352. */
  70353. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70354. /**
  70355. * Sets the value of a custom attribute for a thin instance
  70356. * @param kind name of the attribute
  70357. * @param index index of the thin instance
  70358. * @param value value to set
  70359. * @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
  70360. */
  70361. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70362. /**
  70363. * 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.
  70364. */
  70365. thinInstanceCount: number;
  70366. /**
  70367. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70368. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70369. * @param buffer buffer to set
  70370. * @param stride size in floats of each value of the buffer
  70371. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70372. */
  70373. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70374. /**
  70375. * Gets the list of world matrices
  70376. * @return an array containing all the world matrices from the thin instances
  70377. */
  70378. thinInstanceGetWorldMatrices(): Matrix[];
  70379. /**
  70380. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70381. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70382. */
  70383. thinInstanceBufferUpdated(kind: string): void;
  70384. /**
  70385. * Applies a partial update to a buffer directly on the GPU
  70386. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  70387. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70388. * @param data the data to set in the GPU buffer
  70389. * @param offset the offset in the GPU buffer where to update the data
  70390. */
  70391. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70392. /**
  70393. * Refreshes the bounding info, taking into account all the thin instances defined
  70394. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70395. */
  70396. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70397. /** @hidden */
  70398. _thinInstanceInitializeUserStorage(): void;
  70399. /** @hidden */
  70400. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70401. /** @hidden */
  70402. _userThinInstanceBuffersStorage: {
  70403. data: {
  70404. [key: string]: Float32Array;
  70405. };
  70406. sizes: {
  70407. [key: string]: number;
  70408. };
  70409. vertexBuffers: {
  70410. [key: string]: Nullable<VertexBuffer>;
  70411. };
  70412. strides: {
  70413. [key: string]: number;
  70414. };
  70415. };
  70416. }
  70417. }
  70418. }
  70419. declare module "babylonjs/Meshes/index" {
  70420. export * from "babylonjs/Meshes/abstractMesh";
  70421. export * from "babylonjs/Meshes/buffer";
  70422. export * from "babylonjs/Meshes/Compression/index";
  70423. export * from "babylonjs/Meshes/csg";
  70424. export * from "babylonjs/Meshes/geometry";
  70425. export * from "babylonjs/Meshes/groundMesh";
  70426. export * from "babylonjs/Meshes/trailMesh";
  70427. export * from "babylonjs/Meshes/instancedMesh";
  70428. export * from "babylonjs/Meshes/linesMesh";
  70429. export * from "babylonjs/Meshes/mesh";
  70430. export * from "babylonjs/Meshes/mesh.vertexData";
  70431. export * from "babylonjs/Meshes/meshBuilder";
  70432. export * from "babylonjs/Meshes/meshSimplification";
  70433. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70434. export * from "babylonjs/Meshes/polygonMesh";
  70435. export * from "babylonjs/Meshes/subMesh";
  70436. export * from "babylonjs/Meshes/meshLODLevel";
  70437. export * from "babylonjs/Meshes/transformNode";
  70438. export * from "babylonjs/Meshes/Builders/index";
  70439. export * from "babylonjs/Meshes/dataBuffer";
  70440. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70441. import "babylonjs/Meshes/thinInstanceMesh";
  70442. export * from "babylonjs/Meshes/thinInstanceMesh";
  70443. }
  70444. declare module "babylonjs/Morph/index" {
  70445. export * from "babylonjs/Morph/morphTarget";
  70446. export * from "babylonjs/Morph/morphTargetManager";
  70447. }
  70448. declare module "babylonjs/Navigation/INavigationEngine" {
  70449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70450. import { Vector3 } from "babylonjs/Maths/math";
  70451. import { Mesh } from "babylonjs/Meshes/mesh";
  70452. import { Scene } from "babylonjs/scene";
  70453. /**
  70454. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70455. */
  70456. export interface INavigationEnginePlugin {
  70457. /**
  70458. * plugin name
  70459. */
  70460. name: string;
  70461. /**
  70462. * Creates a navigation mesh
  70463. * @param meshes array of all the geometry used to compute the navigatio mesh
  70464. * @param parameters bunch of parameters used to filter geometry
  70465. */
  70466. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70467. /**
  70468. * Create a navigation mesh debug mesh
  70469. * @param scene is where the mesh will be added
  70470. * @returns debug display mesh
  70471. */
  70472. createDebugNavMesh(scene: Scene): Mesh;
  70473. /**
  70474. * Get a navigation mesh constrained position, closest to the parameter position
  70475. * @param position world position
  70476. * @returns the closest point to position constrained by the navigation mesh
  70477. */
  70478. getClosestPoint(position: Vector3): Vector3;
  70479. /**
  70480. * Get a navigation mesh constrained position, closest to the parameter position
  70481. * @param position world position
  70482. * @param result output the closest point to position constrained by the navigation mesh
  70483. */
  70484. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70485. /**
  70486. * Get a navigation mesh constrained position, within a particular radius
  70487. * @param position world position
  70488. * @param maxRadius the maximum distance to the constrained world position
  70489. * @returns the closest point to position constrained by the navigation mesh
  70490. */
  70491. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70492. /**
  70493. * Get a navigation mesh constrained position, within a particular radius
  70494. * @param position world position
  70495. * @param maxRadius the maximum distance to the constrained world position
  70496. * @param result output the closest point to position constrained by the navigation mesh
  70497. */
  70498. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70499. /**
  70500. * Compute the final position from a segment made of destination-position
  70501. * @param position world position
  70502. * @param destination world position
  70503. * @returns the resulting point along the navmesh
  70504. */
  70505. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70506. /**
  70507. * Compute the final position from a segment made of destination-position
  70508. * @param position world position
  70509. * @param destination world position
  70510. * @param result output the resulting point along the navmesh
  70511. */
  70512. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70513. /**
  70514. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70515. * @param start world position
  70516. * @param end world position
  70517. * @returns array containing world position composing the path
  70518. */
  70519. computePath(start: Vector3, end: Vector3): Vector3[];
  70520. /**
  70521. * If this plugin is supported
  70522. * @returns true if plugin is supported
  70523. */
  70524. isSupported(): boolean;
  70525. /**
  70526. * Create a new Crowd so you can add agents
  70527. * @param maxAgents the maximum agent count in the crowd
  70528. * @param maxAgentRadius the maximum radius an agent can have
  70529. * @param scene to attach the crowd to
  70530. * @returns the crowd you can add agents to
  70531. */
  70532. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70533. /**
  70534. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70535. * The queries will try to find a solution within those bounds
  70536. * default is (1,1,1)
  70537. * @param extent x,y,z value that define the extent around the queries point of reference
  70538. */
  70539. setDefaultQueryExtent(extent: Vector3): void;
  70540. /**
  70541. * Get the Bounding box extent specified by setDefaultQueryExtent
  70542. * @returns the box extent values
  70543. */
  70544. getDefaultQueryExtent(): Vector3;
  70545. /**
  70546. * build the navmesh from a previously saved state using getNavmeshData
  70547. * @param data the Uint8Array returned by getNavmeshData
  70548. */
  70549. buildFromNavmeshData(data: Uint8Array): void;
  70550. /**
  70551. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70552. * @returns data the Uint8Array that can be saved and reused
  70553. */
  70554. getNavmeshData(): Uint8Array;
  70555. /**
  70556. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70557. * @param result output the box extent values
  70558. */
  70559. getDefaultQueryExtentToRef(result: Vector3): void;
  70560. /**
  70561. * Release all resources
  70562. */
  70563. dispose(): void;
  70564. }
  70565. /**
  70566. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70567. */
  70568. export interface ICrowd {
  70569. /**
  70570. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70571. * You can attach anything to that node. The node position is updated in the scene update tick.
  70572. * @param pos world position that will be constrained by the navigation mesh
  70573. * @param parameters agent parameters
  70574. * @param transform hooked to the agent that will be update by the scene
  70575. * @returns agent index
  70576. */
  70577. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70578. /**
  70579. * Returns the agent position in world space
  70580. * @param index agent index returned by addAgent
  70581. * @returns world space position
  70582. */
  70583. getAgentPosition(index: number): Vector3;
  70584. /**
  70585. * Gets the agent position result in world space
  70586. * @param index agent index returned by addAgent
  70587. * @param result output world space position
  70588. */
  70589. getAgentPositionToRef(index: number, result: Vector3): void;
  70590. /**
  70591. * Gets the agent velocity in world space
  70592. * @param index agent index returned by addAgent
  70593. * @returns world space velocity
  70594. */
  70595. getAgentVelocity(index: number): Vector3;
  70596. /**
  70597. * Gets the agent velocity result in world space
  70598. * @param index agent index returned by addAgent
  70599. * @param result output world space velocity
  70600. */
  70601. getAgentVelocityToRef(index: number, result: Vector3): void;
  70602. /**
  70603. * remove a particular agent previously created
  70604. * @param index agent index returned by addAgent
  70605. */
  70606. removeAgent(index: number): void;
  70607. /**
  70608. * get the list of all agents attached to this crowd
  70609. * @returns list of agent indices
  70610. */
  70611. getAgents(): number[];
  70612. /**
  70613. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70614. * @param deltaTime in seconds
  70615. */
  70616. update(deltaTime: number): void;
  70617. /**
  70618. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70619. * @param index agent index returned by addAgent
  70620. * @param destination targeted world position
  70621. */
  70622. agentGoto(index: number, destination: Vector3): void;
  70623. /**
  70624. * Teleport the agent to a new position
  70625. * @param index agent index returned by addAgent
  70626. * @param destination targeted world position
  70627. */
  70628. agentTeleport(index: number, destination: Vector3): void;
  70629. /**
  70630. * Update agent parameters
  70631. * @param index agent index returned by addAgent
  70632. * @param parameters agent parameters
  70633. */
  70634. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70635. /**
  70636. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70637. * The queries will try to find a solution within those bounds
  70638. * default is (1,1,1)
  70639. * @param extent x,y,z value that define the extent around the queries point of reference
  70640. */
  70641. setDefaultQueryExtent(extent: Vector3): void;
  70642. /**
  70643. * Get the Bounding box extent specified by setDefaultQueryExtent
  70644. * @returns the box extent values
  70645. */
  70646. getDefaultQueryExtent(): Vector3;
  70647. /**
  70648. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70649. * @param result output the box extent values
  70650. */
  70651. getDefaultQueryExtentToRef(result: Vector3): void;
  70652. /**
  70653. * Release all resources
  70654. */
  70655. dispose(): void;
  70656. }
  70657. /**
  70658. * Configures an agent
  70659. */
  70660. export interface IAgentParameters {
  70661. /**
  70662. * Agent radius. [Limit: >= 0]
  70663. */
  70664. radius: number;
  70665. /**
  70666. * Agent height. [Limit: > 0]
  70667. */
  70668. height: number;
  70669. /**
  70670. * Maximum allowed acceleration. [Limit: >= 0]
  70671. */
  70672. maxAcceleration: number;
  70673. /**
  70674. * Maximum allowed speed. [Limit: >= 0]
  70675. */
  70676. maxSpeed: number;
  70677. /**
  70678. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70679. */
  70680. collisionQueryRange: number;
  70681. /**
  70682. * The path visibility optimization range. [Limit: > 0]
  70683. */
  70684. pathOptimizationRange: number;
  70685. /**
  70686. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70687. */
  70688. separationWeight: number;
  70689. }
  70690. /**
  70691. * Configures the navigation mesh creation
  70692. */
  70693. export interface INavMeshParameters {
  70694. /**
  70695. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70696. */
  70697. cs: number;
  70698. /**
  70699. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70700. */
  70701. ch: number;
  70702. /**
  70703. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70704. */
  70705. walkableSlopeAngle: number;
  70706. /**
  70707. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70708. * be considered walkable. [Limit: >= 3] [Units: vx]
  70709. */
  70710. walkableHeight: number;
  70711. /**
  70712. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70713. */
  70714. walkableClimb: number;
  70715. /**
  70716. * The distance to erode/shrink the walkable area of the heightfield away from
  70717. * obstructions. [Limit: >=0] [Units: vx]
  70718. */
  70719. walkableRadius: number;
  70720. /**
  70721. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70722. */
  70723. maxEdgeLen: number;
  70724. /**
  70725. * The maximum distance a simplfied contour's border edges should deviate
  70726. * the original raw contour. [Limit: >=0] [Units: vx]
  70727. */
  70728. maxSimplificationError: number;
  70729. /**
  70730. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70731. */
  70732. minRegionArea: number;
  70733. /**
  70734. * Any regions with a span count smaller than this value will, if possible,
  70735. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70736. */
  70737. mergeRegionArea: number;
  70738. /**
  70739. * The maximum number of vertices allowed for polygons generated during the
  70740. * contour to polygon conversion process. [Limit: >= 3]
  70741. */
  70742. maxVertsPerPoly: number;
  70743. /**
  70744. * Sets the sampling distance to use when generating the detail mesh.
  70745. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70746. */
  70747. detailSampleDist: number;
  70748. /**
  70749. * The maximum distance the detail mesh surface should deviate from heightfield
  70750. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70751. */
  70752. detailSampleMaxError: number;
  70753. }
  70754. }
  70755. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70756. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70757. import { Mesh } from "babylonjs/Meshes/mesh";
  70758. import { Scene } from "babylonjs/scene";
  70759. import { Vector3 } from "babylonjs/Maths/math";
  70760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70761. /**
  70762. * RecastJS navigation plugin
  70763. */
  70764. export class RecastJSPlugin implements INavigationEnginePlugin {
  70765. /**
  70766. * Reference to the Recast library
  70767. */
  70768. bjsRECAST: any;
  70769. /**
  70770. * plugin name
  70771. */
  70772. name: string;
  70773. /**
  70774. * the first navmesh created. We might extend this to support multiple navmeshes
  70775. */
  70776. navMesh: any;
  70777. /**
  70778. * Initializes the recastJS plugin
  70779. * @param recastInjection can be used to inject your own recast reference
  70780. */
  70781. constructor(recastInjection?: any);
  70782. /**
  70783. * Creates a navigation mesh
  70784. * @param meshes array of all the geometry used to compute the navigatio mesh
  70785. * @param parameters bunch of parameters used to filter geometry
  70786. */
  70787. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70788. /**
  70789. * Create a navigation mesh debug mesh
  70790. * @param scene is where the mesh will be added
  70791. * @returns debug display mesh
  70792. */
  70793. createDebugNavMesh(scene: Scene): Mesh;
  70794. /**
  70795. * Get a navigation mesh constrained position, closest to the parameter position
  70796. * @param position world position
  70797. * @returns the closest point to position constrained by the navigation mesh
  70798. */
  70799. getClosestPoint(position: Vector3): Vector3;
  70800. /**
  70801. * Get a navigation mesh constrained position, closest to the parameter position
  70802. * @param position world position
  70803. * @param result output the closest point to position constrained by the navigation mesh
  70804. */
  70805. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70806. /**
  70807. * Get a navigation mesh constrained position, within a particular radius
  70808. * @param position world position
  70809. * @param maxRadius the maximum distance to the constrained world position
  70810. * @returns the closest point to position constrained by the navigation mesh
  70811. */
  70812. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70813. /**
  70814. * Get a navigation mesh constrained position, within a particular radius
  70815. * @param position world position
  70816. * @param maxRadius the maximum distance to the constrained world position
  70817. * @param result output the closest point to position constrained by the navigation mesh
  70818. */
  70819. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70820. /**
  70821. * Compute the final position from a segment made of destination-position
  70822. * @param position world position
  70823. * @param destination world position
  70824. * @returns the resulting point along the navmesh
  70825. */
  70826. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70827. /**
  70828. * Compute the final position from a segment made of destination-position
  70829. * @param position world position
  70830. * @param destination world position
  70831. * @param result output the resulting point along the navmesh
  70832. */
  70833. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70834. /**
  70835. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70836. * @param start world position
  70837. * @param end world position
  70838. * @returns array containing world position composing the path
  70839. */
  70840. computePath(start: Vector3, end: Vector3): Vector3[];
  70841. /**
  70842. * Create a new Crowd so you can add agents
  70843. * @param maxAgents the maximum agent count in the crowd
  70844. * @param maxAgentRadius the maximum radius an agent can have
  70845. * @param scene to attach the crowd to
  70846. * @returns the crowd you can add agents to
  70847. */
  70848. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70849. /**
  70850. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70851. * The queries will try to find a solution within those bounds
  70852. * default is (1,1,1)
  70853. * @param extent x,y,z value that define the extent around the queries point of reference
  70854. */
  70855. setDefaultQueryExtent(extent: Vector3): void;
  70856. /**
  70857. * Get the Bounding box extent specified by setDefaultQueryExtent
  70858. * @returns the box extent values
  70859. */
  70860. getDefaultQueryExtent(): Vector3;
  70861. /**
  70862. * build the navmesh from a previously saved state using getNavmeshData
  70863. * @param data the Uint8Array returned by getNavmeshData
  70864. */
  70865. buildFromNavmeshData(data: Uint8Array): void;
  70866. /**
  70867. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70868. * @returns data the Uint8Array that can be saved and reused
  70869. */
  70870. getNavmeshData(): Uint8Array;
  70871. /**
  70872. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70873. * @param result output the box extent values
  70874. */
  70875. getDefaultQueryExtentToRef(result: Vector3): void;
  70876. /**
  70877. * Disposes
  70878. */
  70879. dispose(): void;
  70880. /**
  70881. * If this plugin is supported
  70882. * @returns true if plugin is supported
  70883. */
  70884. isSupported(): boolean;
  70885. }
  70886. /**
  70887. * Recast detour crowd implementation
  70888. */
  70889. export class RecastJSCrowd implements ICrowd {
  70890. /**
  70891. * Recast/detour plugin
  70892. */
  70893. bjsRECASTPlugin: RecastJSPlugin;
  70894. /**
  70895. * Link to the detour crowd
  70896. */
  70897. recastCrowd: any;
  70898. /**
  70899. * One transform per agent
  70900. */
  70901. transforms: TransformNode[];
  70902. /**
  70903. * All agents created
  70904. */
  70905. agents: number[];
  70906. /**
  70907. * Link to the scene is kept to unregister the crowd from the scene
  70908. */
  70909. private _scene;
  70910. /**
  70911. * Observer for crowd updates
  70912. */
  70913. private _onBeforeAnimationsObserver;
  70914. /**
  70915. * Constructor
  70916. * @param plugin recastJS plugin
  70917. * @param maxAgents the maximum agent count in the crowd
  70918. * @param maxAgentRadius the maximum radius an agent can have
  70919. * @param scene to attach the crowd to
  70920. * @returns the crowd you can add agents to
  70921. */
  70922. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70923. /**
  70924. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70925. * You can attach anything to that node. The node position is updated in the scene update tick.
  70926. * @param pos world position that will be constrained by the navigation mesh
  70927. * @param parameters agent parameters
  70928. * @param transform hooked to the agent that will be update by the scene
  70929. * @returns agent index
  70930. */
  70931. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70932. /**
  70933. * Returns the agent position in world space
  70934. * @param index agent index returned by addAgent
  70935. * @returns world space position
  70936. */
  70937. getAgentPosition(index: number): Vector3;
  70938. /**
  70939. * Returns the agent position result in world space
  70940. * @param index agent index returned by addAgent
  70941. * @param result output world space position
  70942. */
  70943. getAgentPositionToRef(index: number, result: Vector3): void;
  70944. /**
  70945. * Returns the agent velocity in world space
  70946. * @param index agent index returned by addAgent
  70947. * @returns world space velocity
  70948. */
  70949. getAgentVelocity(index: number): Vector3;
  70950. /**
  70951. * Returns the agent velocity result in world space
  70952. * @param index agent index returned by addAgent
  70953. * @param result output world space velocity
  70954. */
  70955. getAgentVelocityToRef(index: number, result: Vector3): void;
  70956. /**
  70957. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70958. * @param index agent index returned by addAgent
  70959. * @param destination targeted world position
  70960. */
  70961. agentGoto(index: number, destination: Vector3): void;
  70962. /**
  70963. * Teleport the agent to a new position
  70964. * @param index agent index returned by addAgent
  70965. * @param destination targeted world position
  70966. */
  70967. agentTeleport(index: number, destination: Vector3): void;
  70968. /**
  70969. * Update agent parameters
  70970. * @param index agent index returned by addAgent
  70971. * @param parameters agent parameters
  70972. */
  70973. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70974. /**
  70975. * remove a particular agent previously created
  70976. * @param index agent index returned by addAgent
  70977. */
  70978. removeAgent(index: number): void;
  70979. /**
  70980. * get the list of all agents attached to this crowd
  70981. * @returns list of agent indices
  70982. */
  70983. getAgents(): number[];
  70984. /**
  70985. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70986. * @param deltaTime in seconds
  70987. */
  70988. update(deltaTime: number): void;
  70989. /**
  70990. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70991. * The queries will try to find a solution within those bounds
  70992. * default is (1,1,1)
  70993. * @param extent x,y,z value that define the extent around the queries point of reference
  70994. */
  70995. setDefaultQueryExtent(extent: Vector3): void;
  70996. /**
  70997. * Get the Bounding box extent specified by setDefaultQueryExtent
  70998. * @returns the box extent values
  70999. */
  71000. getDefaultQueryExtent(): Vector3;
  71001. /**
  71002. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71003. * @param result output the box extent values
  71004. */
  71005. getDefaultQueryExtentToRef(result: Vector3): void;
  71006. /**
  71007. * Release all resources
  71008. */
  71009. dispose(): void;
  71010. }
  71011. }
  71012. declare module "babylonjs/Navigation/Plugins/index" {
  71013. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71014. }
  71015. declare module "babylonjs/Navigation/index" {
  71016. export * from "babylonjs/Navigation/INavigationEngine";
  71017. export * from "babylonjs/Navigation/Plugins/index";
  71018. }
  71019. declare module "babylonjs/Offline/database" {
  71020. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71021. /**
  71022. * Class used to enable access to IndexedDB
  71023. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71024. */
  71025. export class Database implements IOfflineProvider {
  71026. private _callbackManifestChecked;
  71027. private _currentSceneUrl;
  71028. private _db;
  71029. private _enableSceneOffline;
  71030. private _enableTexturesOffline;
  71031. private _manifestVersionFound;
  71032. private _mustUpdateRessources;
  71033. private _hasReachedQuota;
  71034. private _isSupported;
  71035. private _idbFactory;
  71036. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71037. private static IsUASupportingBlobStorage;
  71038. /**
  71039. * Gets a boolean indicating if Database storate is enabled (off by default)
  71040. */
  71041. static IDBStorageEnabled: boolean;
  71042. /**
  71043. * Gets a boolean indicating if scene must be saved in the database
  71044. */
  71045. get enableSceneOffline(): boolean;
  71046. /**
  71047. * Gets a boolean indicating if textures must be saved in the database
  71048. */
  71049. get enableTexturesOffline(): boolean;
  71050. /**
  71051. * Creates a new Database
  71052. * @param urlToScene defines the url to load the scene
  71053. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71054. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71055. */
  71056. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71057. private static _ParseURL;
  71058. private static _ReturnFullUrlLocation;
  71059. private _checkManifestFile;
  71060. /**
  71061. * Open the database and make it available
  71062. * @param successCallback defines the callback to call on success
  71063. * @param errorCallback defines the callback to call on error
  71064. */
  71065. open(successCallback: () => void, errorCallback: () => void): void;
  71066. /**
  71067. * Loads an image from the database
  71068. * @param url defines the url to load from
  71069. * @param image defines the target DOM image
  71070. */
  71071. loadImage(url: string, image: HTMLImageElement): void;
  71072. private _loadImageFromDBAsync;
  71073. private _saveImageIntoDBAsync;
  71074. private _checkVersionFromDB;
  71075. private _loadVersionFromDBAsync;
  71076. private _saveVersionIntoDBAsync;
  71077. /**
  71078. * Loads a file from database
  71079. * @param url defines the URL to load from
  71080. * @param sceneLoaded defines a callback to call on success
  71081. * @param progressCallBack defines a callback to call when progress changed
  71082. * @param errorCallback defines a callback to call on error
  71083. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71084. */
  71085. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71086. private _loadFileAsync;
  71087. private _saveFileAsync;
  71088. /**
  71089. * Validates if xhr data is correct
  71090. * @param xhr defines the request to validate
  71091. * @param dataType defines the expected data type
  71092. * @returns true if data is correct
  71093. */
  71094. private static _ValidateXHRData;
  71095. }
  71096. }
  71097. declare module "babylonjs/Offline/index" {
  71098. export * from "babylonjs/Offline/database";
  71099. export * from "babylonjs/Offline/IOfflineProvider";
  71100. }
  71101. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71102. /** @hidden */
  71103. export var gpuUpdateParticlesPixelShader: {
  71104. name: string;
  71105. shader: string;
  71106. };
  71107. }
  71108. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71109. /** @hidden */
  71110. export var gpuUpdateParticlesVertexShader: {
  71111. name: string;
  71112. shader: string;
  71113. };
  71114. }
  71115. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71116. /** @hidden */
  71117. export var clipPlaneFragmentDeclaration2: {
  71118. name: string;
  71119. shader: string;
  71120. };
  71121. }
  71122. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71123. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71124. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71125. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71126. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71127. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71128. /** @hidden */
  71129. export var gpuRenderParticlesPixelShader: {
  71130. name: string;
  71131. shader: string;
  71132. };
  71133. }
  71134. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71135. /** @hidden */
  71136. export var clipPlaneVertexDeclaration2: {
  71137. name: string;
  71138. shader: string;
  71139. };
  71140. }
  71141. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71142. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71144. /** @hidden */
  71145. export var gpuRenderParticlesVertexShader: {
  71146. name: string;
  71147. shader: string;
  71148. };
  71149. }
  71150. declare module "babylonjs/Particles/gpuParticleSystem" {
  71151. import { Nullable } from "babylonjs/types";
  71152. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71153. import { Observable } from "babylonjs/Misc/observable";
  71154. import { Matrix } from "babylonjs/Maths/math.vector";
  71155. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71156. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71157. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71158. import { IDisposable } from "babylonjs/scene";
  71159. import { Effect } from "babylonjs/Materials/effect";
  71160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71161. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71163. import { Scene } from "babylonjs/scene";
  71164. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71165. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71166. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71167. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71168. /**
  71169. * This represents a GPU particle system in Babylon
  71170. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71171. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71172. */
  71173. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71174. /**
  71175. * The layer mask we are rendering the particles through.
  71176. */
  71177. layerMask: number;
  71178. private _capacity;
  71179. private _activeCount;
  71180. private _currentActiveCount;
  71181. private _accumulatedCount;
  71182. private _renderEffect;
  71183. private _updateEffect;
  71184. private _buffer0;
  71185. private _buffer1;
  71186. private _spriteBuffer;
  71187. private _updateVAO;
  71188. private _renderVAO;
  71189. private _targetIndex;
  71190. private _sourceBuffer;
  71191. private _targetBuffer;
  71192. private _currentRenderId;
  71193. private _started;
  71194. private _stopped;
  71195. private _timeDelta;
  71196. private _randomTexture;
  71197. private _randomTexture2;
  71198. private _attributesStrideSize;
  71199. private _updateEffectOptions;
  71200. private _randomTextureSize;
  71201. private _actualFrame;
  71202. private _customEffect;
  71203. private readonly _rawTextureWidth;
  71204. /**
  71205. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71206. */
  71207. static get IsSupported(): boolean;
  71208. /**
  71209. * An event triggered when the system is disposed.
  71210. */
  71211. onDisposeObservable: Observable<IParticleSystem>;
  71212. /**
  71213. * Gets the maximum number of particles active at the same time.
  71214. * @returns The max number of active particles.
  71215. */
  71216. getCapacity(): number;
  71217. /**
  71218. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71219. * to override the particles.
  71220. */
  71221. forceDepthWrite: boolean;
  71222. /**
  71223. * Gets or set the number of active particles
  71224. */
  71225. get activeParticleCount(): number;
  71226. set activeParticleCount(value: number);
  71227. private _preWarmDone;
  71228. /**
  71229. * Specifies if the particles are updated in emitter local space or world space.
  71230. */
  71231. isLocal: boolean;
  71232. /** Gets or sets a matrix to use to compute projection */
  71233. defaultProjectionMatrix: Matrix;
  71234. /**
  71235. * Is this system ready to be used/rendered
  71236. * @return true if the system is ready
  71237. */
  71238. isReady(): boolean;
  71239. /**
  71240. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71241. * @returns True if it has been started, otherwise false.
  71242. */
  71243. isStarted(): boolean;
  71244. /**
  71245. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71246. * @returns True if it has been stopped, otherwise false.
  71247. */
  71248. isStopped(): boolean;
  71249. /**
  71250. * Gets a boolean indicating that the system is stopping
  71251. * @returns true if the system is currently stopping
  71252. */
  71253. isStopping(): boolean;
  71254. /**
  71255. * Gets the number of particles active at the same time.
  71256. * @returns The number of active particles.
  71257. */
  71258. getActiveCount(): number;
  71259. /**
  71260. * Starts the particle system and begins to emit
  71261. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71262. */
  71263. start(delay?: number): void;
  71264. /**
  71265. * Stops the particle system.
  71266. */
  71267. stop(): void;
  71268. /**
  71269. * Remove all active particles
  71270. */
  71271. reset(): void;
  71272. /**
  71273. * Returns the string "GPUParticleSystem"
  71274. * @returns a string containing the class name
  71275. */
  71276. getClassName(): string;
  71277. /**
  71278. * Gets the custom effect used to render the particles
  71279. * @param blendMode Blend mode for which the effect should be retrieved
  71280. * @returns The effect
  71281. */
  71282. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71283. /**
  71284. * Sets the custom effect used to render the particles
  71285. * @param effect The effect to set
  71286. * @param blendMode Blend mode for which the effect should be set
  71287. */
  71288. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71289. /** @hidden */
  71290. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71291. /**
  71292. * Observable that will be called just before the particles are drawn
  71293. */
  71294. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71295. /**
  71296. * Gets the name of the particle vertex shader
  71297. */
  71298. get vertexShaderName(): string;
  71299. private _colorGradientsTexture;
  71300. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71301. /**
  71302. * Adds a new color gradient
  71303. * @param gradient defines the gradient to use (between 0 and 1)
  71304. * @param color1 defines the color to affect to the specified gradient
  71305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71306. * @returns the current particle system
  71307. */
  71308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71309. private _refreshColorGradient;
  71310. /** Force the system to rebuild all gradients that need to be resync */
  71311. forceRefreshGradients(): void;
  71312. /**
  71313. * Remove a specific color gradient
  71314. * @param gradient defines the gradient to remove
  71315. * @returns the current particle system
  71316. */
  71317. removeColorGradient(gradient: number): GPUParticleSystem;
  71318. private _angularSpeedGradientsTexture;
  71319. private _sizeGradientsTexture;
  71320. private _velocityGradientsTexture;
  71321. private _limitVelocityGradientsTexture;
  71322. private _dragGradientsTexture;
  71323. private _addFactorGradient;
  71324. /**
  71325. * Adds a new size gradient
  71326. * @param gradient defines the gradient to use (between 0 and 1)
  71327. * @param factor defines the size factor to affect to the specified gradient
  71328. * @returns the current particle system
  71329. */
  71330. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71331. /**
  71332. * Remove a specific size gradient
  71333. * @param gradient defines the gradient to remove
  71334. * @returns the current particle system
  71335. */
  71336. removeSizeGradient(gradient: number): GPUParticleSystem;
  71337. private _refreshFactorGradient;
  71338. /**
  71339. * Adds a new angular speed gradient
  71340. * @param gradient defines the gradient to use (between 0 and 1)
  71341. * @param factor defines the angular speed to affect to the specified gradient
  71342. * @returns the current particle system
  71343. */
  71344. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71345. /**
  71346. * Remove a specific angular speed gradient
  71347. * @param gradient defines the gradient to remove
  71348. * @returns the current particle system
  71349. */
  71350. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71351. /**
  71352. * Adds a new velocity gradient
  71353. * @param gradient defines the gradient to use (between 0 and 1)
  71354. * @param factor defines the velocity to affect to the specified gradient
  71355. * @returns the current particle system
  71356. */
  71357. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71358. /**
  71359. * Remove a specific velocity gradient
  71360. * @param gradient defines the gradient to remove
  71361. * @returns the current particle system
  71362. */
  71363. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71364. /**
  71365. * Adds a new limit velocity gradient
  71366. * @param gradient defines the gradient to use (between 0 and 1)
  71367. * @param factor defines the limit velocity value to affect to the specified gradient
  71368. * @returns the current particle system
  71369. */
  71370. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71371. /**
  71372. * Remove a specific limit velocity gradient
  71373. * @param gradient defines the gradient to remove
  71374. * @returns the current particle system
  71375. */
  71376. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71377. /**
  71378. * Adds a new drag gradient
  71379. * @param gradient defines the gradient to use (between 0 and 1)
  71380. * @param factor defines the drag value to affect to the specified gradient
  71381. * @returns the current particle system
  71382. */
  71383. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71384. /**
  71385. * Remove a specific drag gradient
  71386. * @param gradient defines the gradient to remove
  71387. * @returns the current particle system
  71388. */
  71389. removeDragGradient(gradient: number): GPUParticleSystem;
  71390. /**
  71391. * Not supported by GPUParticleSystem
  71392. * @param gradient defines the gradient to use (between 0 and 1)
  71393. * @param factor defines the emit rate value to affect to the specified gradient
  71394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71395. * @returns the current particle system
  71396. */
  71397. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71398. /**
  71399. * Not supported by GPUParticleSystem
  71400. * @param gradient defines the gradient to remove
  71401. * @returns the current particle system
  71402. */
  71403. removeEmitRateGradient(gradient: number): IParticleSystem;
  71404. /**
  71405. * Not supported by GPUParticleSystem
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param factor defines the start size value to affect to the specified gradient
  71408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71409. * @returns the current particle system
  71410. */
  71411. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71412. /**
  71413. * Not supported by GPUParticleSystem
  71414. * @param gradient defines the gradient to remove
  71415. * @returns the current particle system
  71416. */
  71417. removeStartSizeGradient(gradient: number): IParticleSystem;
  71418. /**
  71419. * Not supported by GPUParticleSystem
  71420. * @param gradient defines the gradient to use (between 0 and 1)
  71421. * @param min defines the color remap minimal range
  71422. * @param max defines the color remap maximal range
  71423. * @returns the current particle system
  71424. */
  71425. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71426. /**
  71427. * Not supported by GPUParticleSystem
  71428. * @param gradient defines the gradient to remove
  71429. * @returns the current particle system
  71430. */
  71431. removeColorRemapGradient(): IParticleSystem;
  71432. /**
  71433. * Not supported by GPUParticleSystem
  71434. * @param gradient defines the gradient to use (between 0 and 1)
  71435. * @param min defines the alpha remap minimal range
  71436. * @param max defines the alpha remap maximal range
  71437. * @returns the current particle system
  71438. */
  71439. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71440. /**
  71441. * Not supported by GPUParticleSystem
  71442. * @param gradient defines the gradient to remove
  71443. * @returns the current particle system
  71444. */
  71445. removeAlphaRemapGradient(): IParticleSystem;
  71446. /**
  71447. * Not supported by GPUParticleSystem
  71448. * @param gradient defines the gradient to use (between 0 and 1)
  71449. * @param color defines the color to affect to the specified gradient
  71450. * @returns the current particle system
  71451. */
  71452. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71453. /**
  71454. * Not supported by GPUParticleSystem
  71455. * @param gradient defines the gradient to remove
  71456. * @returns the current particle system
  71457. */
  71458. removeRampGradient(): IParticleSystem;
  71459. /**
  71460. * Not supported by GPUParticleSystem
  71461. * @returns the list of ramp gradients
  71462. */
  71463. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71464. /**
  71465. * Not supported by GPUParticleSystem
  71466. * Gets or sets a boolean indicating that ramp gradients must be used
  71467. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71468. */
  71469. get useRampGradients(): boolean;
  71470. set useRampGradients(value: boolean);
  71471. /**
  71472. * Not supported by GPUParticleSystem
  71473. * @param gradient defines the gradient to use (between 0 and 1)
  71474. * @param factor defines the life time factor to affect to the specified gradient
  71475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71476. * @returns the current particle system
  71477. */
  71478. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71479. /**
  71480. * Not supported by GPUParticleSystem
  71481. * @param gradient defines the gradient to remove
  71482. * @returns the current particle system
  71483. */
  71484. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71485. /**
  71486. * Instantiates a GPU particle system.
  71487. * 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.
  71488. * @param name The name of the particle system
  71489. * @param options The options used to create the system
  71490. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71491. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71492. * @param customEffect a custom effect used to change the way particles are rendered by default
  71493. */
  71494. constructor(name: string, options: Partial<{
  71495. capacity: number;
  71496. randomTextureSize: number;
  71497. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71498. protected _reset(): void;
  71499. private _createUpdateVAO;
  71500. private _createRenderVAO;
  71501. private _initialize;
  71502. /** @hidden */
  71503. _recreateUpdateEffect(): void;
  71504. private _getEffect;
  71505. /**
  71506. * Fill the defines array according to the current settings of the particle system
  71507. * @param defines Array to be updated
  71508. * @param blendMode blend mode to take into account when updating the array
  71509. */
  71510. fillDefines(defines: Array<string>, blendMode?: number): void;
  71511. /**
  71512. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71513. * @param uniforms Uniforms array to fill
  71514. * @param attributes Attributes array to fill
  71515. * @param samplers Samplers array to fill
  71516. */
  71517. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71518. /** @hidden */
  71519. _recreateRenderEffect(): Effect;
  71520. /**
  71521. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71522. * @param preWarm defines if we are in the pre-warmimg phase
  71523. */
  71524. animate(preWarm?: boolean): void;
  71525. private _createFactorGradientTexture;
  71526. private _createSizeGradientTexture;
  71527. private _createAngularSpeedGradientTexture;
  71528. private _createVelocityGradientTexture;
  71529. private _createLimitVelocityGradientTexture;
  71530. private _createDragGradientTexture;
  71531. private _createColorGradientTexture;
  71532. /**
  71533. * Renders the particle system in its current state
  71534. * @param preWarm defines if the system should only update the particles but not render them
  71535. * @returns the current number of particles
  71536. */
  71537. render(preWarm?: boolean): number;
  71538. /**
  71539. * Rebuilds the particle system
  71540. */
  71541. rebuild(): void;
  71542. private _releaseBuffers;
  71543. private _releaseVAOs;
  71544. /**
  71545. * Disposes the particle system and free the associated resources
  71546. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71547. */
  71548. dispose(disposeTexture?: boolean): void;
  71549. /**
  71550. * Clones the particle system.
  71551. * @param name The name of the cloned object
  71552. * @param newEmitter The new emitter to use
  71553. * @returns the cloned particle system
  71554. */
  71555. clone(name: string, newEmitter: any): GPUParticleSystem;
  71556. /**
  71557. * Serializes the particle system to a JSON object
  71558. * @param serializeTexture defines if the texture must be serialized as well
  71559. * @returns the JSON object
  71560. */
  71561. serialize(serializeTexture?: boolean): any;
  71562. /**
  71563. * Parses a JSON object to create a GPU particle system.
  71564. * @param parsedParticleSystem The JSON object to parse
  71565. * @param sceneOrEngine The scene or the engine to create the particle system in
  71566. * @param rootUrl The root url to use to load external dependencies like texture
  71567. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71568. * @returns the parsed GPU particle system
  71569. */
  71570. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71571. }
  71572. }
  71573. declare module "babylonjs/Particles/particleSystemSet" {
  71574. import { Nullable } from "babylonjs/types";
  71575. import { Color3 } from "babylonjs/Maths/math.color";
  71576. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71578. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71579. import { Scene, IDisposable } from "babylonjs/scene";
  71580. /**
  71581. * Represents a set of particle systems working together to create a specific effect
  71582. */
  71583. export class ParticleSystemSet implements IDisposable {
  71584. /**
  71585. * Gets or sets base Assets URL
  71586. */
  71587. static BaseAssetsUrl: string;
  71588. private _emitterCreationOptions;
  71589. private _emitterNode;
  71590. /**
  71591. * Gets the particle system list
  71592. */
  71593. systems: IParticleSystem[];
  71594. /**
  71595. * Gets the emitter node used with this set
  71596. */
  71597. get emitterNode(): Nullable<TransformNode>;
  71598. /**
  71599. * Creates a new emitter mesh as a sphere
  71600. * @param options defines the options used to create the sphere
  71601. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71602. * @param scene defines the hosting scene
  71603. */
  71604. setEmitterAsSphere(options: {
  71605. diameter: number;
  71606. segments: number;
  71607. color: Color3;
  71608. }, renderingGroupId: number, scene: Scene): void;
  71609. /**
  71610. * Starts all particle systems of the set
  71611. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71612. */
  71613. start(emitter?: AbstractMesh): void;
  71614. /**
  71615. * Release all associated resources
  71616. */
  71617. dispose(): void;
  71618. /**
  71619. * Serialize the set into a JSON compatible object
  71620. * @param serializeTexture defines if the texture must be serialized as well
  71621. * @returns a JSON compatible representation of the set
  71622. */
  71623. serialize(serializeTexture?: boolean): any;
  71624. /**
  71625. * Parse a new ParticleSystemSet from a serialized source
  71626. * @param data defines a JSON compatible representation of the set
  71627. * @param scene defines the hosting scene
  71628. * @param gpu defines if we want GPU particles or CPU particles
  71629. * @returns a new ParticleSystemSet
  71630. */
  71631. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71632. }
  71633. }
  71634. declare module "babylonjs/Particles/particleHelper" {
  71635. import { Nullable } from "babylonjs/types";
  71636. import { Scene } from "babylonjs/scene";
  71637. import { Vector3 } from "babylonjs/Maths/math.vector";
  71638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71639. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71640. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71641. /**
  71642. * This class is made for on one-liner static method to help creating particle system set.
  71643. */
  71644. export class ParticleHelper {
  71645. /**
  71646. * Gets or sets base Assets URL
  71647. */
  71648. static BaseAssetsUrl: string;
  71649. /** Define the Url to load snippets */
  71650. static SnippetUrl: string;
  71651. /**
  71652. * Create a default particle system that you can tweak
  71653. * @param emitter defines the emitter to use
  71654. * @param capacity defines the system capacity (default is 500 particles)
  71655. * @param scene defines the hosting scene
  71656. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71657. * @returns the new Particle system
  71658. */
  71659. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71660. /**
  71661. * This is the main static method (one-liner) of this helper to create different particle systems
  71662. * @param type This string represents the type to the particle system to create
  71663. * @param scene The scene where the particle system should live
  71664. * @param gpu If the system will use gpu
  71665. * @returns the ParticleSystemSet created
  71666. */
  71667. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71668. /**
  71669. * Static function used to export a particle system to a ParticleSystemSet variable.
  71670. * Please note that the emitter shape is not exported
  71671. * @param systems defines the particle systems to export
  71672. * @returns the created particle system set
  71673. */
  71674. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71675. /**
  71676. * Creates a particle system from a snippet saved in a remote file
  71677. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71678. * @param url defines the url to load from
  71679. * @param scene defines the hosting scene
  71680. * @param gpu If the system will use gpu
  71681. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71682. * @returns a promise that will resolve to the new particle system
  71683. */
  71684. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71685. /**
  71686. * Creates a particle system from a snippet saved by the particle system editor
  71687. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71688. * @param scene defines the hosting scene
  71689. * @param gpu If the system will use gpu
  71690. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71691. * @returns a promise that will resolve to the new particle system
  71692. */
  71693. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71694. }
  71695. }
  71696. declare module "babylonjs/Particles/particleSystemComponent" {
  71697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71698. import { Effect } from "babylonjs/Materials/effect";
  71699. import "babylonjs/Shaders/particles.vertex";
  71700. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71701. module "babylonjs/Engines/engine" {
  71702. interface Engine {
  71703. /**
  71704. * Create an effect to use with particle systems.
  71705. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71706. * the particle system for which you want to create a custom effect in the last parameter
  71707. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71708. * @param uniformsNames defines a list of attribute names
  71709. * @param samplers defines an array of string used to represent textures
  71710. * @param defines defines the string containing the defines to use to compile the shaders
  71711. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71712. * @param onCompiled defines a function to call when the effect creation is successful
  71713. * @param onError defines a function to call when the effect creation has failed
  71714. * @param particleSystem the particle system you want to create the effect for
  71715. * @returns the new Effect
  71716. */
  71717. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71718. }
  71719. }
  71720. module "babylonjs/Meshes/mesh" {
  71721. interface Mesh {
  71722. /**
  71723. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71724. * @returns an array of IParticleSystem
  71725. */
  71726. getEmittedParticleSystems(): IParticleSystem[];
  71727. /**
  71728. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71729. * @returns an array of IParticleSystem
  71730. */
  71731. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71732. }
  71733. }
  71734. }
  71735. declare module "babylonjs/Particles/pointsCloudSystem" {
  71736. import { Color4 } from "babylonjs/Maths/math";
  71737. import { Mesh } from "babylonjs/Meshes/mesh";
  71738. import { Scene, IDisposable } from "babylonjs/scene";
  71739. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71740. /** Defines the 4 color options */
  71741. export enum PointColor {
  71742. /** color value */
  71743. Color = 2,
  71744. /** uv value */
  71745. UV = 1,
  71746. /** random value */
  71747. Random = 0,
  71748. /** stated value */
  71749. Stated = 3
  71750. }
  71751. /**
  71752. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71753. * 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.
  71754. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71756. *
  71757. * Full documentation here : TO BE ENTERED
  71758. */
  71759. export class PointsCloudSystem implements IDisposable {
  71760. /**
  71761. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71762. * Example : var p = SPS.particles[i];
  71763. */
  71764. particles: CloudPoint[];
  71765. /**
  71766. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71767. */
  71768. nbParticles: number;
  71769. /**
  71770. * This a counter for your own usage. It's not set by any SPS functions.
  71771. */
  71772. counter: number;
  71773. /**
  71774. * The PCS name. This name is also given to the underlying mesh.
  71775. */
  71776. name: string;
  71777. /**
  71778. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71779. */
  71780. mesh: Mesh;
  71781. /**
  71782. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71783. * Please read :
  71784. */
  71785. vars: any;
  71786. /**
  71787. * @hidden
  71788. */
  71789. _size: number;
  71790. private _scene;
  71791. private _promises;
  71792. private _positions;
  71793. private _indices;
  71794. private _normals;
  71795. private _colors;
  71796. private _uvs;
  71797. private _indices32;
  71798. private _positions32;
  71799. private _colors32;
  71800. private _uvs32;
  71801. private _updatable;
  71802. private _isVisibilityBoxLocked;
  71803. private _alwaysVisible;
  71804. private _groups;
  71805. private _groupCounter;
  71806. private _computeParticleColor;
  71807. private _computeParticleTexture;
  71808. private _computeParticleRotation;
  71809. private _computeBoundingBox;
  71810. private _isReady;
  71811. /**
  71812. * Creates a PCS (Points Cloud System) object
  71813. * @param name (String) is the PCS name, this will be the underlying mesh name
  71814. * @param pointSize (number) is the size for each point
  71815. * @param scene (Scene) is the scene in which the PCS is added
  71816. * @param options defines the options of the PCS e.g.
  71817. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71818. */
  71819. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71820. updatable?: boolean;
  71821. });
  71822. /**
  71823. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71824. * If no points were added to the PCS, the returned mesh is just a single point.
  71825. * @returns a promise for the created mesh
  71826. */
  71827. buildMeshAsync(): Promise<Mesh>;
  71828. /**
  71829. * @hidden
  71830. */
  71831. private _buildMesh;
  71832. private _addParticle;
  71833. private _randomUnitVector;
  71834. private _getColorIndicesForCoord;
  71835. private _setPointsColorOrUV;
  71836. private _colorFromTexture;
  71837. private _calculateDensity;
  71838. /**
  71839. * Adds points to the PCS in random positions within a unit sphere
  71840. * @param nb (positive integer) the number of particles to be created from this model
  71841. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71842. * @returns the number of groups in the system
  71843. */
  71844. addPoints(nb: number, pointFunction?: any): number;
  71845. /**
  71846. * Adds points to the PCS from the surface of the model shape
  71847. * @param mesh is any Mesh object that will be used as a surface model for the points
  71848. * @param nb (positive integer) the number of particles to be created from this model
  71849. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71850. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71851. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71852. * @returns the number of groups in the system
  71853. */
  71854. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71855. /**
  71856. * Adds points to the PCS inside the model shape
  71857. * @param mesh is any Mesh object that will be used as a surface model for the points
  71858. * @param nb (positive integer) the number of particles to be created from this model
  71859. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71860. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71861. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71862. * @returns the number of groups in the system
  71863. */
  71864. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71865. /**
  71866. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71867. * This method calls `updateParticle()` for each particle of the SPS.
  71868. * For an animated SPS, it is usually called within the render loop.
  71869. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71870. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71871. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71872. * @returns the PCS.
  71873. */
  71874. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71875. /**
  71876. * Disposes the PCS.
  71877. */
  71878. dispose(): void;
  71879. /**
  71880. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71881. * doc :
  71882. * @returns the PCS.
  71883. */
  71884. refreshVisibleSize(): PointsCloudSystem;
  71885. /**
  71886. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71887. * @param size the size (float) of the visibility box
  71888. * note : this doesn't lock the PCS mesh bounding box.
  71889. * doc :
  71890. */
  71891. setVisibilityBox(size: number): void;
  71892. /**
  71893. * Gets whether the PCS is always visible or not
  71894. * doc :
  71895. */
  71896. get isAlwaysVisible(): boolean;
  71897. /**
  71898. * Sets the PCS as always visible or not
  71899. * doc :
  71900. */
  71901. set isAlwaysVisible(val: boolean);
  71902. /**
  71903. * Tells to `setParticles()` to compute the particle rotations or not
  71904. * Default value : false. The PCS is faster when it's set to false
  71905. * Note : particle rotations are only applied to parent particles
  71906. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71907. */
  71908. set computeParticleRotation(val: boolean);
  71909. /**
  71910. * Tells to `setParticles()` to compute the particle colors or not.
  71911. * Default value : true. The PCS is faster when it's set to false.
  71912. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71913. */
  71914. set computeParticleColor(val: boolean);
  71915. set computeParticleTexture(val: boolean);
  71916. /**
  71917. * Gets if `setParticles()` computes the particle colors or not.
  71918. * Default value : false. The PCS is faster when it's set to false.
  71919. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71920. */
  71921. get computeParticleColor(): boolean;
  71922. /**
  71923. * Gets if `setParticles()` computes the particle textures or not.
  71924. * Default value : false. The PCS is faster when it's set to false.
  71925. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71926. */
  71927. get computeParticleTexture(): boolean;
  71928. /**
  71929. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71930. */
  71931. set computeBoundingBox(val: boolean);
  71932. /**
  71933. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71934. */
  71935. get computeBoundingBox(): boolean;
  71936. /**
  71937. * This function does nothing. It may be overwritten to set all the particle first values.
  71938. * The PCS doesn't call this function, you may have to call it by your own.
  71939. * doc :
  71940. */
  71941. initParticles(): void;
  71942. /**
  71943. * This function does nothing. It may be overwritten to recycle a particle
  71944. * The PCS doesn't call this function, you can to call it
  71945. * doc :
  71946. * @param particle The particle to recycle
  71947. * @returns the recycled particle
  71948. */
  71949. recycleParticle(particle: CloudPoint): CloudPoint;
  71950. /**
  71951. * Updates a particle : this function should be overwritten by the user.
  71952. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71953. * doc :
  71954. * @example : just set a particle position or velocity and recycle conditions
  71955. * @param particle The particle to update
  71956. * @returns the updated particle
  71957. */
  71958. updateParticle(particle: CloudPoint): CloudPoint;
  71959. /**
  71960. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71961. * This does nothing and may be overwritten by the user.
  71962. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71963. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71964. * @param update the boolean update value actually passed to setParticles()
  71965. */
  71966. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71967. /**
  71968. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71969. * This will be passed three parameters.
  71970. * This does nothing and may be overwritten by the user.
  71971. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71972. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71973. * @param update the boolean update value actually passed to setParticles()
  71974. */
  71975. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71976. }
  71977. }
  71978. declare module "babylonjs/Particles/cloudPoint" {
  71979. import { Nullable } from "babylonjs/types";
  71980. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71981. import { Mesh } from "babylonjs/Meshes/mesh";
  71982. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71983. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71984. /**
  71985. * Represents one particle of a points cloud system.
  71986. */
  71987. export class CloudPoint {
  71988. /**
  71989. * particle global index
  71990. */
  71991. idx: number;
  71992. /**
  71993. * The color of the particle
  71994. */
  71995. color: Nullable<Color4>;
  71996. /**
  71997. * The world space position of the particle.
  71998. */
  71999. position: Vector3;
  72000. /**
  72001. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72002. */
  72003. rotation: Vector3;
  72004. /**
  72005. * The world space rotation quaternion of the particle.
  72006. */
  72007. rotationQuaternion: Nullable<Quaternion>;
  72008. /**
  72009. * The uv of the particle.
  72010. */
  72011. uv: Nullable<Vector2>;
  72012. /**
  72013. * The current speed of the particle.
  72014. */
  72015. velocity: Vector3;
  72016. /**
  72017. * The pivot point in the particle local space.
  72018. */
  72019. pivot: Vector3;
  72020. /**
  72021. * Must the particle be translated from its pivot point in its local space ?
  72022. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72023. * Default : false
  72024. */
  72025. translateFromPivot: boolean;
  72026. /**
  72027. * Index of this particle in the global "positions" array (Internal use)
  72028. * @hidden
  72029. */
  72030. _pos: number;
  72031. /**
  72032. * @hidden Index of this particle in the global "indices" array (Internal use)
  72033. */
  72034. _ind: number;
  72035. /**
  72036. * Group this particle belongs to
  72037. */
  72038. _group: PointsGroup;
  72039. /**
  72040. * Group id of this particle
  72041. */
  72042. groupId: number;
  72043. /**
  72044. * Index of the particle in its group id (Internal use)
  72045. */
  72046. idxInGroup: number;
  72047. /**
  72048. * @hidden Particle BoundingInfo object (Internal use)
  72049. */
  72050. _boundingInfo: BoundingInfo;
  72051. /**
  72052. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72053. */
  72054. _pcs: PointsCloudSystem;
  72055. /**
  72056. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72057. */
  72058. _stillInvisible: boolean;
  72059. /**
  72060. * @hidden Last computed particle rotation matrix
  72061. */
  72062. _rotationMatrix: number[];
  72063. /**
  72064. * Parent particle Id, if any.
  72065. * Default null.
  72066. */
  72067. parentId: Nullable<number>;
  72068. /**
  72069. * @hidden Internal global position in the PCS.
  72070. */
  72071. _globalPosition: Vector3;
  72072. /**
  72073. * Creates a Point Cloud object.
  72074. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72075. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72076. * @param group (PointsGroup) is the group the particle belongs to
  72077. * @param groupId (integer) is the group identifier in the PCS.
  72078. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72079. * @param pcs defines the PCS it is associated to
  72080. */
  72081. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72082. /**
  72083. * get point size
  72084. */
  72085. get size(): Vector3;
  72086. /**
  72087. * Set point size
  72088. */
  72089. set size(scale: Vector3);
  72090. /**
  72091. * Legacy support, changed quaternion to rotationQuaternion
  72092. */
  72093. get quaternion(): Nullable<Quaternion>;
  72094. /**
  72095. * Legacy support, changed quaternion to rotationQuaternion
  72096. */
  72097. set quaternion(q: Nullable<Quaternion>);
  72098. /**
  72099. * Returns a boolean. True if the particle intersects a mesh, else false
  72100. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72101. * @param target is the object (point or mesh) what the intersection is computed against
  72102. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72103. * @returns true if it intersects
  72104. */
  72105. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72106. /**
  72107. * get the rotation matrix of the particle
  72108. * @hidden
  72109. */
  72110. getRotationMatrix(m: Matrix): void;
  72111. }
  72112. /**
  72113. * Represents a group of points in a points cloud system
  72114. * * PCS internal tool, don't use it manually.
  72115. */
  72116. export class PointsGroup {
  72117. /**
  72118. * The group id
  72119. * @hidden
  72120. */
  72121. groupID: number;
  72122. /**
  72123. * image data for group (internal use)
  72124. * @hidden
  72125. */
  72126. _groupImageData: Nullable<ArrayBufferView>;
  72127. /**
  72128. * Image Width (internal use)
  72129. * @hidden
  72130. */
  72131. _groupImgWidth: number;
  72132. /**
  72133. * Image Height (internal use)
  72134. * @hidden
  72135. */
  72136. _groupImgHeight: number;
  72137. /**
  72138. * Custom position function (internal use)
  72139. * @hidden
  72140. */
  72141. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72142. /**
  72143. * density per facet for surface points
  72144. * @hidden
  72145. */
  72146. _groupDensity: number[];
  72147. /**
  72148. * Only when points are colored by texture carries pointer to texture list array
  72149. * @hidden
  72150. */
  72151. _textureNb: number;
  72152. /**
  72153. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72154. * PCS internal tool, don't use it manually.
  72155. * @hidden
  72156. */
  72157. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72158. }
  72159. }
  72160. declare module "babylonjs/Particles/index" {
  72161. export * from "babylonjs/Particles/baseParticleSystem";
  72162. export * from "babylonjs/Particles/EmitterTypes/index";
  72163. export * from "babylonjs/Particles/gpuParticleSystem";
  72164. export * from "babylonjs/Particles/IParticleSystem";
  72165. export * from "babylonjs/Particles/particle";
  72166. export * from "babylonjs/Particles/particleHelper";
  72167. export * from "babylonjs/Particles/particleSystem";
  72168. import "babylonjs/Particles/particleSystemComponent";
  72169. export * from "babylonjs/Particles/particleSystemComponent";
  72170. export * from "babylonjs/Particles/particleSystemSet";
  72171. export * from "babylonjs/Particles/solidParticle";
  72172. export * from "babylonjs/Particles/solidParticleSystem";
  72173. export * from "babylonjs/Particles/cloudPoint";
  72174. export * from "babylonjs/Particles/pointsCloudSystem";
  72175. export * from "babylonjs/Particles/subEmitter";
  72176. }
  72177. declare module "babylonjs/Physics/physicsEngineComponent" {
  72178. import { Nullable } from "babylonjs/types";
  72179. import { Observable, Observer } from "babylonjs/Misc/observable";
  72180. import { Vector3 } from "babylonjs/Maths/math.vector";
  72181. import { Mesh } from "babylonjs/Meshes/mesh";
  72182. import { ISceneComponent } from "babylonjs/sceneComponent";
  72183. import { Scene } from "babylonjs/scene";
  72184. import { Node } from "babylonjs/node";
  72185. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72186. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72187. module "babylonjs/scene" {
  72188. interface Scene {
  72189. /** @hidden (Backing field) */
  72190. _physicsEngine: Nullable<IPhysicsEngine>;
  72191. /** @hidden */
  72192. _physicsTimeAccumulator: number;
  72193. /**
  72194. * Gets the current physics engine
  72195. * @returns a IPhysicsEngine or null if none attached
  72196. */
  72197. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72198. /**
  72199. * Enables physics to the current scene
  72200. * @param gravity defines the scene's gravity for the physics engine
  72201. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72202. * @return a boolean indicating if the physics engine was initialized
  72203. */
  72204. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72205. /**
  72206. * Disables and disposes the physics engine associated with the scene
  72207. */
  72208. disablePhysicsEngine(): void;
  72209. /**
  72210. * Gets a boolean indicating if there is an active physics engine
  72211. * @returns a boolean indicating if there is an active physics engine
  72212. */
  72213. isPhysicsEnabled(): boolean;
  72214. /**
  72215. * Deletes a physics compound impostor
  72216. * @param compound defines the compound to delete
  72217. */
  72218. deleteCompoundImpostor(compound: any): void;
  72219. /**
  72220. * An event triggered when physic simulation is about to be run
  72221. */
  72222. onBeforePhysicsObservable: Observable<Scene>;
  72223. /**
  72224. * An event triggered when physic simulation has been done
  72225. */
  72226. onAfterPhysicsObservable: Observable<Scene>;
  72227. }
  72228. }
  72229. module "babylonjs/Meshes/abstractMesh" {
  72230. interface AbstractMesh {
  72231. /** @hidden */
  72232. _physicsImpostor: Nullable<PhysicsImpostor>;
  72233. /**
  72234. * Gets or sets impostor used for physic simulation
  72235. * @see https://doc.babylonjs.com/features/physics_engine
  72236. */
  72237. physicsImpostor: Nullable<PhysicsImpostor>;
  72238. /**
  72239. * Gets the current physics impostor
  72240. * @see https://doc.babylonjs.com/features/physics_engine
  72241. * @returns a physics impostor or null
  72242. */
  72243. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72244. /** Apply a physic impulse to the mesh
  72245. * @param force defines the force to apply
  72246. * @param contactPoint defines where to apply the force
  72247. * @returns the current mesh
  72248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72249. */
  72250. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72251. /**
  72252. * Creates a physic joint between two meshes
  72253. * @param otherMesh defines the other mesh to use
  72254. * @param pivot1 defines the pivot to use on this mesh
  72255. * @param pivot2 defines the pivot to use on the other mesh
  72256. * @param options defines additional options (can be plugin dependent)
  72257. * @returns the current mesh
  72258. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72259. */
  72260. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72261. /** @hidden */
  72262. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72263. }
  72264. }
  72265. /**
  72266. * Defines the physics engine scene component responsible to manage a physics engine
  72267. */
  72268. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72269. /**
  72270. * The component name helpful to identify the component in the list of scene components.
  72271. */
  72272. readonly name: string;
  72273. /**
  72274. * The scene the component belongs to.
  72275. */
  72276. scene: Scene;
  72277. /**
  72278. * Creates a new instance of the component for the given scene
  72279. * @param scene Defines the scene to register the component in
  72280. */
  72281. constructor(scene: Scene);
  72282. /**
  72283. * Registers the component in a given scene
  72284. */
  72285. register(): void;
  72286. /**
  72287. * Rebuilds the elements related to this component in case of
  72288. * context lost for instance.
  72289. */
  72290. rebuild(): void;
  72291. /**
  72292. * Disposes the component and the associated ressources
  72293. */
  72294. dispose(): void;
  72295. }
  72296. }
  72297. declare module "babylonjs/Physics/physicsHelper" {
  72298. import { Nullable } from "babylonjs/types";
  72299. import { Vector3 } from "babylonjs/Maths/math.vector";
  72300. import { Mesh } from "babylonjs/Meshes/mesh";
  72301. import { Scene } from "babylonjs/scene";
  72302. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72303. /**
  72304. * A helper for physics simulations
  72305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72306. */
  72307. export class PhysicsHelper {
  72308. private _scene;
  72309. private _physicsEngine;
  72310. /**
  72311. * Initializes the Physics helper
  72312. * @param scene Babylon.js scene
  72313. */
  72314. constructor(scene: Scene);
  72315. /**
  72316. * Applies a radial explosion impulse
  72317. * @param origin the origin of the explosion
  72318. * @param radiusOrEventOptions the radius or the options of radial explosion
  72319. * @param strength the explosion strength
  72320. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72321. * @returns A physics radial explosion event, or null
  72322. */
  72323. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72324. /**
  72325. * Applies a radial explosion force
  72326. * @param origin the origin of the explosion
  72327. * @param radiusOrEventOptions the radius or the options of radial explosion
  72328. * @param strength the explosion strength
  72329. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72330. * @returns A physics radial explosion event, or null
  72331. */
  72332. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72333. /**
  72334. * Creates a gravitational field
  72335. * @param origin the origin of the explosion
  72336. * @param radiusOrEventOptions the radius or the options of radial explosion
  72337. * @param strength the explosion strength
  72338. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72339. * @returns A physics gravitational field event, or null
  72340. */
  72341. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72342. /**
  72343. * Creates a physics updraft event
  72344. * @param origin the origin of the updraft
  72345. * @param radiusOrEventOptions the radius or the options of the updraft
  72346. * @param strength the strength of the updraft
  72347. * @param height the height of the updraft
  72348. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72349. * @returns A physics updraft event, or null
  72350. */
  72351. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72352. /**
  72353. * Creates a physics vortex event
  72354. * @param origin the of the vortex
  72355. * @param radiusOrEventOptions the radius or the options of the vortex
  72356. * @param strength the strength of the vortex
  72357. * @param height the height of the vortex
  72358. * @returns a Physics vortex event, or null
  72359. * A physics vortex event or null
  72360. */
  72361. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72362. }
  72363. /**
  72364. * Represents a physics radial explosion event
  72365. */
  72366. class PhysicsRadialExplosionEvent {
  72367. private _scene;
  72368. private _options;
  72369. private _sphere;
  72370. private _dataFetched;
  72371. /**
  72372. * Initializes a radial explosioin event
  72373. * @param _scene BabylonJS scene
  72374. * @param _options The options for the vortex event
  72375. */
  72376. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72377. /**
  72378. * Returns the data related to the radial explosion event (sphere).
  72379. * @returns The radial explosion event data
  72380. */
  72381. getData(): PhysicsRadialExplosionEventData;
  72382. /**
  72383. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72384. * @param impostor A physics imposter
  72385. * @param origin the origin of the explosion
  72386. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72387. */
  72388. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72389. /**
  72390. * Triggers affecterd impostors callbacks
  72391. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72392. */
  72393. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72394. /**
  72395. * Disposes the sphere.
  72396. * @param force Specifies if the sphere should be disposed by force
  72397. */
  72398. dispose(force?: boolean): void;
  72399. /*** Helpers ***/
  72400. private _prepareSphere;
  72401. private _intersectsWithSphere;
  72402. }
  72403. /**
  72404. * Represents a gravitational field event
  72405. */
  72406. class PhysicsGravitationalFieldEvent {
  72407. private _physicsHelper;
  72408. private _scene;
  72409. private _origin;
  72410. private _options;
  72411. private _tickCallback;
  72412. private _sphere;
  72413. private _dataFetched;
  72414. /**
  72415. * Initializes the physics gravitational field event
  72416. * @param _physicsHelper A physics helper
  72417. * @param _scene BabylonJS scene
  72418. * @param _origin The origin position of the gravitational field event
  72419. * @param _options The options for the vortex event
  72420. */
  72421. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72422. /**
  72423. * Returns the data related to the gravitational field event (sphere).
  72424. * @returns A gravitational field event
  72425. */
  72426. getData(): PhysicsGravitationalFieldEventData;
  72427. /**
  72428. * Enables the gravitational field.
  72429. */
  72430. enable(): void;
  72431. /**
  72432. * Disables the gravitational field.
  72433. */
  72434. disable(): void;
  72435. /**
  72436. * Disposes the sphere.
  72437. * @param force The force to dispose from the gravitational field event
  72438. */
  72439. dispose(force?: boolean): void;
  72440. private _tick;
  72441. }
  72442. /**
  72443. * Represents a physics updraft event
  72444. */
  72445. class PhysicsUpdraftEvent {
  72446. private _scene;
  72447. private _origin;
  72448. private _options;
  72449. private _physicsEngine;
  72450. private _originTop;
  72451. private _originDirection;
  72452. private _tickCallback;
  72453. private _cylinder;
  72454. private _cylinderPosition;
  72455. private _dataFetched;
  72456. /**
  72457. * Initializes the physics updraft event
  72458. * @param _scene BabylonJS scene
  72459. * @param _origin The origin position of the updraft
  72460. * @param _options The options for the updraft event
  72461. */
  72462. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72463. /**
  72464. * Returns the data related to the updraft event (cylinder).
  72465. * @returns A physics updraft event
  72466. */
  72467. getData(): PhysicsUpdraftEventData;
  72468. /**
  72469. * Enables the updraft.
  72470. */
  72471. enable(): void;
  72472. /**
  72473. * Disables the updraft.
  72474. */
  72475. disable(): void;
  72476. /**
  72477. * Disposes the cylinder.
  72478. * @param force Specifies if the updraft should be disposed by force
  72479. */
  72480. dispose(force?: boolean): void;
  72481. private getImpostorHitData;
  72482. private _tick;
  72483. /*** Helpers ***/
  72484. private _prepareCylinder;
  72485. private _intersectsWithCylinder;
  72486. }
  72487. /**
  72488. * Represents a physics vortex event
  72489. */
  72490. class PhysicsVortexEvent {
  72491. private _scene;
  72492. private _origin;
  72493. private _options;
  72494. private _physicsEngine;
  72495. private _originTop;
  72496. private _tickCallback;
  72497. private _cylinder;
  72498. private _cylinderPosition;
  72499. private _dataFetched;
  72500. /**
  72501. * Initializes the physics vortex event
  72502. * @param _scene The BabylonJS scene
  72503. * @param _origin The origin position of the vortex
  72504. * @param _options The options for the vortex event
  72505. */
  72506. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72507. /**
  72508. * Returns the data related to the vortex event (cylinder).
  72509. * @returns The physics vortex event data
  72510. */
  72511. getData(): PhysicsVortexEventData;
  72512. /**
  72513. * Enables the vortex.
  72514. */
  72515. enable(): void;
  72516. /**
  72517. * Disables the cortex.
  72518. */
  72519. disable(): void;
  72520. /**
  72521. * Disposes the sphere.
  72522. * @param force
  72523. */
  72524. dispose(force?: boolean): void;
  72525. private getImpostorHitData;
  72526. private _tick;
  72527. /*** Helpers ***/
  72528. private _prepareCylinder;
  72529. private _intersectsWithCylinder;
  72530. }
  72531. /**
  72532. * Options fot the radial explosion event
  72533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72534. */
  72535. export class PhysicsRadialExplosionEventOptions {
  72536. /**
  72537. * The radius of the sphere for the radial explosion.
  72538. */
  72539. radius: number;
  72540. /**
  72541. * The strenth of the explosion.
  72542. */
  72543. strength: number;
  72544. /**
  72545. * The strenght of the force in correspondence to the distance of the affected object
  72546. */
  72547. falloff: PhysicsRadialImpulseFalloff;
  72548. /**
  72549. * Sphere options for the radial explosion.
  72550. */
  72551. sphere: {
  72552. segments: number;
  72553. diameter: number;
  72554. };
  72555. /**
  72556. * Sphere options for the radial explosion.
  72557. */
  72558. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72559. }
  72560. /**
  72561. * Options fot the updraft event
  72562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72563. */
  72564. export class PhysicsUpdraftEventOptions {
  72565. /**
  72566. * The radius of the cylinder for the vortex
  72567. */
  72568. radius: number;
  72569. /**
  72570. * The strenth of the updraft.
  72571. */
  72572. strength: number;
  72573. /**
  72574. * The height of the cylinder for the updraft.
  72575. */
  72576. height: number;
  72577. /**
  72578. * The mode for the the updraft.
  72579. */
  72580. updraftMode: PhysicsUpdraftMode;
  72581. }
  72582. /**
  72583. * Options fot the vortex event
  72584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72585. */
  72586. export class PhysicsVortexEventOptions {
  72587. /**
  72588. * The radius of the cylinder for the vortex
  72589. */
  72590. radius: number;
  72591. /**
  72592. * The strenth of the vortex.
  72593. */
  72594. strength: number;
  72595. /**
  72596. * The height of the cylinder for the vortex.
  72597. */
  72598. height: number;
  72599. /**
  72600. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72601. */
  72602. centripetalForceThreshold: number;
  72603. /**
  72604. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72605. */
  72606. centripetalForceMultiplier: number;
  72607. /**
  72608. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72609. */
  72610. centrifugalForceMultiplier: number;
  72611. /**
  72612. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72613. */
  72614. updraftForceMultiplier: number;
  72615. }
  72616. /**
  72617. * The strenght of the force in correspondence to the distance of the affected object
  72618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72619. */
  72620. export enum PhysicsRadialImpulseFalloff {
  72621. /** Defines that impulse is constant in strength across it's whole radius */
  72622. Constant = 0,
  72623. /** Defines that impulse gets weaker if it's further from the origin */
  72624. Linear = 1
  72625. }
  72626. /**
  72627. * The strength of the force in correspondence to the distance of the affected object
  72628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72629. */
  72630. export enum PhysicsUpdraftMode {
  72631. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72632. Center = 0,
  72633. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72634. Perpendicular = 1
  72635. }
  72636. /**
  72637. * Interface for a physics hit data
  72638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72639. */
  72640. export interface PhysicsHitData {
  72641. /**
  72642. * The force applied at the contact point
  72643. */
  72644. force: Vector3;
  72645. /**
  72646. * The contact point
  72647. */
  72648. contactPoint: Vector3;
  72649. /**
  72650. * The distance from the origin to the contact point
  72651. */
  72652. distanceFromOrigin: number;
  72653. }
  72654. /**
  72655. * Interface for radial explosion event data
  72656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72657. */
  72658. export interface PhysicsRadialExplosionEventData {
  72659. /**
  72660. * A sphere used for the radial explosion event
  72661. */
  72662. sphere: Mesh;
  72663. }
  72664. /**
  72665. * Interface for gravitational field event data
  72666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72667. */
  72668. export interface PhysicsGravitationalFieldEventData {
  72669. /**
  72670. * A sphere mesh used for the gravitational field event
  72671. */
  72672. sphere: Mesh;
  72673. }
  72674. /**
  72675. * Interface for updraft event data
  72676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72677. */
  72678. export interface PhysicsUpdraftEventData {
  72679. /**
  72680. * A cylinder used for the updraft event
  72681. */
  72682. cylinder: Mesh;
  72683. }
  72684. /**
  72685. * Interface for vortex event data
  72686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72687. */
  72688. export interface PhysicsVortexEventData {
  72689. /**
  72690. * A cylinder used for the vortex event
  72691. */
  72692. cylinder: Mesh;
  72693. }
  72694. /**
  72695. * Interface for an affected physics impostor
  72696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72697. */
  72698. export interface PhysicsAffectedImpostorWithData {
  72699. /**
  72700. * The impostor affected by the effect
  72701. */
  72702. impostor: PhysicsImpostor;
  72703. /**
  72704. * The data about the hit/horce from the explosion
  72705. */
  72706. hitData: PhysicsHitData;
  72707. }
  72708. }
  72709. declare module "babylonjs/Physics/Plugins/index" {
  72710. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72711. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72712. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72713. }
  72714. declare module "babylonjs/Physics/index" {
  72715. export * from "babylonjs/Physics/IPhysicsEngine";
  72716. export * from "babylonjs/Physics/physicsEngine";
  72717. export * from "babylonjs/Physics/physicsEngineComponent";
  72718. export * from "babylonjs/Physics/physicsHelper";
  72719. export * from "babylonjs/Physics/physicsImpostor";
  72720. export * from "babylonjs/Physics/physicsJoint";
  72721. export * from "babylonjs/Physics/Plugins/index";
  72722. }
  72723. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72724. /** @hidden */
  72725. export var blackAndWhitePixelShader: {
  72726. name: string;
  72727. shader: string;
  72728. };
  72729. }
  72730. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72731. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72732. import { Camera } from "babylonjs/Cameras/camera";
  72733. import { Engine } from "babylonjs/Engines/engine";
  72734. import "babylonjs/Shaders/blackAndWhite.fragment";
  72735. import { Nullable } from "babylonjs/types";
  72736. import { Scene } from "babylonjs/scene";
  72737. /**
  72738. * Post process used to render in black and white
  72739. */
  72740. export class BlackAndWhitePostProcess extends PostProcess {
  72741. /**
  72742. * Linear about to convert he result to black and white (default: 1)
  72743. */
  72744. degree: number;
  72745. /**
  72746. * Gets a string identifying the name of the class
  72747. * @returns "BlackAndWhitePostProcess" string
  72748. */
  72749. getClassName(): string;
  72750. /**
  72751. * Creates a black and white post process
  72752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72753. * @param name The name of the effect.
  72754. * @param options The required width/height ratio to downsize to before computing the render pass.
  72755. * @param camera The camera to apply the render pass to.
  72756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72757. * @param engine The engine which the post process will be applied. (default: current engine)
  72758. * @param reusable If the post process can be reused on the same frame. (default: false)
  72759. */
  72760. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72761. /** @hidden */
  72762. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72763. }
  72764. }
  72765. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72766. import { Nullable } from "babylonjs/types";
  72767. import { Camera } from "babylonjs/Cameras/camera";
  72768. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72769. import { Engine } from "babylonjs/Engines/engine";
  72770. /**
  72771. * This represents a set of one or more post processes in Babylon.
  72772. * A post process can be used to apply a shader to a texture after it is rendered.
  72773. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72774. */
  72775. export class PostProcessRenderEffect {
  72776. private _postProcesses;
  72777. private _getPostProcesses;
  72778. private _singleInstance;
  72779. private _cameras;
  72780. private _indicesForCamera;
  72781. /**
  72782. * Name of the effect
  72783. * @hidden
  72784. */
  72785. _name: string;
  72786. /**
  72787. * Instantiates a post process render effect.
  72788. * A post process can be used to apply a shader to a texture after it is rendered.
  72789. * @param engine The engine the effect is tied to
  72790. * @param name The name of the effect
  72791. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72792. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72793. */
  72794. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72795. /**
  72796. * Checks if all the post processes in the effect are supported.
  72797. */
  72798. get isSupported(): boolean;
  72799. /**
  72800. * Updates the current state of the effect
  72801. * @hidden
  72802. */
  72803. _update(): void;
  72804. /**
  72805. * Attaches the effect on cameras
  72806. * @param cameras The camera to attach to.
  72807. * @hidden
  72808. */
  72809. _attachCameras(cameras: Camera): void;
  72810. /**
  72811. * Attaches the effect on cameras
  72812. * @param cameras The camera to attach to.
  72813. * @hidden
  72814. */
  72815. _attachCameras(cameras: Camera[]): void;
  72816. /**
  72817. * Detaches the effect on cameras
  72818. * @param cameras The camera to detatch from.
  72819. * @hidden
  72820. */
  72821. _detachCameras(cameras: Camera): void;
  72822. /**
  72823. * Detatches the effect on cameras
  72824. * @param cameras The camera to detatch from.
  72825. * @hidden
  72826. */
  72827. _detachCameras(cameras: Camera[]): void;
  72828. /**
  72829. * Enables the effect on given cameras
  72830. * @param cameras The camera to enable.
  72831. * @hidden
  72832. */
  72833. _enable(cameras: Camera): void;
  72834. /**
  72835. * Enables the effect on given cameras
  72836. * @param cameras The camera to enable.
  72837. * @hidden
  72838. */
  72839. _enable(cameras: Nullable<Camera[]>): void;
  72840. /**
  72841. * Disables the effect on the given cameras
  72842. * @param cameras The camera to disable.
  72843. * @hidden
  72844. */
  72845. _disable(cameras: Camera): void;
  72846. /**
  72847. * Disables the effect on the given cameras
  72848. * @param cameras The camera to disable.
  72849. * @hidden
  72850. */
  72851. _disable(cameras: Nullable<Camera[]>): void;
  72852. /**
  72853. * Gets a list of the post processes contained in the effect.
  72854. * @param camera The camera to get the post processes on.
  72855. * @returns The list of the post processes in the effect.
  72856. */
  72857. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72858. }
  72859. }
  72860. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72861. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72862. /** @hidden */
  72863. export var extractHighlightsPixelShader: {
  72864. name: string;
  72865. shader: string;
  72866. };
  72867. }
  72868. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72869. import { Nullable } from "babylonjs/types";
  72870. import { Camera } from "babylonjs/Cameras/camera";
  72871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72872. import { Engine } from "babylonjs/Engines/engine";
  72873. import "babylonjs/Shaders/extractHighlights.fragment";
  72874. /**
  72875. * 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.
  72876. */
  72877. export class ExtractHighlightsPostProcess extends PostProcess {
  72878. /**
  72879. * The luminance threshold, pixels below this value will be set to black.
  72880. */
  72881. threshold: number;
  72882. /** @hidden */
  72883. _exposure: number;
  72884. /**
  72885. * Post process which has the input texture to be used when performing highlight extraction
  72886. * @hidden
  72887. */
  72888. _inputPostProcess: Nullable<PostProcess>;
  72889. /**
  72890. * Gets a string identifying the name of the class
  72891. * @returns "ExtractHighlightsPostProcess" string
  72892. */
  72893. getClassName(): string;
  72894. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72895. }
  72896. }
  72897. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72898. /** @hidden */
  72899. export var bloomMergePixelShader: {
  72900. name: string;
  72901. shader: string;
  72902. };
  72903. }
  72904. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72905. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72906. import { Nullable } from "babylonjs/types";
  72907. import { Engine } from "babylonjs/Engines/engine";
  72908. import { Camera } from "babylonjs/Cameras/camera";
  72909. import "babylonjs/Shaders/bloomMerge.fragment";
  72910. /**
  72911. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72912. */
  72913. export class BloomMergePostProcess extends PostProcess {
  72914. /** Weight of the bloom to be added to the original input. */
  72915. weight: number;
  72916. /**
  72917. * Gets a string identifying the name of the class
  72918. * @returns "BloomMergePostProcess" string
  72919. */
  72920. getClassName(): string;
  72921. /**
  72922. * Creates a new instance of @see BloomMergePostProcess
  72923. * @param name The name of the effect.
  72924. * @param originalFromInput Post process which's input will be used for the merge.
  72925. * @param blurred Blurred highlights post process which's output will be used.
  72926. * @param weight Weight of the bloom to be added to the original input.
  72927. * @param options The required width/height ratio to downsize to before computing the render pass.
  72928. * @param camera The camera to apply the render pass to.
  72929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72930. * @param engine The engine which the post process will be applied. (default: current engine)
  72931. * @param reusable If the post process can be reused on the same frame. (default: false)
  72932. * @param textureType Type of textures used when performing the post process. (default: 0)
  72933. * @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)
  72934. */
  72935. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72936. /** Weight of the bloom to be added to the original input. */
  72937. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72938. }
  72939. }
  72940. declare module "babylonjs/PostProcesses/bloomEffect" {
  72941. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72943. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72944. import { Camera } from "babylonjs/Cameras/camera";
  72945. import { Scene } from "babylonjs/scene";
  72946. /**
  72947. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72948. */
  72949. export class BloomEffect extends PostProcessRenderEffect {
  72950. private bloomScale;
  72951. /**
  72952. * @hidden Internal
  72953. */
  72954. _effects: Array<PostProcess>;
  72955. /**
  72956. * @hidden Internal
  72957. */
  72958. _downscale: ExtractHighlightsPostProcess;
  72959. private _blurX;
  72960. private _blurY;
  72961. private _merge;
  72962. /**
  72963. * The luminance threshold to find bright areas of the image to bloom.
  72964. */
  72965. get threshold(): number;
  72966. set threshold(value: number);
  72967. /**
  72968. * The strength of the bloom.
  72969. */
  72970. get weight(): number;
  72971. set weight(value: number);
  72972. /**
  72973. * Specifies the size of the bloom blur kernel, relative to the final output size
  72974. */
  72975. get kernel(): number;
  72976. set kernel(value: number);
  72977. /**
  72978. * Creates a new instance of @see BloomEffect
  72979. * @param scene The scene the effect belongs to.
  72980. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72981. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72982. * @param bloomWeight The the strength of bloom.
  72983. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72984. * @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)
  72985. */
  72986. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72987. /**
  72988. * Disposes each of the internal effects for a given camera.
  72989. * @param camera The camera to dispose the effect on.
  72990. */
  72991. disposeEffects(camera: Camera): void;
  72992. /**
  72993. * @hidden Internal
  72994. */
  72995. _updateEffects(): void;
  72996. /**
  72997. * Internal
  72998. * @returns if all the contained post processes are ready.
  72999. * @hidden
  73000. */
  73001. _isReady(): boolean;
  73002. }
  73003. }
  73004. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73005. /** @hidden */
  73006. export var chromaticAberrationPixelShader: {
  73007. name: string;
  73008. shader: string;
  73009. };
  73010. }
  73011. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73012. import { Vector2 } from "babylonjs/Maths/math.vector";
  73013. import { Nullable } from "babylonjs/types";
  73014. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73015. import { Camera } from "babylonjs/Cameras/camera";
  73016. import { Engine } from "babylonjs/Engines/engine";
  73017. import "babylonjs/Shaders/chromaticAberration.fragment";
  73018. import { Scene } from "babylonjs/scene";
  73019. /**
  73020. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73021. */
  73022. export class ChromaticAberrationPostProcess extends PostProcess {
  73023. /**
  73024. * The amount of seperation of rgb channels (default: 30)
  73025. */
  73026. aberrationAmount: number;
  73027. /**
  73028. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73029. */
  73030. radialIntensity: number;
  73031. /**
  73032. * 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))
  73033. */
  73034. direction: Vector2;
  73035. /**
  73036. * 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))
  73037. */
  73038. centerPosition: Vector2;
  73039. /** The width of the screen to apply the effect on */
  73040. screenWidth: number;
  73041. /** The height of the screen to apply the effect on */
  73042. screenHeight: number;
  73043. /**
  73044. * Gets a string identifying the name of the class
  73045. * @returns "ChromaticAberrationPostProcess" string
  73046. */
  73047. getClassName(): string;
  73048. /**
  73049. * Creates a new instance ChromaticAberrationPostProcess
  73050. * @param name The name of the effect.
  73051. * @param screenWidth The width of the screen to apply the effect on.
  73052. * @param screenHeight The height of the screen to apply the effect on.
  73053. * @param options The required width/height ratio to downsize to before computing the render pass.
  73054. * @param camera The camera to apply the render pass to.
  73055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73056. * @param engine The engine which the post process will be applied. (default: current engine)
  73057. * @param reusable If the post process can be reused on the same frame. (default: false)
  73058. * @param textureType Type of textures used when performing the post process. (default: 0)
  73059. * @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)
  73060. */
  73061. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73062. /** @hidden */
  73063. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73064. }
  73065. }
  73066. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73067. /** @hidden */
  73068. export var circleOfConfusionPixelShader: {
  73069. name: string;
  73070. shader: string;
  73071. };
  73072. }
  73073. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73074. import { Nullable } from "babylonjs/types";
  73075. import { Engine } from "babylonjs/Engines/engine";
  73076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73078. import { Camera } from "babylonjs/Cameras/camera";
  73079. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73080. /**
  73081. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73082. */
  73083. export class CircleOfConfusionPostProcess extends PostProcess {
  73084. /**
  73085. * 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.
  73086. */
  73087. lensSize: number;
  73088. /**
  73089. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73090. */
  73091. fStop: number;
  73092. /**
  73093. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73094. */
  73095. focusDistance: number;
  73096. /**
  73097. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73098. */
  73099. focalLength: number;
  73100. /**
  73101. * Gets a string identifying the name of the class
  73102. * @returns "CircleOfConfusionPostProcess" string
  73103. */
  73104. getClassName(): string;
  73105. private _depthTexture;
  73106. /**
  73107. * Creates a new instance CircleOfConfusionPostProcess
  73108. * @param name The name of the effect.
  73109. * @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.
  73110. * @param options The required width/height ratio to downsize to before computing the render pass.
  73111. * @param camera The camera to apply the render pass to.
  73112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73113. * @param engine The engine which the post process will be applied. (default: current engine)
  73114. * @param reusable If the post process can be reused on the same frame. (default: false)
  73115. * @param textureType Type of textures used when performing the post process. (default: 0)
  73116. * @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)
  73117. */
  73118. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73119. /**
  73120. * 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.
  73121. */
  73122. set depthTexture(value: RenderTargetTexture);
  73123. }
  73124. }
  73125. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73126. /** @hidden */
  73127. export var colorCorrectionPixelShader: {
  73128. name: string;
  73129. shader: string;
  73130. };
  73131. }
  73132. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73134. import { Engine } from "babylonjs/Engines/engine";
  73135. import { Camera } from "babylonjs/Cameras/camera";
  73136. import "babylonjs/Shaders/colorCorrection.fragment";
  73137. import { Nullable } from "babylonjs/types";
  73138. import { Scene } from "babylonjs/scene";
  73139. /**
  73140. *
  73141. * This post-process allows the modification of rendered colors by using
  73142. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73143. *
  73144. * The object needs to be provided an url to a texture containing the color
  73145. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73146. * Use an image editing software to tweak the LUT to match your needs.
  73147. *
  73148. * For an example of a color LUT, see here:
  73149. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73150. * For explanations on color grading, see here:
  73151. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73152. *
  73153. */
  73154. export class ColorCorrectionPostProcess extends PostProcess {
  73155. private _colorTableTexture;
  73156. /**
  73157. * Gets the color table url used to create the LUT texture
  73158. */
  73159. colorTableUrl: string;
  73160. /**
  73161. * Gets a string identifying the name of the class
  73162. * @returns "ColorCorrectionPostProcess" string
  73163. */
  73164. getClassName(): string;
  73165. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73166. /** @hidden */
  73167. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73168. }
  73169. }
  73170. declare module "babylonjs/Shaders/convolution.fragment" {
  73171. /** @hidden */
  73172. export var convolutionPixelShader: {
  73173. name: string;
  73174. shader: string;
  73175. };
  73176. }
  73177. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73179. import { Nullable } from "babylonjs/types";
  73180. import { Camera } from "babylonjs/Cameras/camera";
  73181. import { Engine } from "babylonjs/Engines/engine";
  73182. import "babylonjs/Shaders/convolution.fragment";
  73183. import { Scene } from "babylonjs/scene";
  73184. /**
  73185. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73186. * input texture to perform effects such as edge detection or sharpening
  73187. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73188. */
  73189. export class ConvolutionPostProcess extends PostProcess {
  73190. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73191. kernel: number[];
  73192. /**
  73193. * Gets a string identifying the name of the class
  73194. * @returns "ConvolutionPostProcess" string
  73195. */
  73196. getClassName(): string;
  73197. /**
  73198. * Creates a new instance ConvolutionPostProcess
  73199. * @param name The name of the effect.
  73200. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73201. * @param options The required width/height ratio to downsize to before computing the render pass.
  73202. * @param camera The camera to apply the render pass to.
  73203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73204. * @param engine The engine which the post process will be applied. (default: current engine)
  73205. * @param reusable If the post process can be reused on the same frame. (default: false)
  73206. * @param textureType Type of textures used when performing the post process. (default: 0)
  73207. */
  73208. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73209. /** @hidden */
  73210. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73211. /**
  73212. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73213. */
  73214. static EdgeDetect0Kernel: number[];
  73215. /**
  73216. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73217. */
  73218. static EdgeDetect1Kernel: number[];
  73219. /**
  73220. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73221. */
  73222. static EdgeDetect2Kernel: number[];
  73223. /**
  73224. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73225. */
  73226. static SharpenKernel: number[];
  73227. /**
  73228. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73229. */
  73230. static EmbossKernel: number[];
  73231. /**
  73232. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73233. */
  73234. static GaussianKernel: number[];
  73235. }
  73236. }
  73237. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73238. import { Nullable } from "babylonjs/types";
  73239. import { Vector2 } from "babylonjs/Maths/math.vector";
  73240. import { Camera } from "babylonjs/Cameras/camera";
  73241. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73242. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73243. import { Engine } from "babylonjs/Engines/engine";
  73244. import { Scene } from "babylonjs/scene";
  73245. /**
  73246. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73247. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73248. * based on samples that have a large difference in distance than the center pixel.
  73249. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73250. */
  73251. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73252. /**
  73253. * The direction the blur should be applied
  73254. */
  73255. direction: Vector2;
  73256. /**
  73257. * Gets a string identifying the name of the class
  73258. * @returns "DepthOfFieldBlurPostProcess" string
  73259. */
  73260. getClassName(): string;
  73261. /**
  73262. * Creates a new instance CircleOfConfusionPostProcess
  73263. * @param name The name of the effect.
  73264. * @param scene The scene the effect belongs to.
  73265. * @param direction The direction the blur should be applied.
  73266. * @param kernel The size of the kernel used to blur.
  73267. * @param options The required width/height ratio to downsize to before computing the render pass.
  73268. * @param camera The camera to apply the render pass to.
  73269. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73270. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73272. * @param engine The engine which the post process will be applied. (default: current engine)
  73273. * @param reusable If the post process can be reused on the same frame. (default: false)
  73274. * @param textureType Type of textures used when performing the post process. (default: 0)
  73275. * @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)
  73276. */
  73277. 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);
  73278. }
  73279. }
  73280. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73281. /** @hidden */
  73282. export var depthOfFieldMergePixelShader: {
  73283. name: string;
  73284. shader: string;
  73285. };
  73286. }
  73287. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73288. import { Nullable } from "babylonjs/types";
  73289. import { Camera } from "babylonjs/Cameras/camera";
  73290. import { Effect } from "babylonjs/Materials/effect";
  73291. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73292. import { Engine } from "babylonjs/Engines/engine";
  73293. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73294. /**
  73295. * Options to be set when merging outputs from the default pipeline.
  73296. */
  73297. export class DepthOfFieldMergePostProcessOptions {
  73298. /**
  73299. * The original image to merge on top of
  73300. */
  73301. originalFromInput: PostProcess;
  73302. /**
  73303. * Parameters to perform the merge of the depth of field effect
  73304. */
  73305. depthOfField?: {
  73306. circleOfConfusion: PostProcess;
  73307. blurSteps: Array<PostProcess>;
  73308. };
  73309. /**
  73310. * Parameters to perform the merge of bloom effect
  73311. */
  73312. bloom?: {
  73313. blurred: PostProcess;
  73314. weight: number;
  73315. };
  73316. }
  73317. /**
  73318. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73319. */
  73320. export class DepthOfFieldMergePostProcess extends PostProcess {
  73321. private blurSteps;
  73322. /**
  73323. * Gets a string identifying the name of the class
  73324. * @returns "DepthOfFieldMergePostProcess" string
  73325. */
  73326. getClassName(): string;
  73327. /**
  73328. * Creates a new instance of DepthOfFieldMergePostProcess
  73329. * @param name The name of the effect.
  73330. * @param originalFromInput Post process which's input will be used for the merge.
  73331. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73332. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73333. * @param options The required width/height ratio to downsize to before computing the render pass.
  73334. * @param camera The camera to apply the render pass to.
  73335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73336. * @param engine The engine which the post process will be applied. (default: current engine)
  73337. * @param reusable If the post process can be reused on the same frame. (default: false)
  73338. * @param textureType Type of textures used when performing the post process. (default: 0)
  73339. * @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)
  73340. */
  73341. 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);
  73342. /**
  73343. * Updates the effect with the current post process compile time values and recompiles the shader.
  73344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73347. * @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
  73348. * @param onCompiled Called when the shader has been compiled.
  73349. * @param onError Called if there is an error when compiling a shader.
  73350. */
  73351. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73352. }
  73353. }
  73354. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73355. import { Nullable } from "babylonjs/types";
  73356. import { Camera } from "babylonjs/Cameras/camera";
  73357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73359. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73360. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73361. import { Scene } from "babylonjs/scene";
  73362. /**
  73363. * Specifies the level of max blur that should be applied when using the depth of field effect
  73364. */
  73365. export enum DepthOfFieldEffectBlurLevel {
  73366. /**
  73367. * Subtle blur
  73368. */
  73369. Low = 0,
  73370. /**
  73371. * Medium blur
  73372. */
  73373. Medium = 1,
  73374. /**
  73375. * Large blur
  73376. */
  73377. High = 2
  73378. }
  73379. /**
  73380. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73381. */
  73382. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73383. private _circleOfConfusion;
  73384. /**
  73385. * @hidden Internal, blurs from high to low
  73386. */
  73387. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73388. private _depthOfFieldBlurY;
  73389. private _dofMerge;
  73390. /**
  73391. * @hidden Internal post processes in depth of field effect
  73392. */
  73393. _effects: Array<PostProcess>;
  73394. /**
  73395. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73396. */
  73397. set focalLength(value: number);
  73398. get focalLength(): number;
  73399. /**
  73400. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73401. */
  73402. set fStop(value: number);
  73403. get fStop(): number;
  73404. /**
  73405. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73406. */
  73407. set focusDistance(value: number);
  73408. get focusDistance(): number;
  73409. /**
  73410. * 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.
  73411. */
  73412. set lensSize(value: number);
  73413. get lensSize(): number;
  73414. /**
  73415. * Creates a new instance DepthOfFieldEffect
  73416. * @param scene The scene the effect belongs to.
  73417. * @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.
  73418. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73419. * @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)
  73420. */
  73421. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73422. /**
  73423. * Get the current class name of the current effet
  73424. * @returns "DepthOfFieldEffect"
  73425. */
  73426. getClassName(): string;
  73427. /**
  73428. * 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.
  73429. */
  73430. set depthTexture(value: RenderTargetTexture);
  73431. /**
  73432. * Disposes each of the internal effects for a given camera.
  73433. * @param camera The camera to dispose the effect on.
  73434. */
  73435. disposeEffects(camera: Camera): void;
  73436. /**
  73437. * @hidden Internal
  73438. */
  73439. _updateEffects(): void;
  73440. /**
  73441. * Internal
  73442. * @returns if all the contained post processes are ready.
  73443. * @hidden
  73444. */
  73445. _isReady(): boolean;
  73446. }
  73447. }
  73448. declare module "babylonjs/Shaders/displayPass.fragment" {
  73449. /** @hidden */
  73450. export var displayPassPixelShader: {
  73451. name: string;
  73452. shader: string;
  73453. };
  73454. }
  73455. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73456. import { Nullable } from "babylonjs/types";
  73457. import { Camera } from "babylonjs/Cameras/camera";
  73458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73459. import { Engine } from "babylonjs/Engines/engine";
  73460. import "babylonjs/Shaders/displayPass.fragment";
  73461. import { Scene } from "babylonjs/scene";
  73462. /**
  73463. * DisplayPassPostProcess which produces an output the same as it's input
  73464. */
  73465. export class DisplayPassPostProcess extends PostProcess {
  73466. /**
  73467. * Gets a string identifying the name of the class
  73468. * @returns "DisplayPassPostProcess" string
  73469. */
  73470. getClassName(): string;
  73471. /**
  73472. * Creates the DisplayPassPostProcess
  73473. * @param name The name of the effect.
  73474. * @param options The required width/height ratio to downsize to before computing the render pass.
  73475. * @param camera The camera to apply the render pass to.
  73476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73477. * @param engine The engine which the post process will be applied. (default: current engine)
  73478. * @param reusable If the post process can be reused on the same frame. (default: false)
  73479. */
  73480. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73481. /** @hidden */
  73482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73483. }
  73484. }
  73485. declare module "babylonjs/Shaders/filter.fragment" {
  73486. /** @hidden */
  73487. export var filterPixelShader: {
  73488. name: string;
  73489. shader: string;
  73490. };
  73491. }
  73492. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73493. import { Nullable } from "babylonjs/types";
  73494. import { Matrix } from "babylonjs/Maths/math.vector";
  73495. import { Camera } from "babylonjs/Cameras/camera";
  73496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73497. import { Engine } from "babylonjs/Engines/engine";
  73498. import "babylonjs/Shaders/filter.fragment";
  73499. import { Scene } from "babylonjs/scene";
  73500. /**
  73501. * Applies a kernel filter to the image
  73502. */
  73503. export class FilterPostProcess extends PostProcess {
  73504. /** The matrix to be applied to the image */
  73505. kernelMatrix: Matrix;
  73506. /**
  73507. * Gets a string identifying the name of the class
  73508. * @returns "FilterPostProcess" string
  73509. */
  73510. getClassName(): string;
  73511. /**
  73512. *
  73513. * @param name The name of the effect.
  73514. * @param kernelMatrix The matrix to be applied to the image
  73515. * @param options The required width/height ratio to downsize to before computing the render pass.
  73516. * @param camera The camera to apply the render pass to.
  73517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73518. * @param engine The engine which the post process will be applied. (default: current engine)
  73519. * @param reusable If the post process can be reused on the same frame. (default: false)
  73520. */
  73521. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73522. /** @hidden */
  73523. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73524. }
  73525. }
  73526. declare module "babylonjs/Shaders/fxaa.fragment" {
  73527. /** @hidden */
  73528. export var fxaaPixelShader: {
  73529. name: string;
  73530. shader: string;
  73531. };
  73532. }
  73533. declare module "babylonjs/Shaders/fxaa.vertex" {
  73534. /** @hidden */
  73535. export var fxaaVertexShader: {
  73536. name: string;
  73537. shader: string;
  73538. };
  73539. }
  73540. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73541. import { Nullable } from "babylonjs/types";
  73542. import { Camera } from "babylonjs/Cameras/camera";
  73543. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73544. import { Engine } from "babylonjs/Engines/engine";
  73545. import "babylonjs/Shaders/fxaa.fragment";
  73546. import "babylonjs/Shaders/fxaa.vertex";
  73547. import { Scene } from "babylonjs/scene";
  73548. /**
  73549. * Fxaa post process
  73550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73551. */
  73552. export class FxaaPostProcess extends PostProcess {
  73553. /**
  73554. * Gets a string identifying the name of the class
  73555. * @returns "FxaaPostProcess" string
  73556. */
  73557. getClassName(): string;
  73558. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73559. private _getDefines;
  73560. /** @hidden */
  73561. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73562. }
  73563. }
  73564. declare module "babylonjs/Shaders/grain.fragment" {
  73565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73566. /** @hidden */
  73567. export var grainPixelShader: {
  73568. name: string;
  73569. shader: string;
  73570. };
  73571. }
  73572. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73573. import { Nullable } from "babylonjs/types";
  73574. import { Camera } from "babylonjs/Cameras/camera";
  73575. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73576. import { Engine } from "babylonjs/Engines/engine";
  73577. import "babylonjs/Shaders/grain.fragment";
  73578. import { Scene } from "babylonjs/scene";
  73579. /**
  73580. * The GrainPostProcess adds noise to the image at mid luminance levels
  73581. */
  73582. export class GrainPostProcess extends PostProcess {
  73583. /**
  73584. * The intensity of the grain added (default: 30)
  73585. */
  73586. intensity: number;
  73587. /**
  73588. * If the grain should be randomized on every frame
  73589. */
  73590. animated: boolean;
  73591. /**
  73592. * Gets a string identifying the name of the class
  73593. * @returns "GrainPostProcess" string
  73594. */
  73595. getClassName(): string;
  73596. /**
  73597. * Creates a new instance of @see GrainPostProcess
  73598. * @param name The name of the effect.
  73599. * @param options The required width/height ratio to downsize to before computing the render pass.
  73600. * @param camera The camera to apply the render pass to.
  73601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73602. * @param engine The engine which the post process will be applied. (default: current engine)
  73603. * @param reusable If the post process can be reused on the same frame. (default: false)
  73604. * @param textureType Type of textures used when performing the post process. (default: 0)
  73605. * @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)
  73606. */
  73607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73608. /** @hidden */
  73609. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73610. }
  73611. }
  73612. declare module "babylonjs/Shaders/highlights.fragment" {
  73613. /** @hidden */
  73614. export var highlightsPixelShader: {
  73615. name: string;
  73616. shader: string;
  73617. };
  73618. }
  73619. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73620. import { Nullable } from "babylonjs/types";
  73621. import { Camera } from "babylonjs/Cameras/camera";
  73622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73623. import { Engine } from "babylonjs/Engines/engine";
  73624. import "babylonjs/Shaders/highlights.fragment";
  73625. /**
  73626. * Extracts highlights from the image
  73627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73628. */
  73629. export class HighlightsPostProcess extends PostProcess {
  73630. /**
  73631. * Gets a string identifying the name of the class
  73632. * @returns "HighlightsPostProcess" string
  73633. */
  73634. getClassName(): string;
  73635. /**
  73636. * Extracts highlights from the image
  73637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73638. * @param name The name of the effect.
  73639. * @param options The required width/height ratio to downsize to before computing the render pass.
  73640. * @param camera The camera to apply the render pass to.
  73641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73642. * @param engine The engine which the post process will be applied. (default: current engine)
  73643. * @param reusable If the post process can be reused on the same frame. (default: false)
  73644. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73645. */
  73646. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73647. }
  73648. }
  73649. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73650. /** @hidden */
  73651. export var mrtFragmentDeclaration: {
  73652. name: string;
  73653. shader: string;
  73654. };
  73655. }
  73656. declare module "babylonjs/Shaders/geometry.fragment" {
  73657. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73658. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73659. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73660. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73661. /** @hidden */
  73662. export var geometryPixelShader: {
  73663. name: string;
  73664. shader: string;
  73665. };
  73666. }
  73667. declare module "babylonjs/Shaders/geometry.vertex" {
  73668. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73669. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73670. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73671. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73672. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73673. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73674. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73675. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73676. /** @hidden */
  73677. export var geometryVertexShader: {
  73678. name: string;
  73679. shader: string;
  73680. };
  73681. }
  73682. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73683. import { Matrix } from "babylonjs/Maths/math.vector";
  73684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73685. import { Mesh } from "babylonjs/Meshes/mesh";
  73686. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73687. import { Effect } from "babylonjs/Materials/effect";
  73688. import { Scene } from "babylonjs/scene";
  73689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73690. import "babylonjs/Shaders/geometry.fragment";
  73691. import "babylonjs/Shaders/geometry.vertex";
  73692. /** @hidden */
  73693. interface ISavedTransformationMatrix {
  73694. world: Matrix;
  73695. viewProjection: Matrix;
  73696. }
  73697. /**
  73698. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73699. */
  73700. export class GeometryBufferRenderer {
  73701. /**
  73702. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73703. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73704. */
  73705. static readonly POSITION_TEXTURE_TYPE: number;
  73706. /**
  73707. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73708. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73709. */
  73710. static readonly VELOCITY_TEXTURE_TYPE: number;
  73711. /**
  73712. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73713. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73714. */
  73715. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73716. /**
  73717. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73718. * in order to compute objects velocities when enableVelocity is set to "true"
  73719. * @hidden
  73720. */
  73721. _previousTransformationMatrices: {
  73722. [index: number]: ISavedTransformationMatrix;
  73723. };
  73724. /**
  73725. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73726. * in order to compute objects velocities when enableVelocity is set to "true"
  73727. * @hidden
  73728. */
  73729. _previousBonesTransformationMatrices: {
  73730. [index: number]: Float32Array;
  73731. };
  73732. /**
  73733. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73734. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73735. */
  73736. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73737. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73738. renderTransparentMeshes: boolean;
  73739. private _scene;
  73740. private _resizeObserver;
  73741. private _multiRenderTarget;
  73742. private _ratio;
  73743. private _enablePosition;
  73744. private _enableVelocity;
  73745. private _enableReflectivity;
  73746. private _positionIndex;
  73747. private _velocityIndex;
  73748. private _reflectivityIndex;
  73749. protected _effect: Effect;
  73750. protected _cachedDefines: string;
  73751. /**
  73752. * Set the render list (meshes to be rendered) used in the G buffer.
  73753. */
  73754. set renderList(meshes: Mesh[]);
  73755. /**
  73756. * Gets wether or not G buffer are supported by the running hardware.
  73757. * This requires draw buffer supports
  73758. */
  73759. get isSupported(): boolean;
  73760. /**
  73761. * Returns the index of the given texture type in the G-Buffer textures array
  73762. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73763. * @returns the index of the given texture type in the G-Buffer textures array
  73764. */
  73765. getTextureIndex(textureType: number): number;
  73766. /**
  73767. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73768. */
  73769. get enablePosition(): boolean;
  73770. /**
  73771. * Sets whether or not objects positions are enabled for the G buffer.
  73772. */
  73773. set enablePosition(enable: boolean);
  73774. /**
  73775. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73776. */
  73777. get enableVelocity(): boolean;
  73778. /**
  73779. * Sets wether or not objects velocities are enabled for the G buffer.
  73780. */
  73781. set enableVelocity(enable: boolean);
  73782. /**
  73783. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73784. */
  73785. get enableReflectivity(): boolean;
  73786. /**
  73787. * Sets wether or not objects roughness are enabled for the G buffer.
  73788. */
  73789. set enableReflectivity(enable: boolean);
  73790. /**
  73791. * Gets the scene associated with the buffer.
  73792. */
  73793. get scene(): Scene;
  73794. /**
  73795. * Gets the ratio used by the buffer during its creation.
  73796. * How big is the buffer related to the main canvas.
  73797. */
  73798. get ratio(): number;
  73799. /** @hidden */
  73800. static _SceneComponentInitialization: (scene: Scene) => void;
  73801. /**
  73802. * Creates a new G Buffer for the scene
  73803. * @param scene The scene the buffer belongs to
  73804. * @param ratio How big is the buffer related to the main canvas.
  73805. */
  73806. constructor(scene: Scene, ratio?: number);
  73807. /**
  73808. * Checks wether everything is ready to render a submesh to the G buffer.
  73809. * @param subMesh the submesh to check readiness for
  73810. * @param useInstances is the mesh drawn using instance or not
  73811. * @returns true if ready otherwise false
  73812. */
  73813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73814. /**
  73815. * Gets the current underlying G Buffer.
  73816. * @returns the buffer
  73817. */
  73818. getGBuffer(): MultiRenderTarget;
  73819. /**
  73820. * Gets the number of samples used to render the buffer (anti aliasing).
  73821. */
  73822. get samples(): number;
  73823. /**
  73824. * Sets the number of samples used to render the buffer (anti aliasing).
  73825. */
  73826. set samples(value: number);
  73827. /**
  73828. * Disposes the renderer and frees up associated resources.
  73829. */
  73830. dispose(): void;
  73831. protected _createRenderTargets(): void;
  73832. private _copyBonesTransformationMatrices;
  73833. }
  73834. }
  73835. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73836. import { Nullable } from "babylonjs/types";
  73837. import { Scene } from "babylonjs/scene";
  73838. import { ISceneComponent } from "babylonjs/sceneComponent";
  73839. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73840. module "babylonjs/scene" {
  73841. interface Scene {
  73842. /** @hidden (Backing field) */
  73843. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73844. /**
  73845. * Gets or Sets the current geometry buffer associated to the scene.
  73846. */
  73847. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73848. /**
  73849. * Enables a GeometryBufferRender and associates it with the scene
  73850. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73851. * @returns the GeometryBufferRenderer
  73852. */
  73853. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73854. /**
  73855. * Disables the GeometryBufferRender associated with the scene
  73856. */
  73857. disableGeometryBufferRenderer(): void;
  73858. }
  73859. }
  73860. /**
  73861. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73862. * in several rendering techniques.
  73863. */
  73864. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73865. /**
  73866. * The component name helpful to identify the component in the list of scene components.
  73867. */
  73868. readonly name: string;
  73869. /**
  73870. * The scene the component belongs to.
  73871. */
  73872. scene: Scene;
  73873. /**
  73874. * Creates a new instance of the component for the given scene
  73875. * @param scene Defines the scene to register the component in
  73876. */
  73877. constructor(scene: Scene);
  73878. /**
  73879. * Registers the component in a given scene
  73880. */
  73881. register(): void;
  73882. /**
  73883. * Rebuilds the elements related to this component in case of
  73884. * context lost for instance.
  73885. */
  73886. rebuild(): void;
  73887. /**
  73888. * Disposes the component and the associated ressources
  73889. */
  73890. dispose(): void;
  73891. private _gatherRenderTargets;
  73892. }
  73893. }
  73894. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73895. /** @hidden */
  73896. export var motionBlurPixelShader: {
  73897. name: string;
  73898. shader: string;
  73899. };
  73900. }
  73901. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73902. import { Nullable } from "babylonjs/types";
  73903. import { Camera } from "babylonjs/Cameras/camera";
  73904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73906. import "babylonjs/Animations/animatable";
  73907. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73908. import "babylonjs/Shaders/motionBlur.fragment";
  73909. import { Engine } from "babylonjs/Engines/engine";
  73910. import { Scene } from "babylonjs/scene";
  73911. /**
  73912. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73913. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73914. * As an example, all you have to do is to create the post-process:
  73915. * var mb = new BABYLON.MotionBlurPostProcess(
  73916. * 'mb', // The name of the effect.
  73917. * scene, // The scene containing the objects to blur according to their velocity.
  73918. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73919. * camera // The camera to apply the render pass to.
  73920. * );
  73921. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73922. */
  73923. export class MotionBlurPostProcess extends PostProcess {
  73924. /**
  73925. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73926. */
  73927. motionStrength: number;
  73928. /**
  73929. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73930. */
  73931. get motionBlurSamples(): number;
  73932. /**
  73933. * Sets the number of iterations to be used for motion blur quality
  73934. */
  73935. set motionBlurSamples(samples: number);
  73936. private _motionBlurSamples;
  73937. private _geometryBufferRenderer;
  73938. /**
  73939. * Gets a string identifying the name of the class
  73940. * @returns "MotionBlurPostProcess" string
  73941. */
  73942. getClassName(): string;
  73943. /**
  73944. * Creates a new instance MotionBlurPostProcess
  73945. * @param name The name of the effect.
  73946. * @param scene The scene containing the objects to blur according to their velocity.
  73947. * @param options The required width/height ratio to downsize to before computing the render pass.
  73948. * @param camera The camera to apply the render pass to.
  73949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73950. * @param engine The engine which the post process will be applied. (default: current engine)
  73951. * @param reusable If the post process can be reused on the same frame. (default: false)
  73952. * @param textureType Type of textures used when performing the post process. (default: 0)
  73953. * @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)
  73954. */
  73955. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73956. /**
  73957. * Excludes the given skinned mesh from computing bones velocities.
  73958. * 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.
  73959. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73960. */
  73961. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73962. /**
  73963. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73964. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73965. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73966. */
  73967. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73968. /**
  73969. * Disposes the post process.
  73970. * @param camera The camera to dispose the post process on.
  73971. */
  73972. dispose(camera?: Camera): void;
  73973. /** @hidden */
  73974. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73975. }
  73976. }
  73977. declare module "babylonjs/Shaders/refraction.fragment" {
  73978. /** @hidden */
  73979. export var refractionPixelShader: {
  73980. name: string;
  73981. shader: string;
  73982. };
  73983. }
  73984. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73985. import { Color3 } from "babylonjs/Maths/math.color";
  73986. import { Camera } from "babylonjs/Cameras/camera";
  73987. import { Texture } from "babylonjs/Materials/Textures/texture";
  73988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73989. import { Engine } from "babylonjs/Engines/engine";
  73990. import "babylonjs/Shaders/refraction.fragment";
  73991. import { Scene } from "babylonjs/scene";
  73992. /**
  73993. * Post process which applies a refractin texture
  73994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73995. */
  73996. export class RefractionPostProcess extends PostProcess {
  73997. private _refTexture;
  73998. private _ownRefractionTexture;
  73999. /** the base color of the refraction (used to taint the rendering) */
  74000. color: Color3;
  74001. /** simulated refraction depth */
  74002. depth: number;
  74003. /** the coefficient of the base color (0 to remove base color tainting) */
  74004. colorLevel: number;
  74005. /** Gets the url used to load the refraction texture */
  74006. refractionTextureUrl: string;
  74007. /**
  74008. * Gets or sets the refraction texture
  74009. * Please note that you are responsible for disposing the texture if you set it manually
  74010. */
  74011. get refractionTexture(): Texture;
  74012. set refractionTexture(value: Texture);
  74013. /**
  74014. * Gets a string identifying the name of the class
  74015. * @returns "RefractionPostProcess" string
  74016. */
  74017. getClassName(): string;
  74018. /**
  74019. * Initializes the RefractionPostProcess
  74020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74021. * @param name The name of the effect.
  74022. * @param refractionTextureUrl Url of the refraction texture to use
  74023. * @param color the base color of the refraction (used to taint the rendering)
  74024. * @param depth simulated refraction depth
  74025. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74026. * @param camera The camera to apply the render pass to.
  74027. * @param options The required width/height ratio to downsize to before computing the render pass.
  74028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74029. * @param engine The engine which the post process will be applied. (default: current engine)
  74030. * @param reusable If the post process can be reused on the same frame. (default: false)
  74031. */
  74032. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74033. /**
  74034. * Disposes of the post process
  74035. * @param camera Camera to dispose post process on
  74036. */
  74037. dispose(camera: Camera): void;
  74038. /** @hidden */
  74039. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74040. }
  74041. }
  74042. declare module "babylonjs/Shaders/sharpen.fragment" {
  74043. /** @hidden */
  74044. export var sharpenPixelShader: {
  74045. name: string;
  74046. shader: string;
  74047. };
  74048. }
  74049. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74050. import { Nullable } from "babylonjs/types";
  74051. import { Camera } from "babylonjs/Cameras/camera";
  74052. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74053. import "babylonjs/Shaders/sharpen.fragment";
  74054. import { Engine } from "babylonjs/Engines/engine";
  74055. import { Scene } from "babylonjs/scene";
  74056. /**
  74057. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74058. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74059. */
  74060. export class SharpenPostProcess extends PostProcess {
  74061. /**
  74062. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74063. */
  74064. colorAmount: number;
  74065. /**
  74066. * How much sharpness should be applied (default: 0.3)
  74067. */
  74068. edgeAmount: number;
  74069. /**
  74070. * Gets a string identifying the name of the class
  74071. * @returns "SharpenPostProcess" string
  74072. */
  74073. getClassName(): string;
  74074. /**
  74075. * Creates a new instance ConvolutionPostProcess
  74076. * @param name The name of the effect.
  74077. * @param options The required width/height ratio to downsize to before computing the render pass.
  74078. * @param camera The camera to apply the render pass to.
  74079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74080. * @param engine The engine which the post process will be applied. (default: current engine)
  74081. * @param reusable If the post process can be reused on the same frame. (default: false)
  74082. * @param textureType Type of textures used when performing the post process. (default: 0)
  74083. * @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)
  74084. */
  74085. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74086. /** @hidden */
  74087. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74088. }
  74089. }
  74090. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74091. import { Nullable } from "babylonjs/types";
  74092. import { Camera } from "babylonjs/Cameras/camera";
  74093. import { Engine } from "babylonjs/Engines/engine";
  74094. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74095. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74096. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74097. /**
  74098. * PostProcessRenderPipeline
  74099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74100. */
  74101. export class PostProcessRenderPipeline {
  74102. private engine;
  74103. private _renderEffects;
  74104. private _renderEffectsForIsolatedPass;
  74105. /**
  74106. * List of inspectable custom properties (used by the Inspector)
  74107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74108. */
  74109. inspectableCustomProperties: IInspectable[];
  74110. /**
  74111. * @hidden
  74112. */
  74113. protected _cameras: Camera[];
  74114. /** @hidden */
  74115. _name: string;
  74116. /**
  74117. * Gets pipeline name
  74118. */
  74119. get name(): string;
  74120. /** Gets the list of attached cameras */
  74121. get cameras(): Camera[];
  74122. /**
  74123. * Initializes a PostProcessRenderPipeline
  74124. * @param engine engine to add the pipeline to
  74125. * @param name name of the pipeline
  74126. */
  74127. constructor(engine: Engine, name: string);
  74128. /**
  74129. * Gets the class name
  74130. * @returns "PostProcessRenderPipeline"
  74131. */
  74132. getClassName(): string;
  74133. /**
  74134. * If all the render effects in the pipeline are supported
  74135. */
  74136. get isSupported(): boolean;
  74137. /**
  74138. * Adds an effect to the pipeline
  74139. * @param renderEffect the effect to add
  74140. */
  74141. addEffect(renderEffect: PostProcessRenderEffect): void;
  74142. /** @hidden */
  74143. _rebuild(): void;
  74144. /** @hidden */
  74145. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74146. /** @hidden */
  74147. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74148. /** @hidden */
  74149. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74150. /** @hidden */
  74151. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74152. /** @hidden */
  74153. _attachCameras(cameras: Camera, unique: boolean): void;
  74154. /** @hidden */
  74155. _attachCameras(cameras: Camera[], unique: boolean): void;
  74156. /** @hidden */
  74157. _detachCameras(cameras: Camera): void;
  74158. /** @hidden */
  74159. _detachCameras(cameras: Nullable<Camera[]>): void;
  74160. /** @hidden */
  74161. _update(): void;
  74162. /** @hidden */
  74163. _reset(): void;
  74164. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74165. /**
  74166. * Sets the required values to the prepass renderer.
  74167. * @param prePassRenderer defines the prepass renderer to setup.
  74168. * @returns true if the pre pass is needed.
  74169. */
  74170. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74171. /**
  74172. * Disposes of the pipeline
  74173. */
  74174. dispose(): void;
  74175. }
  74176. }
  74177. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74178. import { Camera } from "babylonjs/Cameras/camera";
  74179. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74180. /**
  74181. * PostProcessRenderPipelineManager class
  74182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74183. */
  74184. export class PostProcessRenderPipelineManager {
  74185. private _renderPipelines;
  74186. /**
  74187. * Initializes a PostProcessRenderPipelineManager
  74188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74189. */
  74190. constructor();
  74191. /**
  74192. * Gets the list of supported render pipelines
  74193. */
  74194. get supportedPipelines(): PostProcessRenderPipeline[];
  74195. /**
  74196. * Adds a pipeline to the manager
  74197. * @param renderPipeline The pipeline to add
  74198. */
  74199. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74200. /**
  74201. * Attaches a camera to the pipeline
  74202. * @param renderPipelineName The name of the pipeline to attach to
  74203. * @param cameras the camera to attach
  74204. * @param unique if the camera can be attached multiple times to the pipeline
  74205. */
  74206. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74207. /**
  74208. * Detaches a camera from the pipeline
  74209. * @param renderPipelineName The name of the pipeline to detach from
  74210. * @param cameras the camera to detach
  74211. */
  74212. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74213. /**
  74214. * Enables an effect by name on a pipeline
  74215. * @param renderPipelineName the name of the pipeline to enable the effect in
  74216. * @param renderEffectName the name of the effect to enable
  74217. * @param cameras the cameras that the effect should be enabled on
  74218. */
  74219. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74220. /**
  74221. * Disables an effect by name on a pipeline
  74222. * @param renderPipelineName the name of the pipeline to disable the effect in
  74223. * @param renderEffectName the name of the effect to disable
  74224. * @param cameras the cameras that the effect should be disabled on
  74225. */
  74226. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74227. /**
  74228. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74229. */
  74230. update(): void;
  74231. /** @hidden */
  74232. _rebuild(): void;
  74233. /**
  74234. * Disposes of the manager and pipelines
  74235. */
  74236. dispose(): void;
  74237. }
  74238. }
  74239. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74240. import { ISceneComponent } from "babylonjs/sceneComponent";
  74241. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74242. import { Scene } from "babylonjs/scene";
  74243. module "babylonjs/scene" {
  74244. interface Scene {
  74245. /** @hidden (Backing field) */
  74246. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74247. /**
  74248. * Gets the postprocess render pipeline manager
  74249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74250. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74251. */
  74252. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74253. }
  74254. }
  74255. /**
  74256. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74257. */
  74258. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74259. /**
  74260. * The component name helpfull to identify the component in the list of scene components.
  74261. */
  74262. readonly name: string;
  74263. /**
  74264. * The scene the component belongs to.
  74265. */
  74266. scene: Scene;
  74267. /**
  74268. * Creates a new instance of the component for the given scene
  74269. * @param scene Defines the scene to register the component in
  74270. */
  74271. constructor(scene: Scene);
  74272. /**
  74273. * Registers the component in a given scene
  74274. */
  74275. register(): void;
  74276. /**
  74277. * Rebuilds the elements related to this component in case of
  74278. * context lost for instance.
  74279. */
  74280. rebuild(): void;
  74281. /**
  74282. * Disposes the component and the associated ressources
  74283. */
  74284. dispose(): void;
  74285. private _gatherRenderTargets;
  74286. }
  74287. }
  74288. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74289. import { Nullable } from "babylonjs/types";
  74290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74291. import { Camera } from "babylonjs/Cameras/camera";
  74292. import { IDisposable } from "babylonjs/scene";
  74293. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74294. import { Scene } from "babylonjs/scene";
  74295. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74296. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74297. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74298. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74299. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74300. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74301. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74302. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74303. import { Animation } from "babylonjs/Animations/animation";
  74304. /**
  74305. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74306. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74307. */
  74308. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74309. private _scene;
  74310. private _camerasToBeAttached;
  74311. /**
  74312. * ID of the sharpen post process,
  74313. */
  74314. private readonly SharpenPostProcessId;
  74315. /**
  74316. * @ignore
  74317. * ID of the image processing post process;
  74318. */
  74319. readonly ImageProcessingPostProcessId: string;
  74320. /**
  74321. * @ignore
  74322. * ID of the Fast Approximate Anti-Aliasing post process;
  74323. */
  74324. readonly FxaaPostProcessId: string;
  74325. /**
  74326. * ID of the chromatic aberration post process,
  74327. */
  74328. private readonly ChromaticAberrationPostProcessId;
  74329. /**
  74330. * ID of the grain post process
  74331. */
  74332. private readonly GrainPostProcessId;
  74333. /**
  74334. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74335. */
  74336. sharpen: SharpenPostProcess;
  74337. private _sharpenEffect;
  74338. private bloom;
  74339. /**
  74340. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74341. */
  74342. depthOfField: DepthOfFieldEffect;
  74343. /**
  74344. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74345. */
  74346. fxaa: FxaaPostProcess;
  74347. /**
  74348. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74349. */
  74350. imageProcessing: ImageProcessingPostProcess;
  74351. /**
  74352. * Chromatic aberration post process which will shift rgb colors in the image
  74353. */
  74354. chromaticAberration: ChromaticAberrationPostProcess;
  74355. private _chromaticAberrationEffect;
  74356. /**
  74357. * Grain post process which add noise to the image
  74358. */
  74359. grain: GrainPostProcess;
  74360. private _grainEffect;
  74361. /**
  74362. * Glow post process which adds a glow to emissive areas of the image
  74363. */
  74364. private _glowLayer;
  74365. /**
  74366. * Animations which can be used to tweak settings over a period of time
  74367. */
  74368. animations: Animation[];
  74369. private _imageProcessingConfigurationObserver;
  74370. private _sharpenEnabled;
  74371. private _bloomEnabled;
  74372. private _depthOfFieldEnabled;
  74373. private _depthOfFieldBlurLevel;
  74374. private _fxaaEnabled;
  74375. private _imageProcessingEnabled;
  74376. private _defaultPipelineTextureType;
  74377. private _bloomScale;
  74378. private _chromaticAberrationEnabled;
  74379. private _grainEnabled;
  74380. private _buildAllowed;
  74381. /**
  74382. * Gets active scene
  74383. */
  74384. get scene(): Scene;
  74385. /**
  74386. * Enable or disable the sharpen process from the pipeline
  74387. */
  74388. set sharpenEnabled(enabled: boolean);
  74389. get sharpenEnabled(): boolean;
  74390. private _resizeObserver;
  74391. private _hardwareScaleLevel;
  74392. private _bloomKernel;
  74393. /**
  74394. * Specifies the size of the bloom blur kernel, relative to the final output size
  74395. */
  74396. get bloomKernel(): number;
  74397. set bloomKernel(value: number);
  74398. /**
  74399. * Specifies the weight of the bloom in the final rendering
  74400. */
  74401. private _bloomWeight;
  74402. /**
  74403. * Specifies the luma threshold for the area that will be blurred by the bloom
  74404. */
  74405. private _bloomThreshold;
  74406. private _hdr;
  74407. /**
  74408. * The strength of the bloom.
  74409. */
  74410. set bloomWeight(value: number);
  74411. get bloomWeight(): number;
  74412. /**
  74413. * The strength of the bloom.
  74414. */
  74415. set bloomThreshold(value: number);
  74416. get bloomThreshold(): number;
  74417. /**
  74418. * The scale of the bloom, lower value will provide better performance.
  74419. */
  74420. set bloomScale(value: number);
  74421. get bloomScale(): number;
  74422. /**
  74423. * Enable or disable the bloom from the pipeline
  74424. */
  74425. set bloomEnabled(enabled: boolean);
  74426. get bloomEnabled(): boolean;
  74427. private _rebuildBloom;
  74428. /**
  74429. * If the depth of field is enabled.
  74430. */
  74431. get depthOfFieldEnabled(): boolean;
  74432. set depthOfFieldEnabled(enabled: boolean);
  74433. /**
  74434. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74435. */
  74436. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74437. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74438. /**
  74439. * If the anti aliasing is enabled.
  74440. */
  74441. set fxaaEnabled(enabled: boolean);
  74442. get fxaaEnabled(): boolean;
  74443. private _samples;
  74444. /**
  74445. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74446. */
  74447. set samples(sampleCount: number);
  74448. get samples(): number;
  74449. /**
  74450. * If image processing is enabled.
  74451. */
  74452. set imageProcessingEnabled(enabled: boolean);
  74453. get imageProcessingEnabled(): boolean;
  74454. /**
  74455. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74456. */
  74457. set glowLayerEnabled(enabled: boolean);
  74458. get glowLayerEnabled(): boolean;
  74459. /**
  74460. * Gets the glow layer (or null if not defined)
  74461. */
  74462. get glowLayer(): Nullable<GlowLayer>;
  74463. /**
  74464. * Enable or disable the chromaticAberration process from the pipeline
  74465. */
  74466. set chromaticAberrationEnabled(enabled: boolean);
  74467. get chromaticAberrationEnabled(): boolean;
  74468. /**
  74469. * Enable or disable the grain process from the pipeline
  74470. */
  74471. set grainEnabled(enabled: boolean);
  74472. get grainEnabled(): boolean;
  74473. /**
  74474. * @constructor
  74475. * @param name - The rendering pipeline name (default: "")
  74476. * @param hdr - If high dynamic range textures should be used (default: true)
  74477. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74478. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74479. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74480. */
  74481. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74482. /**
  74483. * Get the class name
  74484. * @returns "DefaultRenderingPipeline"
  74485. */
  74486. getClassName(): string;
  74487. /**
  74488. * Force the compilation of the entire pipeline.
  74489. */
  74490. prepare(): void;
  74491. private _hasCleared;
  74492. private _prevPostProcess;
  74493. private _prevPrevPostProcess;
  74494. private _setAutoClearAndTextureSharing;
  74495. private _depthOfFieldSceneObserver;
  74496. private _buildPipeline;
  74497. private _disposePostProcesses;
  74498. /**
  74499. * Adds a camera to the pipeline
  74500. * @param camera the camera to be added
  74501. */
  74502. addCamera(camera: Camera): void;
  74503. /**
  74504. * Removes a camera from the pipeline
  74505. * @param camera the camera to remove
  74506. */
  74507. removeCamera(camera: Camera): void;
  74508. /**
  74509. * Dispose of the pipeline and stop all post processes
  74510. */
  74511. dispose(): void;
  74512. /**
  74513. * Serialize the rendering pipeline (Used when exporting)
  74514. * @returns the serialized object
  74515. */
  74516. serialize(): any;
  74517. /**
  74518. * Parse the serialized pipeline
  74519. * @param source Source pipeline.
  74520. * @param scene The scene to load the pipeline to.
  74521. * @param rootUrl The URL of the serialized pipeline.
  74522. * @returns An instantiated pipeline from the serialized object.
  74523. */
  74524. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74525. }
  74526. }
  74527. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74528. /** @hidden */
  74529. export var lensHighlightsPixelShader: {
  74530. name: string;
  74531. shader: string;
  74532. };
  74533. }
  74534. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74535. /** @hidden */
  74536. export var depthOfFieldPixelShader: {
  74537. name: string;
  74538. shader: string;
  74539. };
  74540. }
  74541. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74542. import { Camera } from "babylonjs/Cameras/camera";
  74543. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74544. import { Scene } from "babylonjs/scene";
  74545. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74546. import "babylonjs/Shaders/chromaticAberration.fragment";
  74547. import "babylonjs/Shaders/lensHighlights.fragment";
  74548. import "babylonjs/Shaders/depthOfField.fragment";
  74549. /**
  74550. * BABYLON.JS Chromatic Aberration GLSL Shader
  74551. * Author: Olivier Guyot
  74552. * Separates very slightly R, G and B colors on the edges of the screen
  74553. * Inspired by Francois Tarlier & Martins Upitis
  74554. */
  74555. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74556. /**
  74557. * @ignore
  74558. * The chromatic aberration PostProcess id in the pipeline
  74559. */
  74560. LensChromaticAberrationEffect: string;
  74561. /**
  74562. * @ignore
  74563. * The highlights enhancing PostProcess id in the pipeline
  74564. */
  74565. HighlightsEnhancingEffect: string;
  74566. /**
  74567. * @ignore
  74568. * The depth-of-field PostProcess id in the pipeline
  74569. */
  74570. LensDepthOfFieldEffect: string;
  74571. private _scene;
  74572. private _depthTexture;
  74573. private _grainTexture;
  74574. private _chromaticAberrationPostProcess;
  74575. private _highlightsPostProcess;
  74576. private _depthOfFieldPostProcess;
  74577. private _edgeBlur;
  74578. private _grainAmount;
  74579. private _chromaticAberration;
  74580. private _distortion;
  74581. private _highlightsGain;
  74582. private _highlightsThreshold;
  74583. private _dofDistance;
  74584. private _dofAperture;
  74585. private _dofDarken;
  74586. private _dofPentagon;
  74587. private _blurNoise;
  74588. /**
  74589. * @constructor
  74590. *
  74591. * Effect parameters are as follow:
  74592. * {
  74593. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74594. * edge_blur: number; // from 0 to x (1 for realism)
  74595. * distortion: number; // from 0 to x (1 for realism)
  74596. * grain_amount: number; // from 0 to 1
  74597. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74598. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74599. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74600. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74601. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74602. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74603. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74604. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74605. * }
  74606. * Note: if an effect parameter is unset, effect is disabled
  74607. *
  74608. * @param name The rendering pipeline name
  74609. * @param parameters - An object containing all parameters (see above)
  74610. * @param scene The scene linked to this pipeline
  74611. * @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)
  74612. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74613. */
  74614. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74615. /**
  74616. * Get the class name
  74617. * @returns "LensRenderingPipeline"
  74618. */
  74619. getClassName(): string;
  74620. /**
  74621. * Gets associated scene
  74622. */
  74623. get scene(): Scene;
  74624. /**
  74625. * Gets or sets the edge blur
  74626. */
  74627. get edgeBlur(): number;
  74628. set edgeBlur(value: number);
  74629. /**
  74630. * Gets or sets the grain amount
  74631. */
  74632. get grainAmount(): number;
  74633. set grainAmount(value: number);
  74634. /**
  74635. * Gets or sets the chromatic aberration amount
  74636. */
  74637. get chromaticAberration(): number;
  74638. set chromaticAberration(value: number);
  74639. /**
  74640. * Gets or sets the depth of field aperture
  74641. */
  74642. get dofAperture(): number;
  74643. set dofAperture(value: number);
  74644. /**
  74645. * Gets or sets the edge distortion
  74646. */
  74647. get edgeDistortion(): number;
  74648. set edgeDistortion(value: number);
  74649. /**
  74650. * Gets or sets the depth of field distortion
  74651. */
  74652. get dofDistortion(): number;
  74653. set dofDistortion(value: number);
  74654. /**
  74655. * Gets or sets the darken out of focus amount
  74656. */
  74657. get darkenOutOfFocus(): number;
  74658. set darkenOutOfFocus(value: number);
  74659. /**
  74660. * Gets or sets a boolean indicating if blur noise is enabled
  74661. */
  74662. get blurNoise(): boolean;
  74663. set blurNoise(value: boolean);
  74664. /**
  74665. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74666. */
  74667. get pentagonBokeh(): boolean;
  74668. set pentagonBokeh(value: boolean);
  74669. /**
  74670. * Gets or sets the highlight grain amount
  74671. */
  74672. get highlightsGain(): number;
  74673. set highlightsGain(value: number);
  74674. /**
  74675. * Gets or sets the highlight threshold
  74676. */
  74677. get highlightsThreshold(): number;
  74678. set highlightsThreshold(value: number);
  74679. /**
  74680. * Sets the amount of blur at the edges
  74681. * @param amount blur amount
  74682. */
  74683. setEdgeBlur(amount: number): void;
  74684. /**
  74685. * Sets edge blur to 0
  74686. */
  74687. disableEdgeBlur(): void;
  74688. /**
  74689. * Sets the amout of grain
  74690. * @param amount Amount of grain
  74691. */
  74692. setGrainAmount(amount: number): void;
  74693. /**
  74694. * Set grain amount to 0
  74695. */
  74696. disableGrain(): void;
  74697. /**
  74698. * Sets the chromatic aberration amount
  74699. * @param amount amount of chromatic aberration
  74700. */
  74701. setChromaticAberration(amount: number): void;
  74702. /**
  74703. * Sets chromatic aberration amount to 0
  74704. */
  74705. disableChromaticAberration(): void;
  74706. /**
  74707. * Sets the EdgeDistortion amount
  74708. * @param amount amount of EdgeDistortion
  74709. */
  74710. setEdgeDistortion(amount: number): void;
  74711. /**
  74712. * Sets edge distortion to 0
  74713. */
  74714. disableEdgeDistortion(): void;
  74715. /**
  74716. * Sets the FocusDistance amount
  74717. * @param amount amount of FocusDistance
  74718. */
  74719. setFocusDistance(amount: number): void;
  74720. /**
  74721. * Disables depth of field
  74722. */
  74723. disableDepthOfField(): void;
  74724. /**
  74725. * Sets the Aperture amount
  74726. * @param amount amount of Aperture
  74727. */
  74728. setAperture(amount: number): void;
  74729. /**
  74730. * Sets the DarkenOutOfFocus amount
  74731. * @param amount amount of DarkenOutOfFocus
  74732. */
  74733. setDarkenOutOfFocus(amount: number): void;
  74734. private _pentagonBokehIsEnabled;
  74735. /**
  74736. * Creates a pentagon bokeh effect
  74737. */
  74738. enablePentagonBokeh(): void;
  74739. /**
  74740. * Disables the pentagon bokeh effect
  74741. */
  74742. disablePentagonBokeh(): void;
  74743. /**
  74744. * Enables noise blur
  74745. */
  74746. enableNoiseBlur(): void;
  74747. /**
  74748. * Disables noise blur
  74749. */
  74750. disableNoiseBlur(): void;
  74751. /**
  74752. * Sets the HighlightsGain amount
  74753. * @param amount amount of HighlightsGain
  74754. */
  74755. setHighlightsGain(amount: number): void;
  74756. /**
  74757. * Sets the HighlightsThreshold amount
  74758. * @param amount amount of HighlightsThreshold
  74759. */
  74760. setHighlightsThreshold(amount: number): void;
  74761. /**
  74762. * Disables highlights
  74763. */
  74764. disableHighlights(): void;
  74765. /**
  74766. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74767. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74768. */
  74769. dispose(disableDepthRender?: boolean): void;
  74770. private _createChromaticAberrationPostProcess;
  74771. private _createHighlightsPostProcess;
  74772. private _createDepthOfFieldPostProcess;
  74773. private _createGrainTexture;
  74774. }
  74775. }
  74776. declare module "babylonjs/Rendering/ssao2Configuration" {
  74777. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74778. /**
  74779. * Contains all parameters needed for the prepass to perform
  74780. * screen space subsurface scattering
  74781. */
  74782. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74783. /**
  74784. * Is subsurface enabled
  74785. */
  74786. enabled: boolean;
  74787. /**
  74788. * Name of the configuration
  74789. */
  74790. name: string;
  74791. /**
  74792. * Textures that should be present in the MRT for this effect to work
  74793. */
  74794. readonly texturesRequired: number[];
  74795. /**
  74796. * Builds a ssao2 configuration object
  74797. * @param scene The scene
  74798. */
  74799. constructor();
  74800. /**
  74801. * Disposes the configuration
  74802. */
  74803. dispose(): void;
  74804. }
  74805. }
  74806. declare module "babylonjs/Shaders/ssao2.fragment" {
  74807. /** @hidden */
  74808. export var ssao2PixelShader: {
  74809. name: string;
  74810. shader: string;
  74811. };
  74812. }
  74813. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74814. /** @hidden */
  74815. export var ssaoCombinePixelShader: {
  74816. name: string;
  74817. shader: string;
  74818. };
  74819. }
  74820. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74821. import { Camera } from "babylonjs/Cameras/camera";
  74822. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74823. import { Scene } from "babylonjs/scene";
  74824. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74825. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74826. import "babylonjs/Shaders/ssao2.fragment";
  74827. import "babylonjs/Shaders/ssaoCombine.fragment";
  74828. /**
  74829. * Render pipeline to produce ssao effect
  74830. */
  74831. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74832. /**
  74833. * @ignore
  74834. * The PassPostProcess id in the pipeline that contains the original scene color
  74835. */
  74836. SSAOOriginalSceneColorEffect: string;
  74837. /**
  74838. * @ignore
  74839. * The SSAO PostProcess id in the pipeline
  74840. */
  74841. SSAORenderEffect: string;
  74842. /**
  74843. * @ignore
  74844. * The horizontal blur PostProcess id in the pipeline
  74845. */
  74846. SSAOBlurHRenderEffect: string;
  74847. /**
  74848. * @ignore
  74849. * The vertical blur PostProcess id in the pipeline
  74850. */
  74851. SSAOBlurVRenderEffect: string;
  74852. /**
  74853. * @ignore
  74854. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74855. */
  74856. SSAOCombineRenderEffect: string;
  74857. /**
  74858. * The output strength of the SSAO post-process. Default value is 1.0.
  74859. */
  74860. totalStrength: number;
  74861. /**
  74862. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74863. */
  74864. maxZ: number;
  74865. /**
  74866. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74867. */
  74868. minZAspect: number;
  74869. private _samples;
  74870. /**
  74871. * Number of samples used for the SSAO calculations. Default value is 8
  74872. */
  74873. set samples(n: number);
  74874. get samples(): number;
  74875. private _textureSamples;
  74876. /**
  74877. * Number of samples to use for antialiasing
  74878. */
  74879. set textureSamples(n: number);
  74880. get textureSamples(): number;
  74881. /**
  74882. * Force rendering the geometry through geometry buffer
  74883. */
  74884. private _forceGeometryBuffer;
  74885. /**
  74886. * Ratio object used for SSAO ratio and blur ratio
  74887. */
  74888. private _ratio;
  74889. /**
  74890. * Dynamically generated sphere sampler.
  74891. */
  74892. private _sampleSphere;
  74893. private _ssao2PrePassConfiguration;
  74894. /**
  74895. * Blur filter offsets
  74896. */
  74897. private _samplerOffsets;
  74898. private _expensiveBlur;
  74899. /**
  74900. * If bilateral blur should be used
  74901. */
  74902. set expensiveBlur(b: boolean);
  74903. get expensiveBlur(): boolean;
  74904. /**
  74905. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74906. */
  74907. radius: number;
  74908. /**
  74909. * The base color of the SSAO post-process
  74910. * The final result is "base + ssao" between [0, 1]
  74911. */
  74912. base: number;
  74913. /**
  74914. * Support test.
  74915. */
  74916. static get IsSupported(): boolean;
  74917. private _scene;
  74918. private _randomTexture;
  74919. private _originalColorPostProcess;
  74920. private _ssaoPostProcess;
  74921. private _blurHPostProcess;
  74922. private _blurVPostProcess;
  74923. private _ssaoCombinePostProcess;
  74924. private _prePassRenderer;
  74925. /**
  74926. * Gets active scene
  74927. */
  74928. get scene(): Scene;
  74929. /**
  74930. * @constructor
  74931. * @param name The rendering pipeline name
  74932. * @param scene The scene linked to this pipeline
  74933. * @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 }
  74934. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74935. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74936. */
  74937. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74938. /**
  74939. * Get the class name
  74940. * @returns "SSAO2RenderingPipeline"
  74941. */
  74942. getClassName(): string;
  74943. /**
  74944. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74945. */
  74946. dispose(disableGeometryBufferRenderer?: boolean): void;
  74947. private _createBlurPostProcess;
  74948. /** @hidden */
  74949. _rebuild(): void;
  74950. private _bits;
  74951. private _radicalInverse_VdC;
  74952. private _hammersley;
  74953. private _hemisphereSample_uniform;
  74954. private _generateHemisphere;
  74955. private _getDefinesForSSAO;
  74956. private _createSSAOPostProcess;
  74957. private _createSSAOCombinePostProcess;
  74958. private _createRandomTexture;
  74959. /**
  74960. * Serialize the rendering pipeline (Used when exporting)
  74961. * @returns the serialized object
  74962. */
  74963. serialize(): any;
  74964. /**
  74965. * Parse the serialized pipeline
  74966. * @param source Source pipeline.
  74967. * @param scene The scene to load the pipeline to.
  74968. * @param rootUrl The URL of the serialized pipeline.
  74969. * @returns An instantiated pipeline from the serialized object.
  74970. */
  74971. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74972. /**
  74973. * Sets the required values to the prepass renderer.
  74974. * @param prePassRenderer defines the prepass renderer to setup
  74975. * @returns true if the pre pass is needed.
  74976. */
  74977. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74978. }
  74979. }
  74980. declare module "babylonjs/Shaders/ssao.fragment" {
  74981. /** @hidden */
  74982. export var ssaoPixelShader: {
  74983. name: string;
  74984. shader: string;
  74985. };
  74986. }
  74987. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74988. import { Camera } from "babylonjs/Cameras/camera";
  74989. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74990. import { Scene } from "babylonjs/scene";
  74991. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74992. import "babylonjs/Shaders/ssao.fragment";
  74993. import "babylonjs/Shaders/ssaoCombine.fragment";
  74994. /**
  74995. * Render pipeline to produce ssao effect
  74996. */
  74997. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74998. /**
  74999. * @ignore
  75000. * The PassPostProcess id in the pipeline that contains the original scene color
  75001. */
  75002. SSAOOriginalSceneColorEffect: string;
  75003. /**
  75004. * @ignore
  75005. * The SSAO PostProcess id in the pipeline
  75006. */
  75007. SSAORenderEffect: string;
  75008. /**
  75009. * @ignore
  75010. * The horizontal blur PostProcess id in the pipeline
  75011. */
  75012. SSAOBlurHRenderEffect: string;
  75013. /**
  75014. * @ignore
  75015. * The vertical blur PostProcess id in the pipeline
  75016. */
  75017. SSAOBlurVRenderEffect: string;
  75018. /**
  75019. * @ignore
  75020. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75021. */
  75022. SSAOCombineRenderEffect: string;
  75023. /**
  75024. * The output strength of the SSAO post-process. Default value is 1.0.
  75025. */
  75026. totalStrength: number;
  75027. /**
  75028. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75029. */
  75030. radius: number;
  75031. /**
  75032. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75033. * Must not be equal to fallOff and superior to fallOff.
  75034. * Default value is 0.0075
  75035. */
  75036. area: number;
  75037. /**
  75038. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75039. * Must not be equal to area and inferior to area.
  75040. * Default value is 0.000001
  75041. */
  75042. fallOff: number;
  75043. /**
  75044. * The base color of the SSAO post-process
  75045. * The final result is "base + ssao" between [0, 1]
  75046. */
  75047. base: number;
  75048. private _scene;
  75049. private _depthTexture;
  75050. private _randomTexture;
  75051. private _originalColorPostProcess;
  75052. private _ssaoPostProcess;
  75053. private _blurHPostProcess;
  75054. private _blurVPostProcess;
  75055. private _ssaoCombinePostProcess;
  75056. private _firstUpdate;
  75057. /**
  75058. * Gets active scene
  75059. */
  75060. get scene(): Scene;
  75061. /**
  75062. * @constructor
  75063. * @param name - The rendering pipeline name
  75064. * @param scene - The scene linked to this pipeline
  75065. * @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 }
  75066. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75067. */
  75068. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75069. /**
  75070. * Get the class name
  75071. * @returns "SSAORenderingPipeline"
  75072. */
  75073. getClassName(): string;
  75074. /**
  75075. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75076. */
  75077. dispose(disableDepthRender?: boolean): void;
  75078. private _createBlurPostProcess;
  75079. /** @hidden */
  75080. _rebuild(): void;
  75081. private _createSSAOPostProcess;
  75082. private _createSSAOCombinePostProcess;
  75083. private _createRandomTexture;
  75084. }
  75085. }
  75086. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75087. /** @hidden */
  75088. export var screenSpaceReflectionPixelShader: {
  75089. name: string;
  75090. shader: string;
  75091. };
  75092. }
  75093. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75094. import { Nullable } from "babylonjs/types";
  75095. import { Camera } from "babylonjs/Cameras/camera";
  75096. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75097. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75098. import { Engine } from "babylonjs/Engines/engine";
  75099. import { Scene } from "babylonjs/scene";
  75100. /**
  75101. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75102. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75103. */
  75104. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75105. /**
  75106. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75107. */
  75108. threshold: number;
  75109. /**
  75110. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75111. */
  75112. strength: number;
  75113. /**
  75114. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75115. */
  75116. reflectionSpecularFalloffExponent: number;
  75117. /**
  75118. * 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]
  75119. */
  75120. step: number;
  75121. /**
  75122. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75123. */
  75124. roughnessFactor: number;
  75125. private _geometryBufferRenderer;
  75126. private _enableSmoothReflections;
  75127. private _reflectionSamples;
  75128. private _smoothSteps;
  75129. /**
  75130. * Gets a string identifying the name of the class
  75131. * @returns "ScreenSpaceReflectionPostProcess" string
  75132. */
  75133. getClassName(): string;
  75134. /**
  75135. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75136. * @param name The name of the effect.
  75137. * @param scene The scene containing the objects to calculate reflections.
  75138. * @param options The required width/height ratio to downsize to before computing the render pass.
  75139. * @param camera The camera to apply the render pass to.
  75140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75141. * @param engine The engine which the post process will be applied. (default: current engine)
  75142. * @param reusable If the post process can be reused on the same frame. (default: false)
  75143. * @param textureType Type of textures used when performing the post process. (default: 0)
  75144. * @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)
  75145. */
  75146. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75147. /**
  75148. * Gets wether or not smoothing reflections is enabled.
  75149. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75150. */
  75151. get enableSmoothReflections(): boolean;
  75152. /**
  75153. * Sets wether or not smoothing reflections is enabled.
  75154. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75155. */
  75156. set enableSmoothReflections(enabled: boolean);
  75157. /**
  75158. * Gets the number of samples taken while computing reflections. More samples count is high,
  75159. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75160. */
  75161. get reflectionSamples(): number;
  75162. /**
  75163. * Sets the number of samples taken while computing reflections. More samples count is high,
  75164. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75165. */
  75166. set reflectionSamples(samples: number);
  75167. /**
  75168. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75169. * more the post-process will require GPU power and can generate a drop in FPS.
  75170. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75171. */
  75172. get smoothSteps(): number;
  75173. set smoothSteps(steps: number);
  75174. private _updateEffectDefines;
  75175. /** @hidden */
  75176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75177. }
  75178. }
  75179. declare module "babylonjs/Shaders/standard.fragment" {
  75180. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75181. /** @hidden */
  75182. export var standardPixelShader: {
  75183. name: string;
  75184. shader: string;
  75185. };
  75186. }
  75187. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75188. import { Nullable } from "babylonjs/types";
  75189. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75190. import { Camera } from "babylonjs/Cameras/camera";
  75191. import { Texture } from "babylonjs/Materials/Textures/texture";
  75192. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75193. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75194. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75195. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75196. import { IDisposable } from "babylonjs/scene";
  75197. import { SpotLight } from "babylonjs/Lights/spotLight";
  75198. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75199. import { Scene } from "babylonjs/scene";
  75200. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75201. import { Animation } from "babylonjs/Animations/animation";
  75202. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75203. import "babylonjs/Shaders/standard.fragment";
  75204. /**
  75205. * Standard rendering pipeline
  75206. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75207. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75208. */
  75209. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75210. /**
  75211. * Public members
  75212. */
  75213. /**
  75214. * Post-process which contains the original scene color before the pipeline applies all the effects
  75215. */
  75216. originalPostProcess: Nullable<PostProcess>;
  75217. /**
  75218. * Post-process used to down scale an image x4
  75219. */
  75220. downSampleX4PostProcess: Nullable<PostProcess>;
  75221. /**
  75222. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75223. */
  75224. brightPassPostProcess: Nullable<PostProcess>;
  75225. /**
  75226. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75227. */
  75228. blurHPostProcesses: PostProcess[];
  75229. /**
  75230. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75231. */
  75232. blurVPostProcesses: PostProcess[];
  75233. /**
  75234. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75235. */
  75236. textureAdderPostProcess: Nullable<PostProcess>;
  75237. /**
  75238. * Post-process used to create volumetric lighting effect
  75239. */
  75240. volumetricLightPostProcess: Nullable<PostProcess>;
  75241. /**
  75242. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75243. */
  75244. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75245. /**
  75246. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75247. */
  75248. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75249. /**
  75250. * Post-process used to merge the volumetric light effect and the real scene color
  75251. */
  75252. volumetricLightMergePostProces: Nullable<PostProcess>;
  75253. /**
  75254. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75255. */
  75256. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75257. /**
  75258. * Base post-process used to calculate the average luminance of the final image for HDR
  75259. */
  75260. luminancePostProcess: Nullable<PostProcess>;
  75261. /**
  75262. * Post-processes used to create down sample post-processes in order to get
  75263. * the average luminance of the final image for HDR
  75264. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75265. */
  75266. luminanceDownSamplePostProcesses: PostProcess[];
  75267. /**
  75268. * Post-process used to create a HDR effect (light adaptation)
  75269. */
  75270. hdrPostProcess: Nullable<PostProcess>;
  75271. /**
  75272. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75273. */
  75274. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75275. /**
  75276. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75277. */
  75278. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75279. /**
  75280. * Post-process used to merge the final HDR post-process and the real scene color
  75281. */
  75282. hdrFinalPostProcess: Nullable<PostProcess>;
  75283. /**
  75284. * Post-process used to create a lens flare effect
  75285. */
  75286. lensFlarePostProcess: Nullable<PostProcess>;
  75287. /**
  75288. * Post-process that merges the result of the lens flare post-process and the real scene color
  75289. */
  75290. lensFlareComposePostProcess: Nullable<PostProcess>;
  75291. /**
  75292. * Post-process used to create a motion blur effect
  75293. */
  75294. motionBlurPostProcess: Nullable<PostProcess>;
  75295. /**
  75296. * Post-process used to create a depth of field effect
  75297. */
  75298. depthOfFieldPostProcess: Nullable<PostProcess>;
  75299. /**
  75300. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75301. */
  75302. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75303. /**
  75304. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75305. */
  75306. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75307. /**
  75308. * Represents the brightness threshold in order to configure the illuminated surfaces
  75309. */
  75310. brightThreshold: number;
  75311. /**
  75312. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75313. */
  75314. blurWidth: number;
  75315. /**
  75316. * Sets if the blur for highlighted surfaces must be only horizontal
  75317. */
  75318. horizontalBlur: boolean;
  75319. /**
  75320. * Gets the overall exposure used by the pipeline
  75321. */
  75322. get exposure(): number;
  75323. /**
  75324. * Sets the overall exposure used by the pipeline
  75325. */
  75326. set exposure(value: number);
  75327. /**
  75328. * Texture used typically to simulate "dirty" on camera lens
  75329. */
  75330. lensTexture: Nullable<Texture>;
  75331. /**
  75332. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75333. */
  75334. volumetricLightCoefficient: number;
  75335. /**
  75336. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75337. */
  75338. volumetricLightPower: number;
  75339. /**
  75340. * Used the set the blur intensity to smooth the volumetric lights
  75341. */
  75342. volumetricLightBlurScale: number;
  75343. /**
  75344. * Light (spot or directional) used to generate the volumetric lights rays
  75345. * The source light must have a shadow generate so the pipeline can get its
  75346. * depth map
  75347. */
  75348. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75349. /**
  75350. * For eye adaptation, represents the minimum luminance the eye can see
  75351. */
  75352. hdrMinimumLuminance: number;
  75353. /**
  75354. * For eye adaptation, represents the decrease luminance speed
  75355. */
  75356. hdrDecreaseRate: number;
  75357. /**
  75358. * For eye adaptation, represents the increase luminance speed
  75359. */
  75360. hdrIncreaseRate: number;
  75361. /**
  75362. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75363. */
  75364. get hdrAutoExposure(): boolean;
  75365. /**
  75366. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75367. */
  75368. set hdrAutoExposure(value: boolean);
  75369. /**
  75370. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75371. */
  75372. lensColorTexture: Nullable<Texture>;
  75373. /**
  75374. * The overall strengh for the lens flare effect
  75375. */
  75376. lensFlareStrength: number;
  75377. /**
  75378. * Dispersion coefficient for lens flare ghosts
  75379. */
  75380. lensFlareGhostDispersal: number;
  75381. /**
  75382. * Main lens flare halo width
  75383. */
  75384. lensFlareHaloWidth: number;
  75385. /**
  75386. * Based on the lens distortion effect, defines how much the lens flare result
  75387. * is distorted
  75388. */
  75389. lensFlareDistortionStrength: number;
  75390. /**
  75391. * Configures the blur intensity used for for lens flare (halo)
  75392. */
  75393. lensFlareBlurWidth: number;
  75394. /**
  75395. * Lens star texture must be used to simulate rays on the flares and is available
  75396. * in the documentation
  75397. */
  75398. lensStarTexture: Nullable<Texture>;
  75399. /**
  75400. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75401. * flare effect by taking account of the dirt texture
  75402. */
  75403. lensFlareDirtTexture: Nullable<Texture>;
  75404. /**
  75405. * Represents the focal length for the depth of field effect
  75406. */
  75407. depthOfFieldDistance: number;
  75408. /**
  75409. * Represents the blur intensity for the blurred part of the depth of field effect
  75410. */
  75411. depthOfFieldBlurWidth: number;
  75412. /**
  75413. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75414. */
  75415. get motionStrength(): number;
  75416. /**
  75417. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75418. */
  75419. set motionStrength(strength: number);
  75420. /**
  75421. * Gets wether or not the motion blur post-process is object based or screen based.
  75422. */
  75423. get objectBasedMotionBlur(): boolean;
  75424. /**
  75425. * Sets wether or not the motion blur post-process should be object based or screen based
  75426. */
  75427. set objectBasedMotionBlur(value: boolean);
  75428. /**
  75429. * List of animations for the pipeline (IAnimatable implementation)
  75430. */
  75431. animations: Animation[];
  75432. /**
  75433. * Private members
  75434. */
  75435. private _scene;
  75436. private _currentDepthOfFieldSource;
  75437. private _basePostProcess;
  75438. private _fixedExposure;
  75439. private _currentExposure;
  75440. private _hdrAutoExposure;
  75441. private _hdrCurrentLuminance;
  75442. private _motionStrength;
  75443. private _isObjectBasedMotionBlur;
  75444. private _floatTextureType;
  75445. private _camerasToBeAttached;
  75446. private _ratio;
  75447. private _bloomEnabled;
  75448. private _depthOfFieldEnabled;
  75449. private _vlsEnabled;
  75450. private _lensFlareEnabled;
  75451. private _hdrEnabled;
  75452. private _motionBlurEnabled;
  75453. private _fxaaEnabled;
  75454. private _screenSpaceReflectionsEnabled;
  75455. private _motionBlurSamples;
  75456. private _volumetricLightStepsCount;
  75457. private _samples;
  75458. /**
  75459. * @ignore
  75460. * Specifies if the bloom pipeline is enabled
  75461. */
  75462. get BloomEnabled(): boolean;
  75463. set BloomEnabled(enabled: boolean);
  75464. /**
  75465. * @ignore
  75466. * Specifies if the depth of field pipeline is enabed
  75467. */
  75468. get DepthOfFieldEnabled(): boolean;
  75469. set DepthOfFieldEnabled(enabled: boolean);
  75470. /**
  75471. * @ignore
  75472. * Specifies if the lens flare pipeline is enabed
  75473. */
  75474. get LensFlareEnabled(): boolean;
  75475. set LensFlareEnabled(enabled: boolean);
  75476. /**
  75477. * @ignore
  75478. * Specifies if the HDR pipeline is enabled
  75479. */
  75480. get HDREnabled(): boolean;
  75481. set HDREnabled(enabled: boolean);
  75482. /**
  75483. * @ignore
  75484. * Specifies if the volumetric lights scattering effect is enabled
  75485. */
  75486. get VLSEnabled(): boolean;
  75487. set VLSEnabled(enabled: boolean);
  75488. /**
  75489. * @ignore
  75490. * Specifies if the motion blur effect is enabled
  75491. */
  75492. get MotionBlurEnabled(): boolean;
  75493. set MotionBlurEnabled(enabled: boolean);
  75494. /**
  75495. * Specifies if anti-aliasing is enabled
  75496. */
  75497. get fxaaEnabled(): boolean;
  75498. set fxaaEnabled(enabled: boolean);
  75499. /**
  75500. * Specifies if screen space reflections are enabled.
  75501. */
  75502. get screenSpaceReflectionsEnabled(): boolean;
  75503. set screenSpaceReflectionsEnabled(enabled: boolean);
  75504. /**
  75505. * Specifies the number of steps used to calculate the volumetric lights
  75506. * Typically in interval [50, 200]
  75507. */
  75508. get volumetricLightStepsCount(): number;
  75509. set volumetricLightStepsCount(count: number);
  75510. /**
  75511. * Specifies the number of samples used for the motion blur effect
  75512. * Typically in interval [16, 64]
  75513. */
  75514. get motionBlurSamples(): number;
  75515. set motionBlurSamples(samples: number);
  75516. /**
  75517. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75518. */
  75519. get samples(): number;
  75520. set samples(sampleCount: number);
  75521. /**
  75522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75523. * @constructor
  75524. * @param name The rendering pipeline name
  75525. * @param scene The scene linked to this pipeline
  75526. * @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)
  75527. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75529. */
  75530. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75531. private _buildPipeline;
  75532. private _createDownSampleX4PostProcess;
  75533. private _createBrightPassPostProcess;
  75534. private _createBlurPostProcesses;
  75535. private _createTextureAdderPostProcess;
  75536. private _createVolumetricLightPostProcess;
  75537. private _createLuminancePostProcesses;
  75538. private _createHdrPostProcess;
  75539. private _createLensFlarePostProcess;
  75540. private _createDepthOfFieldPostProcess;
  75541. private _createMotionBlurPostProcess;
  75542. private _getDepthTexture;
  75543. private _disposePostProcesses;
  75544. /**
  75545. * Dispose of the pipeline and stop all post processes
  75546. */
  75547. dispose(): void;
  75548. /**
  75549. * Serialize the rendering pipeline (Used when exporting)
  75550. * @returns the serialized object
  75551. */
  75552. serialize(): any;
  75553. /**
  75554. * Parse the serialized pipeline
  75555. * @param source Source pipeline.
  75556. * @param scene The scene to load the pipeline to.
  75557. * @param rootUrl The URL of the serialized pipeline.
  75558. * @returns An instantiated pipeline from the serialized object.
  75559. */
  75560. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75561. /**
  75562. * Luminance steps
  75563. */
  75564. static LuminanceSteps: number;
  75565. }
  75566. }
  75567. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75570. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75573. }
  75574. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75575. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75576. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75577. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75578. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75579. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75580. }
  75581. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75582. /** @hidden */
  75583. export var stereoscopicInterlacePixelShader: {
  75584. name: string;
  75585. shader: string;
  75586. };
  75587. }
  75588. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75589. import { Camera } from "babylonjs/Cameras/camera";
  75590. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75591. import { Engine } from "babylonjs/Engines/engine";
  75592. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75593. /**
  75594. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75595. */
  75596. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75597. private _stepSize;
  75598. private _passedProcess;
  75599. /**
  75600. * Gets a string identifying the name of the class
  75601. * @returns "StereoscopicInterlacePostProcessI" string
  75602. */
  75603. getClassName(): string;
  75604. /**
  75605. * Initializes a StereoscopicInterlacePostProcessI
  75606. * @param name The name of the effect.
  75607. * @param rigCameras The rig cameras to be appled to the post process
  75608. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75609. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75611. * @param engine The engine which the post process will be applied. (default: current engine)
  75612. * @param reusable If the post process can be reused on the same frame. (default: false)
  75613. */
  75614. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75615. }
  75616. /**
  75617. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75618. */
  75619. export class StereoscopicInterlacePostProcess extends PostProcess {
  75620. private _stepSize;
  75621. private _passedProcess;
  75622. /**
  75623. * Gets a string identifying the name of the class
  75624. * @returns "StereoscopicInterlacePostProcess" string
  75625. */
  75626. getClassName(): string;
  75627. /**
  75628. * Initializes a StereoscopicInterlacePostProcess
  75629. * @param name The name of the effect.
  75630. * @param rigCameras The rig cameras to be appled to the post process
  75631. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75633. * @param engine The engine which the post process will be applied. (default: current engine)
  75634. * @param reusable If the post process can be reused on the same frame. (default: false)
  75635. */
  75636. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75637. }
  75638. }
  75639. declare module "babylonjs/Shaders/tonemap.fragment" {
  75640. /** @hidden */
  75641. export var tonemapPixelShader: {
  75642. name: string;
  75643. shader: string;
  75644. };
  75645. }
  75646. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75647. import { Camera } from "babylonjs/Cameras/camera";
  75648. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75649. import "babylonjs/Shaders/tonemap.fragment";
  75650. import { Engine } from "babylonjs/Engines/engine";
  75651. /** Defines operator used for tonemapping */
  75652. export enum TonemappingOperator {
  75653. /** Hable */
  75654. Hable = 0,
  75655. /** Reinhard */
  75656. Reinhard = 1,
  75657. /** HejiDawson */
  75658. HejiDawson = 2,
  75659. /** Photographic */
  75660. Photographic = 3
  75661. }
  75662. /**
  75663. * Defines a post process to apply tone mapping
  75664. */
  75665. export class TonemapPostProcess extends PostProcess {
  75666. private _operator;
  75667. /** Defines the required exposure adjustement */
  75668. exposureAdjustment: number;
  75669. /**
  75670. * Gets a string identifying the name of the class
  75671. * @returns "TonemapPostProcess" string
  75672. */
  75673. getClassName(): string;
  75674. /**
  75675. * Creates a new TonemapPostProcess
  75676. * @param name defines the name of the postprocess
  75677. * @param _operator defines the operator to use
  75678. * @param exposureAdjustment defines the required exposure adjustement
  75679. * @param camera defines the camera to use (can be null)
  75680. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75681. * @param engine defines the hosting engine (can be ignore if camera is set)
  75682. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75683. */
  75684. constructor(name: string, _operator: TonemappingOperator,
  75685. /** Defines the required exposure adjustement */
  75686. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75687. }
  75688. }
  75689. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75690. /** @hidden */
  75691. export var volumetricLightScatteringPixelShader: {
  75692. name: string;
  75693. shader: string;
  75694. };
  75695. }
  75696. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75697. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75700. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75701. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75702. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75703. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75704. /** @hidden */
  75705. export var volumetricLightScatteringPassVertexShader: {
  75706. name: string;
  75707. shader: string;
  75708. };
  75709. }
  75710. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75711. /** @hidden */
  75712. export var volumetricLightScatteringPassPixelShader: {
  75713. name: string;
  75714. shader: string;
  75715. };
  75716. }
  75717. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75718. import { Vector3 } from "babylonjs/Maths/math.vector";
  75719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75720. import { Mesh } from "babylonjs/Meshes/mesh";
  75721. import { Camera } from "babylonjs/Cameras/camera";
  75722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75724. import { Scene } from "babylonjs/scene";
  75725. import "babylonjs/Meshes/Builders/planeBuilder";
  75726. import "babylonjs/Shaders/depth.vertex";
  75727. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75728. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75729. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75730. import { Engine } from "babylonjs/Engines/engine";
  75731. /**
  75732. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75733. */
  75734. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75735. private _volumetricLightScatteringPass;
  75736. private _volumetricLightScatteringRTT;
  75737. private _viewPort;
  75738. private _screenCoordinates;
  75739. private _cachedDefines;
  75740. /**
  75741. * If not undefined, the mesh position is computed from the attached node position
  75742. */
  75743. attachedNode: {
  75744. position: Vector3;
  75745. };
  75746. /**
  75747. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75748. */
  75749. customMeshPosition: Vector3;
  75750. /**
  75751. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75752. */
  75753. useCustomMeshPosition: boolean;
  75754. /**
  75755. * If the post-process should inverse the light scattering direction
  75756. */
  75757. invert: boolean;
  75758. /**
  75759. * The internal mesh used by the post-process
  75760. */
  75761. mesh: Mesh;
  75762. /**
  75763. * @hidden
  75764. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75765. */
  75766. get useDiffuseColor(): boolean;
  75767. set useDiffuseColor(useDiffuseColor: boolean);
  75768. /**
  75769. * Array containing the excluded meshes not rendered in the internal pass
  75770. */
  75771. excludedMeshes: AbstractMesh[];
  75772. /**
  75773. * Controls the overall intensity of the post-process
  75774. */
  75775. exposure: number;
  75776. /**
  75777. * Dissipates each sample's contribution in range [0, 1]
  75778. */
  75779. decay: number;
  75780. /**
  75781. * Controls the overall intensity of each sample
  75782. */
  75783. weight: number;
  75784. /**
  75785. * Controls the density of each sample
  75786. */
  75787. density: number;
  75788. /**
  75789. * @constructor
  75790. * @param name The post-process name
  75791. * @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)
  75792. * @param camera The camera that the post-process will be attached to
  75793. * @param mesh The mesh used to create the light scattering
  75794. * @param samples The post-process quality, default 100
  75795. * @param samplingModeThe post-process filtering mode
  75796. * @param engine The babylon engine
  75797. * @param reusable If the post-process is reusable
  75798. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75799. */
  75800. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75801. /**
  75802. * Returns the string "VolumetricLightScatteringPostProcess"
  75803. * @returns "VolumetricLightScatteringPostProcess"
  75804. */
  75805. getClassName(): string;
  75806. private _isReady;
  75807. /**
  75808. * Sets the new light position for light scattering effect
  75809. * @param position The new custom light position
  75810. */
  75811. setCustomMeshPosition(position: Vector3): void;
  75812. /**
  75813. * Returns the light position for light scattering effect
  75814. * @return Vector3 The custom light position
  75815. */
  75816. getCustomMeshPosition(): Vector3;
  75817. /**
  75818. * Disposes the internal assets and detaches the post-process from the camera
  75819. */
  75820. dispose(camera: Camera): void;
  75821. /**
  75822. * Returns the render target texture used by the post-process
  75823. * @return the render target texture used by the post-process
  75824. */
  75825. getPass(): RenderTargetTexture;
  75826. private _meshExcluded;
  75827. private _createPass;
  75828. private _updateMeshScreenCoordinates;
  75829. /**
  75830. * Creates a default mesh for the Volumeric Light Scattering post-process
  75831. * @param name The mesh name
  75832. * @param scene The scene where to create the mesh
  75833. * @return the default mesh
  75834. */
  75835. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75836. }
  75837. }
  75838. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75839. /** @hidden */
  75840. export var screenSpaceCurvaturePixelShader: {
  75841. name: string;
  75842. shader: string;
  75843. };
  75844. }
  75845. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75846. import { Nullable } from "babylonjs/types";
  75847. import { Camera } from "babylonjs/Cameras/camera";
  75848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75849. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75850. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75851. import { Engine } from "babylonjs/Engines/engine";
  75852. import { Scene } from "babylonjs/scene";
  75853. /**
  75854. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75855. */
  75856. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75857. /**
  75858. * Defines how much ridge the curvature effect displays.
  75859. */
  75860. ridge: number;
  75861. /**
  75862. * Defines how much valley the curvature effect displays.
  75863. */
  75864. valley: number;
  75865. private _geometryBufferRenderer;
  75866. /**
  75867. * Gets a string identifying the name of the class
  75868. * @returns "ScreenSpaceCurvaturePostProcess" string
  75869. */
  75870. getClassName(): string;
  75871. /**
  75872. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75873. * @param name The name of the effect.
  75874. * @param scene The scene containing the objects to blur according to their velocity.
  75875. * @param options The required width/height ratio to downsize to before computing the render pass.
  75876. * @param camera The camera to apply the render pass to.
  75877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75878. * @param engine The engine which the post process will be applied. (default: current engine)
  75879. * @param reusable If the post process can be reused on the same frame. (default: false)
  75880. * @param textureType Type of textures used when performing the post process. (default: 0)
  75881. * @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)
  75882. */
  75883. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75884. /**
  75885. * Support test.
  75886. */
  75887. static get IsSupported(): boolean;
  75888. /** @hidden */
  75889. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75890. }
  75891. }
  75892. declare module "babylonjs/PostProcesses/index" {
  75893. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75894. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75895. export * from "babylonjs/PostProcesses/bloomEffect";
  75896. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75897. export * from "babylonjs/PostProcesses/blurPostProcess";
  75898. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75899. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75900. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75901. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75902. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75903. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75904. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75905. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75906. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75907. export * from "babylonjs/PostProcesses/filterPostProcess";
  75908. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75909. export * from "babylonjs/PostProcesses/grainPostProcess";
  75910. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75911. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75912. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75913. export * from "babylonjs/PostProcesses/passPostProcess";
  75914. export * from "babylonjs/PostProcesses/postProcess";
  75915. export * from "babylonjs/PostProcesses/postProcessManager";
  75916. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75917. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75918. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75919. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75920. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75921. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75922. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75923. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75924. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75925. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75926. }
  75927. declare module "babylonjs/Probes/index" {
  75928. export * from "babylonjs/Probes/reflectionProbe";
  75929. }
  75930. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75931. import { Scene } from "babylonjs/scene";
  75932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75933. import { SmartArray } from "babylonjs/Misc/smartArray";
  75934. import { ISceneComponent } from "babylonjs/sceneComponent";
  75935. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75936. import "babylonjs/Meshes/Builders/boxBuilder";
  75937. import "babylonjs/Shaders/color.fragment";
  75938. import "babylonjs/Shaders/color.vertex";
  75939. import { Color3 } from "babylonjs/Maths/math.color";
  75940. import { Observable } from "babylonjs/Misc/observable";
  75941. module "babylonjs/scene" {
  75942. interface Scene {
  75943. /** @hidden (Backing field) */
  75944. _boundingBoxRenderer: BoundingBoxRenderer;
  75945. /** @hidden (Backing field) */
  75946. _forceShowBoundingBoxes: boolean;
  75947. /**
  75948. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75949. */
  75950. forceShowBoundingBoxes: boolean;
  75951. /**
  75952. * Gets the bounding box renderer associated with the scene
  75953. * @returns a BoundingBoxRenderer
  75954. */
  75955. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75956. }
  75957. }
  75958. module "babylonjs/Meshes/abstractMesh" {
  75959. interface AbstractMesh {
  75960. /** @hidden (Backing field) */
  75961. _showBoundingBox: boolean;
  75962. /**
  75963. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75964. */
  75965. showBoundingBox: boolean;
  75966. }
  75967. }
  75968. /**
  75969. * Component responsible of rendering the bounding box of the meshes in a scene.
  75970. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75971. */
  75972. export class BoundingBoxRenderer implements ISceneComponent {
  75973. /**
  75974. * The component name helpfull to identify the component in the list of scene components.
  75975. */
  75976. readonly name: string;
  75977. /**
  75978. * The scene the component belongs to.
  75979. */
  75980. scene: Scene;
  75981. /**
  75982. * Color of the bounding box lines placed in front of an object
  75983. */
  75984. frontColor: Color3;
  75985. /**
  75986. * Color of the bounding box lines placed behind an object
  75987. */
  75988. backColor: Color3;
  75989. /**
  75990. * Defines if the renderer should show the back lines or not
  75991. */
  75992. showBackLines: boolean;
  75993. /**
  75994. * Observable raised before rendering a bounding box
  75995. */
  75996. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75997. /**
  75998. * Observable raised after rendering a bounding box
  75999. */
  76000. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76001. /**
  76002. * @hidden
  76003. */
  76004. renderList: SmartArray<BoundingBox>;
  76005. private _colorShader;
  76006. private _vertexBuffers;
  76007. private _indexBuffer;
  76008. private _fillIndexBuffer;
  76009. private _fillIndexData;
  76010. /**
  76011. * Instantiates a new bounding box renderer in a scene.
  76012. * @param scene the scene the renderer renders in
  76013. */
  76014. constructor(scene: Scene);
  76015. /**
  76016. * Registers the component in a given scene
  76017. */
  76018. register(): void;
  76019. private _evaluateSubMesh;
  76020. private _activeMesh;
  76021. private _prepareRessources;
  76022. private _createIndexBuffer;
  76023. /**
  76024. * Rebuilds the elements related to this component in case of
  76025. * context lost for instance.
  76026. */
  76027. rebuild(): void;
  76028. /**
  76029. * @hidden
  76030. */
  76031. reset(): void;
  76032. /**
  76033. * Render the bounding boxes of a specific rendering group
  76034. * @param renderingGroupId defines the rendering group to render
  76035. */
  76036. render(renderingGroupId: number): void;
  76037. /**
  76038. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76039. * @param mesh Define the mesh to render the occlusion bounding box for
  76040. */
  76041. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76042. /**
  76043. * Dispose and release the resources attached to this renderer.
  76044. */
  76045. dispose(): void;
  76046. }
  76047. }
  76048. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76049. import { Nullable } from "babylonjs/types";
  76050. import { Scene } from "babylonjs/scene";
  76051. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76052. import { Camera } from "babylonjs/Cameras/camera";
  76053. import { ISceneComponent } from "babylonjs/sceneComponent";
  76054. module "babylonjs/scene" {
  76055. interface Scene {
  76056. /** @hidden (Backing field) */
  76057. _depthRenderer: {
  76058. [id: string]: DepthRenderer;
  76059. };
  76060. /**
  76061. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76062. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76063. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76064. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76065. * @returns the created depth renderer
  76066. */
  76067. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76068. /**
  76069. * Disables a depth renderer for a given camera
  76070. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76071. */
  76072. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76073. }
  76074. }
  76075. /**
  76076. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76077. * in several rendering techniques.
  76078. */
  76079. export class DepthRendererSceneComponent implements ISceneComponent {
  76080. /**
  76081. * The component name helpfull to identify the component in the list of scene components.
  76082. */
  76083. readonly name: string;
  76084. /**
  76085. * The scene the component belongs to.
  76086. */
  76087. scene: Scene;
  76088. /**
  76089. * Creates a new instance of the component for the given scene
  76090. * @param scene Defines the scene to register the component in
  76091. */
  76092. constructor(scene: Scene);
  76093. /**
  76094. * Registers the component in a given scene
  76095. */
  76096. register(): void;
  76097. /**
  76098. * Rebuilds the elements related to this component in case of
  76099. * context lost for instance.
  76100. */
  76101. rebuild(): void;
  76102. /**
  76103. * Disposes the component and the associated ressources
  76104. */
  76105. dispose(): void;
  76106. private _gatherRenderTargets;
  76107. private _gatherActiveCameraRenderTargets;
  76108. }
  76109. }
  76110. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76111. import { Nullable } from "babylonjs/types";
  76112. import { Scene } from "babylonjs/scene";
  76113. import { ISceneComponent } from "babylonjs/sceneComponent";
  76114. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76115. module "babylonjs/abstractScene" {
  76116. interface AbstractScene {
  76117. /** @hidden (Backing field) */
  76118. _prePassRenderer: Nullable<PrePassRenderer>;
  76119. /**
  76120. * Gets or Sets the current prepass renderer associated to the scene.
  76121. */
  76122. prePassRenderer: Nullable<PrePassRenderer>;
  76123. /**
  76124. * Enables the prepass and associates it with the scene
  76125. * @returns the PrePassRenderer
  76126. */
  76127. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76128. /**
  76129. * Disables the prepass associated with the scene
  76130. */
  76131. disablePrePassRenderer(): void;
  76132. }
  76133. }
  76134. /**
  76135. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76136. * in several rendering techniques.
  76137. */
  76138. export class PrePassRendererSceneComponent implements ISceneComponent {
  76139. /**
  76140. * The component name helpful to identify the component in the list of scene components.
  76141. */
  76142. readonly name: string;
  76143. /**
  76144. * The scene the component belongs to.
  76145. */
  76146. scene: Scene;
  76147. /**
  76148. * Creates a new instance of the component for the given scene
  76149. * @param scene Defines the scene to register the component in
  76150. */
  76151. constructor(scene: Scene);
  76152. /**
  76153. * Registers the component in a given scene
  76154. */
  76155. register(): void;
  76156. private _beforeCameraDraw;
  76157. private _afterCameraDraw;
  76158. private _beforeClearStage;
  76159. /**
  76160. * Rebuilds the elements related to this component in case of
  76161. * context lost for instance.
  76162. */
  76163. rebuild(): void;
  76164. /**
  76165. * Disposes the component and the associated ressources
  76166. */
  76167. dispose(): void;
  76168. }
  76169. }
  76170. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76171. /** @hidden */
  76172. export var fibonacci: {
  76173. name: string;
  76174. shader: string;
  76175. };
  76176. }
  76177. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76178. /** @hidden */
  76179. export var diffusionProfile: {
  76180. name: string;
  76181. shader: string;
  76182. };
  76183. }
  76184. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76185. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76187. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76188. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76189. /** @hidden */
  76190. export var subSurfaceScatteringPixelShader: {
  76191. name: string;
  76192. shader: string;
  76193. };
  76194. }
  76195. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76196. import { Nullable } from "babylonjs/types";
  76197. import { Camera } from "babylonjs/Cameras/camera";
  76198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76199. import { Engine } from "babylonjs/Engines/engine";
  76200. import { Scene } from "babylonjs/scene";
  76201. import "babylonjs/Shaders/imageProcessing.fragment";
  76202. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76203. import "babylonjs/Shaders/postprocess.vertex";
  76204. /**
  76205. * Sub surface scattering post process
  76206. */
  76207. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76208. /**
  76209. * Gets a string identifying the name of the class
  76210. * @returns "SubSurfaceScatteringPostProcess" string
  76211. */
  76212. getClassName(): string;
  76213. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76214. }
  76215. }
  76216. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76217. import { Scene } from "babylonjs/scene";
  76218. import { Color3 } from "babylonjs/Maths/math.color";
  76219. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76220. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76221. /**
  76222. * Contains all parameters needed for the prepass to perform
  76223. * screen space subsurface scattering
  76224. */
  76225. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76226. /** @hidden */
  76227. static _SceneComponentInitialization: (scene: Scene) => void;
  76228. private _ssDiffusionS;
  76229. private _ssFilterRadii;
  76230. private _ssDiffusionD;
  76231. /**
  76232. * Post process to attach for screen space subsurface scattering
  76233. */
  76234. postProcess: SubSurfaceScatteringPostProcess;
  76235. /**
  76236. * Diffusion profile color for subsurface scattering
  76237. */
  76238. get ssDiffusionS(): number[];
  76239. /**
  76240. * Diffusion profile max color channel value for subsurface scattering
  76241. */
  76242. get ssDiffusionD(): number[];
  76243. /**
  76244. * Diffusion profile filter radius for subsurface scattering
  76245. */
  76246. get ssFilterRadii(): number[];
  76247. /**
  76248. * Is subsurface enabled
  76249. */
  76250. enabled: boolean;
  76251. /**
  76252. * Name of the configuration
  76253. */
  76254. name: string;
  76255. /**
  76256. * Diffusion profile colors for subsurface scattering
  76257. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76258. * See ...
  76259. * Note that you can only store up to 5 of them
  76260. */
  76261. ssDiffusionProfileColors: Color3[];
  76262. /**
  76263. * Defines the ratio real world => scene units.
  76264. * Used for subsurface scattering
  76265. */
  76266. metersPerUnit: number;
  76267. /**
  76268. * Textures that should be present in the MRT for this effect to work
  76269. */
  76270. readonly texturesRequired: number[];
  76271. private _scene;
  76272. /**
  76273. * Builds a subsurface configuration object
  76274. * @param scene The scene
  76275. */
  76276. constructor(scene: Scene);
  76277. /**
  76278. * Adds a new diffusion profile.
  76279. * Useful for more realistic subsurface scattering on diverse materials.
  76280. * @param color The color of the diffusion profile. Should be the average color of the material.
  76281. * @return The index of the diffusion profile for the material subsurface configuration
  76282. */
  76283. addDiffusionProfile(color: Color3): number;
  76284. /**
  76285. * Creates the sss post process
  76286. * @return The created post process
  76287. */
  76288. createPostProcess(): SubSurfaceScatteringPostProcess;
  76289. /**
  76290. * Deletes all diffusion profiles.
  76291. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76292. */
  76293. clearAllDiffusionProfiles(): void;
  76294. /**
  76295. * Disposes this object
  76296. */
  76297. dispose(): void;
  76298. /**
  76299. * @hidden
  76300. * https://zero-radiance.github.io/post/sampling-diffusion/
  76301. *
  76302. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76303. * ------------------------------------------------------------------------------------
  76304. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76305. * PDF[r, phi, s] = r * R[r, phi, s]
  76306. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76307. * ------------------------------------------------------------------------------------
  76308. * We importance sample the color channel with the widest scattering distance.
  76309. */
  76310. getDiffusionProfileParameters(color: Color3): number;
  76311. /**
  76312. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76313. * 'u' is the random number (the value of the CDF): [0, 1).
  76314. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76315. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76316. */
  76317. private _sampleBurleyDiffusionProfile;
  76318. }
  76319. }
  76320. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76321. import { Nullable } from "babylonjs/types";
  76322. import { Scene } from "babylonjs/scene";
  76323. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76324. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76325. import { AbstractScene } from "babylonjs/abstractScene";
  76326. module "babylonjs/abstractScene" {
  76327. interface AbstractScene {
  76328. /** @hidden (Backing field) */
  76329. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76330. /**
  76331. * Gets or Sets the current prepass renderer associated to the scene.
  76332. */
  76333. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76334. /**
  76335. * Enables the subsurface effect for prepass
  76336. * @returns the SubSurfaceConfiguration
  76337. */
  76338. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76339. /**
  76340. * Disables the subsurface effect for prepass
  76341. */
  76342. disableSubSurfaceForPrePass(): void;
  76343. }
  76344. }
  76345. /**
  76346. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76347. * in several rendering techniques.
  76348. */
  76349. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76350. /**
  76351. * The component name helpful to identify the component in the list of scene components.
  76352. */
  76353. readonly name: string;
  76354. /**
  76355. * The scene the component belongs to.
  76356. */
  76357. scene: Scene;
  76358. /**
  76359. * Creates a new instance of the component for the given scene
  76360. * @param scene Defines the scene to register the component in
  76361. */
  76362. constructor(scene: Scene);
  76363. /**
  76364. * Registers the component in a given scene
  76365. */
  76366. register(): void;
  76367. /**
  76368. * Serializes the component data to the specified json object
  76369. * @param serializationObject The object to serialize to
  76370. */
  76371. serialize(serializationObject: any): void;
  76372. /**
  76373. * Adds all the elements from the container to the scene
  76374. * @param container the container holding the elements
  76375. */
  76376. addFromContainer(container: AbstractScene): void;
  76377. /**
  76378. * Removes all the elements in the container from the scene
  76379. * @param container contains the elements to remove
  76380. * @param dispose if the removed element should be disposed (default: false)
  76381. */
  76382. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76383. /**
  76384. * Rebuilds the elements related to this component in case of
  76385. * context lost for instance.
  76386. */
  76387. rebuild(): void;
  76388. /**
  76389. * Disposes the component and the associated ressources
  76390. */
  76391. dispose(): void;
  76392. }
  76393. }
  76394. declare module "babylonjs/Shaders/outline.fragment" {
  76395. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76396. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76397. /** @hidden */
  76398. export var outlinePixelShader: {
  76399. name: string;
  76400. shader: string;
  76401. };
  76402. }
  76403. declare module "babylonjs/Shaders/outline.vertex" {
  76404. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76406. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76407. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76408. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76410. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76411. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76412. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76413. /** @hidden */
  76414. export var outlineVertexShader: {
  76415. name: string;
  76416. shader: string;
  76417. };
  76418. }
  76419. declare module "babylonjs/Rendering/outlineRenderer" {
  76420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76421. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76422. import { Scene } from "babylonjs/scene";
  76423. import { ISceneComponent } from "babylonjs/sceneComponent";
  76424. import "babylonjs/Shaders/outline.fragment";
  76425. import "babylonjs/Shaders/outline.vertex";
  76426. module "babylonjs/scene" {
  76427. interface Scene {
  76428. /** @hidden */
  76429. _outlineRenderer: OutlineRenderer;
  76430. /**
  76431. * Gets the outline renderer associated with the scene
  76432. * @returns a OutlineRenderer
  76433. */
  76434. getOutlineRenderer(): OutlineRenderer;
  76435. }
  76436. }
  76437. module "babylonjs/Meshes/abstractMesh" {
  76438. interface AbstractMesh {
  76439. /** @hidden (Backing field) */
  76440. _renderOutline: boolean;
  76441. /**
  76442. * Gets or sets a boolean indicating if the outline must be rendered as well
  76443. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76444. */
  76445. renderOutline: boolean;
  76446. /** @hidden (Backing field) */
  76447. _renderOverlay: boolean;
  76448. /**
  76449. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76450. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76451. */
  76452. renderOverlay: boolean;
  76453. }
  76454. }
  76455. /**
  76456. * This class is responsible to draw bothe outline/overlay of meshes.
  76457. * It should not be used directly but through the available method on mesh.
  76458. */
  76459. export class OutlineRenderer implements ISceneComponent {
  76460. /**
  76461. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76462. */
  76463. private static _StencilReference;
  76464. /**
  76465. * The name of the component. Each component must have a unique name.
  76466. */
  76467. name: string;
  76468. /**
  76469. * The scene the component belongs to.
  76470. */
  76471. scene: Scene;
  76472. /**
  76473. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76474. */
  76475. zOffset: number;
  76476. private _engine;
  76477. private _effect;
  76478. private _cachedDefines;
  76479. private _savedDepthWrite;
  76480. /**
  76481. * Instantiates a new outline renderer. (There could be only one per scene).
  76482. * @param scene Defines the scene it belongs to
  76483. */
  76484. constructor(scene: Scene);
  76485. /**
  76486. * Register the component to one instance of a scene.
  76487. */
  76488. register(): void;
  76489. /**
  76490. * Rebuilds the elements related to this component in case of
  76491. * context lost for instance.
  76492. */
  76493. rebuild(): void;
  76494. /**
  76495. * Disposes the component and the associated ressources.
  76496. */
  76497. dispose(): void;
  76498. /**
  76499. * Renders the outline in the canvas.
  76500. * @param subMesh Defines the sumesh to render
  76501. * @param batch Defines the batch of meshes in case of instances
  76502. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76503. */
  76504. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76505. /**
  76506. * Returns whether or not the outline renderer is ready for a given submesh.
  76507. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76508. * @param subMesh Defines the submesh to check readyness for
  76509. * @param useInstances Defines wheter wee are trying to render instances or not
  76510. * @returns true if ready otherwise false
  76511. */
  76512. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76513. private _beforeRenderingMesh;
  76514. private _afterRenderingMesh;
  76515. }
  76516. }
  76517. declare module "babylonjs/Rendering/index" {
  76518. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76519. export * from "babylonjs/Rendering/depthRenderer";
  76520. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76521. export * from "babylonjs/Rendering/edgesRenderer";
  76522. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76523. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76524. export * from "babylonjs/Rendering/prePassRenderer";
  76525. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76526. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76527. export * from "babylonjs/Rendering/outlineRenderer";
  76528. export * from "babylonjs/Rendering/renderingGroup";
  76529. export * from "babylonjs/Rendering/renderingManager";
  76530. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76531. }
  76532. declare module "babylonjs/Sprites/ISprites" {
  76533. /**
  76534. * Defines the basic options interface of a Sprite Frame Source Size.
  76535. */
  76536. export interface ISpriteJSONSpriteSourceSize {
  76537. /**
  76538. * number of the original width of the Frame
  76539. */
  76540. w: number;
  76541. /**
  76542. * number of the original height of the Frame
  76543. */
  76544. h: number;
  76545. }
  76546. /**
  76547. * Defines the basic options interface of a Sprite Frame Data.
  76548. */
  76549. export interface ISpriteJSONSpriteFrameData {
  76550. /**
  76551. * number of the x offset of the Frame
  76552. */
  76553. x: number;
  76554. /**
  76555. * number of the y offset of the Frame
  76556. */
  76557. y: number;
  76558. /**
  76559. * number of the width of the Frame
  76560. */
  76561. w: number;
  76562. /**
  76563. * number of the height of the Frame
  76564. */
  76565. h: number;
  76566. }
  76567. /**
  76568. * Defines the basic options interface of a JSON Sprite.
  76569. */
  76570. export interface ISpriteJSONSprite {
  76571. /**
  76572. * string name of the Frame
  76573. */
  76574. filename: string;
  76575. /**
  76576. * ISpriteJSONSpriteFrame basic object of the frame data
  76577. */
  76578. frame: ISpriteJSONSpriteFrameData;
  76579. /**
  76580. * boolean to flag is the frame was rotated.
  76581. */
  76582. rotated: boolean;
  76583. /**
  76584. * boolean to flag is the frame was trimmed.
  76585. */
  76586. trimmed: boolean;
  76587. /**
  76588. * ISpriteJSONSpriteFrame basic object of the source data
  76589. */
  76590. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76591. /**
  76592. * ISpriteJSONSpriteFrame basic object of the source data
  76593. */
  76594. sourceSize: ISpriteJSONSpriteSourceSize;
  76595. }
  76596. /**
  76597. * Defines the basic options interface of a JSON atlas.
  76598. */
  76599. export interface ISpriteJSONAtlas {
  76600. /**
  76601. * Array of objects that contain the frame data.
  76602. */
  76603. frames: Array<ISpriteJSONSprite>;
  76604. /**
  76605. * object basic object containing the sprite meta data.
  76606. */
  76607. meta?: object;
  76608. }
  76609. }
  76610. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76611. /** @hidden */
  76612. export var spriteMapPixelShader: {
  76613. name: string;
  76614. shader: string;
  76615. };
  76616. }
  76617. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76618. /** @hidden */
  76619. export var spriteMapVertexShader: {
  76620. name: string;
  76621. shader: string;
  76622. };
  76623. }
  76624. declare module "babylonjs/Sprites/spriteMap" {
  76625. import { IDisposable, Scene } from "babylonjs/scene";
  76626. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76627. import { Texture } from "babylonjs/Materials/Textures/texture";
  76628. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76629. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76630. import "babylonjs/Meshes/Builders/planeBuilder";
  76631. import "babylonjs/Shaders/spriteMap.fragment";
  76632. import "babylonjs/Shaders/spriteMap.vertex";
  76633. /**
  76634. * Defines the basic options interface of a SpriteMap
  76635. */
  76636. export interface ISpriteMapOptions {
  76637. /**
  76638. * Vector2 of the number of cells in the grid.
  76639. */
  76640. stageSize?: Vector2;
  76641. /**
  76642. * Vector2 of the size of the output plane in World Units.
  76643. */
  76644. outputSize?: Vector2;
  76645. /**
  76646. * Vector3 of the position of the output plane in World Units.
  76647. */
  76648. outputPosition?: Vector3;
  76649. /**
  76650. * Vector3 of the rotation of the output plane.
  76651. */
  76652. outputRotation?: Vector3;
  76653. /**
  76654. * number of layers that the system will reserve in resources.
  76655. */
  76656. layerCount?: number;
  76657. /**
  76658. * number of max animation frames a single cell will reserve in resources.
  76659. */
  76660. maxAnimationFrames?: number;
  76661. /**
  76662. * number cell index of the base tile when the system compiles.
  76663. */
  76664. baseTile?: number;
  76665. /**
  76666. * boolean flip the sprite after its been repositioned by the framing data.
  76667. */
  76668. flipU?: boolean;
  76669. /**
  76670. * Vector3 scalar of the global RGB values of the SpriteMap.
  76671. */
  76672. colorMultiply?: Vector3;
  76673. }
  76674. /**
  76675. * Defines the IDisposable interface in order to be cleanable from resources.
  76676. */
  76677. export interface ISpriteMap extends IDisposable {
  76678. /**
  76679. * String name of the SpriteMap.
  76680. */
  76681. name: string;
  76682. /**
  76683. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76684. */
  76685. atlasJSON: ISpriteJSONAtlas;
  76686. /**
  76687. * Texture of the SpriteMap.
  76688. */
  76689. spriteSheet: Texture;
  76690. /**
  76691. * The parameters to initialize the SpriteMap with.
  76692. */
  76693. options: ISpriteMapOptions;
  76694. }
  76695. /**
  76696. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76697. */
  76698. export class SpriteMap implements ISpriteMap {
  76699. /** The Name of the spriteMap */
  76700. name: string;
  76701. /** The JSON file with the frame and meta data */
  76702. atlasJSON: ISpriteJSONAtlas;
  76703. /** The systems Sprite Sheet Texture */
  76704. spriteSheet: Texture;
  76705. /** Arguments passed with the Constructor */
  76706. options: ISpriteMapOptions;
  76707. /** Public Sprite Storage array, parsed from atlasJSON */
  76708. sprites: Array<ISpriteJSONSprite>;
  76709. /** Returns the Number of Sprites in the System */
  76710. get spriteCount(): number;
  76711. /** Returns the Position of Output Plane*/
  76712. get position(): Vector3;
  76713. /** Returns the Position of Output Plane*/
  76714. set position(v: Vector3);
  76715. /** Returns the Rotation of Output Plane*/
  76716. get rotation(): Vector3;
  76717. /** Returns the Rotation of Output Plane*/
  76718. set rotation(v: Vector3);
  76719. /** Sets the AnimationMap*/
  76720. get animationMap(): RawTexture;
  76721. /** Sets the AnimationMap*/
  76722. set animationMap(v: RawTexture);
  76723. /** Scene that the SpriteMap was created in */
  76724. private _scene;
  76725. /** Texture Buffer of Float32 that holds tile frame data*/
  76726. private _frameMap;
  76727. /** Texture Buffers of Float32 that holds tileMap data*/
  76728. private _tileMaps;
  76729. /** Texture Buffer of Float32 that holds Animation Data*/
  76730. private _animationMap;
  76731. /** Custom ShaderMaterial Central to the System*/
  76732. private _material;
  76733. /** Custom ShaderMaterial Central to the System*/
  76734. private _output;
  76735. /** Systems Time Ticker*/
  76736. private _time;
  76737. /**
  76738. * Creates a new SpriteMap
  76739. * @param name defines the SpriteMaps Name
  76740. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76741. * @param spriteSheet is the Texture that the Sprites are on.
  76742. * @param options a basic deployment configuration
  76743. * @param scene The Scene that the map is deployed on
  76744. */
  76745. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76746. /**
  76747. * Returns tileID location
  76748. * @returns Vector2 the cell position ID
  76749. */
  76750. getTileID(): Vector2;
  76751. /**
  76752. * Gets the UV location of the mouse over the SpriteMap.
  76753. * @returns Vector2 the UV position of the mouse interaction
  76754. */
  76755. getMousePosition(): Vector2;
  76756. /**
  76757. * Creates the "frame" texture Buffer
  76758. * -------------------------------------
  76759. * Structure of frames
  76760. * "filename": "Falling-Water-2.png",
  76761. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76762. * "rotated": true,
  76763. * "trimmed": true,
  76764. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76765. * "sourceSize": {"w":32,"h":32}
  76766. * @returns RawTexture of the frameMap
  76767. */
  76768. private _createFrameBuffer;
  76769. /**
  76770. * Creates the tileMap texture Buffer
  76771. * @param buffer normally and array of numbers, or a false to generate from scratch
  76772. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76773. * @returns RawTexture of the tileMap
  76774. */
  76775. private _createTileBuffer;
  76776. /**
  76777. * Modifies the data of the tileMaps
  76778. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76779. * @param pos is the iVector2 Coordinates of the Tile
  76780. * @param tile The SpriteIndex of the new Tile
  76781. */
  76782. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76783. /**
  76784. * Creates the animationMap texture Buffer
  76785. * @param buffer normally and array of numbers, or a false to generate from scratch
  76786. * @returns RawTexture of the animationMap
  76787. */
  76788. private _createTileAnimationBuffer;
  76789. /**
  76790. * Modifies the data of the animationMap
  76791. * @param cellID is the Index of the Sprite
  76792. * @param _frame is the target Animation frame
  76793. * @param toCell is the Target Index of the next frame of the animation
  76794. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76795. * @param speed is a global scalar of the time variable on the map.
  76796. */
  76797. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76798. /**
  76799. * Exports the .tilemaps file
  76800. */
  76801. saveTileMaps(): void;
  76802. /**
  76803. * Imports the .tilemaps file
  76804. * @param url of the .tilemaps file
  76805. */
  76806. loadTileMaps(url: string): void;
  76807. /**
  76808. * Release associated resources
  76809. */
  76810. dispose(): void;
  76811. }
  76812. }
  76813. declare module "babylonjs/Sprites/spritePackedManager" {
  76814. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76815. import { Scene } from "babylonjs/scene";
  76816. /**
  76817. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76818. * @see https://doc.babylonjs.com/babylon101/sprites
  76819. */
  76820. export class SpritePackedManager extends SpriteManager {
  76821. /** defines the packed manager's name */
  76822. name: string;
  76823. /**
  76824. * Creates a new sprite manager from a packed sprite sheet
  76825. * @param name defines the manager's name
  76826. * @param imgUrl defines the sprite sheet url
  76827. * @param capacity defines the maximum allowed number of sprites
  76828. * @param scene defines the hosting scene
  76829. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76830. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76831. * @param samplingMode defines the smapling mode to use with spritesheet
  76832. * @param fromPacked set to true; do not alter
  76833. */
  76834. constructor(
  76835. /** defines the packed manager's name */
  76836. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76837. }
  76838. }
  76839. declare module "babylonjs/Sprites/index" {
  76840. export * from "babylonjs/Sprites/sprite";
  76841. export * from "babylonjs/Sprites/ISprites";
  76842. export * from "babylonjs/Sprites/spriteManager";
  76843. export * from "babylonjs/Sprites/spriteMap";
  76844. export * from "babylonjs/Sprites/spritePackedManager";
  76845. export * from "babylonjs/Sprites/spriteSceneComponent";
  76846. }
  76847. declare module "babylonjs/States/index" {
  76848. export * from "babylonjs/States/alphaCullingState";
  76849. export * from "babylonjs/States/depthCullingState";
  76850. export * from "babylonjs/States/stencilState";
  76851. }
  76852. declare module "babylonjs/Misc/assetsManager" {
  76853. import { Scene } from "babylonjs/scene";
  76854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76856. import { Skeleton } from "babylonjs/Bones/skeleton";
  76857. import { Observable } from "babylonjs/Misc/observable";
  76858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76859. import { Texture } from "babylonjs/Materials/Textures/texture";
  76860. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76861. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76862. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76863. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76864. import { AssetContainer } from "babylonjs/assetContainer";
  76865. /**
  76866. * Defines the list of states available for a task inside a AssetsManager
  76867. */
  76868. export enum AssetTaskState {
  76869. /**
  76870. * Initialization
  76871. */
  76872. INIT = 0,
  76873. /**
  76874. * Running
  76875. */
  76876. RUNNING = 1,
  76877. /**
  76878. * Done
  76879. */
  76880. DONE = 2,
  76881. /**
  76882. * Error
  76883. */
  76884. ERROR = 3
  76885. }
  76886. /**
  76887. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76888. */
  76889. export abstract class AbstractAssetTask {
  76890. /**
  76891. * Task name
  76892. */ name: string;
  76893. /**
  76894. * Callback called when the task is successful
  76895. */
  76896. onSuccess: (task: any) => void;
  76897. /**
  76898. * Callback called when the task is not successful
  76899. */
  76900. onError: (task: any, message?: string, exception?: any) => void;
  76901. /**
  76902. * Creates a new AssetsManager
  76903. * @param name defines the name of the task
  76904. */
  76905. constructor(
  76906. /**
  76907. * Task name
  76908. */ name: string);
  76909. private _isCompleted;
  76910. private _taskState;
  76911. private _errorObject;
  76912. /**
  76913. * Get if the task is completed
  76914. */
  76915. get isCompleted(): boolean;
  76916. /**
  76917. * Gets the current state of the task
  76918. */
  76919. get taskState(): AssetTaskState;
  76920. /**
  76921. * Gets the current error object (if task is in error)
  76922. */
  76923. get errorObject(): {
  76924. message?: string;
  76925. exception?: any;
  76926. };
  76927. /**
  76928. * Internal only
  76929. * @hidden
  76930. */
  76931. _setErrorObject(message?: string, exception?: any): void;
  76932. /**
  76933. * Execute the current task
  76934. * @param scene defines the scene where you want your assets to be loaded
  76935. * @param onSuccess is a callback called when the task is successfully executed
  76936. * @param onError is a callback called if an error occurs
  76937. */
  76938. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76939. /**
  76940. * Execute the current task
  76941. * @param scene defines the scene where you want your assets to be loaded
  76942. * @param onSuccess is a callback called when the task is successfully executed
  76943. * @param onError is a callback called if an error occurs
  76944. */
  76945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76946. /**
  76947. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76948. * This can be used with failed tasks that have the reason for failure fixed.
  76949. */
  76950. reset(): void;
  76951. private onErrorCallback;
  76952. private onDoneCallback;
  76953. }
  76954. /**
  76955. * Define the interface used by progress events raised during assets loading
  76956. */
  76957. export interface IAssetsProgressEvent {
  76958. /**
  76959. * Defines the number of remaining tasks to process
  76960. */
  76961. remainingCount: number;
  76962. /**
  76963. * Defines the total number of tasks
  76964. */
  76965. totalCount: number;
  76966. /**
  76967. * Defines the task that was just processed
  76968. */
  76969. task: AbstractAssetTask;
  76970. }
  76971. /**
  76972. * Class used to share progress information about assets loading
  76973. */
  76974. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76975. /**
  76976. * Defines the number of remaining tasks to process
  76977. */
  76978. remainingCount: number;
  76979. /**
  76980. * Defines the total number of tasks
  76981. */
  76982. totalCount: number;
  76983. /**
  76984. * Defines the task that was just processed
  76985. */
  76986. task: AbstractAssetTask;
  76987. /**
  76988. * Creates a AssetsProgressEvent
  76989. * @param remainingCount defines the number of remaining tasks to process
  76990. * @param totalCount defines the total number of tasks
  76991. * @param task defines the task that was just processed
  76992. */
  76993. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76994. }
  76995. /**
  76996. * Define a task used by AssetsManager to load assets into a container
  76997. */
  76998. export class ContainerAssetTask extends AbstractAssetTask {
  76999. /**
  77000. * Defines the name of the task
  77001. */
  77002. name: string;
  77003. /**
  77004. * Defines the list of mesh's names you want to load
  77005. */
  77006. meshesNames: any;
  77007. /**
  77008. * Defines the root url to use as a base to load your meshes and associated resources
  77009. */
  77010. rootUrl: string;
  77011. /**
  77012. * Defines the filename or File of the scene to load from
  77013. */
  77014. sceneFilename: string | File;
  77015. /**
  77016. * Get the loaded asset container
  77017. */
  77018. loadedContainer: AssetContainer;
  77019. /**
  77020. * Gets the list of loaded meshes
  77021. */
  77022. loadedMeshes: Array<AbstractMesh>;
  77023. /**
  77024. * Gets the list of loaded particle systems
  77025. */
  77026. loadedParticleSystems: Array<IParticleSystem>;
  77027. /**
  77028. * Gets the list of loaded skeletons
  77029. */
  77030. loadedSkeletons: Array<Skeleton>;
  77031. /**
  77032. * Gets the list of loaded animation groups
  77033. */
  77034. loadedAnimationGroups: Array<AnimationGroup>;
  77035. /**
  77036. * Callback called when the task is successful
  77037. */
  77038. onSuccess: (task: ContainerAssetTask) => void;
  77039. /**
  77040. * Callback called when the task is successful
  77041. */
  77042. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77043. /**
  77044. * Creates a new ContainerAssetTask
  77045. * @param name defines the name of the task
  77046. * @param meshesNames defines the list of mesh's names you want to load
  77047. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77048. * @param sceneFilename defines the filename or File of the scene to load from
  77049. */
  77050. constructor(
  77051. /**
  77052. * Defines the name of the task
  77053. */
  77054. name: string,
  77055. /**
  77056. * Defines the list of mesh's names you want to load
  77057. */
  77058. meshesNames: any,
  77059. /**
  77060. * Defines the root url to use as a base to load your meshes and associated resources
  77061. */
  77062. rootUrl: string,
  77063. /**
  77064. * Defines the filename or File of the scene to load from
  77065. */
  77066. sceneFilename: string | File);
  77067. /**
  77068. * Execute the current task
  77069. * @param scene defines the scene where you want your assets to be loaded
  77070. * @param onSuccess is a callback called when the task is successfully executed
  77071. * @param onError is a callback called if an error occurs
  77072. */
  77073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77074. }
  77075. /**
  77076. * Define a task used by AssetsManager to load meshes
  77077. */
  77078. export class MeshAssetTask extends AbstractAssetTask {
  77079. /**
  77080. * Defines the name of the task
  77081. */
  77082. name: string;
  77083. /**
  77084. * Defines the list of mesh's names you want to load
  77085. */
  77086. meshesNames: any;
  77087. /**
  77088. * Defines the root url to use as a base to load your meshes and associated resources
  77089. */
  77090. rootUrl: string;
  77091. /**
  77092. * Defines the filename or File of the scene to load from
  77093. */
  77094. sceneFilename: string | File;
  77095. /**
  77096. * Gets the list of loaded meshes
  77097. */
  77098. loadedMeshes: Array<AbstractMesh>;
  77099. /**
  77100. * Gets the list of loaded particle systems
  77101. */
  77102. loadedParticleSystems: Array<IParticleSystem>;
  77103. /**
  77104. * Gets the list of loaded skeletons
  77105. */
  77106. loadedSkeletons: Array<Skeleton>;
  77107. /**
  77108. * Gets the list of loaded animation groups
  77109. */
  77110. loadedAnimationGroups: Array<AnimationGroup>;
  77111. /**
  77112. * Callback called when the task is successful
  77113. */
  77114. onSuccess: (task: MeshAssetTask) => void;
  77115. /**
  77116. * Callback called when the task is successful
  77117. */
  77118. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77119. /**
  77120. * Creates a new MeshAssetTask
  77121. * @param name defines the name of the task
  77122. * @param meshesNames defines the list of mesh's names you want to load
  77123. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77124. * @param sceneFilename defines the filename or File of the scene to load from
  77125. */
  77126. constructor(
  77127. /**
  77128. * Defines the name of the task
  77129. */
  77130. name: string,
  77131. /**
  77132. * Defines the list of mesh's names you want to load
  77133. */
  77134. meshesNames: any,
  77135. /**
  77136. * Defines the root url to use as a base to load your meshes and associated resources
  77137. */
  77138. rootUrl: string,
  77139. /**
  77140. * Defines the filename or File of the scene to load from
  77141. */
  77142. sceneFilename: string | File);
  77143. /**
  77144. * Execute the current task
  77145. * @param scene defines the scene where you want your assets to be loaded
  77146. * @param onSuccess is a callback called when the task is successfully executed
  77147. * @param onError is a callback called if an error occurs
  77148. */
  77149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77150. }
  77151. /**
  77152. * Define a task used by AssetsManager to load text content
  77153. */
  77154. export class TextFileAssetTask extends AbstractAssetTask {
  77155. /**
  77156. * Defines the name of the task
  77157. */
  77158. name: string;
  77159. /**
  77160. * Defines the location of the file to load
  77161. */
  77162. url: string;
  77163. /**
  77164. * Gets the loaded text string
  77165. */
  77166. text: string;
  77167. /**
  77168. * Callback called when the task is successful
  77169. */
  77170. onSuccess: (task: TextFileAssetTask) => void;
  77171. /**
  77172. * Callback called when the task is successful
  77173. */
  77174. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77175. /**
  77176. * Creates a new TextFileAssetTask object
  77177. * @param name defines the name of the task
  77178. * @param url defines the location of the file to load
  77179. */
  77180. constructor(
  77181. /**
  77182. * Defines the name of the task
  77183. */
  77184. name: string,
  77185. /**
  77186. * Defines the location of the file to load
  77187. */
  77188. url: string);
  77189. /**
  77190. * Execute the current task
  77191. * @param scene defines the scene where you want your assets to be loaded
  77192. * @param onSuccess is a callback called when the task is successfully executed
  77193. * @param onError is a callback called if an error occurs
  77194. */
  77195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77196. }
  77197. /**
  77198. * Define a task used by AssetsManager to load binary data
  77199. */
  77200. export class BinaryFileAssetTask extends AbstractAssetTask {
  77201. /**
  77202. * Defines the name of the task
  77203. */
  77204. name: string;
  77205. /**
  77206. * Defines the location of the file to load
  77207. */
  77208. url: string;
  77209. /**
  77210. * Gets the lodaded data (as an array buffer)
  77211. */
  77212. data: ArrayBuffer;
  77213. /**
  77214. * Callback called when the task is successful
  77215. */
  77216. onSuccess: (task: BinaryFileAssetTask) => void;
  77217. /**
  77218. * Callback called when the task is successful
  77219. */
  77220. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77221. /**
  77222. * Creates a new BinaryFileAssetTask object
  77223. * @param name defines the name of the new task
  77224. * @param url defines the location of the file to load
  77225. */
  77226. constructor(
  77227. /**
  77228. * Defines the name of the task
  77229. */
  77230. name: string,
  77231. /**
  77232. * Defines the location of the file to load
  77233. */
  77234. url: string);
  77235. /**
  77236. * Execute the current task
  77237. * @param scene defines the scene where you want your assets to be loaded
  77238. * @param onSuccess is a callback called when the task is successfully executed
  77239. * @param onError is a callback called if an error occurs
  77240. */
  77241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77242. }
  77243. /**
  77244. * Define a task used by AssetsManager to load images
  77245. */
  77246. export class ImageAssetTask extends AbstractAssetTask {
  77247. /**
  77248. * Defines the name of the task
  77249. */
  77250. name: string;
  77251. /**
  77252. * Defines the location of the image to load
  77253. */
  77254. url: string;
  77255. /**
  77256. * Gets the loaded images
  77257. */
  77258. image: HTMLImageElement;
  77259. /**
  77260. * Callback called when the task is successful
  77261. */
  77262. onSuccess: (task: ImageAssetTask) => void;
  77263. /**
  77264. * Callback called when the task is successful
  77265. */
  77266. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77267. /**
  77268. * Creates a new ImageAssetTask
  77269. * @param name defines the name of the task
  77270. * @param url defines the location of the image to load
  77271. */
  77272. constructor(
  77273. /**
  77274. * Defines the name of the task
  77275. */
  77276. name: string,
  77277. /**
  77278. * Defines the location of the image to load
  77279. */
  77280. url: string);
  77281. /**
  77282. * Execute the current task
  77283. * @param scene defines the scene where you want your assets to be loaded
  77284. * @param onSuccess is a callback called when the task is successfully executed
  77285. * @param onError is a callback called if an error occurs
  77286. */
  77287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77288. }
  77289. /**
  77290. * Defines the interface used by texture loading tasks
  77291. */
  77292. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77293. /**
  77294. * Gets the loaded texture
  77295. */
  77296. texture: TEX;
  77297. }
  77298. /**
  77299. * Define a task used by AssetsManager to load 2D textures
  77300. */
  77301. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77302. /**
  77303. * Defines the name of the task
  77304. */
  77305. name: string;
  77306. /**
  77307. * Defines the location of the file to load
  77308. */
  77309. url: string;
  77310. /**
  77311. * Defines if mipmap should not be generated (default is false)
  77312. */
  77313. noMipmap?: boolean | undefined;
  77314. /**
  77315. * Defines if texture must be inverted on Y axis (default is true)
  77316. */
  77317. invertY: boolean;
  77318. /**
  77319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77320. */
  77321. samplingMode: number;
  77322. /**
  77323. * Gets the loaded texture
  77324. */
  77325. texture: Texture;
  77326. /**
  77327. * Callback called when the task is successful
  77328. */
  77329. onSuccess: (task: TextureAssetTask) => void;
  77330. /**
  77331. * Callback called when the task is successful
  77332. */
  77333. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77334. /**
  77335. * Creates a new TextureAssetTask object
  77336. * @param name defines the name of the task
  77337. * @param url defines the location of the file to load
  77338. * @param noMipmap defines if mipmap should not be generated (default is false)
  77339. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77340. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77341. */
  77342. constructor(
  77343. /**
  77344. * Defines the name of the task
  77345. */
  77346. name: string,
  77347. /**
  77348. * Defines the location of the file to load
  77349. */
  77350. url: string,
  77351. /**
  77352. * Defines if mipmap should not be generated (default is false)
  77353. */
  77354. noMipmap?: boolean | undefined,
  77355. /**
  77356. * Defines if texture must be inverted on Y axis (default is true)
  77357. */
  77358. invertY?: boolean,
  77359. /**
  77360. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77361. */
  77362. samplingMode?: number);
  77363. /**
  77364. * Execute the current task
  77365. * @param scene defines the scene where you want your assets to be loaded
  77366. * @param onSuccess is a callback called when the task is successfully executed
  77367. * @param onError is a callback called if an error occurs
  77368. */
  77369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77370. }
  77371. /**
  77372. * Define a task used by AssetsManager to load cube textures
  77373. */
  77374. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77375. /**
  77376. * Defines the name of the task
  77377. */
  77378. name: string;
  77379. /**
  77380. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77381. */
  77382. url: string;
  77383. /**
  77384. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77385. */
  77386. extensions?: string[] | undefined;
  77387. /**
  77388. * Defines if mipmaps should not be generated (default is false)
  77389. */
  77390. noMipmap?: boolean | undefined;
  77391. /**
  77392. * Defines the explicit list of files (undefined by default)
  77393. */
  77394. files?: string[] | undefined;
  77395. /**
  77396. * Gets the loaded texture
  77397. */
  77398. texture: CubeTexture;
  77399. /**
  77400. * Callback called when the task is successful
  77401. */
  77402. onSuccess: (task: CubeTextureAssetTask) => void;
  77403. /**
  77404. * Callback called when the task is successful
  77405. */
  77406. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77407. /**
  77408. * Creates a new CubeTextureAssetTask
  77409. * @param name defines the name of the task
  77410. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77411. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77413. * @param files defines the explicit list of files (undefined by default)
  77414. */
  77415. constructor(
  77416. /**
  77417. * Defines the name of the task
  77418. */
  77419. name: string,
  77420. /**
  77421. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77422. */
  77423. url: string,
  77424. /**
  77425. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77426. */
  77427. extensions?: string[] | undefined,
  77428. /**
  77429. * Defines if mipmaps should not be generated (default is false)
  77430. */
  77431. noMipmap?: boolean | undefined,
  77432. /**
  77433. * Defines the explicit list of files (undefined by default)
  77434. */
  77435. files?: string[] | undefined);
  77436. /**
  77437. * Execute the current task
  77438. * @param scene defines the scene where you want your assets to be loaded
  77439. * @param onSuccess is a callback called when the task is successfully executed
  77440. * @param onError is a callback called if an error occurs
  77441. */
  77442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77443. }
  77444. /**
  77445. * Define a task used by AssetsManager to load HDR cube textures
  77446. */
  77447. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77448. /**
  77449. * Defines the name of the task
  77450. */
  77451. name: string;
  77452. /**
  77453. * Defines the location of the file to load
  77454. */
  77455. url: string;
  77456. /**
  77457. * Defines the desired size (the more it increases the longer the generation will be)
  77458. */
  77459. size: number;
  77460. /**
  77461. * Defines if mipmaps should not be generated (default is false)
  77462. */
  77463. noMipmap: boolean;
  77464. /**
  77465. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77466. */
  77467. generateHarmonics: boolean;
  77468. /**
  77469. * 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)
  77470. */
  77471. gammaSpace: boolean;
  77472. /**
  77473. * Internal Use Only
  77474. */
  77475. reserved: boolean;
  77476. /**
  77477. * Gets the loaded texture
  77478. */
  77479. texture: HDRCubeTexture;
  77480. /**
  77481. * Callback called when the task is successful
  77482. */
  77483. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77484. /**
  77485. * Callback called when the task is successful
  77486. */
  77487. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77488. /**
  77489. * Creates a new HDRCubeTextureAssetTask object
  77490. * @param name defines the name of the task
  77491. * @param url defines the location of the file to load
  77492. * @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.
  77493. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77494. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77495. * @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)
  77496. * @param reserved Internal use only
  77497. */
  77498. constructor(
  77499. /**
  77500. * Defines the name of the task
  77501. */
  77502. name: string,
  77503. /**
  77504. * Defines the location of the file to load
  77505. */
  77506. url: string,
  77507. /**
  77508. * Defines the desired size (the more it increases the longer the generation will be)
  77509. */
  77510. size: number,
  77511. /**
  77512. * Defines if mipmaps should not be generated (default is false)
  77513. */
  77514. noMipmap?: boolean,
  77515. /**
  77516. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77517. */
  77518. generateHarmonics?: boolean,
  77519. /**
  77520. * 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)
  77521. */
  77522. gammaSpace?: boolean,
  77523. /**
  77524. * Internal Use Only
  77525. */
  77526. reserved?: boolean);
  77527. /**
  77528. * Execute the current task
  77529. * @param scene defines the scene where you want your assets to be loaded
  77530. * @param onSuccess is a callback called when the task is successfully executed
  77531. * @param onError is a callback called if an error occurs
  77532. */
  77533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77534. }
  77535. /**
  77536. * Define a task used by AssetsManager to load Equirectangular cube textures
  77537. */
  77538. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77539. /**
  77540. * Defines the name of the task
  77541. */
  77542. name: string;
  77543. /**
  77544. * Defines the location of the file to load
  77545. */
  77546. url: string;
  77547. /**
  77548. * Defines the desired size (the more it increases the longer the generation will be)
  77549. */
  77550. size: number;
  77551. /**
  77552. * Defines if mipmaps should not be generated (default is false)
  77553. */
  77554. noMipmap: boolean;
  77555. /**
  77556. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77557. * but the standard material would require them in Gamma space) (default is true)
  77558. */
  77559. gammaSpace: boolean;
  77560. /**
  77561. * Gets the loaded texture
  77562. */
  77563. texture: EquiRectangularCubeTexture;
  77564. /**
  77565. * Callback called when the task is successful
  77566. */
  77567. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77568. /**
  77569. * Callback called when the task is successful
  77570. */
  77571. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77572. /**
  77573. * Creates a new EquiRectangularCubeTextureAssetTask object
  77574. * @param name defines the name of the task
  77575. * @param url defines the location of the file to load
  77576. * @param size defines the desired size (the more it increases the longer the generation will be)
  77577. * If the size is omitted this implies you are using a preprocessed cubemap.
  77578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77579. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77580. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77581. * (default is true)
  77582. */
  77583. constructor(
  77584. /**
  77585. * Defines the name of the task
  77586. */
  77587. name: string,
  77588. /**
  77589. * Defines the location of the file to load
  77590. */
  77591. url: string,
  77592. /**
  77593. * Defines the desired size (the more it increases the longer the generation will be)
  77594. */
  77595. size: number,
  77596. /**
  77597. * Defines if mipmaps should not be generated (default is false)
  77598. */
  77599. noMipmap?: boolean,
  77600. /**
  77601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77602. * but the standard material would require them in Gamma space) (default is true)
  77603. */
  77604. gammaSpace?: boolean);
  77605. /**
  77606. * Execute the current task
  77607. * @param scene defines the scene where you want your assets to be loaded
  77608. * @param onSuccess is a callback called when the task is successfully executed
  77609. * @param onError is a callback called if an error occurs
  77610. */
  77611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77612. }
  77613. /**
  77614. * This class can be used to easily import assets into a scene
  77615. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77616. */
  77617. export class AssetsManager {
  77618. private _scene;
  77619. private _isLoading;
  77620. protected _tasks: AbstractAssetTask[];
  77621. protected _waitingTasksCount: number;
  77622. protected _totalTasksCount: number;
  77623. /**
  77624. * Callback called when all tasks are processed
  77625. */
  77626. onFinish: (tasks: AbstractAssetTask[]) => void;
  77627. /**
  77628. * Callback called when a task is successful
  77629. */
  77630. onTaskSuccess: (task: AbstractAssetTask) => void;
  77631. /**
  77632. * Callback called when a task had an error
  77633. */
  77634. onTaskError: (task: AbstractAssetTask) => void;
  77635. /**
  77636. * Callback called when a task is done (whatever the result is)
  77637. */
  77638. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77639. /**
  77640. * Observable called when all tasks are processed
  77641. */
  77642. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77643. /**
  77644. * Observable called when a task had an error
  77645. */
  77646. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77647. /**
  77648. * Observable called when all tasks were executed
  77649. */
  77650. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77651. /**
  77652. * Observable called when a task is done (whatever the result is)
  77653. */
  77654. onProgressObservable: Observable<IAssetsProgressEvent>;
  77655. /**
  77656. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77657. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77658. */
  77659. useDefaultLoadingScreen: boolean;
  77660. /**
  77661. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77662. * when all assets have been downloaded.
  77663. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77664. */
  77665. autoHideLoadingUI: boolean;
  77666. /**
  77667. * Creates a new AssetsManager
  77668. * @param scene defines the scene to work on
  77669. */
  77670. constructor(scene: Scene);
  77671. /**
  77672. * Add a ContainerAssetTask to the list of active tasks
  77673. * @param taskName defines the name of the new task
  77674. * @param meshesNames defines the name of meshes to load
  77675. * @param rootUrl defines the root url to use to locate files
  77676. * @param sceneFilename defines the filename of the scene file
  77677. * @returns a new ContainerAssetTask object
  77678. */
  77679. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77680. /**
  77681. * Add a MeshAssetTask to the list of active tasks
  77682. * @param taskName defines the name of the new task
  77683. * @param meshesNames defines the name of meshes to load
  77684. * @param rootUrl defines the root url to use to locate files
  77685. * @param sceneFilename defines the filename of the scene file
  77686. * @returns a new MeshAssetTask object
  77687. */
  77688. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77689. /**
  77690. * Add a TextFileAssetTask to the list of active tasks
  77691. * @param taskName defines the name of the new task
  77692. * @param url defines the url of the file to load
  77693. * @returns a new TextFileAssetTask object
  77694. */
  77695. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77696. /**
  77697. * Add a BinaryFileAssetTask to the list of active tasks
  77698. * @param taskName defines the name of the new task
  77699. * @param url defines the url of the file to load
  77700. * @returns a new BinaryFileAssetTask object
  77701. */
  77702. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77703. /**
  77704. * Add a ImageAssetTask to the list of active tasks
  77705. * @param taskName defines the name of the new task
  77706. * @param url defines the url of the file to load
  77707. * @returns a new ImageAssetTask object
  77708. */
  77709. addImageTask(taskName: string, url: string): ImageAssetTask;
  77710. /**
  77711. * Add a TextureAssetTask to the list of active tasks
  77712. * @param taskName defines the name of the new task
  77713. * @param url defines the url of the file to load
  77714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77715. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77716. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77717. * @returns a new TextureAssetTask object
  77718. */
  77719. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77720. /**
  77721. * Add a CubeTextureAssetTask to the list of active tasks
  77722. * @param taskName defines the name of the new task
  77723. * @param url defines the url of the file to load
  77724. * @param extensions defines the extension to use to load the cube map (can be null)
  77725. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77726. * @param files defines the list of files to load (can be null)
  77727. * @returns a new CubeTextureAssetTask object
  77728. */
  77729. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77730. /**
  77731. *
  77732. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77733. * @param taskName defines the name of the new task
  77734. * @param url defines the url of the file to load
  77735. * @param size defines the size you want for the cubemap (can be null)
  77736. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77737. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77738. * @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)
  77739. * @param reserved Internal use only
  77740. * @returns a new HDRCubeTextureAssetTask object
  77741. */
  77742. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77743. /**
  77744. *
  77745. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77746. * @param taskName defines the name of the new task
  77747. * @param url defines the url of the file to load
  77748. * @param size defines the size you want for the cubemap (can be null)
  77749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77750. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77751. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77752. * @returns a new EquiRectangularCubeTextureAssetTask object
  77753. */
  77754. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77755. /**
  77756. * Remove a task from the assets manager.
  77757. * @param task the task to remove
  77758. */
  77759. removeTask(task: AbstractAssetTask): void;
  77760. private _decreaseWaitingTasksCount;
  77761. private _runTask;
  77762. /**
  77763. * Reset the AssetsManager and remove all tasks
  77764. * @return the current instance of the AssetsManager
  77765. */
  77766. reset(): AssetsManager;
  77767. /**
  77768. * Start the loading process
  77769. * @return the current instance of the AssetsManager
  77770. */
  77771. load(): AssetsManager;
  77772. /**
  77773. * Start the loading process as an async operation
  77774. * @return a promise returning the list of failed tasks
  77775. */
  77776. loadAsync(): Promise<void>;
  77777. }
  77778. }
  77779. declare module "babylonjs/Misc/deferred" {
  77780. /**
  77781. * Wrapper class for promise with external resolve and reject.
  77782. */
  77783. export class Deferred<T> {
  77784. /**
  77785. * The promise associated with this deferred object.
  77786. */
  77787. readonly promise: Promise<T>;
  77788. private _resolve;
  77789. private _reject;
  77790. /**
  77791. * The resolve method of the promise associated with this deferred object.
  77792. */
  77793. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77794. /**
  77795. * The reject method of the promise associated with this deferred object.
  77796. */
  77797. get reject(): (reason?: any) => void;
  77798. /**
  77799. * Constructor for this deferred object.
  77800. */
  77801. constructor();
  77802. }
  77803. }
  77804. declare module "babylonjs/Misc/meshExploder" {
  77805. import { Mesh } from "babylonjs/Meshes/mesh";
  77806. /**
  77807. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77808. */
  77809. export class MeshExploder {
  77810. private _centerMesh;
  77811. private _meshes;
  77812. private _meshesOrigins;
  77813. private _toCenterVectors;
  77814. private _scaledDirection;
  77815. private _newPosition;
  77816. private _centerPosition;
  77817. /**
  77818. * Explodes meshes from a center mesh.
  77819. * @param meshes The meshes to explode.
  77820. * @param centerMesh The mesh to be center of explosion.
  77821. */
  77822. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77823. private _setCenterMesh;
  77824. /**
  77825. * Get class name
  77826. * @returns "MeshExploder"
  77827. */
  77828. getClassName(): string;
  77829. /**
  77830. * "Exploded meshes"
  77831. * @returns Array of meshes with the centerMesh at index 0.
  77832. */
  77833. getMeshes(): Array<Mesh>;
  77834. /**
  77835. * Explodes meshes giving a specific direction
  77836. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77837. */
  77838. explode(direction?: number): void;
  77839. }
  77840. }
  77841. declare module "babylonjs/Misc/filesInput" {
  77842. import { Engine } from "babylonjs/Engines/engine";
  77843. import { Scene } from "babylonjs/scene";
  77844. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77845. import { Nullable } from "babylonjs/types";
  77846. /**
  77847. * Class used to help managing file picking and drag'n'drop
  77848. */
  77849. export class FilesInput {
  77850. /**
  77851. * List of files ready to be loaded
  77852. */
  77853. static get FilesToLoad(): {
  77854. [key: string]: File;
  77855. };
  77856. /**
  77857. * Callback called when a file is processed
  77858. */
  77859. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77860. private _engine;
  77861. private _currentScene;
  77862. private _sceneLoadedCallback;
  77863. private _progressCallback;
  77864. private _additionalRenderLoopLogicCallback;
  77865. private _textureLoadingCallback;
  77866. private _startingProcessingFilesCallback;
  77867. private _onReloadCallback;
  77868. private _errorCallback;
  77869. private _elementToMonitor;
  77870. private _sceneFileToLoad;
  77871. private _filesToLoad;
  77872. /**
  77873. * Creates a new FilesInput
  77874. * @param engine defines the rendering engine
  77875. * @param scene defines the hosting scene
  77876. * @param sceneLoadedCallback callback called when scene is loaded
  77877. * @param progressCallback callback called to track progress
  77878. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77879. * @param textureLoadingCallback callback called when a texture is loading
  77880. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77881. * @param onReloadCallback callback called when a reload is requested
  77882. * @param errorCallback callback call if an error occurs
  77883. */
  77884. 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>);
  77885. private _dragEnterHandler;
  77886. private _dragOverHandler;
  77887. private _dropHandler;
  77888. /**
  77889. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77890. * @param elementToMonitor defines the DOM element to track
  77891. */
  77892. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77893. /** Gets the current list of files to load */
  77894. get filesToLoad(): File[];
  77895. /**
  77896. * Release all associated resources
  77897. */
  77898. dispose(): void;
  77899. private renderFunction;
  77900. private drag;
  77901. private drop;
  77902. private _traverseFolder;
  77903. private _processFiles;
  77904. /**
  77905. * Load files from a drop event
  77906. * @param event defines the drop event to use as source
  77907. */
  77908. loadFiles(event: any): void;
  77909. private _processReload;
  77910. /**
  77911. * Reload the current scene from the loaded files
  77912. */
  77913. reload(): void;
  77914. }
  77915. }
  77916. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77917. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77918. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77919. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77920. }
  77921. declare module "babylonjs/Misc/sceneOptimizer" {
  77922. import { Scene, IDisposable } from "babylonjs/scene";
  77923. import { Observable } from "babylonjs/Misc/observable";
  77924. /**
  77925. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77926. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77927. */
  77928. export class SceneOptimization {
  77929. /**
  77930. * Defines the priority of this optimization (0 by default which means first in the list)
  77931. */
  77932. priority: number;
  77933. /**
  77934. * Gets a string describing the action executed by the current optimization
  77935. * @returns description string
  77936. */
  77937. getDescription(): string;
  77938. /**
  77939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77940. * @param scene defines the current scene where to apply this optimization
  77941. * @param optimizer defines the current optimizer
  77942. * @returns true if everything that can be done was applied
  77943. */
  77944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77945. /**
  77946. * Creates the SceneOptimization object
  77947. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77948. * @param desc defines the description associated with the optimization
  77949. */
  77950. constructor(
  77951. /**
  77952. * Defines the priority of this optimization (0 by default which means first in the list)
  77953. */
  77954. priority?: number);
  77955. }
  77956. /**
  77957. * Defines an optimization used to reduce the size of render target textures
  77958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77959. */
  77960. export class TextureOptimization extends SceneOptimization {
  77961. /**
  77962. * Defines the priority of this optimization (0 by default which means first in the list)
  77963. */
  77964. priority: number;
  77965. /**
  77966. * 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
  77967. */
  77968. maximumSize: number;
  77969. /**
  77970. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77971. */
  77972. step: number;
  77973. /**
  77974. * Gets a string describing the action executed by the current optimization
  77975. * @returns description string
  77976. */
  77977. getDescription(): string;
  77978. /**
  77979. * Creates the TextureOptimization object
  77980. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77981. * @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
  77982. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77983. */
  77984. constructor(
  77985. /**
  77986. * Defines the priority of this optimization (0 by default which means first in the list)
  77987. */
  77988. priority?: number,
  77989. /**
  77990. * 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
  77991. */
  77992. maximumSize?: number,
  77993. /**
  77994. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77995. */
  77996. step?: number);
  77997. /**
  77998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77999. * @param scene defines the current scene where to apply this optimization
  78000. * @param optimizer defines the current optimizer
  78001. * @returns true if everything that can be done was applied
  78002. */
  78003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78004. }
  78005. /**
  78006. * Defines an optimization used to increase or decrease the rendering resolution
  78007. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78008. */
  78009. export class HardwareScalingOptimization extends SceneOptimization {
  78010. /**
  78011. * Defines the priority of this optimization (0 by default which means first in the list)
  78012. */
  78013. priority: number;
  78014. /**
  78015. * Defines the maximum scale to use (2 by default)
  78016. */
  78017. maximumScale: number;
  78018. /**
  78019. * Defines the step to use between two passes (0.5 by default)
  78020. */
  78021. step: number;
  78022. private _currentScale;
  78023. private _directionOffset;
  78024. /**
  78025. * Gets a string describing the action executed by the current optimization
  78026. * @return description string
  78027. */
  78028. getDescription(): string;
  78029. /**
  78030. * Creates the HardwareScalingOptimization object
  78031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78032. * @param maximumScale defines the maximum scale to use (2 by default)
  78033. * @param step defines the step to use between two passes (0.5 by default)
  78034. */
  78035. constructor(
  78036. /**
  78037. * Defines the priority of this optimization (0 by default which means first in the list)
  78038. */
  78039. priority?: number,
  78040. /**
  78041. * Defines the maximum scale to use (2 by default)
  78042. */
  78043. maximumScale?: number,
  78044. /**
  78045. * Defines the step to use between two passes (0.5 by default)
  78046. */
  78047. step?: number);
  78048. /**
  78049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78050. * @param scene defines the current scene where to apply this optimization
  78051. * @param optimizer defines the current optimizer
  78052. * @returns true if everything that can be done was applied
  78053. */
  78054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78055. }
  78056. /**
  78057. * Defines an optimization used to remove shadows
  78058. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78059. */
  78060. export class ShadowsOptimization extends SceneOptimization {
  78061. /**
  78062. * Gets a string describing the action executed by the current optimization
  78063. * @return description string
  78064. */
  78065. getDescription(): string;
  78066. /**
  78067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78068. * @param scene defines the current scene where to apply this optimization
  78069. * @param optimizer defines the current optimizer
  78070. * @returns true if everything that can be done was applied
  78071. */
  78072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78073. }
  78074. /**
  78075. * Defines an optimization used to turn post-processes off
  78076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78077. */
  78078. export class PostProcessesOptimization extends SceneOptimization {
  78079. /**
  78080. * Gets a string describing the action executed by the current optimization
  78081. * @return description string
  78082. */
  78083. getDescription(): string;
  78084. /**
  78085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78086. * @param scene defines the current scene where to apply this optimization
  78087. * @param optimizer defines the current optimizer
  78088. * @returns true if everything that can be done was applied
  78089. */
  78090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78091. }
  78092. /**
  78093. * Defines an optimization used to turn lens flares off
  78094. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78095. */
  78096. export class LensFlaresOptimization extends SceneOptimization {
  78097. /**
  78098. * Gets a string describing the action executed by the current optimization
  78099. * @return description string
  78100. */
  78101. getDescription(): string;
  78102. /**
  78103. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78104. * @param scene defines the current scene where to apply this optimization
  78105. * @param optimizer defines the current optimizer
  78106. * @returns true if everything that can be done was applied
  78107. */
  78108. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78109. }
  78110. /**
  78111. * Defines an optimization based on user defined callback.
  78112. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78113. */
  78114. export class CustomOptimization extends SceneOptimization {
  78115. /**
  78116. * Callback called to apply the custom optimization.
  78117. */
  78118. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78119. /**
  78120. * Callback called to get custom description
  78121. */
  78122. onGetDescription: () => string;
  78123. /**
  78124. * Gets a string describing the action executed by the current optimization
  78125. * @returns description string
  78126. */
  78127. getDescription(): string;
  78128. /**
  78129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78130. * @param scene defines the current scene where to apply this optimization
  78131. * @param optimizer defines the current optimizer
  78132. * @returns true if everything that can be done was applied
  78133. */
  78134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78135. }
  78136. /**
  78137. * Defines an optimization used to turn particles off
  78138. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78139. */
  78140. export class ParticlesOptimization extends SceneOptimization {
  78141. /**
  78142. * Gets a string describing the action executed by the current optimization
  78143. * @return description string
  78144. */
  78145. getDescription(): string;
  78146. /**
  78147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78148. * @param scene defines the current scene where to apply this optimization
  78149. * @param optimizer defines the current optimizer
  78150. * @returns true if everything that can be done was applied
  78151. */
  78152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78153. }
  78154. /**
  78155. * Defines an optimization used to turn render targets off
  78156. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78157. */
  78158. export class RenderTargetsOptimization extends SceneOptimization {
  78159. /**
  78160. * Gets a string describing the action executed by the current optimization
  78161. * @return description string
  78162. */
  78163. getDescription(): string;
  78164. /**
  78165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78166. * @param scene defines the current scene where to apply this optimization
  78167. * @param optimizer defines the current optimizer
  78168. * @returns true if everything that can be done was applied
  78169. */
  78170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78171. }
  78172. /**
  78173. * Defines an optimization used to merge meshes with compatible materials
  78174. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78175. */
  78176. export class MergeMeshesOptimization extends SceneOptimization {
  78177. private static _UpdateSelectionTree;
  78178. /**
  78179. * Gets or sets a boolean which defines if optimization octree has to be updated
  78180. */
  78181. static get UpdateSelectionTree(): boolean;
  78182. /**
  78183. * Gets or sets a boolean which defines if optimization octree has to be updated
  78184. */
  78185. static set UpdateSelectionTree(value: boolean);
  78186. /**
  78187. * Gets a string describing the action executed by the current optimization
  78188. * @return description string
  78189. */
  78190. getDescription(): string;
  78191. private _canBeMerged;
  78192. /**
  78193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78194. * @param scene defines the current scene where to apply this optimization
  78195. * @param optimizer defines the current optimizer
  78196. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78197. * @returns true if everything that can be done was applied
  78198. */
  78199. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78200. }
  78201. /**
  78202. * Defines a list of options used by SceneOptimizer
  78203. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78204. */
  78205. export class SceneOptimizerOptions {
  78206. /**
  78207. * Defines the target frame rate to reach (60 by default)
  78208. */
  78209. targetFrameRate: number;
  78210. /**
  78211. * Defines the interval between two checkes (2000ms by default)
  78212. */
  78213. trackerDuration: number;
  78214. /**
  78215. * Gets the list of optimizations to apply
  78216. */
  78217. optimizations: SceneOptimization[];
  78218. /**
  78219. * Creates a new list of options used by SceneOptimizer
  78220. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78221. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78222. */
  78223. constructor(
  78224. /**
  78225. * Defines the target frame rate to reach (60 by default)
  78226. */
  78227. targetFrameRate?: number,
  78228. /**
  78229. * Defines the interval between two checkes (2000ms by default)
  78230. */
  78231. trackerDuration?: number);
  78232. /**
  78233. * Add a new optimization
  78234. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78235. * @returns the current SceneOptimizerOptions
  78236. */
  78237. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78238. /**
  78239. * Add a new custom optimization
  78240. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78241. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78242. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78243. * @returns the current SceneOptimizerOptions
  78244. */
  78245. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78246. /**
  78247. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78248. * @param targetFrameRate defines the target frame rate (60 by default)
  78249. * @returns a SceneOptimizerOptions object
  78250. */
  78251. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78252. /**
  78253. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78254. * @param targetFrameRate defines the target frame rate (60 by default)
  78255. * @returns a SceneOptimizerOptions object
  78256. */
  78257. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78258. /**
  78259. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78260. * @param targetFrameRate defines the target frame rate (60 by default)
  78261. * @returns a SceneOptimizerOptions object
  78262. */
  78263. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78264. }
  78265. /**
  78266. * Class used to run optimizations in order to reach a target frame rate
  78267. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78268. */
  78269. export class SceneOptimizer implements IDisposable {
  78270. private _isRunning;
  78271. private _options;
  78272. private _scene;
  78273. private _currentPriorityLevel;
  78274. private _targetFrameRate;
  78275. private _trackerDuration;
  78276. private _currentFrameRate;
  78277. private _sceneDisposeObserver;
  78278. private _improvementMode;
  78279. /**
  78280. * Defines an observable called when the optimizer reaches the target frame rate
  78281. */
  78282. onSuccessObservable: Observable<SceneOptimizer>;
  78283. /**
  78284. * Defines an observable called when the optimizer enables an optimization
  78285. */
  78286. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78287. /**
  78288. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78289. */
  78290. onFailureObservable: Observable<SceneOptimizer>;
  78291. /**
  78292. * Gets a boolean indicating if the optimizer is in improvement mode
  78293. */
  78294. get isInImprovementMode(): boolean;
  78295. /**
  78296. * Gets the current priority level (0 at start)
  78297. */
  78298. get currentPriorityLevel(): number;
  78299. /**
  78300. * Gets the current frame rate checked by the SceneOptimizer
  78301. */
  78302. get currentFrameRate(): number;
  78303. /**
  78304. * Gets or sets the current target frame rate (60 by default)
  78305. */
  78306. get targetFrameRate(): number;
  78307. /**
  78308. * Gets or sets the current target frame rate (60 by default)
  78309. */
  78310. set targetFrameRate(value: number);
  78311. /**
  78312. * Gets or sets the current interval between two checks (every 2000ms by default)
  78313. */
  78314. get trackerDuration(): number;
  78315. /**
  78316. * Gets or sets the current interval between two checks (every 2000ms by default)
  78317. */
  78318. set trackerDuration(value: number);
  78319. /**
  78320. * Gets the list of active optimizations
  78321. */
  78322. get optimizations(): SceneOptimization[];
  78323. /**
  78324. * Creates a new SceneOptimizer
  78325. * @param scene defines the scene to work on
  78326. * @param options defines the options to use with the SceneOptimizer
  78327. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78328. * @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)
  78329. */
  78330. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78331. /**
  78332. * Stops the current optimizer
  78333. */
  78334. stop(): void;
  78335. /**
  78336. * Reset the optimizer to initial step (current priority level = 0)
  78337. */
  78338. reset(): void;
  78339. /**
  78340. * Start the optimizer. By default it will try to reach a specific framerate
  78341. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78342. */
  78343. start(): void;
  78344. private _checkCurrentState;
  78345. /**
  78346. * Release all resources
  78347. */
  78348. dispose(): void;
  78349. /**
  78350. * Helper function to create a SceneOptimizer with one single line of code
  78351. * @param scene defines the scene to work on
  78352. * @param options defines the options to use with the SceneOptimizer
  78353. * @param onSuccess defines a callback to call on success
  78354. * @param onFailure defines a callback to call on failure
  78355. * @returns the new SceneOptimizer object
  78356. */
  78357. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78358. }
  78359. }
  78360. declare module "babylonjs/Misc/sceneSerializer" {
  78361. import { Scene } from "babylonjs/scene";
  78362. /**
  78363. * Class used to serialize a scene into a string
  78364. */
  78365. export class SceneSerializer {
  78366. /**
  78367. * Clear cache used by a previous serialization
  78368. */
  78369. static ClearCache(): void;
  78370. /**
  78371. * Serialize a scene into a JSON compatible object
  78372. * @param scene defines the scene to serialize
  78373. * @returns a JSON compatible object
  78374. */
  78375. static Serialize(scene: Scene): any;
  78376. /**
  78377. * Serialize a mesh into a JSON compatible object
  78378. * @param toSerialize defines the mesh to serialize
  78379. * @param withParents defines if parents must be serialized as well
  78380. * @param withChildren defines if children must be serialized as well
  78381. * @returns a JSON compatible object
  78382. */
  78383. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78384. }
  78385. }
  78386. declare module "babylonjs/Misc/textureTools" {
  78387. import { Texture } from "babylonjs/Materials/Textures/texture";
  78388. /**
  78389. * Class used to host texture specific utilities
  78390. */
  78391. export class TextureTools {
  78392. /**
  78393. * Uses the GPU to create a copy texture rescaled at a given size
  78394. * @param texture Texture to copy from
  78395. * @param width defines the desired width
  78396. * @param height defines the desired height
  78397. * @param useBilinearMode defines if bilinear mode has to be used
  78398. * @return the generated texture
  78399. */
  78400. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78401. }
  78402. }
  78403. declare module "babylonjs/Misc/videoRecorder" {
  78404. import { Nullable } from "babylonjs/types";
  78405. import { Engine } from "babylonjs/Engines/engine";
  78406. /**
  78407. * This represents the different options available for the video capture.
  78408. */
  78409. export interface VideoRecorderOptions {
  78410. /** Defines the mime type of the video. */
  78411. mimeType: string;
  78412. /** Defines the FPS the video should be recorded at. */
  78413. fps: number;
  78414. /** Defines the chunk size for the recording data. */
  78415. recordChunckSize: number;
  78416. /** The audio tracks to attach to the recording. */
  78417. audioTracks?: MediaStreamTrack[];
  78418. }
  78419. /**
  78420. * This can help with recording videos from BabylonJS.
  78421. * This is based on the available WebRTC functionalities of the browser.
  78422. *
  78423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78424. */
  78425. export class VideoRecorder {
  78426. private static readonly _defaultOptions;
  78427. /**
  78428. * Returns whether or not the VideoRecorder is available in your browser.
  78429. * @param engine Defines the Babylon Engine.
  78430. * @returns true if supported otherwise false.
  78431. */
  78432. static IsSupported(engine: Engine): boolean;
  78433. private readonly _options;
  78434. private _canvas;
  78435. private _mediaRecorder;
  78436. private _recordedChunks;
  78437. private _fileName;
  78438. private _resolve;
  78439. private _reject;
  78440. /**
  78441. * True when a recording is already in progress.
  78442. */
  78443. get isRecording(): boolean;
  78444. /**
  78445. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78446. * @param engine Defines the BabylonJS Engine you wish to record.
  78447. * @param options Defines options that can be used to customize the capture.
  78448. */
  78449. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78450. /**
  78451. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78452. */
  78453. stopRecording(): void;
  78454. /**
  78455. * Starts recording the canvas for a max duration specified in parameters.
  78456. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78457. * If null no automatic download will start and you can rely on the promise to get the data back.
  78458. * @param maxDuration Defines the maximum recording time in seconds.
  78459. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78460. * @return A promise callback at the end of the recording with the video data in Blob.
  78461. */
  78462. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78463. /**
  78464. * Releases internal resources used during the recording.
  78465. */
  78466. dispose(): void;
  78467. private _handleDataAvailable;
  78468. private _handleError;
  78469. private _handleStop;
  78470. }
  78471. }
  78472. declare module "babylonjs/Misc/screenshotTools" {
  78473. import { Camera } from "babylonjs/Cameras/camera";
  78474. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78475. import { Engine } from "babylonjs/Engines/engine";
  78476. /**
  78477. * Class containing a set of static utilities functions for screenshots
  78478. */
  78479. export class ScreenshotTools {
  78480. /**
  78481. * Captures a screenshot of the current rendering
  78482. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78483. * @param engine defines the rendering engine
  78484. * @param camera defines the source camera
  78485. * @param size This parameter can be set to a single number or to an object with the
  78486. * following (optional) properties: precision, width, height. If a single number is passed,
  78487. * it will be used for both width and height. If an object is passed, the screenshot size
  78488. * will be derived from the parameters. The precision property is a multiplier allowing
  78489. * rendering at a higher or lower resolution
  78490. * @param successCallback defines the callback receives a single parameter which contains the
  78491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78492. * src parameter of an <img> to display it
  78493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78494. * Check your browser for supported MIME types
  78495. */
  78496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78497. /**
  78498. * Captures a screenshot of the current rendering
  78499. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78500. * @param engine defines the rendering engine
  78501. * @param camera defines the source camera
  78502. * @param size This parameter can be set to a single number or to an object with the
  78503. * following (optional) properties: precision, width, height. If a single number is passed,
  78504. * it will be used for both width and height. If an object is passed, the screenshot size
  78505. * will be derived from the parameters. The precision property is a multiplier allowing
  78506. * rendering at a higher or lower resolution
  78507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78508. * Check your browser for supported MIME types
  78509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78510. * to the src parameter of an <img> to display it
  78511. */
  78512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78513. /**
  78514. * Generates an image screenshot from the specified camera.
  78515. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78516. * @param engine The engine to use for rendering
  78517. * @param camera The camera to use for rendering
  78518. * @param size This parameter can be set to a single number or to an object with the
  78519. * following (optional) properties: precision, width, height. If a single number is passed,
  78520. * it will be used for both width and height. If an object is passed, the screenshot size
  78521. * will be derived from the parameters. The precision property is a multiplier allowing
  78522. * rendering at a higher or lower resolution
  78523. * @param successCallback The callback receives a single parameter which contains the
  78524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78525. * src parameter of an <img> to display it
  78526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78527. * Check your browser for supported MIME types
  78528. * @param samples Texture samples (default: 1)
  78529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78530. * @param fileName A name for for the downloaded file.
  78531. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78532. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78533. */
  78534. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78535. /**
  78536. * Generates an image screenshot from the specified camera.
  78537. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78538. * @param engine The engine to use for rendering
  78539. * @param camera The camera to use for rendering
  78540. * @param size This parameter can be set to a single number or to an object with the
  78541. * following (optional) properties: precision, width, height. If a single number is passed,
  78542. * it will be used for both width and height. If an object is passed, the screenshot size
  78543. * will be derived from the parameters. The precision property is a multiplier allowing
  78544. * rendering at a higher or lower resolution
  78545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78546. * Check your browser for supported MIME types
  78547. * @param samples Texture samples (default: 1)
  78548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78549. * @param fileName A name for for the downloaded file.
  78550. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78551. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78552. * to the src parameter of an <img> to display it
  78553. */
  78554. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78555. /**
  78556. * Gets height and width for screenshot size
  78557. * @private
  78558. */
  78559. private static _getScreenshotSize;
  78560. }
  78561. }
  78562. declare module "babylonjs/Misc/dataReader" {
  78563. /**
  78564. * Interface for a data buffer
  78565. */
  78566. export interface IDataBuffer {
  78567. /**
  78568. * Reads bytes from the data buffer.
  78569. * @param byteOffset The byte offset to read
  78570. * @param byteLength The byte length to read
  78571. * @returns A promise that resolves when the bytes are read
  78572. */
  78573. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78574. /**
  78575. * The byte length of the buffer.
  78576. */
  78577. readonly byteLength: number;
  78578. }
  78579. /**
  78580. * Utility class for reading from a data buffer
  78581. */
  78582. export class DataReader {
  78583. /**
  78584. * The data buffer associated with this data reader.
  78585. */
  78586. readonly buffer: IDataBuffer;
  78587. /**
  78588. * The current byte offset from the beginning of the data buffer.
  78589. */
  78590. byteOffset: number;
  78591. private _dataView;
  78592. private _dataByteOffset;
  78593. /**
  78594. * Constructor
  78595. * @param buffer The buffer to read
  78596. */
  78597. constructor(buffer: IDataBuffer);
  78598. /**
  78599. * Loads the given byte length.
  78600. * @param byteLength The byte length to load
  78601. * @returns A promise that resolves when the load is complete
  78602. */
  78603. loadAsync(byteLength: number): Promise<void>;
  78604. /**
  78605. * Read a unsigned 32-bit integer from the currently loaded data range.
  78606. * @returns The 32-bit integer read
  78607. */
  78608. readUint32(): number;
  78609. /**
  78610. * Read a byte array from the currently loaded data range.
  78611. * @param byteLength The byte length to read
  78612. * @returns The byte array read
  78613. */
  78614. readUint8Array(byteLength: number): Uint8Array;
  78615. /**
  78616. * Read a string from the currently loaded data range.
  78617. * @param byteLength The byte length to read
  78618. * @returns The string read
  78619. */
  78620. readString(byteLength: number): string;
  78621. /**
  78622. * Skips the given byte length the currently loaded data range.
  78623. * @param byteLength The byte length to skip
  78624. */
  78625. skipBytes(byteLength: number): void;
  78626. }
  78627. }
  78628. declare module "babylonjs/Misc/dataStorage" {
  78629. /**
  78630. * Class for storing data to local storage if available or in-memory storage otherwise
  78631. */
  78632. export class DataStorage {
  78633. private static _Storage;
  78634. private static _GetStorage;
  78635. /**
  78636. * Reads a string from the data storage
  78637. * @param key The key to read
  78638. * @param defaultValue The value if the key doesn't exist
  78639. * @returns The string value
  78640. */
  78641. static ReadString(key: string, defaultValue: string): string;
  78642. /**
  78643. * Writes a string to the data storage
  78644. * @param key The key to write
  78645. * @param value The value to write
  78646. */
  78647. static WriteString(key: string, value: string): void;
  78648. /**
  78649. * Reads a boolean from the data storage
  78650. * @param key The key to read
  78651. * @param defaultValue The value if the key doesn't exist
  78652. * @returns The boolean value
  78653. */
  78654. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78655. /**
  78656. * Writes a boolean to the data storage
  78657. * @param key The key to write
  78658. * @param value The value to write
  78659. */
  78660. static WriteBoolean(key: string, value: boolean): void;
  78661. /**
  78662. * Reads a number from the data storage
  78663. * @param key The key to read
  78664. * @param defaultValue The value if the key doesn't exist
  78665. * @returns The number value
  78666. */
  78667. static ReadNumber(key: string, defaultValue: number): number;
  78668. /**
  78669. * Writes a number to the data storage
  78670. * @param key The key to write
  78671. * @param value The value to write
  78672. */
  78673. static WriteNumber(key: string, value: number): void;
  78674. }
  78675. }
  78676. declare module "babylonjs/Misc/sceneRecorder" {
  78677. import { Scene } from "babylonjs/scene";
  78678. /**
  78679. * Class used to record delta files between 2 scene states
  78680. */
  78681. export class SceneRecorder {
  78682. private _trackedScene;
  78683. private _savedJSON;
  78684. /**
  78685. * Track a given scene. This means the current scene state will be considered the original state
  78686. * @param scene defines the scene to track
  78687. */
  78688. track(scene: Scene): void;
  78689. /**
  78690. * Get the delta between current state and original state
  78691. * @returns a string containing the delta
  78692. */
  78693. getDelta(): any;
  78694. private _compareArray;
  78695. private _compareObjects;
  78696. private _compareCollections;
  78697. private static GetShadowGeneratorById;
  78698. /**
  78699. * Apply a given delta to a given scene
  78700. * @param deltaJSON defines the JSON containing the delta
  78701. * @param scene defines the scene to apply the delta to
  78702. */
  78703. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78704. private static _ApplyPropertiesToEntity;
  78705. private static _ApplyDeltaForEntity;
  78706. }
  78707. }
  78708. declare module "babylonjs/Misc/trajectoryClassifier" {
  78709. import { DeepImmutable, Nullable } from "babylonjs/types";
  78710. import { Vector3 } from "babylonjs/Maths/math.vector";
  78711. /**
  78712. * A 3D trajectory consisting of an order list of vectors describing a
  78713. * path of motion through 3D space.
  78714. */
  78715. export class Trajectory {
  78716. private _points;
  78717. private readonly _segmentLength;
  78718. /**
  78719. * Serialize to JSON.
  78720. * @returns serialized JSON string
  78721. */
  78722. serialize(): string;
  78723. /**
  78724. * Deserialize from JSON.
  78725. * @param json serialized JSON string
  78726. * @returns deserialized Trajectory
  78727. */
  78728. static Deserialize(json: string): Trajectory;
  78729. /**
  78730. * Create a new empty Trajectory.
  78731. * @param segmentLength radius of discretization for Trajectory points
  78732. */
  78733. constructor(segmentLength?: number);
  78734. /**
  78735. * Get the length of the Trajectory.
  78736. * @returns length of the Trajectory
  78737. */
  78738. getLength(): number;
  78739. /**
  78740. * Append a new point to the Trajectory.
  78741. * NOTE: This implementation has many allocations.
  78742. * @param point point to append to the Trajectory
  78743. */
  78744. add(point: DeepImmutable<Vector3>): void;
  78745. /**
  78746. * Create a new Trajectory with a segment length chosen to make it
  78747. * probable that the new Trajectory will have a specified number of
  78748. * segments. This operation is imprecise.
  78749. * @param targetResolution number of segments desired
  78750. * @returns new Trajectory with approximately the requested number of segments
  78751. */
  78752. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78753. /**
  78754. * Convert Trajectory segments into tokenized representation. This
  78755. * representation is an array of numbers where each nth number is the
  78756. * index of the token which is most similar to the nth segment of the
  78757. * Trajectory.
  78758. * @param tokens list of vectors which serve as discrete tokens
  78759. * @returns list of indices of most similar token per segment
  78760. */
  78761. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78762. private static _forwardDir;
  78763. private static _inverseFromVec;
  78764. private static _upDir;
  78765. private static _fromToVec;
  78766. private static _lookMatrix;
  78767. /**
  78768. * Transform the rotation (i.e., direction) of a segment to isolate
  78769. * the relative transformation represented by the segment. This operation
  78770. * may or may not succeed due to singularities in the equations that define
  78771. * motion relativity in this context.
  78772. * @param priorVec the origin of the prior segment
  78773. * @param fromVec the origin of the current segment
  78774. * @param toVec the destination of the current segment
  78775. * @param result reference to output variable
  78776. * @returns whether or not transformation was successful
  78777. */
  78778. private static _transformSegmentDirToRef;
  78779. private static _bestMatch;
  78780. private static _score;
  78781. private static _bestScore;
  78782. /**
  78783. * Determine which token vector is most similar to the
  78784. * segment vector.
  78785. * @param segment segment vector
  78786. * @param tokens token vector list
  78787. * @returns index of the most similar token to the segment
  78788. */
  78789. private static _tokenizeSegment;
  78790. }
  78791. /**
  78792. * Class representing a set of known, named trajectories to which Trajectories can be
  78793. * added and using which Trajectories can be recognized.
  78794. */
  78795. export class TrajectoryClassifier {
  78796. private _maximumAllowableMatchCost;
  78797. private _vector3Alphabet;
  78798. private _levenshteinAlphabet;
  78799. private _nameToDescribedTrajectory;
  78800. /**
  78801. * Serialize to JSON.
  78802. * @returns JSON serialization
  78803. */
  78804. serialize(): string;
  78805. /**
  78806. * Deserialize from JSON.
  78807. * @param json JSON serialization
  78808. * @returns deserialized TrajectorySet
  78809. */
  78810. static Deserialize(json: string): TrajectoryClassifier;
  78811. /**
  78812. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78813. * VERY naive, need to be generating these things from known
  78814. * sets. Better version later, probably eliminating this one.
  78815. * @returns auto-generated TrajectorySet
  78816. */
  78817. static Generate(): TrajectoryClassifier;
  78818. private constructor();
  78819. /**
  78820. * Add a new Trajectory to the set with a given name.
  78821. * @param trajectory new Trajectory to be added
  78822. * @param classification name to which to add the Trajectory
  78823. */
  78824. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78825. /**
  78826. * Remove a known named trajectory and all Trajectories associated with it.
  78827. * @param classification name to remove
  78828. * @returns whether anything was removed
  78829. */
  78830. deleteClassification(classification: string): boolean;
  78831. /**
  78832. * Attempt to recognize a Trajectory from among all the classifications
  78833. * already known to the classifier.
  78834. * @param trajectory Trajectory to be recognized
  78835. * @returns classification of Trajectory if recognized, null otherwise
  78836. */
  78837. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78838. }
  78839. }
  78840. declare module "babylonjs/Misc/index" {
  78841. export * from "babylonjs/Misc/andOrNotEvaluator";
  78842. export * from "babylonjs/Misc/assetsManager";
  78843. export * from "babylonjs/Misc/basis";
  78844. export * from "babylonjs/Misc/dds";
  78845. export * from "babylonjs/Misc/decorators";
  78846. export * from "babylonjs/Misc/deferred";
  78847. export * from "babylonjs/Misc/environmentTextureTools";
  78848. export * from "babylonjs/Misc/meshExploder";
  78849. export * from "babylonjs/Misc/filesInput";
  78850. export * from "babylonjs/Misc/HighDynamicRange/index";
  78851. export * from "babylonjs/Misc/khronosTextureContainer";
  78852. export * from "babylonjs/Misc/observable";
  78853. export * from "babylonjs/Misc/performanceMonitor";
  78854. export * from "babylonjs/Misc/promise";
  78855. export * from "babylonjs/Misc/sceneOptimizer";
  78856. export * from "babylonjs/Misc/sceneSerializer";
  78857. export * from "babylonjs/Misc/smartArray";
  78858. export * from "babylonjs/Misc/stringDictionary";
  78859. export * from "babylonjs/Misc/tags";
  78860. export * from "babylonjs/Misc/textureTools";
  78861. export * from "babylonjs/Misc/tga";
  78862. export * from "babylonjs/Misc/tools";
  78863. export * from "babylonjs/Misc/videoRecorder";
  78864. export * from "babylonjs/Misc/virtualJoystick";
  78865. export * from "babylonjs/Misc/workerPool";
  78866. export * from "babylonjs/Misc/logger";
  78867. export * from "babylonjs/Misc/typeStore";
  78868. export * from "babylonjs/Misc/filesInputStore";
  78869. export * from "babylonjs/Misc/deepCopier";
  78870. export * from "babylonjs/Misc/pivotTools";
  78871. export * from "babylonjs/Misc/precisionDate";
  78872. export * from "babylonjs/Misc/screenshotTools";
  78873. export * from "babylonjs/Misc/typeStore";
  78874. export * from "babylonjs/Misc/webRequest";
  78875. export * from "babylonjs/Misc/iInspectable";
  78876. export * from "babylonjs/Misc/brdfTextureTools";
  78877. export * from "babylonjs/Misc/rgbdTextureTools";
  78878. export * from "babylonjs/Misc/gradients";
  78879. export * from "babylonjs/Misc/perfCounter";
  78880. export * from "babylonjs/Misc/fileRequest";
  78881. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78882. export * from "babylonjs/Misc/retryStrategy";
  78883. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78884. export * from "babylonjs/Misc/canvasGenerator";
  78885. export * from "babylonjs/Misc/fileTools";
  78886. export * from "babylonjs/Misc/stringTools";
  78887. export * from "babylonjs/Misc/dataReader";
  78888. export * from "babylonjs/Misc/minMaxReducer";
  78889. export * from "babylonjs/Misc/depthReducer";
  78890. export * from "babylonjs/Misc/dataStorage";
  78891. export * from "babylonjs/Misc/sceneRecorder";
  78892. export * from "babylonjs/Misc/khronosTextureContainer2";
  78893. export * from "babylonjs/Misc/trajectoryClassifier";
  78894. }
  78895. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78896. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78897. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78898. import { Observable } from "babylonjs/Misc/observable";
  78899. import { Matrix } from "babylonjs/Maths/math.vector";
  78900. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78901. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78902. /**
  78903. * An interface for all Hit test features
  78904. */
  78905. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78906. /**
  78907. * Triggered when new babylon (transformed) hit test results are available
  78908. */
  78909. onHitTestResultObservable: Observable<T[]>;
  78910. }
  78911. /**
  78912. * Options used for hit testing
  78913. */
  78914. export interface IWebXRLegacyHitTestOptions {
  78915. /**
  78916. * Only test when user interacted with the scene. Default - hit test every frame
  78917. */
  78918. testOnPointerDownOnly?: boolean;
  78919. /**
  78920. * The node to use to transform the local results to world coordinates
  78921. */
  78922. worldParentNode?: TransformNode;
  78923. }
  78924. /**
  78925. * Interface defining the babylon result of raycasting/hit-test
  78926. */
  78927. export interface IWebXRLegacyHitResult {
  78928. /**
  78929. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78930. */
  78931. transformationMatrix: Matrix;
  78932. /**
  78933. * The native hit test result
  78934. */
  78935. xrHitResult: XRHitResult | XRHitTestResult;
  78936. }
  78937. /**
  78938. * The currently-working hit-test module.
  78939. * Hit test (or Ray-casting) is used to interact with the real world.
  78940. * For further information read here - https://github.com/immersive-web/hit-test
  78941. */
  78942. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78943. /**
  78944. * options to use when constructing this feature
  78945. */
  78946. readonly options: IWebXRLegacyHitTestOptions;
  78947. private _direction;
  78948. private _mat;
  78949. private _onSelectEnabled;
  78950. private _origin;
  78951. /**
  78952. * The module's name
  78953. */
  78954. static readonly Name: string;
  78955. /**
  78956. * The (Babylon) version of this module.
  78957. * This is an integer representing the implementation version.
  78958. * This number does not correspond to the WebXR specs version
  78959. */
  78960. static readonly Version: number;
  78961. /**
  78962. * Populated with the last native XR Hit Results
  78963. */
  78964. lastNativeXRHitResults: XRHitResult[];
  78965. /**
  78966. * Triggered when new babylon (transformed) hit test results are available
  78967. */
  78968. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78969. /**
  78970. * Creates a new instance of the (legacy version) hit test feature
  78971. * @param _xrSessionManager an instance of WebXRSessionManager
  78972. * @param options options to use when constructing this feature
  78973. */
  78974. constructor(_xrSessionManager: WebXRSessionManager,
  78975. /**
  78976. * options to use when constructing this feature
  78977. */
  78978. options?: IWebXRLegacyHitTestOptions);
  78979. /**
  78980. * execute a hit test with an XR Ray
  78981. *
  78982. * @param xrSession a native xrSession that will execute this hit test
  78983. * @param xrRay the ray (position and direction) to use for ray-casting
  78984. * @param referenceSpace native XR reference space to use for the hit-test
  78985. * @param filter filter function that will filter the results
  78986. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78987. */
  78988. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78989. /**
  78990. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78991. * @param event the (select) event to use to select with
  78992. * @param referenceSpace the reference space to use for this hit test
  78993. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78994. */
  78995. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78996. /**
  78997. * attach this feature
  78998. * Will usually be called by the features manager
  78999. *
  79000. * @returns true if successful.
  79001. */
  79002. attach(): boolean;
  79003. /**
  79004. * detach this feature.
  79005. * Will usually be called by the features manager
  79006. *
  79007. * @returns true if successful.
  79008. */
  79009. detach(): boolean;
  79010. /**
  79011. * Dispose this feature and all of the resources attached
  79012. */
  79013. dispose(): void;
  79014. protected _onXRFrame(frame: XRFrame): void;
  79015. private _onHitTestResults;
  79016. private _onSelect;
  79017. }
  79018. }
  79019. declare module "babylonjs/XR/features/WebXRHitTest" {
  79020. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79021. import { Observable } from "babylonjs/Misc/observable";
  79022. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79023. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79024. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79025. /**
  79026. * Options used for hit testing (version 2)
  79027. */
  79028. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79029. /**
  79030. * Do not create a permanent hit test. Will usually be used when only
  79031. * transient inputs are needed.
  79032. */
  79033. disablePermanentHitTest?: boolean;
  79034. /**
  79035. * Enable transient (for example touch-based) hit test inspections
  79036. */
  79037. enableTransientHitTest?: boolean;
  79038. /**
  79039. * Offset ray for the permanent hit test
  79040. */
  79041. offsetRay?: Vector3;
  79042. /**
  79043. * Offset ray for the transient hit test
  79044. */
  79045. transientOffsetRay?: Vector3;
  79046. /**
  79047. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79048. */
  79049. useReferenceSpace?: boolean;
  79050. /**
  79051. * Override the default entity type(s) of the hit-test result
  79052. */
  79053. entityTypes?: XRHitTestTrackableType[];
  79054. }
  79055. /**
  79056. * Interface defining the babylon result of hit-test
  79057. */
  79058. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79059. /**
  79060. * The input source that generated this hit test (if transient)
  79061. */
  79062. inputSource?: XRInputSource;
  79063. /**
  79064. * Is this a transient hit test
  79065. */
  79066. isTransient?: boolean;
  79067. /**
  79068. * Position of the hit test result
  79069. */
  79070. position: Vector3;
  79071. /**
  79072. * Rotation of the hit test result
  79073. */
  79074. rotationQuaternion: Quaternion;
  79075. /**
  79076. * The native hit test result
  79077. */
  79078. xrHitResult: XRHitTestResult;
  79079. }
  79080. /**
  79081. * The currently-working hit-test module.
  79082. * Hit test (or Ray-casting) is used to interact with the real world.
  79083. * For further information read here - https://github.com/immersive-web/hit-test
  79084. *
  79085. * Tested on chrome (mobile) 80.
  79086. */
  79087. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79088. /**
  79089. * options to use when constructing this feature
  79090. */
  79091. readonly options: IWebXRHitTestOptions;
  79092. private _tmpMat;
  79093. private _tmpPos;
  79094. private _tmpQuat;
  79095. private _transientXrHitTestSource;
  79096. private _xrHitTestSource;
  79097. private initHitTestSource;
  79098. /**
  79099. * The module's name
  79100. */
  79101. static readonly Name: string;
  79102. /**
  79103. * The (Babylon) version of this module.
  79104. * This is an integer representing the implementation version.
  79105. * This number does not correspond to the WebXR specs version
  79106. */
  79107. static readonly Version: number;
  79108. /**
  79109. * When set to true, each hit test will have its own position/rotation objects
  79110. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79111. * the developers will clone them or copy them as they see fit.
  79112. */
  79113. autoCloneTransformation: boolean;
  79114. /**
  79115. * Triggered when new babylon (transformed) hit test results are available
  79116. * Note - this will be called when results come back from the device. It can be an empty array!!
  79117. */
  79118. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79119. /**
  79120. * Use this to temporarily pause hit test checks.
  79121. */
  79122. paused: boolean;
  79123. /**
  79124. * Creates a new instance of the hit test feature
  79125. * @param _xrSessionManager an instance of WebXRSessionManager
  79126. * @param options options to use when constructing this feature
  79127. */
  79128. constructor(_xrSessionManager: WebXRSessionManager,
  79129. /**
  79130. * options to use when constructing this feature
  79131. */
  79132. options?: IWebXRHitTestOptions);
  79133. /**
  79134. * attach this feature
  79135. * Will usually be called by the features manager
  79136. *
  79137. * @returns true if successful.
  79138. */
  79139. attach(): boolean;
  79140. /**
  79141. * detach this feature.
  79142. * Will usually be called by the features manager
  79143. *
  79144. * @returns true if successful.
  79145. */
  79146. detach(): boolean;
  79147. /**
  79148. * Dispose this feature and all of the resources attached
  79149. */
  79150. dispose(): void;
  79151. protected _onXRFrame(frame: XRFrame): void;
  79152. private _processWebXRHitTestResult;
  79153. }
  79154. }
  79155. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79156. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79157. import { Observable } from "babylonjs/Misc/observable";
  79158. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79159. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79160. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79161. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79162. /**
  79163. * Configuration options of the anchor system
  79164. */
  79165. export interface IWebXRAnchorSystemOptions {
  79166. /**
  79167. * a node that will be used to convert local to world coordinates
  79168. */
  79169. worldParentNode?: TransformNode;
  79170. /**
  79171. * If set to true a reference of the created anchors will be kept until the next session starts
  79172. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79173. */
  79174. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79175. }
  79176. /**
  79177. * A babylon container for an XR Anchor
  79178. */
  79179. export interface IWebXRAnchor {
  79180. /**
  79181. * A babylon-assigned ID for this anchor
  79182. */
  79183. id: number;
  79184. /**
  79185. * Transformation matrix to apply to an object attached to this anchor
  79186. */
  79187. transformationMatrix: Matrix;
  79188. /**
  79189. * The native anchor object
  79190. */
  79191. xrAnchor: XRAnchor;
  79192. /**
  79193. * if defined, this object will be constantly updated by the anchor's position and rotation
  79194. */
  79195. attachedNode?: TransformNode;
  79196. }
  79197. /**
  79198. * An implementation of the anchor system for WebXR.
  79199. * For further information see https://github.com/immersive-web/anchors/
  79200. */
  79201. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79202. private _options;
  79203. private _lastFrameDetected;
  79204. private _trackedAnchors;
  79205. private _referenceSpaceForFrameAnchors;
  79206. private _futureAnchors;
  79207. /**
  79208. * The module's name
  79209. */
  79210. static readonly Name: string;
  79211. /**
  79212. * The (Babylon) version of this module.
  79213. * This is an integer representing the implementation version.
  79214. * This number does not correspond to the WebXR specs version
  79215. */
  79216. static readonly Version: number;
  79217. /**
  79218. * Observers registered here will be executed when a new anchor was added to the session
  79219. */
  79220. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79221. /**
  79222. * Observers registered here will be executed when an anchor was removed from the session
  79223. */
  79224. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79225. /**
  79226. * Observers registered here will be executed when an existing anchor updates
  79227. * This can execute N times every frame
  79228. */
  79229. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79230. /**
  79231. * Set the reference space to use for anchor creation, when not using a hit test.
  79232. * Will default to the session's reference space if not defined
  79233. */
  79234. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79235. /**
  79236. * constructs a new anchor system
  79237. * @param _xrSessionManager an instance of WebXRSessionManager
  79238. * @param _options configuration object for this feature
  79239. */
  79240. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79241. private _tmpVector;
  79242. private _tmpQuaternion;
  79243. private _populateTmpTransformation;
  79244. /**
  79245. * Create a new anchor point using a hit test result at a specific point in the scene
  79246. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79247. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79248. *
  79249. * @param hitTestResult The hit test result to use for this anchor creation
  79250. * @param position an optional position offset for this anchor
  79251. * @param rotationQuaternion an optional rotation offset for this anchor
  79252. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79253. */
  79254. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79255. /**
  79256. * Add a new anchor at a specific position and rotation
  79257. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79258. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79259. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79260. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79261. *
  79262. * @param position the position in which to add an anchor
  79263. * @param rotationQuaternion an optional rotation for the anchor transformation
  79264. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79265. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79266. */
  79267. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79268. /**
  79269. * detach this feature.
  79270. * Will usually be called by the features manager
  79271. *
  79272. * @returns true if successful.
  79273. */
  79274. detach(): boolean;
  79275. /**
  79276. * Dispose this feature and all of the resources attached
  79277. */
  79278. dispose(): void;
  79279. protected _onXRFrame(frame: XRFrame): void;
  79280. /**
  79281. * avoiding using Array.find for global support.
  79282. * @param xrAnchor the plane to find in the array
  79283. */
  79284. private _findIndexInAnchorArray;
  79285. private _updateAnchorWithXRFrame;
  79286. private _createAnchorAtTransformation;
  79287. }
  79288. }
  79289. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79290. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79291. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79292. import { Observable } from "babylonjs/Misc/observable";
  79293. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79294. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79295. /**
  79296. * Options used in the plane detector module
  79297. */
  79298. export interface IWebXRPlaneDetectorOptions {
  79299. /**
  79300. * The node to use to transform the local results to world coordinates
  79301. */
  79302. worldParentNode?: TransformNode;
  79303. /**
  79304. * If set to true a reference of the created planes will be kept until the next session starts
  79305. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79306. */
  79307. doNotRemovePlanesOnSessionEnded?: boolean;
  79308. }
  79309. /**
  79310. * A babylon interface for a WebXR plane.
  79311. * A Plane is actually a polygon, built from N points in space
  79312. *
  79313. * Supported in chrome 79, not supported in canary 81 ATM
  79314. */
  79315. export interface IWebXRPlane {
  79316. /**
  79317. * a babylon-assigned ID for this polygon
  79318. */
  79319. id: number;
  79320. /**
  79321. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79322. */
  79323. polygonDefinition: Array<Vector3>;
  79324. /**
  79325. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79326. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79327. */
  79328. transformationMatrix: Matrix;
  79329. /**
  79330. * the native xr-plane object
  79331. */
  79332. xrPlane: XRPlane;
  79333. }
  79334. /**
  79335. * The plane detector is used to detect planes in the real world when in AR
  79336. * For more information see https://github.com/immersive-web/real-world-geometry/
  79337. */
  79338. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79339. private _options;
  79340. private _detectedPlanes;
  79341. private _enabled;
  79342. private _lastFrameDetected;
  79343. /**
  79344. * The module's name
  79345. */
  79346. static readonly Name: string;
  79347. /**
  79348. * The (Babylon) version of this module.
  79349. * This is an integer representing the implementation version.
  79350. * This number does not correspond to the WebXR specs version
  79351. */
  79352. static readonly Version: number;
  79353. /**
  79354. * Observers registered here will be executed when a new plane was added to the session
  79355. */
  79356. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79357. /**
  79358. * Observers registered here will be executed when a plane is no longer detected in the session
  79359. */
  79360. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79361. /**
  79362. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79363. * This can execute N times every frame
  79364. */
  79365. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79366. /**
  79367. * construct a new Plane Detector
  79368. * @param _xrSessionManager an instance of xr Session manager
  79369. * @param _options configuration to use when constructing this feature
  79370. */
  79371. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79372. /**
  79373. * detach this feature.
  79374. * Will usually be called by the features manager
  79375. *
  79376. * @returns true if successful.
  79377. */
  79378. detach(): boolean;
  79379. /**
  79380. * Dispose this feature and all of the resources attached
  79381. */
  79382. dispose(): void;
  79383. protected _onXRFrame(frame: XRFrame): void;
  79384. private _init;
  79385. private _updatePlaneWithXRPlane;
  79386. /**
  79387. * avoiding using Array.find for global support.
  79388. * @param xrPlane the plane to find in the array
  79389. */
  79390. private findIndexInPlaneArray;
  79391. }
  79392. }
  79393. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79394. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79396. import { Observable } from "babylonjs/Misc/observable";
  79397. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79398. /**
  79399. * Options interface for the background remover plugin
  79400. */
  79401. export interface IWebXRBackgroundRemoverOptions {
  79402. /**
  79403. * Further background meshes to disable when entering AR
  79404. */
  79405. backgroundMeshes?: AbstractMesh[];
  79406. /**
  79407. * flags to configure the removal of the environment helper.
  79408. * If not set, the entire background will be removed. If set, flags should be set as well.
  79409. */
  79410. environmentHelperRemovalFlags?: {
  79411. /**
  79412. * Should the skybox be removed (default false)
  79413. */
  79414. skyBox?: boolean;
  79415. /**
  79416. * Should the ground be removed (default false)
  79417. */
  79418. ground?: boolean;
  79419. };
  79420. /**
  79421. * don't disable the environment helper
  79422. */
  79423. ignoreEnvironmentHelper?: boolean;
  79424. }
  79425. /**
  79426. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79427. */
  79428. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79429. /**
  79430. * read-only options to be used in this module
  79431. */
  79432. readonly options: IWebXRBackgroundRemoverOptions;
  79433. /**
  79434. * The module's name
  79435. */
  79436. static readonly Name: string;
  79437. /**
  79438. * The (Babylon) version of this module.
  79439. * This is an integer representing the implementation version.
  79440. * This number does not correspond to the WebXR specs version
  79441. */
  79442. static readonly Version: number;
  79443. /**
  79444. * registered observers will be triggered when the background state changes
  79445. */
  79446. onBackgroundStateChangedObservable: Observable<boolean>;
  79447. /**
  79448. * constructs a new background remover module
  79449. * @param _xrSessionManager the session manager for this module
  79450. * @param options read-only options to be used in this module
  79451. */
  79452. constructor(_xrSessionManager: WebXRSessionManager,
  79453. /**
  79454. * read-only options to be used in this module
  79455. */
  79456. options?: IWebXRBackgroundRemoverOptions);
  79457. /**
  79458. * attach this feature
  79459. * Will usually be called by the features manager
  79460. *
  79461. * @returns true if successful.
  79462. */
  79463. attach(): boolean;
  79464. /**
  79465. * detach this feature.
  79466. * Will usually be called by the features manager
  79467. *
  79468. * @returns true if successful.
  79469. */
  79470. detach(): boolean;
  79471. /**
  79472. * Dispose this feature and all of the resources attached
  79473. */
  79474. dispose(): void;
  79475. protected _onXRFrame(_xrFrame: XRFrame): void;
  79476. private _setBackgroundState;
  79477. }
  79478. }
  79479. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79480. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79481. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79482. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79483. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79484. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79485. import { Nullable } from "babylonjs/types";
  79486. /**
  79487. * Options for the controller physics feature
  79488. */
  79489. export class IWebXRControllerPhysicsOptions {
  79490. /**
  79491. * Should the headset get its own impostor
  79492. */
  79493. enableHeadsetImpostor?: boolean;
  79494. /**
  79495. * Optional parameters for the headset impostor
  79496. */
  79497. headsetImpostorParams?: {
  79498. /**
  79499. * The type of impostor to create. Default is sphere
  79500. */
  79501. impostorType: number;
  79502. /**
  79503. * the size of the impostor. Defaults to 10cm
  79504. */
  79505. impostorSize?: number | {
  79506. width: number;
  79507. height: number;
  79508. depth: number;
  79509. };
  79510. /**
  79511. * Friction definitions
  79512. */
  79513. friction?: number;
  79514. /**
  79515. * Restitution
  79516. */
  79517. restitution?: number;
  79518. };
  79519. /**
  79520. * The physics properties of the future impostors
  79521. */
  79522. physicsProperties?: {
  79523. /**
  79524. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79525. * Note that this requires a physics engine that supports mesh impostors!
  79526. */
  79527. useControllerMesh?: boolean;
  79528. /**
  79529. * The type of impostor to create. Default is sphere
  79530. */
  79531. impostorType?: number;
  79532. /**
  79533. * the size of the impostor. Defaults to 10cm
  79534. */
  79535. impostorSize?: number | {
  79536. width: number;
  79537. height: number;
  79538. depth: number;
  79539. };
  79540. /**
  79541. * Friction definitions
  79542. */
  79543. friction?: number;
  79544. /**
  79545. * Restitution
  79546. */
  79547. restitution?: number;
  79548. };
  79549. /**
  79550. * the xr input to use with this pointer selection
  79551. */
  79552. xrInput: WebXRInput;
  79553. }
  79554. /**
  79555. * Add physics impostor to your webxr controllers,
  79556. * including naive calculation of their linear and angular velocity
  79557. */
  79558. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79559. private readonly _options;
  79560. private _attachController;
  79561. private _controllers;
  79562. private _debugMode;
  79563. private _delta;
  79564. private _headsetImpostor?;
  79565. private _headsetMesh?;
  79566. private _lastTimestamp;
  79567. private _tmpQuaternion;
  79568. private _tmpVector;
  79569. /**
  79570. * The module's name
  79571. */
  79572. static readonly Name: string;
  79573. /**
  79574. * The (Babylon) version of this module.
  79575. * This is an integer representing the implementation version.
  79576. * This number does not correspond to the webxr specs version
  79577. */
  79578. static readonly Version: number;
  79579. /**
  79580. * Construct a new Controller Physics Feature
  79581. * @param _xrSessionManager the corresponding xr session manager
  79582. * @param _options options to create this feature with
  79583. */
  79584. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79585. /**
  79586. * @hidden
  79587. * enable debugging - will show console outputs and the impostor mesh
  79588. */
  79589. _enablePhysicsDebug(): void;
  79590. /**
  79591. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79592. * @param xrController the controller to add
  79593. */
  79594. addController(xrController: WebXRInputSource): void;
  79595. /**
  79596. * attach this feature
  79597. * Will usually be called by the features manager
  79598. *
  79599. * @returns true if successful.
  79600. */
  79601. attach(): boolean;
  79602. /**
  79603. * detach this feature.
  79604. * Will usually be called by the features manager
  79605. *
  79606. * @returns true if successful.
  79607. */
  79608. detach(): boolean;
  79609. /**
  79610. * Get the headset impostor, if enabled
  79611. * @returns the impostor
  79612. */
  79613. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79614. /**
  79615. * Get the physics impostor of a specific controller.
  79616. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79617. * @param controller the controller or the controller id of which to get the impostor
  79618. * @returns the impostor or null
  79619. */
  79620. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79621. /**
  79622. * Update the physics properties provided in the constructor
  79623. * @param newProperties the new properties object
  79624. */
  79625. setPhysicsProperties(newProperties: {
  79626. impostorType?: number;
  79627. impostorSize?: number | {
  79628. width: number;
  79629. height: number;
  79630. depth: number;
  79631. };
  79632. friction?: number;
  79633. restitution?: number;
  79634. }): void;
  79635. protected _onXRFrame(_xrFrame: any): void;
  79636. private _detachController;
  79637. }
  79638. }
  79639. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79640. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79641. import { Observable } from "babylonjs/Misc/observable";
  79642. import { Vector3 } from "babylonjs/Maths/math.vector";
  79643. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79644. /**
  79645. * A babylon interface for a "WebXR" feature point.
  79646. * Represents the position and confidence value of a given feature point.
  79647. */
  79648. export interface IWebXRFeaturePoint {
  79649. /**
  79650. * Represents the position of the feature point in world space.
  79651. */
  79652. position: Vector3;
  79653. /**
  79654. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79655. */
  79656. confidenceValue: number;
  79657. }
  79658. /**
  79659. * The feature point system is used to detect feature points from real world geometry.
  79660. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79661. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79662. */
  79663. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79664. private _enabled;
  79665. private _featurePointCloud;
  79666. /**
  79667. * The module's name
  79668. */
  79669. static readonly Name: string;
  79670. /**
  79671. * The (Babylon) version of this module.
  79672. * This is an integer representing the implementation version.
  79673. * This number does not correspond to the WebXR specs version
  79674. */
  79675. static readonly Version: number;
  79676. /**
  79677. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79678. * Will notify the observers about which feature points have been added.
  79679. */
  79680. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79681. /**
  79682. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79683. * Will notify the observers about which feature points have been updated.
  79684. */
  79685. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79686. /**
  79687. * The current feature point cloud maintained across frames.
  79688. */
  79689. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79690. /**
  79691. * construct the feature point system
  79692. * @param _xrSessionManager an instance of xr Session manager
  79693. */
  79694. constructor(_xrSessionManager: WebXRSessionManager);
  79695. /**
  79696. * Detach this feature.
  79697. * Will usually be called by the features manager
  79698. *
  79699. * @returns true if successful.
  79700. */
  79701. detach(): boolean;
  79702. /**
  79703. * Dispose this feature and all of the resources attached
  79704. */
  79705. dispose(): void;
  79706. /**
  79707. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79708. */
  79709. protected _onXRFrame(frame: XRFrame): void;
  79710. /**
  79711. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79712. */
  79713. private _init;
  79714. }
  79715. }
  79716. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79717. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79718. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79720. import { Mesh } from "babylonjs/Meshes/mesh";
  79721. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79722. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79723. import { Nullable } from "babylonjs/types";
  79724. import { IDisposable } from "babylonjs/scene";
  79725. import { Observable } from "babylonjs/Misc/observable";
  79726. /**
  79727. * Configuration interface for the hand tracking feature
  79728. */
  79729. export interface IWebXRHandTrackingOptions {
  79730. /**
  79731. * The xrInput that will be used as source for new hands
  79732. */
  79733. xrInput: WebXRInput;
  79734. /**
  79735. * Configuration object for the joint meshes
  79736. */
  79737. jointMeshes?: {
  79738. /**
  79739. * Should the meshes created be invisible (defaults to false)
  79740. */
  79741. invisible?: boolean;
  79742. /**
  79743. * A source mesh to be used to create instances. Defaults to a sphere.
  79744. * This mesh will be the source for all other (25) meshes.
  79745. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79746. */
  79747. sourceMesh?: Mesh;
  79748. /**
  79749. * Should the source mesh stay visible. Defaults to false
  79750. */
  79751. keepOriginalVisible?: boolean;
  79752. /**
  79753. * Scale factor for all instances (defaults to 2)
  79754. */
  79755. scaleFactor?: number;
  79756. /**
  79757. * Should each instance have its own physics impostor
  79758. */
  79759. enablePhysics?: boolean;
  79760. /**
  79761. * If enabled, override default physics properties
  79762. */
  79763. physicsProps?: {
  79764. friction?: number;
  79765. restitution?: number;
  79766. impostorType?: number;
  79767. };
  79768. /**
  79769. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79770. */
  79771. handMesh?: AbstractMesh;
  79772. };
  79773. }
  79774. /**
  79775. * Parts of the hands divided to writs and finger names
  79776. */
  79777. export const enum HandPart {
  79778. /**
  79779. * HandPart - Wrist
  79780. */
  79781. WRIST = "wrist",
  79782. /**
  79783. * HandPart - The THumb
  79784. */
  79785. THUMB = "thumb",
  79786. /**
  79787. * HandPart - Index finger
  79788. */
  79789. INDEX = "index",
  79790. /**
  79791. * HandPart - Middle finger
  79792. */
  79793. MIDDLE = "middle",
  79794. /**
  79795. * HandPart - Ring finger
  79796. */
  79797. RING = "ring",
  79798. /**
  79799. * HandPart - Little finger
  79800. */
  79801. LITTLE = "little"
  79802. }
  79803. /**
  79804. * Representing a single hand (with its corresponding native XRHand object)
  79805. */
  79806. export class WebXRHand implements IDisposable {
  79807. /** the controller to which the hand correlates */
  79808. readonly xrController: WebXRInputSource;
  79809. /** the meshes to be used to track the hand joints */
  79810. readonly trackedMeshes: AbstractMesh[];
  79811. /**
  79812. * Hand-parts definition (key is HandPart)
  79813. */
  79814. handPartsDefinition: {
  79815. [key: string]: number[];
  79816. };
  79817. /**
  79818. * Populate the HandPartsDefinition object.
  79819. * This is called as a side effect since certain browsers don't have XRHand defined.
  79820. */
  79821. private generateHandPartsDefinition;
  79822. /**
  79823. * Construct a new hand object
  79824. * @param xrController the controller to which the hand correlates
  79825. * @param trackedMeshes the meshes to be used to track the hand joints
  79826. */
  79827. constructor(
  79828. /** the controller to which the hand correlates */
  79829. xrController: WebXRInputSource,
  79830. /** the meshes to be used to track the hand joints */
  79831. trackedMeshes: AbstractMesh[]);
  79832. /**
  79833. * Update this hand from the latest xr frame
  79834. * @param xrFrame xrFrame to update from
  79835. * @param referenceSpace The current viewer reference space
  79836. * @param scaleFactor optional scale factor for the meshes
  79837. */
  79838. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79839. /**
  79840. * Get meshes of part of the hand
  79841. * @param part the part of hand to get
  79842. * @returns An array of meshes that correlate to the hand part requested
  79843. */
  79844. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79845. /**
  79846. * Dispose this Hand object
  79847. */
  79848. dispose(): void;
  79849. }
  79850. /**
  79851. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79852. */
  79853. export class WebXRHandTracking extends WebXRAbstractFeature {
  79854. /**
  79855. * options to use when constructing this feature
  79856. */
  79857. readonly options: IWebXRHandTrackingOptions;
  79858. private static _idCounter;
  79859. /**
  79860. * The module's name
  79861. */
  79862. static readonly Name: string;
  79863. /**
  79864. * The (Babylon) version of this module.
  79865. * This is an integer representing the implementation version.
  79866. * This number does not correspond to the WebXR specs version
  79867. */
  79868. static readonly Version: number;
  79869. /**
  79870. * This observable will notify registered observers when a new hand object was added and initialized
  79871. */
  79872. onHandAddedObservable: Observable<WebXRHand>;
  79873. /**
  79874. * This observable will notify its observers right before the hand object is disposed
  79875. */
  79876. onHandRemovedObservable: Observable<WebXRHand>;
  79877. private _hands;
  79878. /**
  79879. * Creates a new instance of the hit test feature
  79880. * @param _xrSessionManager an instance of WebXRSessionManager
  79881. * @param options options to use when constructing this feature
  79882. */
  79883. constructor(_xrSessionManager: WebXRSessionManager,
  79884. /**
  79885. * options to use when constructing this feature
  79886. */
  79887. options: IWebXRHandTrackingOptions);
  79888. /**
  79889. * Check if the needed objects are defined.
  79890. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79891. */
  79892. isCompatible(): boolean;
  79893. /**
  79894. * attach this feature
  79895. * Will usually be called by the features manager
  79896. *
  79897. * @returns true if successful.
  79898. */
  79899. attach(): boolean;
  79900. /**
  79901. * detach this feature.
  79902. * Will usually be called by the features manager
  79903. *
  79904. * @returns true if successful.
  79905. */
  79906. detach(): boolean;
  79907. /**
  79908. * Dispose this feature and all of the resources attached
  79909. */
  79910. dispose(): void;
  79911. /**
  79912. * Get the hand object according to the controller id
  79913. * @param controllerId the controller id to which we want to get the hand
  79914. * @returns null if not found or the WebXRHand object if found
  79915. */
  79916. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79917. /**
  79918. * Get a hand object according to the requested handedness
  79919. * @param handedness the handedness to request
  79920. * @returns null if not found or the WebXRHand object if found
  79921. */
  79922. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79923. protected _onXRFrame(_xrFrame: XRFrame): void;
  79924. private _attachHand;
  79925. private _detachHand;
  79926. }
  79927. }
  79928. declare module "babylonjs/XR/features/index" {
  79929. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79930. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79931. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79932. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79933. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79934. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79935. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79936. export * from "babylonjs/XR/features/WebXRHitTest";
  79937. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79938. export * from "babylonjs/XR/features/WebXRHandTracking";
  79939. }
  79940. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79941. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79943. import { Scene } from "babylonjs/scene";
  79944. /**
  79945. * The motion controller class for all microsoft mixed reality controllers
  79946. */
  79947. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79948. protected readonly _mapping: {
  79949. defaultButton: {
  79950. valueNodeName: string;
  79951. unpressedNodeName: string;
  79952. pressedNodeName: string;
  79953. };
  79954. defaultAxis: {
  79955. valueNodeName: string;
  79956. minNodeName: string;
  79957. maxNodeName: string;
  79958. };
  79959. buttons: {
  79960. "xr-standard-trigger": {
  79961. rootNodeName: string;
  79962. componentProperty: string;
  79963. states: string[];
  79964. };
  79965. "xr-standard-squeeze": {
  79966. rootNodeName: string;
  79967. componentProperty: string;
  79968. states: string[];
  79969. };
  79970. "xr-standard-touchpad": {
  79971. rootNodeName: string;
  79972. labelAnchorNodeName: string;
  79973. touchPointNodeName: string;
  79974. };
  79975. "xr-standard-thumbstick": {
  79976. rootNodeName: string;
  79977. componentProperty: string;
  79978. states: string[];
  79979. };
  79980. };
  79981. axes: {
  79982. "xr-standard-touchpad": {
  79983. "x-axis": {
  79984. rootNodeName: string;
  79985. };
  79986. "y-axis": {
  79987. rootNodeName: string;
  79988. };
  79989. };
  79990. "xr-standard-thumbstick": {
  79991. "x-axis": {
  79992. rootNodeName: string;
  79993. };
  79994. "y-axis": {
  79995. rootNodeName: string;
  79996. };
  79997. };
  79998. };
  79999. };
  80000. /**
  80001. * The base url used to load the left and right controller models
  80002. */
  80003. static MODEL_BASE_URL: string;
  80004. /**
  80005. * The name of the left controller model file
  80006. */
  80007. static MODEL_LEFT_FILENAME: string;
  80008. /**
  80009. * The name of the right controller model file
  80010. */
  80011. static MODEL_RIGHT_FILENAME: string;
  80012. profileId: string;
  80013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80014. protected _getFilenameAndPath(): {
  80015. filename: string;
  80016. path: string;
  80017. };
  80018. protected _getModelLoadingConstraints(): boolean;
  80019. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80020. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80021. protected _updateModel(): void;
  80022. }
  80023. }
  80024. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80025. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80027. import { Scene } from "babylonjs/scene";
  80028. /**
  80029. * The motion controller class for oculus touch (quest, rift).
  80030. * This class supports legacy mapping as well the standard xr mapping
  80031. */
  80032. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80033. private _forceLegacyControllers;
  80034. private _modelRootNode;
  80035. /**
  80036. * The base url used to load the left and right controller models
  80037. */
  80038. static MODEL_BASE_URL: string;
  80039. /**
  80040. * The name of the left controller model file
  80041. */
  80042. static MODEL_LEFT_FILENAME: string;
  80043. /**
  80044. * The name of the right controller model file
  80045. */
  80046. static MODEL_RIGHT_FILENAME: string;
  80047. /**
  80048. * Base Url for the Quest controller model.
  80049. */
  80050. static QUEST_MODEL_BASE_URL: string;
  80051. profileId: string;
  80052. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80053. protected _getFilenameAndPath(): {
  80054. filename: string;
  80055. path: string;
  80056. };
  80057. protected _getModelLoadingConstraints(): boolean;
  80058. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80059. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80060. protected _updateModel(): void;
  80061. /**
  80062. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80063. * between the touch and touch 2.
  80064. */
  80065. private _isQuest;
  80066. }
  80067. }
  80068. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80069. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80070. import { Scene } from "babylonjs/scene";
  80071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80072. /**
  80073. * The motion controller class for the standard HTC-Vive controllers
  80074. */
  80075. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80076. private _modelRootNode;
  80077. /**
  80078. * The base url used to load the left and right controller models
  80079. */
  80080. static MODEL_BASE_URL: string;
  80081. /**
  80082. * File name for the controller model.
  80083. */
  80084. static MODEL_FILENAME: string;
  80085. profileId: string;
  80086. /**
  80087. * Create a new Vive motion controller object
  80088. * @param scene the scene to use to create this controller
  80089. * @param gamepadObject the corresponding gamepad object
  80090. * @param handedness the handedness of the controller
  80091. */
  80092. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80093. protected _getFilenameAndPath(): {
  80094. filename: string;
  80095. path: string;
  80096. };
  80097. protected _getModelLoadingConstraints(): boolean;
  80098. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80099. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80100. protected _updateModel(): void;
  80101. }
  80102. }
  80103. declare module "babylonjs/XR/motionController/index" {
  80104. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80105. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80106. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80107. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80108. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80109. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80110. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80111. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80112. }
  80113. declare module "babylonjs/XR/index" {
  80114. export * from "babylonjs/XR/webXRCamera";
  80115. export * from "babylonjs/XR/webXREnterExitUI";
  80116. export * from "babylonjs/XR/webXRExperienceHelper";
  80117. export * from "babylonjs/XR/webXRInput";
  80118. export * from "babylonjs/XR/webXRInputSource";
  80119. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80120. export * from "babylonjs/XR/webXRTypes";
  80121. export * from "babylonjs/XR/webXRSessionManager";
  80122. export * from "babylonjs/XR/webXRDefaultExperience";
  80123. export * from "babylonjs/XR/webXRFeaturesManager";
  80124. export * from "babylonjs/XR/features/index";
  80125. export * from "babylonjs/XR/motionController/index";
  80126. }
  80127. declare module "babylonjs/index" {
  80128. export * from "babylonjs/abstractScene";
  80129. export * from "babylonjs/Actions/index";
  80130. export * from "babylonjs/Animations/index";
  80131. export * from "babylonjs/assetContainer";
  80132. export * from "babylonjs/Audio/index";
  80133. export * from "babylonjs/Behaviors/index";
  80134. export * from "babylonjs/Bones/index";
  80135. export * from "babylonjs/Cameras/index";
  80136. export * from "babylonjs/Collisions/index";
  80137. export * from "babylonjs/Culling/index";
  80138. export * from "babylonjs/Debug/index";
  80139. export * from "babylonjs/DeviceInput/index";
  80140. export * from "babylonjs/Engines/index";
  80141. export * from "babylonjs/Events/index";
  80142. export * from "babylonjs/Gamepads/index";
  80143. export * from "babylonjs/Gizmos/index";
  80144. export * from "babylonjs/Helpers/index";
  80145. export * from "babylonjs/Instrumentation/index";
  80146. export * from "babylonjs/Layers/index";
  80147. export * from "babylonjs/LensFlares/index";
  80148. export * from "babylonjs/Lights/index";
  80149. export * from "babylonjs/Loading/index";
  80150. export * from "babylonjs/Materials/index";
  80151. export * from "babylonjs/Maths/index";
  80152. export * from "babylonjs/Meshes/index";
  80153. export * from "babylonjs/Morph/index";
  80154. export * from "babylonjs/Navigation/index";
  80155. export * from "babylonjs/node";
  80156. export * from "babylonjs/Offline/index";
  80157. export * from "babylonjs/Particles/index";
  80158. export * from "babylonjs/Physics/index";
  80159. export * from "babylonjs/PostProcesses/index";
  80160. export * from "babylonjs/Probes/index";
  80161. export * from "babylonjs/Rendering/index";
  80162. export * from "babylonjs/scene";
  80163. export * from "babylonjs/sceneComponent";
  80164. export * from "babylonjs/Sprites/index";
  80165. export * from "babylonjs/States/index";
  80166. export * from "babylonjs/Misc/index";
  80167. export * from "babylonjs/XR/index";
  80168. export * from "babylonjs/types";
  80169. }
  80170. declare module "babylonjs/Animations/pathCursor" {
  80171. import { Vector3 } from "babylonjs/Maths/math.vector";
  80172. import { Path2 } from "babylonjs/Maths/math.path";
  80173. /**
  80174. * A cursor which tracks a point on a path
  80175. */
  80176. export class PathCursor {
  80177. private path;
  80178. /**
  80179. * Stores path cursor callbacks for when an onchange event is triggered
  80180. */
  80181. private _onchange;
  80182. /**
  80183. * The value of the path cursor
  80184. */
  80185. value: number;
  80186. /**
  80187. * The animation array of the path cursor
  80188. */
  80189. animations: Animation[];
  80190. /**
  80191. * Initializes the path cursor
  80192. * @param path The path to track
  80193. */
  80194. constructor(path: Path2);
  80195. /**
  80196. * Gets the cursor point on the path
  80197. * @returns A point on the path cursor at the cursor location
  80198. */
  80199. getPoint(): Vector3;
  80200. /**
  80201. * Moves the cursor ahead by the step amount
  80202. * @param step The amount to move the cursor forward
  80203. * @returns This path cursor
  80204. */
  80205. moveAhead(step?: number): PathCursor;
  80206. /**
  80207. * Moves the cursor behind by the step amount
  80208. * @param step The amount to move the cursor back
  80209. * @returns This path cursor
  80210. */
  80211. moveBack(step?: number): PathCursor;
  80212. /**
  80213. * Moves the cursor by the step amount
  80214. * If the step amount is greater than one, an exception is thrown
  80215. * @param step The amount to move the cursor
  80216. * @returns This path cursor
  80217. */
  80218. move(step: number): PathCursor;
  80219. /**
  80220. * Ensures that the value is limited between zero and one
  80221. * @returns This path cursor
  80222. */
  80223. private ensureLimits;
  80224. /**
  80225. * Runs onchange callbacks on change (used by the animation engine)
  80226. * @returns This path cursor
  80227. */
  80228. private raiseOnChange;
  80229. /**
  80230. * Executes a function on change
  80231. * @param f A path cursor onchange callback
  80232. * @returns This path cursor
  80233. */
  80234. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80235. }
  80236. }
  80237. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80238. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80239. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80240. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80241. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80242. }
  80243. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80244. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80245. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80246. }
  80247. declare module "babylonjs/Engines/Processors/index" {
  80248. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80249. export * from "babylonjs/Engines/Processors/Expressions/index";
  80250. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80251. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80252. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80253. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80254. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80255. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80256. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80257. }
  80258. declare module "babylonjs/Legacy/legacy" {
  80259. import * as Babylon from "babylonjs/index";
  80260. export * from "babylonjs/index";
  80261. }
  80262. declare module "babylonjs/Shaders/blur.fragment" {
  80263. /** @hidden */
  80264. export var blurPixelShader: {
  80265. name: string;
  80266. shader: string;
  80267. };
  80268. }
  80269. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80270. /** @hidden */
  80271. export var pointCloudVertexDeclaration: {
  80272. name: string;
  80273. shader: string;
  80274. };
  80275. }
  80276. declare module "babylonjs" {
  80277. export * from "babylonjs/Legacy/legacy";
  80278. }
  80279. declare module BABYLON {
  80280. /** Alias type for value that can be null */
  80281. export type Nullable<T> = T | null;
  80282. /**
  80283. * Alias type for number that are floats
  80284. * @ignorenaming
  80285. */
  80286. export type float = number;
  80287. /**
  80288. * Alias type for number that are doubles.
  80289. * @ignorenaming
  80290. */
  80291. export type double = number;
  80292. /**
  80293. * Alias type for number that are integer
  80294. * @ignorenaming
  80295. */
  80296. export type int = number;
  80297. /** Alias type for number array or Float32Array */
  80298. export type FloatArray = number[] | Float32Array;
  80299. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80300. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80301. /**
  80302. * Alias for types that can be used by a Buffer or VertexBuffer.
  80303. */
  80304. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80305. /**
  80306. * Alias type for primitive types
  80307. * @ignorenaming
  80308. */
  80309. type Primitive = undefined | null | boolean | string | number | Function;
  80310. /**
  80311. * Type modifier to make all the properties of an object Readonly
  80312. */
  80313. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80314. /**
  80315. * Type modifier to make all the properties of an object Readonly recursively
  80316. */
  80317. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80318. /**
  80319. * Type modifier to make object properties readonly.
  80320. */
  80321. export type DeepImmutableObject<T> = {
  80322. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80323. };
  80324. /** @hidden */
  80325. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80326. }
  80327. }
  80328. declare module BABYLON {
  80329. /**
  80330. * A class serves as a medium between the observable and its observers
  80331. */
  80332. export class EventState {
  80333. /**
  80334. * Create a new EventState
  80335. * @param mask defines the mask associated with this state
  80336. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80337. * @param target defines the original target of the state
  80338. * @param currentTarget defines the current target of the state
  80339. */
  80340. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80341. /**
  80342. * Initialize the current event state
  80343. * @param mask defines the mask associated with this state
  80344. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80345. * @param target defines the original target of the state
  80346. * @param currentTarget defines the current target of the state
  80347. * @returns the current event state
  80348. */
  80349. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80350. /**
  80351. * An Observer can set this property to true to prevent subsequent observers of being notified
  80352. */
  80353. skipNextObservers: boolean;
  80354. /**
  80355. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80356. */
  80357. mask: number;
  80358. /**
  80359. * The object that originally notified the event
  80360. */
  80361. target?: any;
  80362. /**
  80363. * The current object in the bubbling phase
  80364. */
  80365. currentTarget?: any;
  80366. /**
  80367. * This will be populated with the return value of the last function that was executed.
  80368. * If it is the first function in the callback chain it will be the event data.
  80369. */
  80370. lastReturnValue?: any;
  80371. }
  80372. /**
  80373. * Represent an Observer registered to a given Observable object.
  80374. */
  80375. export class Observer<T> {
  80376. /**
  80377. * Defines the callback to call when the observer is notified
  80378. */
  80379. callback: (eventData: T, eventState: EventState) => void;
  80380. /**
  80381. * Defines the mask of the observer (used to filter notifications)
  80382. */
  80383. mask: number;
  80384. /**
  80385. * Defines the current scope used to restore the JS context
  80386. */
  80387. scope: any;
  80388. /** @hidden */
  80389. _willBeUnregistered: boolean;
  80390. /**
  80391. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80392. */
  80393. unregisterOnNextCall: boolean;
  80394. /**
  80395. * Creates a new observer
  80396. * @param callback defines the callback to call when the observer is notified
  80397. * @param mask defines the mask of the observer (used to filter notifications)
  80398. * @param scope defines the current scope used to restore the JS context
  80399. */
  80400. constructor(
  80401. /**
  80402. * Defines the callback to call when the observer is notified
  80403. */
  80404. callback: (eventData: T, eventState: EventState) => void,
  80405. /**
  80406. * Defines the mask of the observer (used to filter notifications)
  80407. */
  80408. mask: number,
  80409. /**
  80410. * Defines the current scope used to restore the JS context
  80411. */
  80412. scope?: any);
  80413. }
  80414. /**
  80415. * Represent a list of observers registered to multiple Observables object.
  80416. */
  80417. export class MultiObserver<T> {
  80418. private _observers;
  80419. private _observables;
  80420. /**
  80421. * Release associated resources
  80422. */
  80423. dispose(): void;
  80424. /**
  80425. * Raise a callback when one of the observable will notify
  80426. * @param observables defines a list of observables to watch
  80427. * @param callback defines the callback to call on notification
  80428. * @param mask defines the mask used to filter notifications
  80429. * @param scope defines the current scope used to restore the JS context
  80430. * @returns the new MultiObserver
  80431. */
  80432. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80433. }
  80434. /**
  80435. * The Observable class is a simple implementation of the Observable pattern.
  80436. *
  80437. * 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.
  80438. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80439. * 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).
  80440. * 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.
  80441. */
  80442. export class Observable<T> {
  80443. private _observers;
  80444. private _eventState;
  80445. private _onObserverAdded;
  80446. /**
  80447. * Gets the list of observers
  80448. */
  80449. get observers(): Array<Observer<T>>;
  80450. /**
  80451. * Creates a new observable
  80452. * @param onObserverAdded defines a callback to call when a new observer is added
  80453. */
  80454. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80455. /**
  80456. * Create a new Observer with the specified callback
  80457. * @param callback the callback that will be executed for that Observer
  80458. * @param mask the mask used to filter observers
  80459. * @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.
  80460. * @param scope optional scope for the callback to be called from
  80461. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80462. * @returns the new observer created for the callback
  80463. */
  80464. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80465. /**
  80466. * Create a new Observer with the specified callback and unregisters after the next notification
  80467. * @param callback the callback that will be executed for that Observer
  80468. * @returns the new observer created for the callback
  80469. */
  80470. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80471. /**
  80472. * Remove an Observer from the Observable object
  80473. * @param observer the instance of the Observer to remove
  80474. * @returns false if it doesn't belong to this Observable
  80475. */
  80476. remove(observer: Nullable<Observer<T>>): boolean;
  80477. /**
  80478. * Remove a callback from the Observable object
  80479. * @param callback the callback to remove
  80480. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80481. * @returns false if it doesn't belong to this Observable
  80482. */
  80483. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80484. private _deferUnregister;
  80485. private _remove;
  80486. /**
  80487. * Moves the observable to the top of the observer list making it get called first when notified
  80488. * @param observer the observer to move
  80489. */
  80490. makeObserverTopPriority(observer: Observer<T>): void;
  80491. /**
  80492. * Moves the observable to the bottom of the observer list making it get called last when notified
  80493. * @param observer the observer to move
  80494. */
  80495. makeObserverBottomPriority(observer: Observer<T>): void;
  80496. /**
  80497. * Notify all Observers by calling their respective callback with the given data
  80498. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80499. * @param eventData defines the data to send to all observers
  80500. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80501. * @param target defines the original target of the state
  80502. * @param currentTarget defines the current target of the state
  80503. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80504. */
  80505. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80506. /**
  80507. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80508. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80509. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80510. * and it is crucial that all callbacks will be executed.
  80511. * The order of the callbacks is kept, callbacks are not executed parallel.
  80512. *
  80513. * @param eventData The data to be sent to each callback
  80514. * @param mask is used to filter observers defaults to -1
  80515. * @param target defines the callback target (see EventState)
  80516. * @param currentTarget defines he current object in the bubbling phase
  80517. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80518. */
  80519. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80520. /**
  80521. * Notify a specific observer
  80522. * @param observer defines the observer to notify
  80523. * @param eventData defines the data to be sent to each callback
  80524. * @param mask is used to filter observers defaults to -1
  80525. */
  80526. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80527. /**
  80528. * Gets a boolean indicating if the observable has at least one observer
  80529. * @returns true is the Observable has at least one Observer registered
  80530. */
  80531. hasObservers(): boolean;
  80532. /**
  80533. * Clear the list of observers
  80534. */
  80535. clear(): void;
  80536. /**
  80537. * Clone the current observable
  80538. * @returns a new observable
  80539. */
  80540. clone(): Observable<T>;
  80541. /**
  80542. * Does this observable handles observer registered with a given mask
  80543. * @param mask defines the mask to be tested
  80544. * @return whether or not one observer registered with the given mask is handeled
  80545. **/
  80546. hasSpecificMask(mask?: number): boolean;
  80547. }
  80548. }
  80549. declare module BABYLON {
  80550. /**
  80551. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80552. * Babylon.js
  80553. */
  80554. export class DomManagement {
  80555. /**
  80556. * Checks if the window object exists
  80557. * @returns true if the window object exists
  80558. */
  80559. static IsWindowObjectExist(): boolean;
  80560. /**
  80561. * Checks if the navigator object exists
  80562. * @returns true if the navigator object exists
  80563. */
  80564. static IsNavigatorAvailable(): boolean;
  80565. /**
  80566. * Check if the document object exists
  80567. * @returns true if the document object exists
  80568. */
  80569. static IsDocumentAvailable(): boolean;
  80570. /**
  80571. * Extracts text content from a DOM element hierarchy
  80572. * @param element defines the root element
  80573. * @returns a string
  80574. */
  80575. static GetDOMTextContent(element: HTMLElement): string;
  80576. }
  80577. }
  80578. declare module BABYLON {
  80579. /**
  80580. * Logger used througouht the application to allow configuration of
  80581. * the log level required for the messages.
  80582. */
  80583. export class Logger {
  80584. /**
  80585. * No log
  80586. */
  80587. static readonly NoneLogLevel: number;
  80588. /**
  80589. * Only message logs
  80590. */
  80591. static readonly MessageLogLevel: number;
  80592. /**
  80593. * Only warning logs
  80594. */
  80595. static readonly WarningLogLevel: number;
  80596. /**
  80597. * Only error logs
  80598. */
  80599. static readonly ErrorLogLevel: number;
  80600. /**
  80601. * All logs
  80602. */
  80603. static readonly AllLogLevel: number;
  80604. private static _LogCache;
  80605. /**
  80606. * Gets a value indicating the number of loading errors
  80607. * @ignorenaming
  80608. */
  80609. static errorsCount: number;
  80610. /**
  80611. * Callback called when a new log is added
  80612. */
  80613. static OnNewCacheEntry: (entry: string) => void;
  80614. private static _AddLogEntry;
  80615. private static _FormatMessage;
  80616. private static _LogDisabled;
  80617. private static _LogEnabled;
  80618. private static _WarnDisabled;
  80619. private static _WarnEnabled;
  80620. private static _ErrorDisabled;
  80621. private static _ErrorEnabled;
  80622. /**
  80623. * Log a message to the console
  80624. */
  80625. static Log: (message: string) => void;
  80626. /**
  80627. * Write a warning message to the console
  80628. */
  80629. static Warn: (message: string) => void;
  80630. /**
  80631. * Write an error message to the console
  80632. */
  80633. static Error: (message: string) => void;
  80634. /**
  80635. * Gets current log cache (list of logs)
  80636. */
  80637. static get LogCache(): string;
  80638. /**
  80639. * Clears the log cache
  80640. */
  80641. static ClearLogCache(): void;
  80642. /**
  80643. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80644. */
  80645. static set LogLevels(level: number);
  80646. }
  80647. }
  80648. declare module BABYLON {
  80649. /** @hidden */
  80650. export class _TypeStore {
  80651. /** @hidden */
  80652. static RegisteredTypes: {
  80653. [key: string]: Object;
  80654. };
  80655. /** @hidden */
  80656. static GetClass(fqdn: string): any;
  80657. }
  80658. }
  80659. declare module BABYLON {
  80660. /**
  80661. * Helper to manipulate strings
  80662. */
  80663. export class StringTools {
  80664. /**
  80665. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80666. * @param str Source string
  80667. * @param suffix Suffix to search for in the source string
  80668. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80669. */
  80670. static EndsWith(str: string, suffix: string): boolean;
  80671. /**
  80672. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80673. * @param str Source string
  80674. * @param suffix Suffix to search for in the source string
  80675. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80676. */
  80677. static StartsWith(str: string, suffix: string): boolean;
  80678. /**
  80679. * Decodes a buffer into a string
  80680. * @param buffer The buffer to decode
  80681. * @returns The decoded string
  80682. */
  80683. static Decode(buffer: Uint8Array | Uint16Array): string;
  80684. /**
  80685. * Encode a buffer to a base64 string
  80686. * @param buffer defines the buffer to encode
  80687. * @returns the encoded string
  80688. */
  80689. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80690. /**
  80691. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80692. * @param num the number to convert and pad
  80693. * @param length the expected length of the string
  80694. * @returns the padded string
  80695. */
  80696. static PadNumber(num: number, length: number): string;
  80697. }
  80698. }
  80699. declare module BABYLON {
  80700. /**
  80701. * Class containing a set of static utilities functions for deep copy.
  80702. */
  80703. export class DeepCopier {
  80704. /**
  80705. * Tries to copy an object by duplicating every property
  80706. * @param source defines the source object
  80707. * @param destination defines the target object
  80708. * @param doNotCopyList defines a list of properties to avoid
  80709. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80710. */
  80711. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80712. }
  80713. }
  80714. declare module BABYLON {
  80715. /**
  80716. * Class containing a set of static utilities functions for precision date
  80717. */
  80718. export class PrecisionDate {
  80719. /**
  80720. * Gets either window.performance.now() if supported or Date.now() else
  80721. */
  80722. static get Now(): number;
  80723. }
  80724. }
  80725. declare module BABYLON {
  80726. /** @hidden */
  80727. export class _DevTools {
  80728. static WarnImport(name: string): string;
  80729. }
  80730. }
  80731. declare module BABYLON {
  80732. /**
  80733. * Interface used to define the mechanism to get data from the network
  80734. */
  80735. export interface IWebRequest {
  80736. /**
  80737. * Returns client's response url
  80738. */
  80739. responseURL: string;
  80740. /**
  80741. * Returns client's status
  80742. */
  80743. status: number;
  80744. /**
  80745. * Returns client's status as a text
  80746. */
  80747. statusText: string;
  80748. }
  80749. }
  80750. declare module BABYLON {
  80751. /**
  80752. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80753. */
  80754. export class WebRequest implements IWebRequest {
  80755. private _xhr;
  80756. /**
  80757. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80758. * i.e. when loading files, where the server/service expects an Authorization header
  80759. */
  80760. static CustomRequestHeaders: {
  80761. [key: string]: string;
  80762. };
  80763. /**
  80764. * Add callback functions in this array to update all the requests before they get sent to the network
  80765. */
  80766. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80767. private _injectCustomRequestHeaders;
  80768. /**
  80769. * Gets or sets a function to be called when loading progress changes
  80770. */
  80771. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80772. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80773. /**
  80774. * Returns client's state
  80775. */
  80776. get readyState(): number;
  80777. /**
  80778. * Returns client's status
  80779. */
  80780. get status(): number;
  80781. /**
  80782. * Returns client's status as a text
  80783. */
  80784. get statusText(): string;
  80785. /**
  80786. * Returns client's response
  80787. */
  80788. get response(): any;
  80789. /**
  80790. * Returns client's response url
  80791. */
  80792. get responseURL(): string;
  80793. /**
  80794. * Returns client's response as text
  80795. */
  80796. get responseText(): string;
  80797. /**
  80798. * Gets or sets the expected response type
  80799. */
  80800. get responseType(): XMLHttpRequestResponseType;
  80801. set responseType(value: XMLHttpRequestResponseType);
  80802. /** @hidden */
  80803. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80804. /** @hidden */
  80805. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80806. /**
  80807. * Cancels any network activity
  80808. */
  80809. abort(): void;
  80810. /**
  80811. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80812. * @param body defines an optional request body
  80813. */
  80814. send(body?: Document | BodyInit | null): void;
  80815. /**
  80816. * Sets the request method, request URL
  80817. * @param method defines the method to use (GET, POST, etc..)
  80818. * @param url defines the url to connect with
  80819. */
  80820. open(method: string, url: string): void;
  80821. /**
  80822. * Sets the value of a request header.
  80823. * @param name The name of the header whose value is to be set
  80824. * @param value The value to set as the body of the header
  80825. */
  80826. setRequestHeader(name: string, value: string): void;
  80827. /**
  80828. * Get the string containing the text of a particular header's value.
  80829. * @param name The name of the header
  80830. * @returns The string containing the text of the given header name
  80831. */
  80832. getResponseHeader(name: string): Nullable<string>;
  80833. }
  80834. }
  80835. declare module BABYLON {
  80836. /**
  80837. * File request interface
  80838. */
  80839. export interface IFileRequest {
  80840. /**
  80841. * Raised when the request is complete (success or error).
  80842. */
  80843. onCompleteObservable: Observable<IFileRequest>;
  80844. /**
  80845. * Aborts the request for a file.
  80846. */
  80847. abort: () => void;
  80848. }
  80849. }
  80850. declare module BABYLON {
  80851. /**
  80852. * Define options used to create a render target texture
  80853. */
  80854. export class RenderTargetCreationOptions {
  80855. /**
  80856. * Specifies is mipmaps must be generated
  80857. */
  80858. generateMipMaps?: boolean;
  80859. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80860. generateDepthBuffer?: boolean;
  80861. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80862. generateStencilBuffer?: boolean;
  80863. /** Defines texture type (int by default) */
  80864. type?: number;
  80865. /** Defines sampling mode (trilinear by default) */
  80866. samplingMode?: number;
  80867. /** Defines format (RGBA by default) */
  80868. format?: number;
  80869. }
  80870. }
  80871. declare module BABYLON {
  80872. /** Defines the cross module used constants to avoid circular dependncies */
  80873. export class Constants {
  80874. /** Defines that alpha blending is disabled */
  80875. static readonly ALPHA_DISABLE: number;
  80876. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80877. static readonly ALPHA_ADD: number;
  80878. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80879. static readonly ALPHA_COMBINE: number;
  80880. /** Defines that alpha blending is DEST - SRC * DEST */
  80881. static readonly ALPHA_SUBTRACT: number;
  80882. /** Defines that alpha blending is SRC * DEST */
  80883. static readonly ALPHA_MULTIPLY: number;
  80884. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80885. static readonly ALPHA_MAXIMIZED: number;
  80886. /** Defines that alpha blending is SRC + DEST */
  80887. static readonly ALPHA_ONEONE: number;
  80888. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80889. static readonly ALPHA_PREMULTIPLIED: number;
  80890. /**
  80891. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80892. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80893. */
  80894. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80895. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80896. static readonly ALPHA_INTERPOLATE: number;
  80897. /**
  80898. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80899. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80900. */
  80901. static readonly ALPHA_SCREENMODE: number;
  80902. /**
  80903. * Defines that alpha blending is SRC + DST
  80904. * Alpha will be set to SRC ALPHA + DST ALPHA
  80905. */
  80906. static readonly ALPHA_ONEONE_ONEONE: number;
  80907. /**
  80908. * Defines that alpha blending is SRC * DST ALPHA + DST
  80909. * Alpha will be set to 0
  80910. */
  80911. static readonly ALPHA_ALPHATOCOLOR: number;
  80912. /**
  80913. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80914. */
  80915. static readonly ALPHA_REVERSEONEMINUS: number;
  80916. /**
  80917. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80918. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80919. */
  80920. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80921. /**
  80922. * Defines that alpha blending is SRC + DST
  80923. * Alpha will be set to SRC ALPHA
  80924. */
  80925. static readonly ALPHA_ONEONE_ONEZERO: number;
  80926. /**
  80927. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80928. * Alpha will be set to DST ALPHA
  80929. */
  80930. static readonly ALPHA_EXCLUSION: number;
  80931. /** Defines that alpha blending equation a SUM */
  80932. static readonly ALPHA_EQUATION_ADD: number;
  80933. /** Defines that alpha blending equation a SUBSTRACTION */
  80934. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80935. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80936. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80937. /** Defines that alpha blending equation a MAX operation */
  80938. static readonly ALPHA_EQUATION_MAX: number;
  80939. /** Defines that alpha blending equation a MIN operation */
  80940. static readonly ALPHA_EQUATION_MIN: number;
  80941. /**
  80942. * Defines that alpha blending equation a DARKEN operation:
  80943. * It takes the min of the src and sums the alpha channels.
  80944. */
  80945. static readonly ALPHA_EQUATION_DARKEN: number;
  80946. /** Defines that the ressource is not delayed*/
  80947. static readonly DELAYLOADSTATE_NONE: number;
  80948. /** Defines that the ressource was successfully delay loaded */
  80949. static readonly DELAYLOADSTATE_LOADED: number;
  80950. /** Defines that the ressource is currently delay loading */
  80951. static readonly DELAYLOADSTATE_LOADING: number;
  80952. /** Defines that the ressource is delayed and has not started loading */
  80953. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80955. static readonly NEVER: number;
  80956. /** 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 */
  80957. static readonly ALWAYS: number;
  80958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80959. static readonly LESS: number;
  80960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80961. static readonly EQUAL: number;
  80962. /** 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 */
  80963. static readonly LEQUAL: number;
  80964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80965. static readonly GREATER: number;
  80966. /** 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 */
  80967. static readonly GEQUAL: number;
  80968. /** 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 */
  80969. static readonly NOTEQUAL: number;
  80970. /** Passed to stencilOperation to specify that stencil value must be kept */
  80971. static readonly KEEP: number;
  80972. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80973. static readonly REPLACE: number;
  80974. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80975. static readonly INCR: number;
  80976. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80977. static readonly DECR: number;
  80978. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80979. static readonly INVERT: number;
  80980. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80981. static readonly INCR_WRAP: number;
  80982. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80983. static readonly DECR_WRAP: number;
  80984. /** Texture is not repeating outside of 0..1 UVs */
  80985. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80986. /** Texture is repeating outside of 0..1 UVs */
  80987. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80988. /** Texture is repeating and mirrored */
  80989. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80990. /** ALPHA */
  80991. static readonly TEXTUREFORMAT_ALPHA: number;
  80992. /** LUMINANCE */
  80993. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80994. /** LUMINANCE_ALPHA */
  80995. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80996. /** RGB */
  80997. static readonly TEXTUREFORMAT_RGB: number;
  80998. /** RGBA */
  80999. static readonly TEXTUREFORMAT_RGBA: number;
  81000. /** RED */
  81001. static readonly TEXTUREFORMAT_RED: number;
  81002. /** RED (2nd reference) */
  81003. static readonly TEXTUREFORMAT_R: number;
  81004. /** RG */
  81005. static readonly TEXTUREFORMAT_RG: number;
  81006. /** RED_INTEGER */
  81007. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81008. /** RED_INTEGER (2nd reference) */
  81009. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81010. /** RG_INTEGER */
  81011. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81012. /** RGB_INTEGER */
  81013. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81014. /** RGBA_INTEGER */
  81015. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81016. /** UNSIGNED_BYTE */
  81017. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81018. /** UNSIGNED_BYTE (2nd reference) */
  81019. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81020. /** FLOAT */
  81021. static readonly TEXTURETYPE_FLOAT: number;
  81022. /** HALF_FLOAT */
  81023. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81024. /** BYTE */
  81025. static readonly TEXTURETYPE_BYTE: number;
  81026. /** SHORT */
  81027. static readonly TEXTURETYPE_SHORT: number;
  81028. /** UNSIGNED_SHORT */
  81029. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81030. /** INT */
  81031. static readonly TEXTURETYPE_INT: number;
  81032. /** UNSIGNED_INT */
  81033. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81034. /** UNSIGNED_SHORT_4_4_4_4 */
  81035. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81036. /** UNSIGNED_SHORT_5_5_5_1 */
  81037. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81038. /** UNSIGNED_SHORT_5_6_5 */
  81039. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81040. /** UNSIGNED_INT_2_10_10_10_REV */
  81041. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81042. /** UNSIGNED_INT_24_8 */
  81043. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81044. /** UNSIGNED_INT_10F_11F_11F_REV */
  81045. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81046. /** UNSIGNED_INT_5_9_9_9_REV */
  81047. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81048. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81049. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81050. /** nearest is mag = nearest and min = nearest and no mip */
  81051. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81052. /** mag = nearest and min = nearest and mip = none */
  81053. static readonly TEXTURE_NEAREST_NEAREST: number;
  81054. /** Bilinear is mag = linear and min = linear and no mip */
  81055. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81056. /** mag = linear and min = linear and mip = none */
  81057. static readonly TEXTURE_LINEAR_LINEAR: number;
  81058. /** Trilinear is mag = linear and min = linear and mip = linear */
  81059. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81060. /** Trilinear is mag = linear and min = linear and mip = linear */
  81061. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81062. /** mag = nearest and min = nearest and mip = nearest */
  81063. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81064. /** mag = nearest and min = linear and mip = nearest */
  81065. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81066. /** mag = nearest and min = linear and mip = linear */
  81067. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81068. /** mag = nearest and min = linear and mip = none */
  81069. static readonly TEXTURE_NEAREST_LINEAR: number;
  81070. /** nearest is mag = nearest and min = nearest and mip = linear */
  81071. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81072. /** mag = linear and min = nearest and mip = nearest */
  81073. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81074. /** mag = linear and min = nearest and mip = linear */
  81075. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81077. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81078. /** mag = linear and min = nearest and mip = none */
  81079. static readonly TEXTURE_LINEAR_NEAREST: number;
  81080. /** Explicit coordinates mode */
  81081. static readonly TEXTURE_EXPLICIT_MODE: number;
  81082. /** Spherical coordinates mode */
  81083. static readonly TEXTURE_SPHERICAL_MODE: number;
  81084. /** Planar coordinates mode */
  81085. static readonly TEXTURE_PLANAR_MODE: number;
  81086. /** Cubic coordinates mode */
  81087. static readonly TEXTURE_CUBIC_MODE: number;
  81088. /** Projection coordinates mode */
  81089. static readonly TEXTURE_PROJECTION_MODE: number;
  81090. /** Skybox coordinates mode */
  81091. static readonly TEXTURE_SKYBOX_MODE: number;
  81092. /** Inverse Cubic coordinates mode */
  81093. static readonly TEXTURE_INVCUBIC_MODE: number;
  81094. /** Equirectangular coordinates mode */
  81095. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81096. /** Equirectangular Fixed coordinates mode */
  81097. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81098. /** Equirectangular Fixed Mirrored coordinates mode */
  81099. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81100. /** Offline (baking) quality for texture filtering */
  81101. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81102. /** High quality for texture filtering */
  81103. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81104. /** Medium quality for texture filtering */
  81105. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81106. /** Low quality for texture filtering */
  81107. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81108. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81109. static readonly SCALEMODE_FLOOR: number;
  81110. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81111. static readonly SCALEMODE_NEAREST: number;
  81112. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81113. static readonly SCALEMODE_CEILING: number;
  81114. /**
  81115. * The dirty texture flag value
  81116. */
  81117. static readonly MATERIAL_TextureDirtyFlag: number;
  81118. /**
  81119. * The dirty light flag value
  81120. */
  81121. static readonly MATERIAL_LightDirtyFlag: number;
  81122. /**
  81123. * The dirty fresnel flag value
  81124. */
  81125. static readonly MATERIAL_FresnelDirtyFlag: number;
  81126. /**
  81127. * The dirty attribute flag value
  81128. */
  81129. static readonly MATERIAL_AttributesDirtyFlag: number;
  81130. /**
  81131. * The dirty misc flag value
  81132. */
  81133. static readonly MATERIAL_MiscDirtyFlag: number;
  81134. /**
  81135. * The all dirty flag value
  81136. */
  81137. static readonly MATERIAL_AllDirtyFlag: number;
  81138. /**
  81139. * Returns the triangle fill mode
  81140. */
  81141. static readonly MATERIAL_TriangleFillMode: number;
  81142. /**
  81143. * Returns the wireframe mode
  81144. */
  81145. static readonly MATERIAL_WireFrameFillMode: number;
  81146. /**
  81147. * Returns the point fill mode
  81148. */
  81149. static readonly MATERIAL_PointFillMode: number;
  81150. /**
  81151. * Returns the point list draw mode
  81152. */
  81153. static readonly MATERIAL_PointListDrawMode: number;
  81154. /**
  81155. * Returns the line list draw mode
  81156. */
  81157. static readonly MATERIAL_LineListDrawMode: number;
  81158. /**
  81159. * Returns the line loop draw mode
  81160. */
  81161. static readonly MATERIAL_LineLoopDrawMode: number;
  81162. /**
  81163. * Returns the line strip draw mode
  81164. */
  81165. static readonly MATERIAL_LineStripDrawMode: number;
  81166. /**
  81167. * Returns the triangle strip draw mode
  81168. */
  81169. static readonly MATERIAL_TriangleStripDrawMode: number;
  81170. /**
  81171. * Returns the triangle fan draw mode
  81172. */
  81173. static readonly MATERIAL_TriangleFanDrawMode: number;
  81174. /**
  81175. * Stores the clock-wise side orientation
  81176. */
  81177. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81178. /**
  81179. * Stores the counter clock-wise side orientation
  81180. */
  81181. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81182. /**
  81183. * Nothing
  81184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81185. */
  81186. static readonly ACTION_NothingTrigger: number;
  81187. /**
  81188. * On pick
  81189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81190. */
  81191. static readonly ACTION_OnPickTrigger: number;
  81192. /**
  81193. * On left pick
  81194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81195. */
  81196. static readonly ACTION_OnLeftPickTrigger: number;
  81197. /**
  81198. * On right pick
  81199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81200. */
  81201. static readonly ACTION_OnRightPickTrigger: number;
  81202. /**
  81203. * On center pick
  81204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81205. */
  81206. static readonly ACTION_OnCenterPickTrigger: number;
  81207. /**
  81208. * On pick down
  81209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81210. */
  81211. static readonly ACTION_OnPickDownTrigger: number;
  81212. /**
  81213. * On double pick
  81214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81215. */
  81216. static readonly ACTION_OnDoublePickTrigger: number;
  81217. /**
  81218. * On pick up
  81219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81220. */
  81221. static readonly ACTION_OnPickUpTrigger: number;
  81222. /**
  81223. * On pick out.
  81224. * This trigger will only be raised if you also declared a OnPickDown
  81225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81226. */
  81227. static readonly ACTION_OnPickOutTrigger: number;
  81228. /**
  81229. * On long press
  81230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81231. */
  81232. static readonly ACTION_OnLongPressTrigger: number;
  81233. /**
  81234. * On pointer over
  81235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81236. */
  81237. static readonly ACTION_OnPointerOverTrigger: number;
  81238. /**
  81239. * On pointer out
  81240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81241. */
  81242. static readonly ACTION_OnPointerOutTrigger: number;
  81243. /**
  81244. * On every frame
  81245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81246. */
  81247. static readonly ACTION_OnEveryFrameTrigger: number;
  81248. /**
  81249. * On intersection enter
  81250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81251. */
  81252. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81253. /**
  81254. * On intersection exit
  81255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81256. */
  81257. static readonly ACTION_OnIntersectionExitTrigger: number;
  81258. /**
  81259. * On key down
  81260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81261. */
  81262. static readonly ACTION_OnKeyDownTrigger: number;
  81263. /**
  81264. * On key up
  81265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81266. */
  81267. static readonly ACTION_OnKeyUpTrigger: number;
  81268. /**
  81269. * Billboard mode will only apply to Y axis
  81270. */
  81271. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81272. /**
  81273. * Billboard mode will apply to all axes
  81274. */
  81275. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81276. /**
  81277. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81278. */
  81279. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81280. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81281. * Test order :
  81282. * Is the bounding sphere outside the frustum ?
  81283. * If not, are the bounding box vertices outside the frustum ?
  81284. * It not, then the cullable object is in the frustum.
  81285. */
  81286. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81287. /** Culling strategy : Bounding Sphere Only.
  81288. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81289. * It's also less accurate than the standard because some not visible objects can still be selected.
  81290. * Test : is the bounding sphere outside the frustum ?
  81291. * If not, then the cullable object is in the frustum.
  81292. */
  81293. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81294. /** Culling strategy : Optimistic Inclusion.
  81295. * This in an inclusion test first, then the standard exclusion test.
  81296. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81297. * 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.
  81298. * Anyway, it's as accurate as the standard strategy.
  81299. * Test :
  81300. * Is the cullable object bounding sphere center in the frustum ?
  81301. * If not, apply the default culling strategy.
  81302. */
  81303. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81304. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81305. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81306. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81307. * 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.
  81308. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81309. * Test :
  81310. * Is the cullable object bounding sphere center in the frustum ?
  81311. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81312. */
  81313. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81314. /**
  81315. * No logging while loading
  81316. */
  81317. static readonly SCENELOADER_NO_LOGGING: number;
  81318. /**
  81319. * Minimal logging while loading
  81320. */
  81321. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81322. /**
  81323. * Summary logging while loading
  81324. */
  81325. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81326. /**
  81327. * Detailled logging while loading
  81328. */
  81329. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81330. /**
  81331. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81332. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81333. */
  81334. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81335. /**
  81336. * Constant used to retrieve the position texture index in the textures array in the prepass
  81337. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81338. */
  81339. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81340. /**
  81341. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81342. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81343. */
  81344. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81345. /**
  81346. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81347. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81348. */
  81349. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81350. /**
  81351. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81352. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81353. */
  81354. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81355. /**
  81356. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81357. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81358. */
  81359. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81360. /**
  81361. * Constant used to retrieve albedo index in the textures array in the prepass
  81362. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81363. */
  81364. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81365. }
  81366. }
  81367. declare module BABYLON {
  81368. /**
  81369. * This represents the required contract to create a new type of texture loader.
  81370. */
  81371. export interface IInternalTextureLoader {
  81372. /**
  81373. * Defines wether the loader supports cascade loading the different faces.
  81374. */
  81375. supportCascades: boolean;
  81376. /**
  81377. * This returns if the loader support the current file information.
  81378. * @param extension defines the file extension of the file being loaded
  81379. * @param mimeType defines the optional mime type of the file being loaded
  81380. * @returns true if the loader can load the specified file
  81381. */
  81382. canLoad(extension: string, mimeType?: string): boolean;
  81383. /**
  81384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81385. * @param data contains the texture data
  81386. * @param texture defines the BabylonJS internal texture
  81387. * @param createPolynomials will be true if polynomials have been requested
  81388. * @param onLoad defines the callback to trigger once the texture is ready
  81389. * @param onError defines the callback to trigger in case of error
  81390. */
  81391. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81392. /**
  81393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81394. * @param data contains the texture data
  81395. * @param texture defines the BabylonJS internal texture
  81396. * @param callback defines the method to call once ready to upload
  81397. */
  81398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81399. }
  81400. }
  81401. declare module BABYLON {
  81402. /**
  81403. * Class used to store and describe the pipeline context associated with an effect
  81404. */
  81405. export interface IPipelineContext {
  81406. /**
  81407. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81408. */
  81409. isAsync: boolean;
  81410. /**
  81411. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81412. */
  81413. isReady: boolean;
  81414. /** @hidden */
  81415. _getVertexShaderCode(): string | null;
  81416. /** @hidden */
  81417. _getFragmentShaderCode(): string | null;
  81418. /** @hidden */
  81419. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81420. }
  81421. }
  81422. declare module BABYLON {
  81423. /**
  81424. * Class used to store gfx data (like WebGLBuffer)
  81425. */
  81426. export class DataBuffer {
  81427. /**
  81428. * Gets or sets the number of objects referencing this buffer
  81429. */
  81430. references: number;
  81431. /** Gets or sets the size of the underlying buffer */
  81432. capacity: number;
  81433. /**
  81434. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81435. */
  81436. is32Bits: boolean;
  81437. /**
  81438. * Gets the underlying buffer
  81439. */
  81440. get underlyingResource(): any;
  81441. }
  81442. }
  81443. declare module BABYLON {
  81444. /** @hidden */
  81445. export interface IShaderProcessor {
  81446. attributeProcessor?: (attribute: string) => string;
  81447. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81448. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81449. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81450. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81451. lineProcessor?: (line: string, isFragment: boolean) => string;
  81452. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81453. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81454. }
  81455. }
  81456. declare module BABYLON {
  81457. /** @hidden */
  81458. export interface ProcessingOptions {
  81459. defines: string[];
  81460. indexParameters: any;
  81461. isFragment: boolean;
  81462. shouldUseHighPrecisionShader: boolean;
  81463. supportsUniformBuffers: boolean;
  81464. shadersRepository: string;
  81465. includesShadersStore: {
  81466. [key: string]: string;
  81467. };
  81468. processor?: IShaderProcessor;
  81469. version: string;
  81470. platformName: string;
  81471. lookForClosingBracketForUniformBuffer?: boolean;
  81472. }
  81473. }
  81474. declare module BABYLON {
  81475. /** @hidden */
  81476. export class ShaderCodeNode {
  81477. line: string;
  81478. children: ShaderCodeNode[];
  81479. additionalDefineKey?: string;
  81480. additionalDefineValue?: string;
  81481. isValid(preprocessors: {
  81482. [key: string]: string;
  81483. }): boolean;
  81484. process(preprocessors: {
  81485. [key: string]: string;
  81486. }, options: ProcessingOptions): string;
  81487. }
  81488. }
  81489. declare module BABYLON {
  81490. /** @hidden */
  81491. export class ShaderCodeCursor {
  81492. private _lines;
  81493. lineIndex: number;
  81494. get currentLine(): string;
  81495. get canRead(): boolean;
  81496. set lines(value: string[]);
  81497. }
  81498. }
  81499. declare module BABYLON {
  81500. /** @hidden */
  81501. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81502. process(preprocessors: {
  81503. [key: string]: string;
  81504. }, options: ProcessingOptions): string;
  81505. }
  81506. }
  81507. declare module BABYLON {
  81508. /** @hidden */
  81509. export class ShaderDefineExpression {
  81510. isTrue(preprocessors: {
  81511. [key: string]: string;
  81512. }): boolean;
  81513. private static _OperatorPriority;
  81514. private static _Stack;
  81515. static postfixToInfix(postfix: string[]): string;
  81516. static infixToPostfix(infix: string): string[];
  81517. }
  81518. }
  81519. declare module BABYLON {
  81520. /** @hidden */
  81521. export class ShaderCodeTestNode extends ShaderCodeNode {
  81522. testExpression: ShaderDefineExpression;
  81523. isValid(preprocessors: {
  81524. [key: string]: string;
  81525. }): boolean;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /** @hidden */
  81530. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81531. define: string;
  81532. not: boolean;
  81533. constructor(define: string, not?: boolean);
  81534. isTrue(preprocessors: {
  81535. [key: string]: string;
  81536. }): boolean;
  81537. }
  81538. }
  81539. declare module BABYLON {
  81540. /** @hidden */
  81541. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81542. leftOperand: ShaderDefineExpression;
  81543. rightOperand: ShaderDefineExpression;
  81544. isTrue(preprocessors: {
  81545. [key: string]: string;
  81546. }): boolean;
  81547. }
  81548. }
  81549. declare module BABYLON {
  81550. /** @hidden */
  81551. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81552. leftOperand: ShaderDefineExpression;
  81553. rightOperand: ShaderDefineExpression;
  81554. isTrue(preprocessors: {
  81555. [key: string]: string;
  81556. }): boolean;
  81557. }
  81558. }
  81559. declare module BABYLON {
  81560. /** @hidden */
  81561. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81562. define: string;
  81563. operand: string;
  81564. testValue: string;
  81565. constructor(define: string, operand: string, testValue: string);
  81566. isTrue(preprocessors: {
  81567. [key: string]: string;
  81568. }): boolean;
  81569. }
  81570. }
  81571. declare module BABYLON {
  81572. /**
  81573. * Class used to enable access to offline support
  81574. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81575. */
  81576. export interface IOfflineProvider {
  81577. /**
  81578. * Gets a boolean indicating if scene must be saved in the database
  81579. */
  81580. enableSceneOffline: boolean;
  81581. /**
  81582. * Gets a boolean indicating if textures must be saved in the database
  81583. */
  81584. enableTexturesOffline: boolean;
  81585. /**
  81586. * Open the offline support and make it available
  81587. * @param successCallback defines the callback to call on success
  81588. * @param errorCallback defines the callback to call on error
  81589. */
  81590. open(successCallback: () => void, errorCallback: () => void): void;
  81591. /**
  81592. * Loads an image from the offline support
  81593. * @param url defines the url to load from
  81594. * @param image defines the target DOM image
  81595. */
  81596. loadImage(url: string, image: HTMLImageElement): void;
  81597. /**
  81598. * Loads a file from offline support
  81599. * @param url defines the URL to load from
  81600. * @param sceneLoaded defines a callback to call on success
  81601. * @param progressCallBack defines a callback to call when progress changed
  81602. * @param errorCallback defines a callback to call on error
  81603. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81604. */
  81605. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81606. }
  81607. }
  81608. declare module BABYLON {
  81609. /**
  81610. * Class used to help managing file picking and drag'n'drop
  81611. * File Storage
  81612. */
  81613. export class FilesInputStore {
  81614. /**
  81615. * List of files ready to be loaded
  81616. */
  81617. static FilesToLoad: {
  81618. [key: string]: File;
  81619. };
  81620. }
  81621. }
  81622. declare module BABYLON {
  81623. /**
  81624. * Class used to define a retry strategy when error happens while loading assets
  81625. */
  81626. export class RetryStrategy {
  81627. /**
  81628. * Function used to defines an exponential back off strategy
  81629. * @param maxRetries defines the maximum number of retries (3 by default)
  81630. * @param baseInterval defines the interval between retries
  81631. * @returns the strategy function to use
  81632. */
  81633. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81634. }
  81635. }
  81636. declare module BABYLON {
  81637. /**
  81638. * @ignore
  81639. * Application error to support additional information when loading a file
  81640. */
  81641. export abstract class BaseError extends Error {
  81642. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81643. }
  81644. }
  81645. declare module BABYLON {
  81646. /** @ignore */
  81647. export class LoadFileError extends BaseError {
  81648. request?: WebRequest;
  81649. file?: File;
  81650. /**
  81651. * Creates a new LoadFileError
  81652. * @param message defines the message of the error
  81653. * @param request defines the optional web request
  81654. * @param file defines the optional file
  81655. */
  81656. constructor(message: string, object?: WebRequest | File);
  81657. }
  81658. /** @ignore */
  81659. export class RequestFileError extends BaseError {
  81660. request: WebRequest;
  81661. /**
  81662. * Creates a new LoadFileError
  81663. * @param message defines the message of the error
  81664. * @param request defines the optional web request
  81665. */
  81666. constructor(message: string, request: WebRequest);
  81667. }
  81668. /** @ignore */
  81669. export class ReadFileError extends BaseError {
  81670. file: File;
  81671. /**
  81672. * Creates a new ReadFileError
  81673. * @param message defines the message of the error
  81674. * @param file defines the optional file
  81675. */
  81676. constructor(message: string, file: File);
  81677. }
  81678. /**
  81679. * @hidden
  81680. */
  81681. export class FileTools {
  81682. /**
  81683. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81684. */
  81685. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81686. /**
  81687. * Gets or sets the base URL to use to load assets
  81688. */
  81689. static BaseUrl: string;
  81690. /**
  81691. * Default behaviour for cors in the application.
  81692. * It can be a string if the expected behavior is identical in the entire app.
  81693. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81694. */
  81695. static CorsBehavior: string | ((url: string | string[]) => string);
  81696. /**
  81697. * Gets or sets a function used to pre-process url before using them to load assets
  81698. */
  81699. static PreprocessUrl: (url: string) => string;
  81700. /**
  81701. * Removes unwanted characters from an url
  81702. * @param url defines the url to clean
  81703. * @returns the cleaned url
  81704. */
  81705. private static _CleanUrl;
  81706. /**
  81707. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81708. * @param url define the url we are trying
  81709. * @param element define the dom element where to configure the cors policy
  81710. */
  81711. static SetCorsBehavior(url: string | string[], element: {
  81712. crossOrigin: string | null;
  81713. }): void;
  81714. /**
  81715. * Loads an image as an HTMLImageElement.
  81716. * @param input url string, ArrayBuffer, or Blob to load
  81717. * @param onLoad callback called when the image successfully loads
  81718. * @param onError callback called when the image fails to load
  81719. * @param offlineProvider offline provider for caching
  81720. * @param mimeType optional mime type
  81721. * @returns the HTMLImageElement of the loaded image
  81722. */
  81723. 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>;
  81724. /**
  81725. * Reads a file from a File object
  81726. * @param file defines the file to load
  81727. * @param onSuccess defines the callback to call when data is loaded
  81728. * @param onProgress defines the callback to call during loading process
  81729. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81730. * @param onError defines the callback to call when an error occurs
  81731. * @returns a file request object
  81732. */
  81733. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81734. /**
  81735. * Loads a file from a url
  81736. * @param url url to load
  81737. * @param onSuccess callback called when the file successfully loads
  81738. * @param onProgress callback called while file is loading (if the server supports this mode)
  81739. * @param offlineProvider defines the offline provider for caching
  81740. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81741. * @param onError callback called when the file fails to load
  81742. * @returns a file request object
  81743. */
  81744. 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;
  81745. /**
  81746. * Loads a file
  81747. * @param url url to load
  81748. * @param onSuccess callback called when the file successfully loads
  81749. * @param onProgress callback called while file is loading (if the server supports this mode)
  81750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81751. * @param onError callback called when the file fails to load
  81752. * @param onOpened callback called when the web request is opened
  81753. * @returns a file request object
  81754. */
  81755. 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;
  81756. /**
  81757. * Checks if the loaded document was accessed via `file:`-Protocol.
  81758. * @returns boolean
  81759. */
  81760. static IsFileURL(): boolean;
  81761. }
  81762. }
  81763. declare module BABYLON {
  81764. /** @hidden */
  81765. export class ShaderProcessor {
  81766. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81767. private static _ProcessPrecision;
  81768. private static _ExtractOperation;
  81769. private static _BuildSubExpression;
  81770. private static _BuildExpression;
  81771. private static _MoveCursorWithinIf;
  81772. private static _MoveCursor;
  81773. private static _EvaluatePreProcessors;
  81774. private static _PreparePreProcessors;
  81775. private static _ProcessShaderConversion;
  81776. private static _ProcessIncludes;
  81777. /**
  81778. * Loads a file from a url
  81779. * @param url url to load
  81780. * @param onSuccess callback called when the file successfully loads
  81781. * @param onProgress callback called while file is loading (if the server supports this mode)
  81782. * @param offlineProvider defines the offline provider for caching
  81783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81784. * @param onError callback called when the file fails to load
  81785. * @returns a file request object
  81786. * @hidden
  81787. */
  81788. 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;
  81789. }
  81790. }
  81791. declare module BABYLON {
  81792. /**
  81793. * @hidden
  81794. */
  81795. export interface IColor4Like {
  81796. r: float;
  81797. g: float;
  81798. b: float;
  81799. a: float;
  81800. }
  81801. /**
  81802. * @hidden
  81803. */
  81804. export interface IColor3Like {
  81805. r: float;
  81806. g: float;
  81807. b: float;
  81808. }
  81809. /**
  81810. * @hidden
  81811. */
  81812. export interface IVector4Like {
  81813. x: float;
  81814. y: float;
  81815. z: float;
  81816. w: float;
  81817. }
  81818. /**
  81819. * @hidden
  81820. */
  81821. export interface IVector3Like {
  81822. x: float;
  81823. y: float;
  81824. z: float;
  81825. }
  81826. /**
  81827. * @hidden
  81828. */
  81829. export interface IVector2Like {
  81830. x: float;
  81831. y: float;
  81832. }
  81833. /**
  81834. * @hidden
  81835. */
  81836. export interface IMatrixLike {
  81837. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81838. updateFlag: int;
  81839. }
  81840. /**
  81841. * @hidden
  81842. */
  81843. export interface IViewportLike {
  81844. x: float;
  81845. y: float;
  81846. width: float;
  81847. height: float;
  81848. }
  81849. /**
  81850. * @hidden
  81851. */
  81852. export interface IPlaneLike {
  81853. normal: IVector3Like;
  81854. d: float;
  81855. normalize(): void;
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * Interface used to define common properties for effect fallbacks
  81861. */
  81862. export interface IEffectFallbacks {
  81863. /**
  81864. * Removes the defines that should be removed when falling back.
  81865. * @param currentDefines defines the current define statements for the shader.
  81866. * @param effect defines the current effect we try to compile
  81867. * @returns The resulting defines with defines of the current rank removed.
  81868. */
  81869. reduce(currentDefines: string, effect: Effect): string;
  81870. /**
  81871. * Removes the fallback from the bound mesh.
  81872. */
  81873. unBindMesh(): void;
  81874. /**
  81875. * Checks to see if more fallbacks are still availible.
  81876. */
  81877. hasMoreFallbacks: boolean;
  81878. }
  81879. }
  81880. declare module BABYLON {
  81881. /**
  81882. * Class used to evalaute queries containing `and` and `or` operators
  81883. */
  81884. export class AndOrNotEvaluator {
  81885. /**
  81886. * Evaluate a query
  81887. * @param query defines the query to evaluate
  81888. * @param evaluateCallback defines the callback used to filter result
  81889. * @returns true if the query matches
  81890. */
  81891. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81892. private static _HandleParenthesisContent;
  81893. private static _SimplifyNegation;
  81894. }
  81895. }
  81896. declare module BABYLON {
  81897. /**
  81898. * Class used to store custom tags
  81899. */
  81900. export class Tags {
  81901. /**
  81902. * Adds support for tags on the given object
  81903. * @param obj defines the object to use
  81904. */
  81905. static EnableFor(obj: any): void;
  81906. /**
  81907. * Removes tags support
  81908. * @param obj defines the object to use
  81909. */
  81910. static DisableFor(obj: any): void;
  81911. /**
  81912. * Gets a boolean indicating if the given object has tags
  81913. * @param obj defines the object to use
  81914. * @returns a boolean
  81915. */
  81916. static HasTags(obj: any): boolean;
  81917. /**
  81918. * Gets the tags available on a given object
  81919. * @param obj defines the object to use
  81920. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81921. * @returns the tags
  81922. */
  81923. static GetTags(obj: any, asString?: boolean): any;
  81924. /**
  81925. * Adds tags to an object
  81926. * @param obj defines the object to use
  81927. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81928. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81929. */
  81930. static AddTagsTo(obj: any, tagsString: string): void;
  81931. /**
  81932. * @hidden
  81933. */
  81934. static _AddTagTo(obj: any, tag: string): void;
  81935. /**
  81936. * Removes specific tags from a specific object
  81937. * @param obj defines the object to use
  81938. * @param tagsString defines the tags to remove
  81939. */
  81940. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81941. /**
  81942. * @hidden
  81943. */
  81944. static _RemoveTagFrom(obj: any, tag: string): void;
  81945. /**
  81946. * Defines if tags hosted on an object match a given query
  81947. * @param obj defines the object to use
  81948. * @param tagsQuery defines the tag query
  81949. * @returns a boolean
  81950. */
  81951. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81952. }
  81953. }
  81954. declare module BABYLON {
  81955. /**
  81956. * Scalar computation library
  81957. */
  81958. export class Scalar {
  81959. /**
  81960. * Two pi constants convenient for computation.
  81961. */
  81962. static TwoPi: number;
  81963. /**
  81964. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81965. * @param a number
  81966. * @param b number
  81967. * @param epsilon (default = 1.401298E-45)
  81968. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81969. */
  81970. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81971. /**
  81972. * Returns a string : the upper case translation of the number i to hexadecimal.
  81973. * @param i number
  81974. * @returns the upper case translation of the number i to hexadecimal.
  81975. */
  81976. static ToHex(i: number): string;
  81977. /**
  81978. * Returns -1 if value is negative and +1 is value is positive.
  81979. * @param value the value
  81980. * @returns the value itself if it's equal to zero.
  81981. */
  81982. static Sign(value: number): number;
  81983. /**
  81984. * Returns the value itself if it's between min and max.
  81985. * Returns min if the value is lower than min.
  81986. * Returns max if the value is greater than max.
  81987. * @param value the value to clmap
  81988. * @param min the min value to clamp to (default: 0)
  81989. * @param max the max value to clamp to (default: 1)
  81990. * @returns the clamped value
  81991. */
  81992. static Clamp(value: number, min?: number, max?: number): number;
  81993. /**
  81994. * the log2 of value.
  81995. * @param value the value to compute log2 of
  81996. * @returns the log2 of value.
  81997. */
  81998. static Log2(value: number): number;
  81999. /**
  82000. * Loops the value, so that it is never larger than length and never smaller than 0.
  82001. *
  82002. * This is similar to the modulo operator but it works with floating point numbers.
  82003. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82004. * With t = 5 and length = 2.5, the result would be 0.0.
  82005. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82006. * @param value the value
  82007. * @param length the length
  82008. * @returns the looped value
  82009. */
  82010. static Repeat(value: number, length: number): number;
  82011. /**
  82012. * Normalize the value between 0.0 and 1.0 using min and max values
  82013. * @param value value to normalize
  82014. * @param min max to normalize between
  82015. * @param max min to normalize between
  82016. * @returns the normalized value
  82017. */
  82018. static Normalize(value: number, min: number, max: number): number;
  82019. /**
  82020. * Denormalize the value from 0.0 and 1.0 using min and max values
  82021. * @param normalized value to denormalize
  82022. * @param min max to denormalize between
  82023. * @param max min to denormalize between
  82024. * @returns the denormalized value
  82025. */
  82026. static Denormalize(normalized: number, min: number, max: number): number;
  82027. /**
  82028. * Calculates the shortest difference between two given angles given in degrees.
  82029. * @param current current angle in degrees
  82030. * @param target target angle in degrees
  82031. * @returns the delta
  82032. */
  82033. static DeltaAngle(current: number, target: number): number;
  82034. /**
  82035. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82036. * @param tx value
  82037. * @param length length
  82038. * @returns The returned value will move back and forth between 0 and length
  82039. */
  82040. static PingPong(tx: number, length: number): number;
  82041. /**
  82042. * Interpolates between min and max with smoothing at the limits.
  82043. *
  82044. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82045. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82046. * @param from from
  82047. * @param to to
  82048. * @param tx value
  82049. * @returns the smooth stepped value
  82050. */
  82051. static SmoothStep(from: number, to: number, tx: number): number;
  82052. /**
  82053. * Moves a value current towards target.
  82054. *
  82055. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82056. * Negative values of maxDelta pushes the value away from target.
  82057. * @param current current value
  82058. * @param target target value
  82059. * @param maxDelta max distance to move
  82060. * @returns resulting value
  82061. */
  82062. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82063. /**
  82064. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82065. *
  82066. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82067. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82068. * @param current current value
  82069. * @param target target value
  82070. * @param maxDelta max distance to move
  82071. * @returns resulting angle
  82072. */
  82073. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82074. /**
  82075. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82076. * @param start start value
  82077. * @param end target value
  82078. * @param amount amount to lerp between
  82079. * @returns the lerped value
  82080. */
  82081. static Lerp(start: number, end: number, amount: number): number;
  82082. /**
  82083. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82084. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82085. * @param start start value
  82086. * @param end target value
  82087. * @param amount amount to lerp between
  82088. * @returns the lerped value
  82089. */
  82090. static LerpAngle(start: number, end: number, amount: number): number;
  82091. /**
  82092. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82093. * @param a start value
  82094. * @param b target value
  82095. * @param value value between a and b
  82096. * @returns the inverseLerp value
  82097. */
  82098. static InverseLerp(a: number, b: number, value: number): number;
  82099. /**
  82100. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82101. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82102. * @param value1 spline value
  82103. * @param tangent1 spline value
  82104. * @param value2 spline value
  82105. * @param tangent2 spline value
  82106. * @param amount input value
  82107. * @returns hermite result
  82108. */
  82109. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82110. /**
  82111. * Returns a random float number between and min and max values
  82112. * @param min min value of random
  82113. * @param max max value of random
  82114. * @returns random value
  82115. */
  82116. static RandomRange(min: number, max: number): number;
  82117. /**
  82118. * This function returns percentage of a number in a given range.
  82119. *
  82120. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82121. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82122. * @param number to convert to percentage
  82123. * @param min min range
  82124. * @param max max range
  82125. * @returns the percentage
  82126. */
  82127. static RangeToPercent(number: number, min: number, max: number): number;
  82128. /**
  82129. * This function returns number that corresponds to the percentage in a given range.
  82130. *
  82131. * PercentToRange(0.34,0,100) will return 34.
  82132. * @param percent to convert to number
  82133. * @param min min range
  82134. * @param max max range
  82135. * @returns the number
  82136. */
  82137. static PercentToRange(percent: number, min: number, max: number): number;
  82138. /**
  82139. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82140. * @param angle The angle to normalize in radian.
  82141. * @return The converted angle.
  82142. */
  82143. static NormalizeRadians(angle: number): number;
  82144. }
  82145. }
  82146. declare module BABYLON {
  82147. /**
  82148. * Constant used to convert a value to gamma space
  82149. * @ignorenaming
  82150. */
  82151. export const ToGammaSpace: number;
  82152. /**
  82153. * Constant used to convert a value to linear space
  82154. * @ignorenaming
  82155. */
  82156. export const ToLinearSpace = 2.2;
  82157. /**
  82158. * Constant used to define the minimal number value in Babylon.js
  82159. * @ignorenaming
  82160. */
  82161. let Epsilon: number;
  82162. }
  82163. declare module BABYLON {
  82164. /**
  82165. * Class used to represent a viewport on screen
  82166. */
  82167. export class Viewport {
  82168. /** viewport left coordinate */
  82169. x: number;
  82170. /** viewport top coordinate */
  82171. y: number;
  82172. /**viewport width */
  82173. width: number;
  82174. /** viewport height */
  82175. height: number;
  82176. /**
  82177. * Creates a Viewport object located at (x, y) and sized (width, height)
  82178. * @param x defines viewport left coordinate
  82179. * @param y defines viewport top coordinate
  82180. * @param width defines the viewport width
  82181. * @param height defines the viewport height
  82182. */
  82183. constructor(
  82184. /** viewport left coordinate */
  82185. x: number,
  82186. /** viewport top coordinate */
  82187. y: number,
  82188. /**viewport width */
  82189. width: number,
  82190. /** viewport height */
  82191. height: number);
  82192. /**
  82193. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82194. * @param renderWidth defines the rendering width
  82195. * @param renderHeight defines the rendering height
  82196. * @returns a new Viewport
  82197. */
  82198. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82199. /**
  82200. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82201. * @param renderWidth defines the rendering width
  82202. * @param renderHeight defines the rendering height
  82203. * @param ref defines the target viewport
  82204. * @returns the current viewport
  82205. */
  82206. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82207. /**
  82208. * Returns a new Viewport copied from the current one
  82209. * @returns a new Viewport
  82210. */
  82211. clone(): Viewport;
  82212. }
  82213. }
  82214. declare module BABYLON {
  82215. /**
  82216. * Class containing a set of static utilities functions for arrays.
  82217. */
  82218. export class ArrayTools {
  82219. /**
  82220. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82221. * @param size the number of element to construct and put in the array
  82222. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82223. * @returns a new array filled with new objects
  82224. */
  82225. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82226. }
  82227. }
  82228. declare module BABYLON {
  82229. /**
  82230. * Represents a plane by the equation ax + by + cz + d = 0
  82231. */
  82232. export class Plane {
  82233. private static _TmpMatrix;
  82234. /**
  82235. * Normal of the plane (a,b,c)
  82236. */
  82237. normal: Vector3;
  82238. /**
  82239. * d component of the plane
  82240. */
  82241. d: number;
  82242. /**
  82243. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82244. * @param a a component of the plane
  82245. * @param b b component of the plane
  82246. * @param c c component of the plane
  82247. * @param d d component of the plane
  82248. */
  82249. constructor(a: number, b: number, c: number, d: number);
  82250. /**
  82251. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82252. */
  82253. asArray(): number[];
  82254. /**
  82255. * @returns a new plane copied from the current Plane.
  82256. */
  82257. clone(): Plane;
  82258. /**
  82259. * @returns the string "Plane".
  82260. */
  82261. getClassName(): string;
  82262. /**
  82263. * @returns the Plane hash code.
  82264. */
  82265. getHashCode(): number;
  82266. /**
  82267. * Normalize the current Plane in place.
  82268. * @returns the updated Plane.
  82269. */
  82270. normalize(): Plane;
  82271. /**
  82272. * Applies a transformation the plane and returns the result
  82273. * @param transformation the transformation matrix to be applied to the plane
  82274. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82275. */
  82276. transform(transformation: DeepImmutable<Matrix>): Plane;
  82277. /**
  82278. * Compute the dot product between the point and the plane normal
  82279. * @param point point to calculate the dot product with
  82280. * @returns the dot product (float) of the point coordinates and the plane normal.
  82281. */
  82282. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82283. /**
  82284. * Updates the current Plane from the plane defined by the three given points.
  82285. * @param point1 one of the points used to contruct the plane
  82286. * @param point2 one of the points used to contruct the plane
  82287. * @param point3 one of the points used to contruct the plane
  82288. * @returns the updated Plane.
  82289. */
  82290. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82291. /**
  82292. * Checks if the plane is facing a given direction
  82293. * @param direction the direction to check if the plane is facing
  82294. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82295. * @returns True is the vector "direction" is the same side than the plane normal.
  82296. */
  82297. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82298. /**
  82299. * Calculates the distance to a point
  82300. * @param point point to calculate distance to
  82301. * @returns the signed distance (float) from the given point to the Plane.
  82302. */
  82303. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82304. /**
  82305. * Creates a plane from an array
  82306. * @param array the array to create a plane from
  82307. * @returns a new Plane from the given array.
  82308. */
  82309. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82310. /**
  82311. * Creates a plane from three points
  82312. * @param point1 point used to create the plane
  82313. * @param point2 point used to create the plane
  82314. * @param point3 point used to create the plane
  82315. * @returns a new Plane defined by the three given points.
  82316. */
  82317. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82318. /**
  82319. * Creates a plane from an origin point and a normal
  82320. * @param origin origin of the plane to be constructed
  82321. * @param normal normal of the plane to be constructed
  82322. * @returns a new Plane the normal vector to this plane at the given origin point.
  82323. * Note : the vector "normal" is updated because normalized.
  82324. */
  82325. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82326. /**
  82327. * Calculates the distance from a plane and a point
  82328. * @param origin origin of the plane to be constructed
  82329. * @param normal normal of the plane to be constructed
  82330. * @param point point to calculate distance to
  82331. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82332. */
  82333. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82334. }
  82335. }
  82336. declare module BABYLON {
  82337. /** @hidden */
  82338. export class PerformanceConfigurator {
  82339. /** @hidden */
  82340. static MatrixUse64Bits: boolean;
  82341. /** @hidden */
  82342. static MatrixTrackPrecisionChange: boolean;
  82343. /** @hidden */
  82344. static MatrixCurrentType: any;
  82345. /** @hidden */
  82346. static MatrixTrackedMatrices: Array<any> | null;
  82347. /** @hidden */
  82348. static SetMatrixPrecision(use64bits: boolean): void;
  82349. }
  82350. }
  82351. declare module BABYLON {
  82352. /**
  82353. * Class representing a vector containing 2 coordinates
  82354. */
  82355. export class Vector2 {
  82356. /** defines the first coordinate */
  82357. x: number;
  82358. /** defines the second coordinate */
  82359. y: number;
  82360. /**
  82361. * Creates a new Vector2 from the given x and y coordinates
  82362. * @param x defines the first coordinate
  82363. * @param y defines the second coordinate
  82364. */
  82365. constructor(
  82366. /** defines the first coordinate */
  82367. x?: number,
  82368. /** defines the second coordinate */
  82369. y?: number);
  82370. /**
  82371. * Gets a string with the Vector2 coordinates
  82372. * @returns a string with the Vector2 coordinates
  82373. */
  82374. toString(): string;
  82375. /**
  82376. * Gets class name
  82377. * @returns the string "Vector2"
  82378. */
  82379. getClassName(): string;
  82380. /**
  82381. * Gets current vector hash code
  82382. * @returns the Vector2 hash code as a number
  82383. */
  82384. getHashCode(): number;
  82385. /**
  82386. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82387. * @param array defines the source array
  82388. * @param index defines the offset in source array
  82389. * @returns the current Vector2
  82390. */
  82391. toArray(array: FloatArray, index?: number): Vector2;
  82392. /**
  82393. * Update the current vector from an array
  82394. * @param array defines the destination array
  82395. * @param index defines the offset in the destination array
  82396. * @returns the current Vector3
  82397. */
  82398. fromArray(array: FloatArray, index?: number): Vector2;
  82399. /**
  82400. * Copy the current vector to an array
  82401. * @returns a new array with 2 elements: the Vector2 coordinates.
  82402. */
  82403. asArray(): number[];
  82404. /**
  82405. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82406. * @param source defines the source Vector2
  82407. * @returns the current updated Vector2
  82408. */
  82409. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82410. /**
  82411. * Sets the Vector2 coordinates with the given floats
  82412. * @param x defines the first coordinate
  82413. * @param y defines the second coordinate
  82414. * @returns the current updated Vector2
  82415. */
  82416. copyFromFloats(x: number, y: number): Vector2;
  82417. /**
  82418. * Sets the Vector2 coordinates with the given floats
  82419. * @param x defines the first coordinate
  82420. * @param y defines the second coordinate
  82421. * @returns the current updated Vector2
  82422. */
  82423. set(x: number, y: number): Vector2;
  82424. /**
  82425. * Add another vector with the current one
  82426. * @param otherVector defines the other vector
  82427. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82428. */
  82429. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82430. /**
  82431. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82432. * @param otherVector defines the other vector
  82433. * @param result defines the target vector
  82434. * @returns the unmodified current Vector2
  82435. */
  82436. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82437. /**
  82438. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82439. * @param otherVector defines the other vector
  82440. * @returns the current updated Vector2
  82441. */
  82442. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82443. /**
  82444. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82445. * @param otherVector defines the other vector
  82446. * @returns a new Vector2
  82447. */
  82448. addVector3(otherVector: Vector3): Vector2;
  82449. /**
  82450. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82451. * @param otherVector defines the other vector
  82452. * @returns a new Vector2
  82453. */
  82454. subtract(otherVector: Vector2): Vector2;
  82455. /**
  82456. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82457. * @param otherVector defines the other vector
  82458. * @param result defines the target vector
  82459. * @returns the unmodified current Vector2
  82460. */
  82461. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82462. /**
  82463. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82464. * @param otherVector defines the other vector
  82465. * @returns the current updated Vector2
  82466. */
  82467. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82468. /**
  82469. * Multiplies in place the current Vector2 coordinates by the given ones
  82470. * @param otherVector defines the other vector
  82471. * @returns the current updated Vector2
  82472. */
  82473. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82474. /**
  82475. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82476. * @param otherVector defines the other vector
  82477. * @returns a new Vector2
  82478. */
  82479. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82480. /**
  82481. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82482. * @param otherVector defines the other vector
  82483. * @param result defines the target vector
  82484. * @returns the unmodified current Vector2
  82485. */
  82486. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82487. /**
  82488. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82489. * @param x defines the first coordinate
  82490. * @param y defines the second coordinate
  82491. * @returns a new Vector2
  82492. */
  82493. multiplyByFloats(x: number, y: number): Vector2;
  82494. /**
  82495. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82496. * @param otherVector defines the other vector
  82497. * @returns a new Vector2
  82498. */
  82499. divide(otherVector: Vector2): Vector2;
  82500. /**
  82501. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82502. * @param otherVector defines the other vector
  82503. * @param result defines the target vector
  82504. * @returns the unmodified current Vector2
  82505. */
  82506. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82507. /**
  82508. * Divides the current Vector2 coordinates by the given ones
  82509. * @param otherVector defines the other vector
  82510. * @returns the current updated Vector2
  82511. */
  82512. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82513. /**
  82514. * Gets a new Vector2 with current Vector2 negated coordinates
  82515. * @returns a new Vector2
  82516. */
  82517. negate(): Vector2;
  82518. /**
  82519. * Negate this vector in place
  82520. * @returns this
  82521. */
  82522. negateInPlace(): Vector2;
  82523. /**
  82524. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82525. * @param result defines the Vector3 object where to store the result
  82526. * @returns the current Vector2
  82527. */
  82528. negateToRef(result: Vector2): Vector2;
  82529. /**
  82530. * Multiply the Vector2 coordinates by scale
  82531. * @param scale defines the scaling factor
  82532. * @returns the current updated Vector2
  82533. */
  82534. scaleInPlace(scale: number): Vector2;
  82535. /**
  82536. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82537. * @param scale defines the scaling factor
  82538. * @returns a new Vector2
  82539. */
  82540. scale(scale: number): Vector2;
  82541. /**
  82542. * Scale the current Vector2 values by a factor to a given Vector2
  82543. * @param scale defines the scale factor
  82544. * @param result defines the Vector2 object where to store the result
  82545. * @returns the unmodified current Vector2
  82546. */
  82547. scaleToRef(scale: number, result: Vector2): Vector2;
  82548. /**
  82549. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82550. * @param scale defines the scale factor
  82551. * @param result defines the Vector2 object where to store the result
  82552. * @returns the unmodified current Vector2
  82553. */
  82554. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82555. /**
  82556. * Gets a boolean if two vectors are equals
  82557. * @param otherVector defines the other vector
  82558. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82559. */
  82560. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82561. /**
  82562. * Gets a boolean if two vectors are equals (using an epsilon value)
  82563. * @param otherVector defines the other vector
  82564. * @param epsilon defines the minimal distance to consider equality
  82565. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82566. */
  82567. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82568. /**
  82569. * Gets a new Vector2 from current Vector2 floored values
  82570. * @returns a new Vector2
  82571. */
  82572. floor(): Vector2;
  82573. /**
  82574. * Gets a new Vector2 from current Vector2 floored values
  82575. * @returns a new Vector2
  82576. */
  82577. fract(): Vector2;
  82578. /**
  82579. * Gets the length of the vector
  82580. * @returns the vector length (float)
  82581. */
  82582. length(): number;
  82583. /**
  82584. * Gets the vector squared length
  82585. * @returns the vector squared length (float)
  82586. */
  82587. lengthSquared(): number;
  82588. /**
  82589. * Normalize the vector
  82590. * @returns the current updated Vector2
  82591. */
  82592. normalize(): Vector2;
  82593. /**
  82594. * Gets a new Vector2 copied from the Vector2
  82595. * @returns a new Vector2
  82596. */
  82597. clone(): Vector2;
  82598. /**
  82599. * Gets a new Vector2(0, 0)
  82600. * @returns a new Vector2
  82601. */
  82602. static Zero(): Vector2;
  82603. /**
  82604. * Gets a new Vector2(1, 1)
  82605. * @returns a new Vector2
  82606. */
  82607. static One(): Vector2;
  82608. /**
  82609. * Gets a new Vector2 set from the given index element of the given array
  82610. * @param array defines the data source
  82611. * @param offset defines the offset in the data source
  82612. * @returns a new Vector2
  82613. */
  82614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82615. /**
  82616. * Sets "result" from the given index element of the given array
  82617. * @param array defines the data source
  82618. * @param offset defines the offset in the data source
  82619. * @param result defines the target vector
  82620. */
  82621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82622. /**
  82623. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82624. * @param value1 defines 1st point of control
  82625. * @param value2 defines 2nd point of control
  82626. * @param value3 defines 3rd point of control
  82627. * @param value4 defines 4th point of control
  82628. * @param amount defines the interpolation factor
  82629. * @returns a new Vector2
  82630. */
  82631. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82632. /**
  82633. * 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".
  82634. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82635. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82636. * @param value defines the value to clamp
  82637. * @param min defines the lower limit
  82638. * @param max defines the upper limit
  82639. * @returns a new Vector2
  82640. */
  82641. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82642. /**
  82643. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82644. * @param value1 defines the 1st control point
  82645. * @param tangent1 defines the outgoing tangent
  82646. * @param value2 defines the 2nd control point
  82647. * @param tangent2 defines the incoming tangent
  82648. * @param amount defines the interpolation factor
  82649. * @returns a new Vector2
  82650. */
  82651. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82652. /**
  82653. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82654. * @param start defines the start vector
  82655. * @param end defines the end vector
  82656. * @param amount defines the interpolation factor
  82657. * @returns a new Vector2
  82658. */
  82659. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82660. /**
  82661. * Gets the dot product of the vector "left" and the vector "right"
  82662. * @param left defines first vector
  82663. * @param right defines second vector
  82664. * @returns the dot product (float)
  82665. */
  82666. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82667. /**
  82668. * Returns a new Vector2 equal to the normalized given vector
  82669. * @param vector defines the vector to normalize
  82670. * @returns a new Vector2
  82671. */
  82672. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82673. /**
  82674. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82675. * @param left defines 1st vector
  82676. * @param right defines 2nd vector
  82677. * @returns a new Vector2
  82678. */
  82679. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82680. /**
  82681. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82682. * @param left defines 1st vector
  82683. * @param right defines 2nd vector
  82684. * @returns a new Vector2
  82685. */
  82686. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82687. /**
  82688. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82689. * @param vector defines the vector to transform
  82690. * @param transformation defines the matrix to apply
  82691. * @returns a new Vector2
  82692. */
  82693. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82694. /**
  82695. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82696. * @param vector defines the vector to transform
  82697. * @param transformation defines the matrix to apply
  82698. * @param result defines the target vector
  82699. */
  82700. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82701. /**
  82702. * Determines if a given vector is included in a triangle
  82703. * @param p defines the vector to test
  82704. * @param p0 defines 1st triangle point
  82705. * @param p1 defines 2nd triangle point
  82706. * @param p2 defines 3rd triangle point
  82707. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82708. */
  82709. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82710. /**
  82711. * Gets the distance between the vectors "value1" and "value2"
  82712. * @param value1 defines first vector
  82713. * @param value2 defines second vector
  82714. * @returns the distance between vectors
  82715. */
  82716. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82717. /**
  82718. * Returns the squared distance between the vectors "value1" and "value2"
  82719. * @param value1 defines first vector
  82720. * @param value2 defines second vector
  82721. * @returns the squared distance between vectors
  82722. */
  82723. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82724. /**
  82725. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82726. * @param value1 defines first vector
  82727. * @param value2 defines second vector
  82728. * @returns a new Vector2
  82729. */
  82730. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82731. /**
  82732. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82733. * @param p defines the middle point
  82734. * @param segA defines one point of the segment
  82735. * @param segB defines the other point of the segment
  82736. * @returns the shortest distance
  82737. */
  82738. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82739. }
  82740. /**
  82741. * Class used to store (x,y,z) vector representation
  82742. * A Vector3 is the main object used in 3D geometry
  82743. * It can represent etiher the coordinates of a point the space, either a direction
  82744. * Reminder: js uses a left handed forward facing system
  82745. */
  82746. export class Vector3 {
  82747. private static _UpReadOnly;
  82748. private static _ZeroReadOnly;
  82749. /** @hidden */
  82750. _x: number;
  82751. /** @hidden */
  82752. _y: number;
  82753. /** @hidden */
  82754. _z: number;
  82755. /** @hidden */
  82756. _isDirty: boolean;
  82757. /** Gets or sets the x coordinate */
  82758. get x(): number;
  82759. set x(value: number);
  82760. /** Gets or sets the y coordinate */
  82761. get y(): number;
  82762. set y(value: number);
  82763. /** Gets or sets the z coordinate */
  82764. get z(): number;
  82765. set z(value: number);
  82766. /**
  82767. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82768. * @param x defines the first coordinates (on X axis)
  82769. * @param y defines the second coordinates (on Y axis)
  82770. * @param z defines the third coordinates (on Z axis)
  82771. */
  82772. constructor(x?: number, y?: number, z?: number);
  82773. /**
  82774. * Creates a string representation of the Vector3
  82775. * @returns a string with the Vector3 coordinates.
  82776. */
  82777. toString(): string;
  82778. /**
  82779. * Gets the class name
  82780. * @returns the string "Vector3"
  82781. */
  82782. getClassName(): string;
  82783. /**
  82784. * Creates the Vector3 hash code
  82785. * @returns a number which tends to be unique between Vector3 instances
  82786. */
  82787. getHashCode(): number;
  82788. /**
  82789. * Creates an array containing three elements : the coordinates of the Vector3
  82790. * @returns a new array of numbers
  82791. */
  82792. asArray(): number[];
  82793. /**
  82794. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82795. * @param array defines the destination array
  82796. * @param index defines the offset in the destination array
  82797. * @returns the current Vector3
  82798. */
  82799. toArray(array: FloatArray, index?: number): Vector3;
  82800. /**
  82801. * Update the current vector from an array
  82802. * @param array defines the destination array
  82803. * @param index defines the offset in the destination array
  82804. * @returns the current Vector3
  82805. */
  82806. fromArray(array: FloatArray, index?: number): Vector3;
  82807. /**
  82808. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82809. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82810. */
  82811. toQuaternion(): Quaternion;
  82812. /**
  82813. * Adds the given vector to the current Vector3
  82814. * @param otherVector defines the second operand
  82815. * @returns the current updated Vector3
  82816. */
  82817. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82818. /**
  82819. * Adds the given coordinates to the current Vector3
  82820. * @param x defines the x coordinate of the operand
  82821. * @param y defines the y coordinate of the operand
  82822. * @param z defines the z coordinate of the operand
  82823. * @returns the current updated Vector3
  82824. */
  82825. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82826. /**
  82827. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82828. * @param otherVector defines the second operand
  82829. * @returns the resulting Vector3
  82830. */
  82831. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82832. /**
  82833. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82834. * @param otherVector defines the second operand
  82835. * @param result defines the Vector3 object where to store the result
  82836. * @returns the current Vector3
  82837. */
  82838. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82839. /**
  82840. * Subtract the given vector from the current Vector3
  82841. * @param otherVector defines the second operand
  82842. * @returns the current updated Vector3
  82843. */
  82844. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82845. /**
  82846. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82847. * @param otherVector defines the second operand
  82848. * @returns the resulting Vector3
  82849. */
  82850. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82851. /**
  82852. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82853. * @param otherVector defines the second operand
  82854. * @param result defines the Vector3 object where to store the result
  82855. * @returns the current Vector3
  82856. */
  82857. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82858. /**
  82859. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82860. * @param x defines the x coordinate of the operand
  82861. * @param y defines the y coordinate of the operand
  82862. * @param z defines the z coordinate of the operand
  82863. * @returns the resulting Vector3
  82864. */
  82865. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82866. /**
  82867. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82868. * @param x defines the x coordinate of the operand
  82869. * @param y defines the y coordinate of the operand
  82870. * @param z defines the z coordinate of the operand
  82871. * @param result defines the Vector3 object where to store the result
  82872. * @returns the current Vector3
  82873. */
  82874. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82875. /**
  82876. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82877. * @returns a new Vector3
  82878. */
  82879. negate(): Vector3;
  82880. /**
  82881. * Negate this vector in place
  82882. * @returns this
  82883. */
  82884. negateInPlace(): Vector3;
  82885. /**
  82886. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82887. * @param result defines the Vector3 object where to store the result
  82888. * @returns the current Vector3
  82889. */
  82890. negateToRef(result: Vector3): Vector3;
  82891. /**
  82892. * Multiplies the Vector3 coordinates by the float "scale"
  82893. * @param scale defines the multiplier factor
  82894. * @returns the current updated Vector3
  82895. */
  82896. scaleInPlace(scale: number): Vector3;
  82897. /**
  82898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82899. * @param scale defines the multiplier factor
  82900. * @returns a new Vector3
  82901. */
  82902. scale(scale: number): Vector3;
  82903. /**
  82904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82905. * @param scale defines the multiplier factor
  82906. * @param result defines the Vector3 object where to store the result
  82907. * @returns the current Vector3
  82908. */
  82909. scaleToRef(scale: number, result: Vector3): Vector3;
  82910. /**
  82911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82912. * @param scale defines the scale factor
  82913. * @param result defines the Vector3 object where to store the result
  82914. * @returns the unmodified current Vector3
  82915. */
  82916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82917. /**
  82918. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82919. * @param origin defines the origin of the projection ray
  82920. * @param plane defines the plane to project to
  82921. * @returns the projected vector3
  82922. */
  82923. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82924. /**
  82925. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82926. * @param origin defines the origin of the projection ray
  82927. * @param plane defines the plane to project to
  82928. * @param result defines the Vector3 where to store the result
  82929. */
  82930. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82931. /**
  82932. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82933. * @param otherVector defines the second operand
  82934. * @returns true if both vectors are equals
  82935. */
  82936. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82937. /**
  82938. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82939. * @param otherVector defines the second operand
  82940. * @param epsilon defines the minimal distance to define values as equals
  82941. * @returns true if both vectors are distant less than epsilon
  82942. */
  82943. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82944. /**
  82945. * Returns true if the current Vector3 coordinates equals the given floats
  82946. * @param x defines the x coordinate of the operand
  82947. * @param y defines the y coordinate of the operand
  82948. * @param z defines the z coordinate of the operand
  82949. * @returns true if both vectors are equals
  82950. */
  82951. equalsToFloats(x: number, y: number, z: number): boolean;
  82952. /**
  82953. * Multiplies the current Vector3 coordinates by the given ones
  82954. * @param otherVector defines the second operand
  82955. * @returns the current updated Vector3
  82956. */
  82957. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82958. /**
  82959. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82960. * @param otherVector defines the second operand
  82961. * @returns the new Vector3
  82962. */
  82963. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82964. /**
  82965. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82966. * @param otherVector defines the second operand
  82967. * @param result defines the Vector3 object where to store the result
  82968. * @returns the current Vector3
  82969. */
  82970. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82971. /**
  82972. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82973. * @param x defines the x coordinate of the operand
  82974. * @param y defines the y coordinate of the operand
  82975. * @param z defines the z coordinate of the operand
  82976. * @returns the new Vector3
  82977. */
  82978. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82979. /**
  82980. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82981. * @param otherVector defines the second operand
  82982. * @returns the new Vector3
  82983. */
  82984. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82985. /**
  82986. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82987. * @param otherVector defines the second operand
  82988. * @param result defines the Vector3 object where to store the result
  82989. * @returns the current Vector3
  82990. */
  82991. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82992. /**
  82993. * Divides the current Vector3 coordinates by the given ones.
  82994. * @param otherVector defines the second operand
  82995. * @returns the current updated Vector3
  82996. */
  82997. divideInPlace(otherVector: Vector3): Vector3;
  82998. /**
  82999. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83000. * @param other defines the second operand
  83001. * @returns the current updated Vector3
  83002. */
  83003. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83004. /**
  83005. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83006. * @param other defines the second operand
  83007. * @returns the current updated Vector3
  83008. */
  83009. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83010. /**
  83011. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83012. * @param x defines the x coordinate of the operand
  83013. * @param y defines the y coordinate of the operand
  83014. * @param z defines the z coordinate of the operand
  83015. * @returns the current updated Vector3
  83016. */
  83017. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83018. /**
  83019. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83020. * @param x defines the x coordinate of the operand
  83021. * @param y defines the y coordinate of the operand
  83022. * @param z defines the z coordinate of the operand
  83023. * @returns the current updated Vector3
  83024. */
  83025. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83026. /**
  83027. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83028. * Check if is non uniform within a certain amount of decimal places to account for this
  83029. * @param epsilon the amount the values can differ
  83030. * @returns if the the vector is non uniform to a certain number of decimal places
  83031. */
  83032. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83033. /**
  83034. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83035. */
  83036. get isNonUniform(): boolean;
  83037. /**
  83038. * Gets a new Vector3 from current Vector3 floored values
  83039. * @returns a new Vector3
  83040. */
  83041. floor(): Vector3;
  83042. /**
  83043. * Gets a new Vector3 from current Vector3 floored values
  83044. * @returns a new Vector3
  83045. */
  83046. fract(): Vector3;
  83047. /**
  83048. * Gets the length of the Vector3
  83049. * @returns the length of the Vector3
  83050. */
  83051. length(): number;
  83052. /**
  83053. * Gets the squared length of the Vector3
  83054. * @returns squared length of the Vector3
  83055. */
  83056. lengthSquared(): number;
  83057. /**
  83058. * Normalize the current Vector3.
  83059. * Please note that this is an in place operation.
  83060. * @returns the current updated Vector3
  83061. */
  83062. normalize(): Vector3;
  83063. /**
  83064. * Reorders the x y z properties of the vector in place
  83065. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83066. * @returns the current updated vector
  83067. */
  83068. reorderInPlace(order: string): this;
  83069. /**
  83070. * Rotates the vector around 0,0,0 by a quaternion
  83071. * @param quaternion the rotation quaternion
  83072. * @param result vector to store the result
  83073. * @returns the resulting vector
  83074. */
  83075. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83076. /**
  83077. * Rotates a vector around a given point
  83078. * @param quaternion the rotation quaternion
  83079. * @param point the point to rotate around
  83080. * @param result vector to store the result
  83081. * @returns the resulting vector
  83082. */
  83083. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83084. /**
  83085. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83086. * The cross product is then orthogonal to both current and "other"
  83087. * @param other defines the right operand
  83088. * @returns the cross product
  83089. */
  83090. cross(other: Vector3): Vector3;
  83091. /**
  83092. * Normalize the current Vector3 with the given input length.
  83093. * Please note that this is an in place operation.
  83094. * @param len the length of the vector
  83095. * @returns the current updated Vector3
  83096. */
  83097. normalizeFromLength(len: number): Vector3;
  83098. /**
  83099. * Normalize the current Vector3 to a new vector
  83100. * @returns the new Vector3
  83101. */
  83102. normalizeToNew(): Vector3;
  83103. /**
  83104. * Normalize the current Vector3 to the reference
  83105. * @param reference define the Vector3 to update
  83106. * @returns the updated Vector3
  83107. */
  83108. normalizeToRef(reference: Vector3): Vector3;
  83109. /**
  83110. * Creates a new Vector3 copied from the current Vector3
  83111. * @returns the new Vector3
  83112. */
  83113. clone(): Vector3;
  83114. /**
  83115. * Copies the given vector coordinates to the current Vector3 ones
  83116. * @param source defines the source Vector3
  83117. * @returns the current updated Vector3
  83118. */
  83119. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83120. /**
  83121. * Copies the given floats to the current Vector3 coordinates
  83122. * @param x defines the x coordinate of the operand
  83123. * @param y defines the y coordinate of the operand
  83124. * @param z defines the z coordinate of the operand
  83125. * @returns the current updated Vector3
  83126. */
  83127. copyFromFloats(x: number, y: number, z: number): Vector3;
  83128. /**
  83129. * Copies the given floats to the current Vector3 coordinates
  83130. * @param x defines the x coordinate of the operand
  83131. * @param y defines the y coordinate of the operand
  83132. * @param z defines the z coordinate of the operand
  83133. * @returns the current updated Vector3
  83134. */
  83135. set(x: number, y: number, z: number): Vector3;
  83136. /**
  83137. * Copies the given float to the current Vector3 coordinates
  83138. * @param v defines the x, y and z coordinates of the operand
  83139. * @returns the current updated Vector3
  83140. */
  83141. setAll(v: number): Vector3;
  83142. /**
  83143. * Get the clip factor between two vectors
  83144. * @param vector0 defines the first operand
  83145. * @param vector1 defines the second operand
  83146. * @param axis defines the axis to use
  83147. * @param size defines the size along the axis
  83148. * @returns the clip factor
  83149. */
  83150. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83151. /**
  83152. * Get angle between two vectors
  83153. * @param vector0 angle between vector0 and vector1
  83154. * @param vector1 angle between vector0 and vector1
  83155. * @param normal direction of the normal
  83156. * @return the angle between vector0 and vector1
  83157. */
  83158. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83159. /**
  83160. * Returns a new Vector3 set from the index "offset" of the given array
  83161. * @param array defines the source array
  83162. * @param offset defines the offset in the source array
  83163. * @returns the new Vector3
  83164. */
  83165. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83166. /**
  83167. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83168. * @param array defines the source array
  83169. * @param offset defines the offset in the source array
  83170. * @returns the new Vector3
  83171. * @deprecated Please use FromArray instead.
  83172. */
  83173. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83174. /**
  83175. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83176. * @param array defines the source array
  83177. * @param offset defines the offset in the source array
  83178. * @param result defines the Vector3 where to store the result
  83179. */
  83180. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83181. /**
  83182. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83183. * @param array defines the source array
  83184. * @param offset defines the offset in the source array
  83185. * @param result defines the Vector3 where to store the result
  83186. * @deprecated Please use FromArrayToRef instead.
  83187. */
  83188. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83189. /**
  83190. * Sets the given vector "result" with the given floats.
  83191. * @param x defines the x coordinate of the source
  83192. * @param y defines the y coordinate of the source
  83193. * @param z defines the z coordinate of the source
  83194. * @param result defines the Vector3 where to store the result
  83195. */
  83196. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83197. /**
  83198. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83199. * @returns a new empty Vector3
  83200. */
  83201. static Zero(): Vector3;
  83202. /**
  83203. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83204. * @returns a new unit Vector3
  83205. */
  83206. static One(): Vector3;
  83207. /**
  83208. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83209. * @returns a new up Vector3
  83210. */
  83211. static Up(): Vector3;
  83212. /**
  83213. * Gets a up Vector3 that must not be updated
  83214. */
  83215. static get UpReadOnly(): DeepImmutable<Vector3>;
  83216. /**
  83217. * Gets a zero Vector3 that must not be updated
  83218. */
  83219. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83220. /**
  83221. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83222. * @returns a new down Vector3
  83223. */
  83224. static Down(): Vector3;
  83225. /**
  83226. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83227. * @param rightHandedSystem is the scene right-handed (negative z)
  83228. * @returns a new forward Vector3
  83229. */
  83230. static Forward(rightHandedSystem?: boolean): Vector3;
  83231. /**
  83232. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83233. * @param rightHandedSystem is the scene right-handed (negative-z)
  83234. * @returns a new forward Vector3
  83235. */
  83236. static Backward(rightHandedSystem?: boolean): Vector3;
  83237. /**
  83238. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83239. * @returns a new right Vector3
  83240. */
  83241. static Right(): Vector3;
  83242. /**
  83243. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83244. * @returns a new left Vector3
  83245. */
  83246. static Left(): Vector3;
  83247. /**
  83248. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83249. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83250. * @param vector defines the Vector3 to transform
  83251. * @param transformation defines the transformation matrix
  83252. * @returns the transformed Vector3
  83253. */
  83254. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83255. /**
  83256. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83257. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83258. * @param vector defines the Vector3 to transform
  83259. * @param transformation defines the transformation matrix
  83260. * @param result defines the Vector3 where to store the result
  83261. */
  83262. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83263. /**
  83264. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83265. * This method computes tranformed coordinates only, not transformed direction vectors
  83266. * @param x define the x coordinate of the source vector
  83267. * @param y define the y coordinate of the source vector
  83268. * @param z define the z coordinate of the source vector
  83269. * @param transformation defines the transformation matrix
  83270. * @param result defines the Vector3 where to store the result
  83271. */
  83272. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83273. /**
  83274. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83275. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83276. * @param vector defines the Vector3 to transform
  83277. * @param transformation defines the transformation matrix
  83278. * @returns the new Vector3
  83279. */
  83280. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83281. /**
  83282. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83283. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83284. * @param vector defines the Vector3 to transform
  83285. * @param transformation defines the transformation matrix
  83286. * @param result defines the Vector3 where to store the result
  83287. */
  83288. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83289. /**
  83290. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83291. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83292. * @param x define the x coordinate of the source vector
  83293. * @param y define the y coordinate of the source vector
  83294. * @param z define the z coordinate of the source vector
  83295. * @param transformation defines the transformation matrix
  83296. * @param result defines the Vector3 where to store the result
  83297. */
  83298. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83299. /**
  83300. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83301. * @param value1 defines the first control point
  83302. * @param value2 defines the second control point
  83303. * @param value3 defines the third control point
  83304. * @param value4 defines the fourth control point
  83305. * @param amount defines the amount on the spline to use
  83306. * @returns the new Vector3
  83307. */
  83308. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83309. /**
  83310. * 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"
  83311. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83312. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83313. * @param value defines the current value
  83314. * @param min defines the lower range value
  83315. * @param max defines the upper range value
  83316. * @returns the new Vector3
  83317. */
  83318. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83319. /**
  83320. * 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"
  83321. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83322. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83323. * @param value defines the current value
  83324. * @param min defines the lower range value
  83325. * @param max defines the upper range value
  83326. * @param result defines the Vector3 where to store the result
  83327. */
  83328. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83329. /**
  83330. * Checks if a given vector is inside a specific range
  83331. * @param v defines the vector to test
  83332. * @param min defines the minimum range
  83333. * @param max defines the maximum range
  83334. */
  83335. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83336. /**
  83337. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83338. * @param value1 defines the first control point
  83339. * @param tangent1 defines the first tangent vector
  83340. * @param value2 defines the second control point
  83341. * @param tangent2 defines the second tangent vector
  83342. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83343. * @returns the new Vector3
  83344. */
  83345. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83346. /**
  83347. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83348. * @param start defines the start value
  83349. * @param end defines the end value
  83350. * @param amount max defines amount between both (between 0 and 1)
  83351. * @returns the new Vector3
  83352. */
  83353. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83354. /**
  83355. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83356. * @param start defines the start value
  83357. * @param end defines the end value
  83358. * @param amount max defines amount between both (between 0 and 1)
  83359. * @param result defines the Vector3 where to store the result
  83360. */
  83361. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83362. /**
  83363. * Returns the dot product (float) between the vectors "left" and "right"
  83364. * @param left defines the left operand
  83365. * @param right defines the right operand
  83366. * @returns the dot product
  83367. */
  83368. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83369. /**
  83370. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83371. * The cross product is then orthogonal to both "left" and "right"
  83372. * @param left defines the left operand
  83373. * @param right defines the right operand
  83374. * @returns the cross product
  83375. */
  83376. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83377. /**
  83378. * Sets the given vector "result" with the cross product of "left" and "right"
  83379. * The cross product is then orthogonal to both "left" and "right"
  83380. * @param left defines the left operand
  83381. * @param right defines the right operand
  83382. * @param result defines the Vector3 where to store the result
  83383. */
  83384. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83385. /**
  83386. * Returns a new Vector3 as the normalization of the given vector
  83387. * @param vector defines the Vector3 to normalize
  83388. * @returns the new Vector3
  83389. */
  83390. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83391. /**
  83392. * Sets the given vector "result" with the normalization of the given first vector
  83393. * @param vector defines the Vector3 to normalize
  83394. * @param result defines the Vector3 where to store the result
  83395. */
  83396. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83397. /**
  83398. * Project a Vector3 onto screen space
  83399. * @param vector defines the Vector3 to project
  83400. * @param world defines the world matrix to use
  83401. * @param transform defines the transform (view x projection) matrix to use
  83402. * @param viewport defines the screen viewport to use
  83403. * @returns the new Vector3
  83404. */
  83405. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83406. /** @hidden */
  83407. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83408. /**
  83409. * Unproject from screen space to object space
  83410. * @param source defines the screen space Vector3 to use
  83411. * @param viewportWidth defines the current width of the viewport
  83412. * @param viewportHeight defines the current height of the viewport
  83413. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83414. * @param transform defines the transform (view x projection) matrix to use
  83415. * @returns the new Vector3
  83416. */
  83417. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83418. /**
  83419. * Unproject from screen space to object space
  83420. * @param source defines the screen space Vector3 to use
  83421. * @param viewportWidth defines the current width of the viewport
  83422. * @param viewportHeight defines the current height of the viewport
  83423. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83424. * @param view defines the view matrix to use
  83425. * @param projection defines the projection matrix to use
  83426. * @returns the new Vector3
  83427. */
  83428. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83429. /**
  83430. * Unproject from screen space to object space
  83431. * @param source defines the screen space Vector3 to use
  83432. * @param viewportWidth defines the current width of the viewport
  83433. * @param viewportHeight defines the current height of the viewport
  83434. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83435. * @param view defines the view matrix to use
  83436. * @param projection defines the projection matrix to use
  83437. * @param result defines the Vector3 where to store the result
  83438. */
  83439. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83440. /**
  83441. * Unproject from screen space to object space
  83442. * @param sourceX defines the screen space x coordinate to use
  83443. * @param sourceY defines the screen space y coordinate to use
  83444. * @param sourceZ defines the screen space z coordinate to use
  83445. * @param viewportWidth defines the current width of the viewport
  83446. * @param viewportHeight defines the current height of the viewport
  83447. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83448. * @param view defines the view matrix to use
  83449. * @param projection defines the projection matrix to use
  83450. * @param result defines the Vector3 where to store the result
  83451. */
  83452. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83453. /**
  83454. * Gets the minimal coordinate values between two Vector3
  83455. * @param left defines the first operand
  83456. * @param right defines the second operand
  83457. * @returns the new Vector3
  83458. */
  83459. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83460. /**
  83461. * Gets the maximal coordinate values between two Vector3
  83462. * @param left defines the first operand
  83463. * @param right defines the second operand
  83464. * @returns the new Vector3
  83465. */
  83466. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83467. /**
  83468. * Returns the distance between the vectors "value1" and "value2"
  83469. * @param value1 defines the first operand
  83470. * @param value2 defines the second operand
  83471. * @returns the distance
  83472. */
  83473. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83474. /**
  83475. * Returns the squared distance between the vectors "value1" and "value2"
  83476. * @param value1 defines the first operand
  83477. * @param value2 defines the second operand
  83478. * @returns the squared distance
  83479. */
  83480. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83481. /**
  83482. * Returns a new Vector3 located at the center between "value1" and "value2"
  83483. * @param value1 defines the first operand
  83484. * @param value2 defines the second operand
  83485. * @returns the new Vector3
  83486. */
  83487. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83488. /**
  83489. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83490. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83491. * to something in order to rotate it from its local system to the given target system
  83492. * Note: axis1, axis2 and axis3 are normalized during this operation
  83493. * @param axis1 defines the first axis
  83494. * @param axis2 defines the second axis
  83495. * @param axis3 defines the third axis
  83496. * @returns a new Vector3
  83497. */
  83498. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83499. /**
  83500. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83501. * @param axis1 defines the first axis
  83502. * @param axis2 defines the second axis
  83503. * @param axis3 defines the third axis
  83504. * @param ref defines the Vector3 where to store the result
  83505. */
  83506. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83507. }
  83508. /**
  83509. * Vector4 class created for EulerAngle class conversion to Quaternion
  83510. */
  83511. export class Vector4 {
  83512. /** x value of the vector */
  83513. x: number;
  83514. /** y value of the vector */
  83515. y: number;
  83516. /** z value of the vector */
  83517. z: number;
  83518. /** w value of the vector */
  83519. w: number;
  83520. /**
  83521. * Creates a Vector4 object from the given floats.
  83522. * @param x x value of the vector
  83523. * @param y y value of the vector
  83524. * @param z z value of the vector
  83525. * @param w w value of the vector
  83526. */
  83527. constructor(
  83528. /** x value of the vector */
  83529. x: number,
  83530. /** y value of the vector */
  83531. y: number,
  83532. /** z value of the vector */
  83533. z: number,
  83534. /** w value of the vector */
  83535. w: number);
  83536. /**
  83537. * Returns the string with the Vector4 coordinates.
  83538. * @returns a string containing all the vector values
  83539. */
  83540. toString(): string;
  83541. /**
  83542. * Returns the string "Vector4".
  83543. * @returns "Vector4"
  83544. */
  83545. getClassName(): string;
  83546. /**
  83547. * Returns the Vector4 hash code.
  83548. * @returns a unique hash code
  83549. */
  83550. getHashCode(): number;
  83551. /**
  83552. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83553. * @returns the resulting array
  83554. */
  83555. asArray(): number[];
  83556. /**
  83557. * Populates the given array from the given index with the Vector4 coordinates.
  83558. * @param array array to populate
  83559. * @param index index of the array to start at (default: 0)
  83560. * @returns the Vector4.
  83561. */
  83562. toArray(array: FloatArray, index?: number): Vector4;
  83563. /**
  83564. * Update the current vector from an array
  83565. * @param array defines the destination array
  83566. * @param index defines the offset in the destination array
  83567. * @returns the current Vector3
  83568. */
  83569. fromArray(array: FloatArray, index?: number): Vector4;
  83570. /**
  83571. * Adds the given vector to the current Vector4.
  83572. * @param otherVector the vector to add
  83573. * @returns the updated Vector4.
  83574. */
  83575. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83576. /**
  83577. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83578. * @param otherVector the vector to add
  83579. * @returns the resulting vector
  83580. */
  83581. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83582. /**
  83583. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83584. * @param otherVector the vector to add
  83585. * @param result the vector to store the result
  83586. * @returns the current Vector4.
  83587. */
  83588. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83589. /**
  83590. * Subtract in place the given vector from the current Vector4.
  83591. * @param otherVector the vector to subtract
  83592. * @returns the updated Vector4.
  83593. */
  83594. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83595. /**
  83596. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83597. * @param otherVector the vector to add
  83598. * @returns the new vector with the result
  83599. */
  83600. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83601. /**
  83602. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83603. * @param otherVector the vector to subtract
  83604. * @param result the vector to store the result
  83605. * @returns the current Vector4.
  83606. */
  83607. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83608. /**
  83609. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83610. */
  83611. /**
  83612. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83613. * @param x value to subtract
  83614. * @param y value to subtract
  83615. * @param z value to subtract
  83616. * @param w value to subtract
  83617. * @returns new vector containing the result
  83618. */
  83619. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83620. /**
  83621. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83622. * @param x value to subtract
  83623. * @param y value to subtract
  83624. * @param z value to subtract
  83625. * @param w value to subtract
  83626. * @param result the vector to store the result in
  83627. * @returns the current Vector4.
  83628. */
  83629. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83630. /**
  83631. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83632. * @returns a new vector with the negated values
  83633. */
  83634. negate(): Vector4;
  83635. /**
  83636. * Negate this vector in place
  83637. * @returns this
  83638. */
  83639. negateInPlace(): Vector4;
  83640. /**
  83641. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83642. * @param result defines the Vector3 object where to store the result
  83643. * @returns the current Vector4
  83644. */
  83645. negateToRef(result: Vector4): Vector4;
  83646. /**
  83647. * Multiplies the current Vector4 coordinates by scale (float).
  83648. * @param scale the number to scale with
  83649. * @returns the updated Vector4.
  83650. */
  83651. scaleInPlace(scale: number): Vector4;
  83652. /**
  83653. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83654. * @param scale the number to scale with
  83655. * @returns a new vector with the result
  83656. */
  83657. scale(scale: number): Vector4;
  83658. /**
  83659. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83660. * @param scale the number to scale with
  83661. * @param result a vector to store the result in
  83662. * @returns the current Vector4.
  83663. */
  83664. scaleToRef(scale: number, result: Vector4): Vector4;
  83665. /**
  83666. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83667. * @param scale defines the scale factor
  83668. * @param result defines the Vector4 object where to store the result
  83669. * @returns the unmodified current Vector4
  83670. */
  83671. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83672. /**
  83673. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83674. * @param otherVector the vector to compare against
  83675. * @returns true if they are equal
  83676. */
  83677. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83678. /**
  83679. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83680. * @param otherVector vector to compare against
  83681. * @param epsilon (Default: very small number)
  83682. * @returns true if they are equal
  83683. */
  83684. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83685. /**
  83686. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83687. * @param x x value to compare against
  83688. * @param y y value to compare against
  83689. * @param z z value to compare against
  83690. * @param w w value to compare against
  83691. * @returns true if equal
  83692. */
  83693. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83694. /**
  83695. * Multiplies in place the current Vector4 by the given one.
  83696. * @param otherVector vector to multiple with
  83697. * @returns the updated Vector4.
  83698. */
  83699. multiplyInPlace(otherVector: Vector4): Vector4;
  83700. /**
  83701. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83702. * @param otherVector vector to multiple with
  83703. * @returns resulting new vector
  83704. */
  83705. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83706. /**
  83707. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83708. * @param otherVector vector to multiple with
  83709. * @param result vector to store the result
  83710. * @returns the current Vector4.
  83711. */
  83712. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83713. /**
  83714. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83715. * @param x x value multiply with
  83716. * @param y y value multiply with
  83717. * @param z z value multiply with
  83718. * @param w w value multiply with
  83719. * @returns resulting new vector
  83720. */
  83721. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83722. /**
  83723. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83724. * @param otherVector vector to devide with
  83725. * @returns resulting new vector
  83726. */
  83727. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83728. /**
  83729. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83730. * @param otherVector vector to devide with
  83731. * @param result vector to store the result
  83732. * @returns the current Vector4.
  83733. */
  83734. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83735. /**
  83736. * Divides the current Vector3 coordinates by the given ones.
  83737. * @param otherVector vector to devide with
  83738. * @returns the updated Vector3.
  83739. */
  83740. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83741. /**
  83742. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83743. * @param other defines the second operand
  83744. * @returns the current updated Vector4
  83745. */
  83746. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83747. /**
  83748. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83749. * @param other defines the second operand
  83750. * @returns the current updated Vector4
  83751. */
  83752. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83753. /**
  83754. * Gets a new Vector4 from current Vector4 floored values
  83755. * @returns a new Vector4
  83756. */
  83757. floor(): Vector4;
  83758. /**
  83759. * Gets a new Vector4 from current Vector3 floored values
  83760. * @returns a new Vector4
  83761. */
  83762. fract(): Vector4;
  83763. /**
  83764. * Returns the Vector4 length (float).
  83765. * @returns the length
  83766. */
  83767. length(): number;
  83768. /**
  83769. * Returns the Vector4 squared length (float).
  83770. * @returns the length squared
  83771. */
  83772. lengthSquared(): number;
  83773. /**
  83774. * Normalizes in place the Vector4.
  83775. * @returns the updated Vector4.
  83776. */
  83777. normalize(): Vector4;
  83778. /**
  83779. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83780. * @returns this converted to a new vector3
  83781. */
  83782. toVector3(): Vector3;
  83783. /**
  83784. * Returns a new Vector4 copied from the current one.
  83785. * @returns the new cloned vector
  83786. */
  83787. clone(): Vector4;
  83788. /**
  83789. * Updates the current Vector4 with the given one coordinates.
  83790. * @param source the source vector to copy from
  83791. * @returns the updated Vector4.
  83792. */
  83793. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83794. /**
  83795. * Updates the current Vector4 coordinates with the given floats.
  83796. * @param x float to copy from
  83797. * @param y float to copy from
  83798. * @param z float to copy from
  83799. * @param w float to copy from
  83800. * @returns the updated Vector4.
  83801. */
  83802. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83803. /**
  83804. * Updates the current Vector4 coordinates with the given floats.
  83805. * @param x float to set from
  83806. * @param y float to set from
  83807. * @param z float to set from
  83808. * @param w float to set from
  83809. * @returns the updated Vector4.
  83810. */
  83811. set(x: number, y: number, z: number, w: number): Vector4;
  83812. /**
  83813. * Copies the given float to the current Vector3 coordinates
  83814. * @param v defines the x, y, z and w coordinates of the operand
  83815. * @returns the current updated Vector3
  83816. */
  83817. setAll(v: number): Vector4;
  83818. /**
  83819. * Returns a new Vector4 set from the starting index of the given array.
  83820. * @param array the array to pull values from
  83821. * @param offset the offset into the array to start at
  83822. * @returns the new vector
  83823. */
  83824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83825. /**
  83826. * Updates the given vector "result" from the starting index of the given array.
  83827. * @param array the array to pull values from
  83828. * @param offset the offset into the array to start at
  83829. * @param result the vector to store the result in
  83830. */
  83831. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83832. /**
  83833. * Updates the given vector "result" from the starting index of the given Float32Array.
  83834. * @param array the array to pull values from
  83835. * @param offset the offset into the array to start at
  83836. * @param result the vector to store the result in
  83837. */
  83838. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83839. /**
  83840. * Updates the given vector "result" coordinates from the given floats.
  83841. * @param x float to set from
  83842. * @param y float to set from
  83843. * @param z float to set from
  83844. * @param w float to set from
  83845. * @param result the vector to the floats in
  83846. */
  83847. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83848. /**
  83849. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83850. * @returns the new vector
  83851. */
  83852. static Zero(): Vector4;
  83853. /**
  83854. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83855. * @returns the new vector
  83856. */
  83857. static One(): Vector4;
  83858. /**
  83859. * Returns a new normalized Vector4 from the given one.
  83860. * @param vector the vector to normalize
  83861. * @returns the vector
  83862. */
  83863. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83864. /**
  83865. * Updates the given vector "result" from the normalization of the given one.
  83866. * @param vector the vector to normalize
  83867. * @param result the vector to store the result in
  83868. */
  83869. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83870. /**
  83871. * Returns a vector with the minimum values from the left and right vectors
  83872. * @param left left vector to minimize
  83873. * @param right right vector to minimize
  83874. * @returns a new vector with the minimum of the left and right vector values
  83875. */
  83876. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83877. /**
  83878. * Returns a vector with the maximum values from the left and right vectors
  83879. * @param left left vector to maximize
  83880. * @param right right vector to maximize
  83881. * @returns a new vector with the maximum of the left and right vector values
  83882. */
  83883. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83884. /**
  83885. * Returns the distance (float) between the vectors "value1" and "value2".
  83886. * @param value1 value to calulate the distance between
  83887. * @param value2 value to calulate the distance between
  83888. * @return the distance between the two vectors
  83889. */
  83890. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83891. /**
  83892. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83893. * @param value1 value to calulate the distance between
  83894. * @param value2 value to calulate the distance between
  83895. * @return the distance between the two vectors squared
  83896. */
  83897. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83898. /**
  83899. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83900. * @param value1 value to calulate the center between
  83901. * @param value2 value to calulate the center between
  83902. * @return the center between the two vectors
  83903. */
  83904. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83905. /**
  83906. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83907. * This methods computes transformed normalized direction vectors only.
  83908. * @param vector the vector to transform
  83909. * @param transformation the transformation matrix to apply
  83910. * @returns the new vector
  83911. */
  83912. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83913. /**
  83914. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83915. * This methods computes transformed normalized direction vectors only.
  83916. * @param vector the vector to transform
  83917. * @param transformation the transformation matrix to apply
  83918. * @param result the vector to store the result in
  83919. */
  83920. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83921. /**
  83922. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83923. * This methods computes transformed normalized direction vectors only.
  83924. * @param x value to transform
  83925. * @param y value to transform
  83926. * @param z value to transform
  83927. * @param w value to transform
  83928. * @param transformation the transformation matrix to apply
  83929. * @param result the vector to store the results in
  83930. */
  83931. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83932. /**
  83933. * Creates a new Vector4 from a Vector3
  83934. * @param source defines the source data
  83935. * @param w defines the 4th component (default is 0)
  83936. * @returns a new Vector4
  83937. */
  83938. static FromVector3(source: Vector3, w?: number): Vector4;
  83939. }
  83940. /**
  83941. * Class used to store quaternion data
  83942. * @see https://en.wikipedia.org/wiki/Quaternion
  83943. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83944. */
  83945. export class Quaternion {
  83946. /** @hidden */
  83947. _x: number;
  83948. /** @hidden */
  83949. _y: number;
  83950. /** @hidden */
  83951. _z: number;
  83952. /** @hidden */
  83953. _w: number;
  83954. /** @hidden */
  83955. _isDirty: boolean;
  83956. /** Gets or sets the x coordinate */
  83957. get x(): number;
  83958. set x(value: number);
  83959. /** Gets or sets the y coordinate */
  83960. get y(): number;
  83961. set y(value: number);
  83962. /** Gets or sets the z coordinate */
  83963. get z(): number;
  83964. set z(value: number);
  83965. /** Gets or sets the w coordinate */
  83966. get w(): number;
  83967. set w(value: number);
  83968. /**
  83969. * Creates a new Quaternion from the given floats
  83970. * @param x defines the first component (0 by default)
  83971. * @param y defines the second component (0 by default)
  83972. * @param z defines the third component (0 by default)
  83973. * @param w defines the fourth component (1.0 by default)
  83974. */
  83975. constructor(x?: number, y?: number, z?: number, w?: number);
  83976. /**
  83977. * Gets a string representation for the current quaternion
  83978. * @returns a string with the Quaternion coordinates
  83979. */
  83980. toString(): string;
  83981. /**
  83982. * Gets the class name of the quaternion
  83983. * @returns the string "Quaternion"
  83984. */
  83985. getClassName(): string;
  83986. /**
  83987. * Gets a hash code for this quaternion
  83988. * @returns the quaternion hash code
  83989. */
  83990. getHashCode(): number;
  83991. /**
  83992. * Copy the quaternion to an array
  83993. * @returns a new array populated with 4 elements from the quaternion coordinates
  83994. */
  83995. asArray(): number[];
  83996. /**
  83997. * Check if two quaternions are equals
  83998. * @param otherQuaternion defines the second operand
  83999. * @return true if the current quaternion and the given one coordinates are strictly equals
  84000. */
  84001. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84002. /**
  84003. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84004. * @param otherQuaternion defines the other quaternion
  84005. * @param epsilon defines the minimal distance to consider equality
  84006. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84007. */
  84008. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84009. /**
  84010. * Clone the current quaternion
  84011. * @returns a new quaternion copied from the current one
  84012. */
  84013. clone(): Quaternion;
  84014. /**
  84015. * Copy a quaternion to the current one
  84016. * @param other defines the other quaternion
  84017. * @returns the updated current quaternion
  84018. */
  84019. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84020. /**
  84021. * Updates the current quaternion with the given float coordinates
  84022. * @param x defines the x coordinate
  84023. * @param y defines the y coordinate
  84024. * @param z defines the z coordinate
  84025. * @param w defines the w coordinate
  84026. * @returns the updated current quaternion
  84027. */
  84028. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84029. /**
  84030. * Updates the current quaternion from the given float coordinates
  84031. * @param x defines the x coordinate
  84032. * @param y defines the y coordinate
  84033. * @param z defines the z coordinate
  84034. * @param w defines the w coordinate
  84035. * @returns the updated current quaternion
  84036. */
  84037. set(x: number, y: number, z: number, w: number): Quaternion;
  84038. /**
  84039. * Adds two quaternions
  84040. * @param other defines the second operand
  84041. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84042. */
  84043. add(other: DeepImmutable<Quaternion>): Quaternion;
  84044. /**
  84045. * Add a quaternion to the current one
  84046. * @param other defines the quaternion to add
  84047. * @returns the current quaternion
  84048. */
  84049. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84050. /**
  84051. * Subtract two quaternions
  84052. * @param other defines the second operand
  84053. * @returns a new quaternion as the subtraction result of the given one from the current one
  84054. */
  84055. subtract(other: Quaternion): Quaternion;
  84056. /**
  84057. * Multiplies the current quaternion by a scale factor
  84058. * @param value defines the scale factor
  84059. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84060. */
  84061. scale(value: number): Quaternion;
  84062. /**
  84063. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84064. * @param scale defines the scale factor
  84065. * @param result defines the Quaternion object where to store the result
  84066. * @returns the unmodified current quaternion
  84067. */
  84068. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84069. /**
  84070. * Multiplies in place the current quaternion by a scale factor
  84071. * @param value defines the scale factor
  84072. * @returns the current modified quaternion
  84073. */
  84074. scaleInPlace(value: number): Quaternion;
  84075. /**
  84076. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84077. * @param scale defines the scale factor
  84078. * @param result defines the Quaternion object where to store the result
  84079. * @returns the unmodified current quaternion
  84080. */
  84081. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84082. /**
  84083. * Multiplies two quaternions
  84084. * @param q1 defines the second operand
  84085. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84086. */
  84087. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84088. /**
  84089. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84090. * @param q1 defines the second operand
  84091. * @param result defines the target quaternion
  84092. * @returns the current quaternion
  84093. */
  84094. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84095. /**
  84096. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84097. * @param q1 defines the second operand
  84098. * @returns the currentupdated quaternion
  84099. */
  84100. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84101. /**
  84102. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84103. * @param ref defines the target quaternion
  84104. * @returns the current quaternion
  84105. */
  84106. conjugateToRef(ref: Quaternion): Quaternion;
  84107. /**
  84108. * Conjugates in place (1-q) the current quaternion
  84109. * @returns the current updated quaternion
  84110. */
  84111. conjugateInPlace(): Quaternion;
  84112. /**
  84113. * Conjugates in place (1-q) the current quaternion
  84114. * @returns a new quaternion
  84115. */
  84116. conjugate(): Quaternion;
  84117. /**
  84118. * Gets length of current quaternion
  84119. * @returns the quaternion length (float)
  84120. */
  84121. length(): number;
  84122. /**
  84123. * Normalize in place the current quaternion
  84124. * @returns the current updated quaternion
  84125. */
  84126. normalize(): Quaternion;
  84127. /**
  84128. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84129. * @param order is a reserved parameter and is ignored for now
  84130. * @returns a new Vector3 containing the Euler angles
  84131. */
  84132. toEulerAngles(order?: string): Vector3;
  84133. /**
  84134. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84135. * @param result defines the vector which will be filled with the Euler angles
  84136. * @returns the current unchanged quaternion
  84137. */
  84138. toEulerAnglesToRef(result: Vector3): Quaternion;
  84139. /**
  84140. * Updates the given rotation matrix with the current quaternion values
  84141. * @param result defines the target matrix
  84142. * @returns the current unchanged quaternion
  84143. */
  84144. toRotationMatrix(result: Matrix): Quaternion;
  84145. /**
  84146. * Updates the current quaternion from the given rotation matrix values
  84147. * @param matrix defines the source matrix
  84148. * @returns the current updated quaternion
  84149. */
  84150. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84151. /**
  84152. * Creates a new quaternion from a rotation matrix
  84153. * @param matrix defines the source matrix
  84154. * @returns a new quaternion created from the given rotation matrix values
  84155. */
  84156. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84157. /**
  84158. * Updates the given quaternion with the given rotation matrix values
  84159. * @param matrix defines the source matrix
  84160. * @param result defines the target quaternion
  84161. */
  84162. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84163. /**
  84164. * Returns the dot product (float) between the quaternions "left" and "right"
  84165. * @param left defines the left operand
  84166. * @param right defines the right operand
  84167. * @returns the dot product
  84168. */
  84169. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84170. /**
  84171. * Checks if the two quaternions are close to each other
  84172. * @param quat0 defines the first quaternion to check
  84173. * @param quat1 defines the second quaternion to check
  84174. * @returns true if the two quaternions are close to each other
  84175. */
  84176. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84177. /**
  84178. * Creates an empty quaternion
  84179. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84180. */
  84181. static Zero(): Quaternion;
  84182. /**
  84183. * Inverse a given quaternion
  84184. * @param q defines the source quaternion
  84185. * @returns a new quaternion as the inverted current quaternion
  84186. */
  84187. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84188. /**
  84189. * Inverse a given quaternion
  84190. * @param q defines the source quaternion
  84191. * @param result the quaternion the result will be stored in
  84192. * @returns the result quaternion
  84193. */
  84194. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84195. /**
  84196. * Creates an identity quaternion
  84197. * @returns the identity quaternion
  84198. */
  84199. static Identity(): Quaternion;
  84200. /**
  84201. * Gets a boolean indicating if the given quaternion is identity
  84202. * @param quaternion defines the quaternion to check
  84203. * @returns true if the quaternion is identity
  84204. */
  84205. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84206. /**
  84207. * Creates a quaternion from a rotation around an axis
  84208. * @param axis defines the axis to use
  84209. * @param angle defines the angle to use
  84210. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84211. */
  84212. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84213. /**
  84214. * Creates a rotation around an axis and stores it into the given quaternion
  84215. * @param axis defines the axis to use
  84216. * @param angle defines the angle to use
  84217. * @param result defines the target quaternion
  84218. * @returns the target quaternion
  84219. */
  84220. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84221. /**
  84222. * Creates a new quaternion from data stored into an array
  84223. * @param array defines the data source
  84224. * @param offset defines the offset in the source array where the data starts
  84225. * @returns a new quaternion
  84226. */
  84227. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84228. /**
  84229. * Updates the given quaternion "result" from the starting index of the given array.
  84230. * @param array the array to pull values from
  84231. * @param offset the offset into the array to start at
  84232. * @param result the quaternion to store the result in
  84233. */
  84234. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84235. /**
  84236. * Create a quaternion from Euler rotation angles
  84237. * @param x Pitch
  84238. * @param y Yaw
  84239. * @param z Roll
  84240. * @returns the new Quaternion
  84241. */
  84242. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84243. /**
  84244. * Updates a quaternion from Euler rotation angles
  84245. * @param x Pitch
  84246. * @param y Yaw
  84247. * @param z Roll
  84248. * @param result the quaternion to store the result
  84249. * @returns the updated quaternion
  84250. */
  84251. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84252. /**
  84253. * Create a quaternion from Euler rotation vector
  84254. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84255. * @returns the new Quaternion
  84256. */
  84257. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84258. /**
  84259. * Updates a quaternion from Euler rotation vector
  84260. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84261. * @param result the quaternion to store the result
  84262. * @returns the updated quaternion
  84263. */
  84264. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84265. /**
  84266. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84267. * @param yaw defines the rotation around Y axis
  84268. * @param pitch defines the rotation around X axis
  84269. * @param roll defines the rotation around Z axis
  84270. * @returns the new quaternion
  84271. */
  84272. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84273. /**
  84274. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84275. * @param yaw defines the rotation around Y axis
  84276. * @param pitch defines the rotation around X axis
  84277. * @param roll defines the rotation around Z axis
  84278. * @param result defines the target quaternion
  84279. */
  84280. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84281. /**
  84282. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84283. * @param alpha defines the rotation around first axis
  84284. * @param beta defines the rotation around second axis
  84285. * @param gamma defines the rotation around third axis
  84286. * @returns the new quaternion
  84287. */
  84288. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84289. /**
  84290. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84291. * @param alpha defines the rotation around first axis
  84292. * @param beta defines the rotation around second axis
  84293. * @param gamma defines the rotation around third axis
  84294. * @param result defines the target quaternion
  84295. */
  84296. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84297. /**
  84298. * 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)
  84299. * @param axis1 defines the first axis
  84300. * @param axis2 defines the second axis
  84301. * @param axis3 defines the third axis
  84302. * @returns the new quaternion
  84303. */
  84304. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84305. /**
  84306. * 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
  84307. * @param axis1 defines the first axis
  84308. * @param axis2 defines the second axis
  84309. * @param axis3 defines the third axis
  84310. * @param ref defines the target quaternion
  84311. */
  84312. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84313. /**
  84314. * Interpolates between two quaternions
  84315. * @param left defines first quaternion
  84316. * @param right defines second quaternion
  84317. * @param amount defines the gradient to use
  84318. * @returns the new interpolated quaternion
  84319. */
  84320. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84321. /**
  84322. * Interpolates between two quaternions and stores it into a target quaternion
  84323. * @param left defines first quaternion
  84324. * @param right defines second quaternion
  84325. * @param amount defines the gradient to use
  84326. * @param result defines the target quaternion
  84327. */
  84328. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84329. /**
  84330. * Interpolate between two quaternions using Hermite interpolation
  84331. * @param value1 defines first quaternion
  84332. * @param tangent1 defines the incoming tangent
  84333. * @param value2 defines second quaternion
  84334. * @param tangent2 defines the outgoing tangent
  84335. * @param amount defines the target quaternion
  84336. * @returns the new interpolated quaternion
  84337. */
  84338. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84339. }
  84340. /**
  84341. * Class used to store matrix data (4x4)
  84342. */
  84343. export class Matrix {
  84344. /**
  84345. * Gets the precision of matrix computations
  84346. */
  84347. static get Use64Bits(): boolean;
  84348. private static _updateFlagSeed;
  84349. private static _identityReadOnly;
  84350. private _isIdentity;
  84351. private _isIdentityDirty;
  84352. private _isIdentity3x2;
  84353. private _isIdentity3x2Dirty;
  84354. /**
  84355. * Gets the update flag of the matrix which is an unique number for the matrix.
  84356. * It will be incremented every time the matrix data change.
  84357. * You can use it to speed the comparison between two versions of the same matrix.
  84358. */
  84359. updateFlag: number;
  84360. private readonly _m;
  84361. /**
  84362. * Gets the internal data of the matrix
  84363. */
  84364. get m(): DeepImmutable<Float32Array | Array<number>>;
  84365. /** @hidden */
  84366. _markAsUpdated(): void;
  84367. /** @hidden */
  84368. private _updateIdentityStatus;
  84369. /**
  84370. * Creates an empty matrix (filled with zeros)
  84371. */
  84372. constructor();
  84373. /**
  84374. * Check if the current matrix is identity
  84375. * @returns true is the matrix is the identity matrix
  84376. */
  84377. isIdentity(): boolean;
  84378. /**
  84379. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84380. * @returns true is the matrix is the identity matrix
  84381. */
  84382. isIdentityAs3x2(): boolean;
  84383. /**
  84384. * Gets the determinant of the matrix
  84385. * @returns the matrix determinant
  84386. */
  84387. determinant(): number;
  84388. /**
  84389. * Returns the matrix as a Float32Array or Array<number>
  84390. * @returns the matrix underlying array
  84391. */
  84392. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84393. /**
  84394. * Returns the matrix as a Float32Array or Array<number>
  84395. * @returns the matrix underlying array.
  84396. */
  84397. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84398. /**
  84399. * Inverts the current matrix in place
  84400. * @returns the current inverted matrix
  84401. */
  84402. invert(): Matrix;
  84403. /**
  84404. * Sets all the matrix elements to zero
  84405. * @returns the current matrix
  84406. */
  84407. reset(): Matrix;
  84408. /**
  84409. * Adds the current matrix with a second one
  84410. * @param other defines the matrix to add
  84411. * @returns a new matrix as the addition of the current matrix and the given one
  84412. */
  84413. add(other: DeepImmutable<Matrix>): Matrix;
  84414. /**
  84415. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84416. * @param other defines the matrix to add
  84417. * @param result defines the target matrix
  84418. * @returns the current matrix
  84419. */
  84420. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84421. /**
  84422. * Adds in place the given matrix to the current matrix
  84423. * @param other defines the second operand
  84424. * @returns the current updated matrix
  84425. */
  84426. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84427. /**
  84428. * Sets the given matrix to the current inverted Matrix
  84429. * @param other defines the target matrix
  84430. * @returns the unmodified current matrix
  84431. */
  84432. invertToRef(other: Matrix): Matrix;
  84433. /**
  84434. * add a value at the specified position in the current Matrix
  84435. * @param index the index of the value within the matrix. between 0 and 15.
  84436. * @param value the value to be added
  84437. * @returns the current updated matrix
  84438. */
  84439. addAtIndex(index: number, value: number): Matrix;
  84440. /**
  84441. * mutiply the specified position in the current Matrix by a value
  84442. * @param index the index of the value within the matrix. between 0 and 15.
  84443. * @param value the value to be added
  84444. * @returns the current updated matrix
  84445. */
  84446. multiplyAtIndex(index: number, value: number): Matrix;
  84447. /**
  84448. * Inserts the translation vector (using 3 floats) in the current matrix
  84449. * @param x defines the 1st component of the translation
  84450. * @param y defines the 2nd component of the translation
  84451. * @param z defines the 3rd component of the translation
  84452. * @returns the current updated matrix
  84453. */
  84454. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84455. /**
  84456. * Adds the translation vector (using 3 floats) in the current matrix
  84457. * @param x defines the 1st component of the translation
  84458. * @param y defines the 2nd component of the translation
  84459. * @param z defines the 3rd component of the translation
  84460. * @returns the current updated matrix
  84461. */
  84462. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84463. /**
  84464. * Inserts the translation vector in the current matrix
  84465. * @param vector3 defines the translation to insert
  84466. * @returns the current updated matrix
  84467. */
  84468. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84469. /**
  84470. * Gets the translation value of the current matrix
  84471. * @returns a new Vector3 as the extracted translation from the matrix
  84472. */
  84473. getTranslation(): Vector3;
  84474. /**
  84475. * Fill a Vector3 with the extracted translation from the matrix
  84476. * @param result defines the Vector3 where to store the translation
  84477. * @returns the current matrix
  84478. */
  84479. getTranslationToRef(result: Vector3): Matrix;
  84480. /**
  84481. * Remove rotation and scaling part from the matrix
  84482. * @returns the updated matrix
  84483. */
  84484. removeRotationAndScaling(): Matrix;
  84485. /**
  84486. * Multiply two matrices
  84487. * @param other defines the second operand
  84488. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84489. */
  84490. multiply(other: DeepImmutable<Matrix>): Matrix;
  84491. /**
  84492. * Copy the current matrix from the given one
  84493. * @param other defines the source matrix
  84494. * @returns the current updated matrix
  84495. */
  84496. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84497. /**
  84498. * Populates the given array from the starting index with the current matrix values
  84499. * @param array defines the target array
  84500. * @param offset defines the offset in the target array where to start storing values
  84501. * @returns the current matrix
  84502. */
  84503. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84504. /**
  84505. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84506. * @param other defines the second operand
  84507. * @param result defines the matrix where to store the multiplication
  84508. * @returns the current matrix
  84509. */
  84510. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84511. /**
  84512. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84513. * @param other defines the second operand
  84514. * @param result defines the array where to store the multiplication
  84515. * @param offset defines the offset in the target array where to start storing values
  84516. * @returns the current matrix
  84517. */
  84518. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84519. /**
  84520. * Check equality between this matrix and a second one
  84521. * @param value defines the second matrix to compare
  84522. * @returns true is the current matrix and the given one values are strictly equal
  84523. */
  84524. equals(value: DeepImmutable<Matrix>): boolean;
  84525. /**
  84526. * Clone the current matrix
  84527. * @returns a new matrix from the current matrix
  84528. */
  84529. clone(): Matrix;
  84530. /**
  84531. * Returns the name of the current matrix class
  84532. * @returns the string "Matrix"
  84533. */
  84534. getClassName(): string;
  84535. /**
  84536. * Gets the hash code of the current matrix
  84537. * @returns the hash code
  84538. */
  84539. getHashCode(): number;
  84540. /**
  84541. * Decomposes the current Matrix into a translation, rotation and scaling components
  84542. * @param scale defines the scale vector3 given as a reference to update
  84543. * @param rotation defines the rotation quaternion given as a reference to update
  84544. * @param translation defines the translation vector3 given as a reference to update
  84545. * @returns true if operation was successful
  84546. */
  84547. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84548. /**
  84549. * Gets specific row of the matrix
  84550. * @param index defines the number of the row to get
  84551. * @returns the index-th row of the current matrix as a new Vector4
  84552. */
  84553. getRow(index: number): Nullable<Vector4>;
  84554. /**
  84555. * Sets the index-th row of the current matrix to the vector4 values
  84556. * @param index defines the number of the row to set
  84557. * @param row defines the target vector4
  84558. * @returns the updated current matrix
  84559. */
  84560. setRow(index: number, row: Vector4): Matrix;
  84561. /**
  84562. * Compute the transpose of the matrix
  84563. * @returns the new transposed matrix
  84564. */
  84565. transpose(): Matrix;
  84566. /**
  84567. * Compute the transpose of the matrix and store it in a given matrix
  84568. * @param result defines the target matrix
  84569. * @returns the current matrix
  84570. */
  84571. transposeToRef(result: Matrix): Matrix;
  84572. /**
  84573. * Sets the index-th row of the current matrix with the given 4 x float values
  84574. * @param index defines the row index
  84575. * @param x defines the x component to set
  84576. * @param y defines the y component to set
  84577. * @param z defines the z component to set
  84578. * @param w defines the w component to set
  84579. * @returns the updated current matrix
  84580. */
  84581. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84582. /**
  84583. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84584. * @param scale defines the scale factor
  84585. * @returns a new matrix
  84586. */
  84587. scale(scale: number): Matrix;
  84588. /**
  84589. * Scale the current matrix values by a factor to a given result matrix
  84590. * @param scale defines the scale factor
  84591. * @param result defines the matrix to store the result
  84592. * @returns the current matrix
  84593. */
  84594. scaleToRef(scale: number, result: Matrix): Matrix;
  84595. /**
  84596. * Scale the current matrix values by a factor and add the result to a given matrix
  84597. * @param scale defines the scale factor
  84598. * @param result defines the Matrix to store the result
  84599. * @returns the current matrix
  84600. */
  84601. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84602. /**
  84603. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84604. * @param ref matrix to store the result
  84605. */
  84606. toNormalMatrix(ref: Matrix): void;
  84607. /**
  84608. * Gets only rotation part of the current matrix
  84609. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84610. */
  84611. getRotationMatrix(): Matrix;
  84612. /**
  84613. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84614. * @param result defines the target matrix to store data to
  84615. * @returns the current matrix
  84616. */
  84617. getRotationMatrixToRef(result: Matrix): Matrix;
  84618. /**
  84619. * Toggles model matrix from being right handed to left handed in place and vice versa
  84620. */
  84621. toggleModelMatrixHandInPlace(): void;
  84622. /**
  84623. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84624. */
  84625. toggleProjectionMatrixHandInPlace(): void;
  84626. /**
  84627. * Creates a matrix from an array
  84628. * @param array defines the source array
  84629. * @param offset defines an offset in the source array
  84630. * @returns a new Matrix set from the starting index of the given array
  84631. */
  84632. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84633. /**
  84634. * Copy the content of an array into a given matrix
  84635. * @param array defines the source array
  84636. * @param offset defines an offset in the source array
  84637. * @param result defines the target matrix
  84638. */
  84639. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84640. /**
  84641. * Stores an array into a matrix after having multiplied each component by a given factor
  84642. * @param array defines the source array
  84643. * @param offset defines the offset in the source array
  84644. * @param scale defines the scaling factor
  84645. * @param result defines the target matrix
  84646. */
  84647. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84648. /**
  84649. * Gets an identity matrix that must not be updated
  84650. */
  84651. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84652. /**
  84653. * Stores a list of values (16) inside a given matrix
  84654. * @param initialM11 defines 1st value of 1st row
  84655. * @param initialM12 defines 2nd value of 1st row
  84656. * @param initialM13 defines 3rd value of 1st row
  84657. * @param initialM14 defines 4th value of 1st row
  84658. * @param initialM21 defines 1st value of 2nd row
  84659. * @param initialM22 defines 2nd value of 2nd row
  84660. * @param initialM23 defines 3rd value of 2nd row
  84661. * @param initialM24 defines 4th value of 2nd row
  84662. * @param initialM31 defines 1st value of 3rd row
  84663. * @param initialM32 defines 2nd value of 3rd row
  84664. * @param initialM33 defines 3rd value of 3rd row
  84665. * @param initialM34 defines 4th value of 3rd row
  84666. * @param initialM41 defines 1st value of 4th row
  84667. * @param initialM42 defines 2nd value of 4th row
  84668. * @param initialM43 defines 3rd value of 4th row
  84669. * @param initialM44 defines 4th value of 4th row
  84670. * @param result defines the target matrix
  84671. */
  84672. 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;
  84673. /**
  84674. * Creates new matrix from a list of values (16)
  84675. * @param initialM11 defines 1st value of 1st row
  84676. * @param initialM12 defines 2nd value of 1st row
  84677. * @param initialM13 defines 3rd value of 1st row
  84678. * @param initialM14 defines 4th value of 1st row
  84679. * @param initialM21 defines 1st value of 2nd row
  84680. * @param initialM22 defines 2nd value of 2nd row
  84681. * @param initialM23 defines 3rd value of 2nd row
  84682. * @param initialM24 defines 4th value of 2nd row
  84683. * @param initialM31 defines 1st value of 3rd row
  84684. * @param initialM32 defines 2nd value of 3rd row
  84685. * @param initialM33 defines 3rd value of 3rd row
  84686. * @param initialM34 defines 4th value of 3rd row
  84687. * @param initialM41 defines 1st value of 4th row
  84688. * @param initialM42 defines 2nd value of 4th row
  84689. * @param initialM43 defines 3rd value of 4th row
  84690. * @param initialM44 defines 4th value of 4th row
  84691. * @returns the new matrix
  84692. */
  84693. 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;
  84694. /**
  84695. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84696. * @param scale defines the scale vector3
  84697. * @param rotation defines the rotation quaternion
  84698. * @param translation defines the translation vector3
  84699. * @returns a new matrix
  84700. */
  84701. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84702. /**
  84703. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84704. * @param scale defines the scale vector3
  84705. * @param rotation defines the rotation quaternion
  84706. * @param translation defines the translation vector3
  84707. * @param result defines the target matrix
  84708. */
  84709. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84710. /**
  84711. * Creates a new identity matrix
  84712. * @returns a new identity matrix
  84713. */
  84714. static Identity(): Matrix;
  84715. /**
  84716. * Creates a new identity matrix and stores the result in a given matrix
  84717. * @param result defines the target matrix
  84718. */
  84719. static IdentityToRef(result: Matrix): void;
  84720. /**
  84721. * Creates a new zero matrix
  84722. * @returns a new zero matrix
  84723. */
  84724. static Zero(): Matrix;
  84725. /**
  84726. * Creates a new rotation matrix for "angle" radians around the X axis
  84727. * @param angle defines the angle (in radians) to use
  84728. * @return the new matrix
  84729. */
  84730. static RotationX(angle: number): Matrix;
  84731. /**
  84732. * Creates a new matrix as the invert of a given matrix
  84733. * @param source defines the source matrix
  84734. * @returns the new matrix
  84735. */
  84736. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84737. /**
  84738. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84739. * @param angle defines the angle (in radians) to use
  84740. * @param result defines the target matrix
  84741. */
  84742. static RotationXToRef(angle: number, result: Matrix): void;
  84743. /**
  84744. * Creates a new rotation matrix for "angle" radians around the Y axis
  84745. * @param angle defines the angle (in radians) to use
  84746. * @return the new matrix
  84747. */
  84748. static RotationY(angle: number): Matrix;
  84749. /**
  84750. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84751. * @param angle defines the angle (in radians) to use
  84752. * @param result defines the target matrix
  84753. */
  84754. static RotationYToRef(angle: number, result: Matrix): void;
  84755. /**
  84756. * Creates a new rotation matrix for "angle" radians around the Z axis
  84757. * @param angle defines the angle (in radians) to use
  84758. * @return the new matrix
  84759. */
  84760. static RotationZ(angle: number): Matrix;
  84761. /**
  84762. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84763. * @param angle defines the angle (in radians) to use
  84764. * @param result defines the target matrix
  84765. */
  84766. static RotationZToRef(angle: number, result: Matrix): void;
  84767. /**
  84768. * Creates a new rotation matrix for "angle" radians around the given axis
  84769. * @param axis defines the axis to use
  84770. * @param angle defines the angle (in radians) to use
  84771. * @return the new matrix
  84772. */
  84773. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84774. /**
  84775. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84776. * @param axis defines the axis to use
  84777. * @param angle defines the angle (in radians) to use
  84778. * @param result defines the target matrix
  84779. */
  84780. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84781. /**
  84782. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84783. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84784. * @param from defines the vector to align
  84785. * @param to defines the vector to align to
  84786. * @param result defines the target matrix
  84787. */
  84788. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84789. /**
  84790. * Creates a rotation matrix
  84791. * @param yaw defines the yaw angle in radians (Y axis)
  84792. * @param pitch defines the pitch angle in radians (X axis)
  84793. * @param roll defines the roll angle in radians (Z axis)
  84794. * @returns the new rotation matrix
  84795. */
  84796. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84797. /**
  84798. * Creates a rotation matrix and stores it in a given matrix
  84799. * @param yaw defines the yaw angle in radians (Y axis)
  84800. * @param pitch defines the pitch angle in radians (X axis)
  84801. * @param roll defines the roll angle in radians (Z axis)
  84802. * @param result defines the target matrix
  84803. */
  84804. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84805. /**
  84806. * Creates a scaling matrix
  84807. * @param x defines the scale factor on X axis
  84808. * @param y defines the scale factor on Y axis
  84809. * @param z defines the scale factor on Z axis
  84810. * @returns the new matrix
  84811. */
  84812. static Scaling(x: number, y: number, z: number): Matrix;
  84813. /**
  84814. * Creates a scaling matrix and stores it in a given matrix
  84815. * @param x defines the scale factor on X axis
  84816. * @param y defines the scale factor on Y axis
  84817. * @param z defines the scale factor on Z axis
  84818. * @param result defines the target matrix
  84819. */
  84820. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84821. /**
  84822. * Creates a translation matrix
  84823. * @param x defines the translation on X axis
  84824. * @param y defines the translation on Y axis
  84825. * @param z defines the translationon Z axis
  84826. * @returns the new matrix
  84827. */
  84828. static Translation(x: number, y: number, z: number): Matrix;
  84829. /**
  84830. * Creates a translation matrix and stores it in a given matrix
  84831. * @param x defines the translation on X axis
  84832. * @param y defines the translation on Y axis
  84833. * @param z defines the translationon Z axis
  84834. * @param result defines the target matrix
  84835. */
  84836. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84837. /**
  84838. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84839. * @param startValue defines the start value
  84840. * @param endValue defines the end value
  84841. * @param gradient defines the gradient factor
  84842. * @returns the new matrix
  84843. */
  84844. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84845. /**
  84846. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84847. * @param startValue defines the start value
  84848. * @param endValue defines the end value
  84849. * @param gradient defines the gradient factor
  84850. * @param result defines the Matrix object where to store data
  84851. */
  84852. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84853. /**
  84854. * Builds a new matrix whose values are computed by:
  84855. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84856. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84857. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84858. * @param startValue defines the first matrix
  84859. * @param endValue defines the second matrix
  84860. * @param gradient defines the gradient between the two matrices
  84861. * @returns the new matrix
  84862. */
  84863. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84864. /**
  84865. * Update a matrix to values which are computed by:
  84866. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84867. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84868. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84869. * @param startValue defines the first matrix
  84870. * @param endValue defines the second matrix
  84871. * @param gradient defines the gradient between the two matrices
  84872. * @param result defines the target matrix
  84873. */
  84874. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84875. /**
  84876. * 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"
  84877. * This function works in left handed mode
  84878. * @param eye defines the final position of the entity
  84879. * @param target defines where the entity should look at
  84880. * @param up defines the up vector for the entity
  84881. * @returns the new matrix
  84882. */
  84883. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84884. /**
  84885. * 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".
  84886. * This function works in left handed mode
  84887. * @param eye defines the final position of the entity
  84888. * @param target defines where the entity should look at
  84889. * @param up defines the up vector for the entity
  84890. * @param result defines the target matrix
  84891. */
  84892. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84893. /**
  84894. * 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"
  84895. * This function works in right handed mode
  84896. * @param eye defines the final position of the entity
  84897. * @param target defines where the entity should look at
  84898. * @param up defines the up vector for the entity
  84899. * @returns the new matrix
  84900. */
  84901. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84902. /**
  84903. * 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".
  84904. * This function works in right handed mode
  84905. * @param eye defines the final position of the entity
  84906. * @param target defines where the entity should look at
  84907. * @param up defines the up vector for the entity
  84908. * @param result defines the target matrix
  84909. */
  84910. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84911. /**
  84912. * Create a left-handed orthographic projection matrix
  84913. * @param width defines the viewport width
  84914. * @param height defines the viewport height
  84915. * @param znear defines the near clip plane
  84916. * @param zfar defines the far clip plane
  84917. * @returns a new matrix as a left-handed orthographic projection matrix
  84918. */
  84919. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84920. /**
  84921. * Store a left-handed orthographic projection to a given matrix
  84922. * @param width defines the viewport width
  84923. * @param height defines the viewport height
  84924. * @param znear defines the near clip plane
  84925. * @param zfar defines the far clip plane
  84926. * @param result defines the target matrix
  84927. */
  84928. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84929. /**
  84930. * Create a left-handed orthographic projection matrix
  84931. * @param left defines the viewport left coordinate
  84932. * @param right defines the viewport right coordinate
  84933. * @param bottom defines the viewport bottom coordinate
  84934. * @param top defines the viewport top coordinate
  84935. * @param znear defines the near clip plane
  84936. * @param zfar defines the far clip plane
  84937. * @returns a new matrix as a left-handed orthographic projection matrix
  84938. */
  84939. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84940. /**
  84941. * Stores a left-handed orthographic projection into a given matrix
  84942. * @param left defines the viewport left coordinate
  84943. * @param right defines the viewport right coordinate
  84944. * @param bottom defines the viewport bottom coordinate
  84945. * @param top defines the viewport top coordinate
  84946. * @param znear defines the near clip plane
  84947. * @param zfar defines the far clip plane
  84948. * @param result defines the target matrix
  84949. */
  84950. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84951. /**
  84952. * Creates a right-handed orthographic projection matrix
  84953. * @param left defines the viewport left coordinate
  84954. * @param right defines the viewport right coordinate
  84955. * @param bottom defines the viewport bottom coordinate
  84956. * @param top defines the viewport top coordinate
  84957. * @param znear defines the near clip plane
  84958. * @param zfar defines the far clip plane
  84959. * @returns a new matrix as a right-handed orthographic projection matrix
  84960. */
  84961. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84962. /**
  84963. * Stores a right-handed orthographic projection into a given matrix
  84964. * @param left defines the viewport left coordinate
  84965. * @param right defines the viewport right coordinate
  84966. * @param bottom defines the viewport bottom coordinate
  84967. * @param top defines the viewport top coordinate
  84968. * @param znear defines the near clip plane
  84969. * @param zfar defines the far clip plane
  84970. * @param result defines the target matrix
  84971. */
  84972. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84973. /**
  84974. * Creates a left-handed perspective projection matrix
  84975. * @param width defines the viewport width
  84976. * @param height defines the viewport height
  84977. * @param znear defines the near clip plane
  84978. * @param zfar defines the far clip plane
  84979. * @returns a new matrix as a left-handed perspective projection matrix
  84980. */
  84981. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84982. /**
  84983. * Creates a left-handed perspective projection matrix
  84984. * @param fov defines the horizontal field of view
  84985. * @param aspect defines the aspect ratio
  84986. * @param znear defines the near clip plane
  84987. * @param zfar defines the far clip plane
  84988. * @returns a new matrix as a left-handed perspective projection matrix
  84989. */
  84990. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84991. /**
  84992. * Stores a left-handed perspective projection into a given matrix
  84993. * @param fov defines the horizontal field of view
  84994. * @param aspect defines the aspect ratio
  84995. * @param znear defines the near clip plane
  84996. * @param zfar defines the far clip plane
  84997. * @param result defines the target matrix
  84998. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84999. */
  85000. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85001. /**
  85002. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85003. * @param fov defines the horizontal field of view
  85004. * @param aspect defines the aspect ratio
  85005. * @param znear defines the near clip plane
  85006. * @param zfar not used as infinity is used as far clip
  85007. * @param result defines the target matrix
  85008. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85009. */
  85010. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85011. /**
  85012. * Creates a right-handed perspective projection matrix
  85013. * @param fov defines the horizontal field of view
  85014. * @param aspect defines the aspect ratio
  85015. * @param znear defines the near clip plane
  85016. * @param zfar defines the far clip plane
  85017. * @returns a new matrix as a right-handed perspective projection matrix
  85018. */
  85019. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85020. /**
  85021. * Stores a right-handed perspective projection into a given matrix
  85022. * @param fov defines the horizontal field of view
  85023. * @param aspect defines the aspect ratio
  85024. * @param znear defines the near clip plane
  85025. * @param zfar defines the far clip plane
  85026. * @param result defines the target matrix
  85027. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85028. */
  85029. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85030. /**
  85031. * Stores a right-handed perspective projection into a given matrix
  85032. * @param fov defines the horizontal field of view
  85033. * @param aspect defines the aspect ratio
  85034. * @param znear defines the near clip plane
  85035. * @param zfar not used as infinity is used as far clip
  85036. * @param result defines the target matrix
  85037. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85038. */
  85039. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85040. /**
  85041. * Stores a perspective projection for WebVR info a given matrix
  85042. * @param fov defines the field of view
  85043. * @param znear defines the near clip plane
  85044. * @param zfar defines the far clip plane
  85045. * @param result defines the target matrix
  85046. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85047. */
  85048. static PerspectiveFovWebVRToRef(fov: {
  85049. upDegrees: number;
  85050. downDegrees: number;
  85051. leftDegrees: number;
  85052. rightDegrees: number;
  85053. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85054. /**
  85055. * Computes a complete transformation matrix
  85056. * @param viewport defines the viewport to use
  85057. * @param world defines the world matrix
  85058. * @param view defines the view matrix
  85059. * @param projection defines the projection matrix
  85060. * @param zmin defines the near clip plane
  85061. * @param zmax defines the far clip plane
  85062. * @returns the transformation matrix
  85063. */
  85064. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85065. /**
  85066. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85067. * @param matrix defines the matrix to use
  85068. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85069. */
  85070. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85071. /**
  85072. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85073. * @param matrix defines the matrix to use
  85074. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85075. */
  85076. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85077. /**
  85078. * Compute the transpose of a given matrix
  85079. * @param matrix defines the matrix to transpose
  85080. * @returns the new matrix
  85081. */
  85082. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85083. /**
  85084. * Compute the transpose of a matrix and store it in a target matrix
  85085. * @param matrix defines the matrix to transpose
  85086. * @param result defines the target matrix
  85087. */
  85088. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85089. /**
  85090. * Computes a reflection matrix from a plane
  85091. * @param plane defines the reflection plane
  85092. * @returns a new matrix
  85093. */
  85094. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85095. /**
  85096. * Computes a reflection matrix from a plane
  85097. * @param plane defines the reflection plane
  85098. * @param result defines the target matrix
  85099. */
  85100. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85101. /**
  85102. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85103. * @param xaxis defines the value of the 1st axis
  85104. * @param yaxis defines the value of the 2nd axis
  85105. * @param zaxis defines the value of the 3rd axis
  85106. * @param result defines the target matrix
  85107. */
  85108. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85109. /**
  85110. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85111. * @param quat defines the quaternion to use
  85112. * @param result defines the target matrix
  85113. */
  85114. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85115. }
  85116. /**
  85117. * @hidden
  85118. */
  85119. export class TmpVectors {
  85120. static Vector2: Vector2[];
  85121. static Vector3: Vector3[];
  85122. static Vector4: Vector4[];
  85123. static Quaternion: Quaternion[];
  85124. static Matrix: Matrix[];
  85125. }
  85126. }
  85127. declare module BABYLON {
  85128. /**
  85129. * Defines potential orientation for back face culling
  85130. */
  85131. export enum Orientation {
  85132. /**
  85133. * Clockwise
  85134. */
  85135. CW = 0,
  85136. /** Counter clockwise */
  85137. CCW = 1
  85138. }
  85139. /** Class used to represent a Bezier curve */
  85140. export class BezierCurve {
  85141. /**
  85142. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85143. * @param t defines the time
  85144. * @param x1 defines the left coordinate on X axis
  85145. * @param y1 defines the left coordinate on Y axis
  85146. * @param x2 defines the right coordinate on X axis
  85147. * @param y2 defines the right coordinate on Y axis
  85148. * @returns the interpolated value
  85149. */
  85150. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85151. }
  85152. /**
  85153. * Defines angle representation
  85154. */
  85155. export class Angle {
  85156. private _radians;
  85157. /**
  85158. * Creates an Angle object of "radians" radians (float).
  85159. * @param radians the angle in radians
  85160. */
  85161. constructor(radians: number);
  85162. /**
  85163. * Get value in degrees
  85164. * @returns the Angle value in degrees (float)
  85165. */
  85166. degrees(): number;
  85167. /**
  85168. * Get value in radians
  85169. * @returns the Angle value in radians (float)
  85170. */
  85171. radians(): number;
  85172. /**
  85173. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85174. * @param a defines first point as the origin
  85175. * @param b defines point
  85176. * @returns a new Angle
  85177. */
  85178. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85179. /**
  85180. * Gets a new Angle object from the given float in radians
  85181. * @param radians defines the angle value in radians
  85182. * @returns a new Angle
  85183. */
  85184. static FromRadians(radians: number): Angle;
  85185. /**
  85186. * Gets a new Angle object from the given float in degrees
  85187. * @param degrees defines the angle value in degrees
  85188. * @returns a new Angle
  85189. */
  85190. static FromDegrees(degrees: number): Angle;
  85191. }
  85192. /**
  85193. * This represents an arc in a 2d space.
  85194. */
  85195. export class Arc2 {
  85196. /** Defines the start point of the arc */
  85197. startPoint: Vector2;
  85198. /** Defines the mid point of the arc */
  85199. midPoint: Vector2;
  85200. /** Defines the end point of the arc */
  85201. endPoint: Vector2;
  85202. /**
  85203. * Defines the center point of the arc.
  85204. */
  85205. centerPoint: Vector2;
  85206. /**
  85207. * Defines the radius of the arc.
  85208. */
  85209. radius: number;
  85210. /**
  85211. * Defines the angle of the arc (from mid point to end point).
  85212. */
  85213. angle: Angle;
  85214. /**
  85215. * Defines the start angle of the arc (from start point to middle point).
  85216. */
  85217. startAngle: Angle;
  85218. /**
  85219. * Defines the orientation of the arc (clock wise/counter clock wise).
  85220. */
  85221. orientation: Orientation;
  85222. /**
  85223. * Creates an Arc object from the three given points : start, middle and end.
  85224. * @param startPoint Defines the start point of the arc
  85225. * @param midPoint Defines the midlle point of the arc
  85226. * @param endPoint Defines the end point of the arc
  85227. */
  85228. constructor(
  85229. /** Defines the start point of the arc */
  85230. startPoint: Vector2,
  85231. /** Defines the mid point of the arc */
  85232. midPoint: Vector2,
  85233. /** Defines the end point of the arc */
  85234. endPoint: Vector2);
  85235. }
  85236. /**
  85237. * Represents a 2D path made up of multiple 2D points
  85238. */
  85239. export class Path2 {
  85240. private _points;
  85241. private _length;
  85242. /**
  85243. * If the path start and end point are the same
  85244. */
  85245. closed: boolean;
  85246. /**
  85247. * Creates a Path2 object from the starting 2D coordinates x and y.
  85248. * @param x the starting points x value
  85249. * @param y the starting points y value
  85250. */
  85251. constructor(x: number, y: number);
  85252. /**
  85253. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85254. * @param x the added points x value
  85255. * @param y the added points y value
  85256. * @returns the updated Path2.
  85257. */
  85258. addLineTo(x: number, y: number): Path2;
  85259. /**
  85260. * 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.
  85261. * @param midX middle point x value
  85262. * @param midY middle point y value
  85263. * @param endX end point x value
  85264. * @param endY end point y value
  85265. * @param numberOfSegments (default: 36)
  85266. * @returns the updated Path2.
  85267. */
  85268. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85269. /**
  85270. * Closes the Path2.
  85271. * @returns the Path2.
  85272. */
  85273. close(): Path2;
  85274. /**
  85275. * Gets the sum of the distance between each sequential point in the path
  85276. * @returns the Path2 total length (float).
  85277. */
  85278. length(): number;
  85279. /**
  85280. * Gets the points which construct the path
  85281. * @returns the Path2 internal array of points.
  85282. */
  85283. getPoints(): Vector2[];
  85284. /**
  85285. * Retreives the point at the distance aways from the starting point
  85286. * @param normalizedLengthPosition the length along the path to retreive the point from
  85287. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85288. */
  85289. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85290. /**
  85291. * Creates a new path starting from an x and y position
  85292. * @param x starting x value
  85293. * @param y starting y value
  85294. * @returns a new Path2 starting at the coordinates (x, y).
  85295. */
  85296. static StartingAt(x: number, y: number): Path2;
  85297. }
  85298. /**
  85299. * Represents a 3D path made up of multiple 3D points
  85300. */
  85301. export class Path3D {
  85302. /**
  85303. * an array of Vector3, the curve axis of the Path3D
  85304. */
  85305. path: Vector3[];
  85306. private _curve;
  85307. private _distances;
  85308. private _tangents;
  85309. private _normals;
  85310. private _binormals;
  85311. private _raw;
  85312. private _alignTangentsWithPath;
  85313. private readonly _pointAtData;
  85314. /**
  85315. * new Path3D(path, normal, raw)
  85316. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85317. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85318. * @param path an array of Vector3, the curve axis of the Path3D
  85319. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85320. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85321. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85322. */
  85323. constructor(
  85324. /**
  85325. * an array of Vector3, the curve axis of the Path3D
  85326. */
  85327. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85328. /**
  85329. * Returns the Path3D array of successive Vector3 designing its curve.
  85330. * @returns the Path3D array of successive Vector3 designing its curve.
  85331. */
  85332. getCurve(): Vector3[];
  85333. /**
  85334. * Returns the Path3D array of successive Vector3 designing its curve.
  85335. * @returns the Path3D array of successive Vector3 designing its curve.
  85336. */
  85337. getPoints(): Vector3[];
  85338. /**
  85339. * @returns the computed length (float) of the path.
  85340. */
  85341. length(): number;
  85342. /**
  85343. * Returns an array populated with tangent vectors on each Path3D curve point.
  85344. * @returns an array populated with tangent vectors on each Path3D curve point.
  85345. */
  85346. getTangents(): Vector3[];
  85347. /**
  85348. * Returns an array populated with normal vectors on each Path3D curve point.
  85349. * @returns an array populated with normal vectors on each Path3D curve point.
  85350. */
  85351. getNormals(): Vector3[];
  85352. /**
  85353. * Returns an array populated with binormal vectors on each Path3D curve point.
  85354. * @returns an array populated with binormal vectors on each Path3D curve point.
  85355. */
  85356. getBinormals(): Vector3[];
  85357. /**
  85358. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85359. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85360. */
  85361. getDistances(): number[];
  85362. /**
  85363. * Returns an interpolated point along this path
  85364. * @param position the position of the point along this path, from 0.0 to 1.0
  85365. * @returns a new Vector3 as the point
  85366. */
  85367. getPointAt(position: number): Vector3;
  85368. /**
  85369. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85370. * @param position the position of the point along this path, from 0.0 to 1.0
  85371. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85372. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85373. */
  85374. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85375. /**
  85376. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85377. * @param position the position of the point along this path, from 0.0 to 1.0
  85378. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85379. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85380. */
  85381. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85382. /**
  85383. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85384. * @param position the position of the point along this path, from 0.0 to 1.0
  85385. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85386. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85387. */
  85388. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85389. /**
  85390. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85391. * @param position the position of the point along this path, from 0.0 to 1.0
  85392. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85393. */
  85394. getDistanceAt(position: number): number;
  85395. /**
  85396. * Returns the array index of the previous point of an interpolated point along this path
  85397. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85398. * @returns the array index
  85399. */
  85400. getPreviousPointIndexAt(position: number): number;
  85401. /**
  85402. * 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)
  85403. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85404. * @returns the sub position
  85405. */
  85406. getSubPositionAt(position: number): number;
  85407. /**
  85408. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85409. * @param target the vector of which to get the closest position to
  85410. * @returns the position of the closest virtual point on this path to the target vector
  85411. */
  85412. getClosestPositionTo(target: Vector3): number;
  85413. /**
  85414. * Returns a sub path (slice) of this path
  85415. * @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
  85416. * @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
  85417. * @returns a sub path (slice) of this path
  85418. */
  85419. slice(start?: number, end?: number): Path3D;
  85420. /**
  85421. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85422. * @param path path which all values are copied into the curves points
  85423. * @param firstNormal which should be projected onto the curve
  85424. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85425. * @returns the same object updated.
  85426. */
  85427. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85428. private _compute;
  85429. private _getFirstNonNullVector;
  85430. private _getLastNonNullVector;
  85431. private _normalVector;
  85432. /**
  85433. * Updates the point at data for an interpolated point along this curve
  85434. * @param position the position of the point along this curve, from 0.0 to 1.0
  85435. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85436. * @returns the (updated) point at data
  85437. */
  85438. private _updatePointAtData;
  85439. /**
  85440. * Updates the point at data from the specified parameters
  85441. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85442. * @param point the interpolated point
  85443. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85444. */
  85445. private _setPointAtData;
  85446. /**
  85447. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85448. */
  85449. private _updateInterpolationMatrix;
  85450. }
  85451. /**
  85452. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85453. * A Curve3 is designed from a series of successive Vector3.
  85454. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85455. */
  85456. export class Curve3 {
  85457. private _points;
  85458. private _length;
  85459. /**
  85460. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85461. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85462. * @param v1 (Vector3) the control point
  85463. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85464. * @param nbPoints (integer) the wanted number of points in the curve
  85465. * @returns the created Curve3
  85466. */
  85467. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85468. /**
  85469. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85470. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85471. * @param v1 (Vector3) the first control point
  85472. * @param v2 (Vector3) the second control point
  85473. * @param v3 (Vector3) the end point of the Cubic Bezier
  85474. * @param nbPoints (integer) the wanted number of points in the curve
  85475. * @returns the created Curve3
  85476. */
  85477. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85478. /**
  85479. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85480. * @param p1 (Vector3) the origin point of the Hermite Spline
  85481. * @param t1 (Vector3) the tangent vector at the origin point
  85482. * @param p2 (Vector3) the end point of the Hermite Spline
  85483. * @param t2 (Vector3) the tangent vector at the end point
  85484. * @param nbPoints (integer) the wanted number of points in the curve
  85485. * @returns the created Curve3
  85486. */
  85487. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85488. /**
  85489. * Returns a Curve3 object along a CatmullRom Spline curve :
  85490. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85491. * @param nbPoints (integer) the wanted number of points between each curve control points
  85492. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85493. * @returns the created Curve3
  85494. */
  85495. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85496. /**
  85497. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85498. * A Curve3 is designed from a series of successive Vector3.
  85499. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85500. * @param points points which make up the curve
  85501. */
  85502. constructor(points: Vector3[]);
  85503. /**
  85504. * @returns the Curve3 stored array of successive Vector3
  85505. */
  85506. getPoints(): Vector3[];
  85507. /**
  85508. * @returns the computed length (float) of the curve.
  85509. */
  85510. length(): number;
  85511. /**
  85512. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85513. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85514. * curveA and curveB keep unchanged.
  85515. * @param curve the curve to continue from this curve
  85516. * @returns the newly constructed curve
  85517. */
  85518. continue(curve: DeepImmutable<Curve3>): Curve3;
  85519. private _computeLength;
  85520. }
  85521. }
  85522. declare module BABYLON {
  85523. /**
  85524. * This represents the main contract an easing function should follow.
  85525. * Easing functions are used throughout the animation system.
  85526. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85527. */
  85528. export interface IEasingFunction {
  85529. /**
  85530. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85531. * of the easing function.
  85532. * The link below provides some of the most common examples of easing functions.
  85533. * @see https://easings.net/
  85534. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85535. * @returns the corresponding value on the curve defined by the easing function
  85536. */
  85537. ease(gradient: number): number;
  85538. }
  85539. /**
  85540. * Base class used for every default easing function.
  85541. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85542. */
  85543. export class EasingFunction implements IEasingFunction {
  85544. /**
  85545. * Interpolation follows the mathematical formula associated with the easing function.
  85546. */
  85547. static readonly EASINGMODE_EASEIN: number;
  85548. /**
  85549. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85550. */
  85551. static readonly EASINGMODE_EASEOUT: number;
  85552. /**
  85553. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85554. */
  85555. static readonly EASINGMODE_EASEINOUT: number;
  85556. private _easingMode;
  85557. /**
  85558. * Sets the easing mode of the current function.
  85559. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85560. */
  85561. setEasingMode(easingMode: number): void;
  85562. /**
  85563. * Gets the current easing mode.
  85564. * @returns the easing mode
  85565. */
  85566. getEasingMode(): number;
  85567. /**
  85568. * @hidden
  85569. */
  85570. easeInCore(gradient: number): number;
  85571. /**
  85572. * Given an input gradient between 0 and 1, this returns the corresponding value
  85573. * of the easing function.
  85574. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85575. * @returns the corresponding value on the curve defined by the easing function
  85576. */
  85577. ease(gradient: number): number;
  85578. }
  85579. /**
  85580. * Easing function with a circle shape (see link below).
  85581. * @see https://easings.net/#easeInCirc
  85582. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85583. */
  85584. export class CircleEase extends EasingFunction implements IEasingFunction {
  85585. /** @hidden */
  85586. easeInCore(gradient: number): number;
  85587. }
  85588. /**
  85589. * Easing function with a ease back shape (see link below).
  85590. * @see https://easings.net/#easeInBack
  85591. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85592. */
  85593. export class BackEase extends EasingFunction implements IEasingFunction {
  85594. /** Defines the amplitude of the function */
  85595. amplitude: number;
  85596. /**
  85597. * Instantiates a back ease easing
  85598. * @see https://easings.net/#easeInBack
  85599. * @param amplitude Defines the amplitude of the function
  85600. */
  85601. constructor(
  85602. /** Defines the amplitude of the function */
  85603. amplitude?: number);
  85604. /** @hidden */
  85605. easeInCore(gradient: number): number;
  85606. }
  85607. /**
  85608. * Easing function with a bouncing shape (see link below).
  85609. * @see https://easings.net/#easeInBounce
  85610. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85611. */
  85612. export class BounceEase extends EasingFunction implements IEasingFunction {
  85613. /** Defines the number of bounces */
  85614. bounces: number;
  85615. /** Defines the amplitude of the bounce */
  85616. bounciness: number;
  85617. /**
  85618. * Instantiates a bounce easing
  85619. * @see https://easings.net/#easeInBounce
  85620. * @param bounces Defines the number of bounces
  85621. * @param bounciness Defines the amplitude of the bounce
  85622. */
  85623. constructor(
  85624. /** Defines the number of bounces */
  85625. bounces?: number,
  85626. /** Defines the amplitude of the bounce */
  85627. bounciness?: number);
  85628. /** @hidden */
  85629. easeInCore(gradient: number): number;
  85630. }
  85631. /**
  85632. * Easing function with a power of 3 shape (see link below).
  85633. * @see https://easings.net/#easeInCubic
  85634. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85635. */
  85636. export class CubicEase extends EasingFunction implements IEasingFunction {
  85637. /** @hidden */
  85638. easeInCore(gradient: number): number;
  85639. }
  85640. /**
  85641. * Easing function with an elastic shape (see link below).
  85642. * @see https://easings.net/#easeInElastic
  85643. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85644. */
  85645. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85646. /** Defines the number of oscillations*/
  85647. oscillations: number;
  85648. /** Defines the amplitude of the oscillations*/
  85649. springiness: number;
  85650. /**
  85651. * Instantiates an elastic easing function
  85652. * @see https://easings.net/#easeInElastic
  85653. * @param oscillations Defines the number of oscillations
  85654. * @param springiness Defines the amplitude of the oscillations
  85655. */
  85656. constructor(
  85657. /** Defines the number of oscillations*/
  85658. oscillations?: number,
  85659. /** Defines the amplitude of the oscillations*/
  85660. springiness?: number);
  85661. /** @hidden */
  85662. easeInCore(gradient: number): number;
  85663. }
  85664. /**
  85665. * Easing function with an exponential shape (see link below).
  85666. * @see https://easings.net/#easeInExpo
  85667. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85668. */
  85669. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85670. /** Defines the exponent of the function */
  85671. exponent: number;
  85672. /**
  85673. * Instantiates an exponential easing function
  85674. * @see https://easings.net/#easeInExpo
  85675. * @param exponent Defines the exponent of the function
  85676. */
  85677. constructor(
  85678. /** Defines the exponent of the function */
  85679. exponent?: number);
  85680. /** @hidden */
  85681. easeInCore(gradient: number): number;
  85682. }
  85683. /**
  85684. * Easing function with a power shape (see link below).
  85685. * @see https://easings.net/#easeInQuad
  85686. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85687. */
  85688. export class PowerEase extends EasingFunction implements IEasingFunction {
  85689. /** Defines the power of the function */
  85690. power: number;
  85691. /**
  85692. * Instantiates an power base easing function
  85693. * @see https://easings.net/#easeInQuad
  85694. * @param power Defines the power of the function
  85695. */
  85696. constructor(
  85697. /** Defines the power of the function */
  85698. power?: number);
  85699. /** @hidden */
  85700. easeInCore(gradient: number): number;
  85701. }
  85702. /**
  85703. * Easing function with a power of 2 shape (see link below).
  85704. * @see https://easings.net/#easeInQuad
  85705. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85706. */
  85707. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85708. /** @hidden */
  85709. easeInCore(gradient: number): number;
  85710. }
  85711. /**
  85712. * Easing function with a power of 4 shape (see link below).
  85713. * @see https://easings.net/#easeInQuart
  85714. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85715. */
  85716. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85717. /** @hidden */
  85718. easeInCore(gradient: number): number;
  85719. }
  85720. /**
  85721. * Easing function with a power of 5 shape (see link below).
  85722. * @see https://easings.net/#easeInQuint
  85723. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85724. */
  85725. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85726. /** @hidden */
  85727. easeInCore(gradient: number): number;
  85728. }
  85729. /**
  85730. * Easing function with a sin shape (see link below).
  85731. * @see https://easings.net/#easeInSine
  85732. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85733. */
  85734. export class SineEase extends EasingFunction implements IEasingFunction {
  85735. /** @hidden */
  85736. easeInCore(gradient: number): number;
  85737. }
  85738. /**
  85739. * Easing function with a bezier shape (see link below).
  85740. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85741. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85742. */
  85743. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85744. /** Defines the x component of the start tangent in the bezier curve */
  85745. x1: number;
  85746. /** Defines the y component of the start tangent in the bezier curve */
  85747. y1: number;
  85748. /** Defines the x component of the end tangent in the bezier curve */
  85749. x2: number;
  85750. /** Defines the y component of the end tangent in the bezier curve */
  85751. y2: number;
  85752. /**
  85753. * Instantiates a bezier function
  85754. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85755. * @param x1 Defines the x component of the start tangent in the bezier curve
  85756. * @param y1 Defines the y component of the start tangent in the bezier curve
  85757. * @param x2 Defines the x component of the end tangent in the bezier curve
  85758. * @param y2 Defines the y component of the end tangent in the bezier curve
  85759. */
  85760. constructor(
  85761. /** Defines the x component of the start tangent in the bezier curve */
  85762. x1?: number,
  85763. /** Defines the y component of the start tangent in the bezier curve */
  85764. y1?: number,
  85765. /** Defines the x component of the end tangent in the bezier curve */
  85766. x2?: number,
  85767. /** Defines the y component of the end tangent in the bezier curve */
  85768. y2?: number);
  85769. /** @hidden */
  85770. easeInCore(gradient: number): number;
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /**
  85775. * Class used to hold a RBG color
  85776. */
  85777. export class Color3 {
  85778. /**
  85779. * Defines the red component (between 0 and 1, default is 0)
  85780. */
  85781. r: number;
  85782. /**
  85783. * Defines the green component (between 0 and 1, default is 0)
  85784. */
  85785. g: number;
  85786. /**
  85787. * Defines the blue component (between 0 and 1, default is 0)
  85788. */
  85789. b: number;
  85790. /**
  85791. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85792. * @param r defines the red component (between 0 and 1, default is 0)
  85793. * @param g defines the green component (between 0 and 1, default is 0)
  85794. * @param b defines the blue component (between 0 and 1, default is 0)
  85795. */
  85796. constructor(
  85797. /**
  85798. * Defines the red component (between 0 and 1, default is 0)
  85799. */
  85800. r?: number,
  85801. /**
  85802. * Defines the green component (between 0 and 1, default is 0)
  85803. */
  85804. g?: number,
  85805. /**
  85806. * Defines the blue component (between 0 and 1, default is 0)
  85807. */
  85808. b?: number);
  85809. /**
  85810. * Creates a string with the Color3 current values
  85811. * @returns the string representation of the Color3 object
  85812. */
  85813. toString(): string;
  85814. /**
  85815. * Returns the string "Color3"
  85816. * @returns "Color3"
  85817. */
  85818. getClassName(): string;
  85819. /**
  85820. * Compute the Color3 hash code
  85821. * @returns an unique number that can be used to hash Color3 objects
  85822. */
  85823. getHashCode(): number;
  85824. /**
  85825. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85826. * @param array defines the array where to store the r,g,b components
  85827. * @param index defines an optional index in the target array to define where to start storing values
  85828. * @returns the current Color3 object
  85829. */
  85830. toArray(array: FloatArray, index?: number): Color3;
  85831. /**
  85832. * Update the current color with values stored in an array from the starting index of the given array
  85833. * @param array defines the source array
  85834. * @param offset defines an offset in the source array
  85835. * @returns the current Color3 object
  85836. */
  85837. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85838. /**
  85839. * Returns a new Color4 object from the current Color3 and the given alpha
  85840. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85841. * @returns a new Color4 object
  85842. */
  85843. toColor4(alpha?: number): Color4;
  85844. /**
  85845. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85846. * @returns the new array
  85847. */
  85848. asArray(): number[];
  85849. /**
  85850. * Returns the luminance value
  85851. * @returns a float value
  85852. */
  85853. toLuminance(): number;
  85854. /**
  85855. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85856. * @param otherColor defines the second operand
  85857. * @returns the new Color3 object
  85858. */
  85859. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85860. /**
  85861. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85862. * @param otherColor defines the second operand
  85863. * @param result defines the Color3 object where to store the result
  85864. * @returns the current Color3
  85865. */
  85866. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85867. /**
  85868. * Determines equality between Color3 objects
  85869. * @param otherColor defines the second operand
  85870. * @returns true if the rgb values are equal to the given ones
  85871. */
  85872. equals(otherColor: DeepImmutable<Color3>): boolean;
  85873. /**
  85874. * Determines equality between the current Color3 object and a set of r,b,g values
  85875. * @param r defines the red component to check
  85876. * @param g defines the green component to check
  85877. * @param b defines the blue component to check
  85878. * @returns true if the rgb values are equal to the given ones
  85879. */
  85880. equalsFloats(r: number, g: number, b: number): boolean;
  85881. /**
  85882. * Multiplies in place each rgb value by scale
  85883. * @param scale defines the scaling factor
  85884. * @returns the updated Color3
  85885. */
  85886. scale(scale: number): Color3;
  85887. /**
  85888. * Multiplies the rgb values by scale and stores the result into "result"
  85889. * @param scale defines the scaling factor
  85890. * @param result defines the Color3 object where to store the result
  85891. * @returns the unmodified current Color3
  85892. */
  85893. scaleToRef(scale: number, result: Color3): Color3;
  85894. /**
  85895. * Scale the current Color3 values by a factor and add the result to a given Color3
  85896. * @param scale defines the scale factor
  85897. * @param result defines color to store the result into
  85898. * @returns the unmodified current Color3
  85899. */
  85900. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85901. /**
  85902. * Clamps the rgb values by the min and max values and stores the result into "result"
  85903. * @param min defines minimum clamping value (default is 0)
  85904. * @param max defines maximum clamping value (default is 1)
  85905. * @param result defines color to store the result into
  85906. * @returns the original Color3
  85907. */
  85908. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85909. /**
  85910. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85911. * @param otherColor defines the second operand
  85912. * @returns the new Color3
  85913. */
  85914. add(otherColor: DeepImmutable<Color3>): Color3;
  85915. /**
  85916. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85917. * @param otherColor defines the second operand
  85918. * @param result defines Color3 object to store the result into
  85919. * @returns the unmodified current Color3
  85920. */
  85921. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85922. /**
  85923. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85924. * @param otherColor defines the second operand
  85925. * @returns the new Color3
  85926. */
  85927. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85928. /**
  85929. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85930. * @param otherColor defines the second operand
  85931. * @param result defines Color3 object to store the result into
  85932. * @returns the unmodified current Color3
  85933. */
  85934. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85935. /**
  85936. * Copy the current object
  85937. * @returns a new Color3 copied the current one
  85938. */
  85939. clone(): Color3;
  85940. /**
  85941. * Copies the rgb values from the source in the current Color3
  85942. * @param source defines the source Color3 object
  85943. * @returns the updated Color3 object
  85944. */
  85945. copyFrom(source: DeepImmutable<Color3>): Color3;
  85946. /**
  85947. * Updates the Color3 rgb values from the given floats
  85948. * @param r defines the red component to read from
  85949. * @param g defines the green component to read from
  85950. * @param b defines the blue component to read from
  85951. * @returns the current Color3 object
  85952. */
  85953. copyFromFloats(r: number, g: number, b: number): Color3;
  85954. /**
  85955. * Updates the Color3 rgb values from the given floats
  85956. * @param r defines the red component to read from
  85957. * @param g defines the green component to read from
  85958. * @param b defines the blue component to read from
  85959. * @returns the current Color3 object
  85960. */
  85961. set(r: number, g: number, b: number): Color3;
  85962. /**
  85963. * Compute the Color3 hexadecimal code as a string
  85964. * @returns a string containing the hexadecimal representation of the Color3 object
  85965. */
  85966. toHexString(): string;
  85967. /**
  85968. * Computes a new Color3 converted from the current one to linear space
  85969. * @returns a new Color3 object
  85970. */
  85971. toLinearSpace(): Color3;
  85972. /**
  85973. * Converts current color in rgb space to HSV values
  85974. * @returns a new color3 representing the HSV values
  85975. */
  85976. toHSV(): Color3;
  85977. /**
  85978. * Converts current color in rgb space to HSV values
  85979. * @param result defines the Color3 where to store the HSV values
  85980. */
  85981. toHSVToRef(result: Color3): void;
  85982. /**
  85983. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85984. * @param convertedColor defines the Color3 object where to store the linear space version
  85985. * @returns the unmodified Color3
  85986. */
  85987. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85988. /**
  85989. * Computes a new Color3 converted from the current one to gamma space
  85990. * @returns a new Color3 object
  85991. */
  85992. toGammaSpace(): Color3;
  85993. /**
  85994. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85995. * @param convertedColor defines the Color3 object where to store the gamma space version
  85996. * @returns the unmodified Color3
  85997. */
  85998. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85999. private static _BlackReadOnly;
  86000. /**
  86001. * Convert Hue, saturation and value to a Color3 (RGB)
  86002. * @param hue defines the hue
  86003. * @param saturation defines the saturation
  86004. * @param value defines the value
  86005. * @param result defines the Color3 where to store the RGB values
  86006. */
  86007. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86008. /**
  86009. * Creates a new Color3 from the string containing valid hexadecimal values
  86010. * @param hex defines a string containing valid hexadecimal values
  86011. * @returns a new Color3 object
  86012. */
  86013. static FromHexString(hex: string): Color3;
  86014. /**
  86015. * Creates a new Color3 from the starting index of the given array
  86016. * @param array defines the source array
  86017. * @param offset defines an offset in the source array
  86018. * @returns a new Color3 object
  86019. */
  86020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86021. /**
  86022. * Creates a new Color3 from the starting index element of the given array
  86023. * @param array defines the source array to read from
  86024. * @param offset defines the offset in the source array
  86025. * @param result defines the target Color3 object
  86026. */
  86027. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86028. /**
  86029. * Creates a new Color3 from integer values (< 256)
  86030. * @param r defines the red component to read from (value between 0 and 255)
  86031. * @param g defines the green component to read from (value between 0 and 255)
  86032. * @param b defines the blue component to read from (value between 0 and 255)
  86033. * @returns a new Color3 object
  86034. */
  86035. static FromInts(r: number, g: number, b: number): Color3;
  86036. /**
  86037. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86038. * @param start defines the start Color3 value
  86039. * @param end defines the end Color3 value
  86040. * @param amount defines the gradient value between start and end
  86041. * @returns a new Color3 object
  86042. */
  86043. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86044. /**
  86045. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86046. * @param left defines the start value
  86047. * @param right defines the end value
  86048. * @param amount defines the gradient factor
  86049. * @param result defines the Color3 object where to store the result
  86050. */
  86051. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86052. /**
  86053. * Returns a Color3 value containing a red color
  86054. * @returns a new Color3 object
  86055. */
  86056. static Red(): Color3;
  86057. /**
  86058. * Returns a Color3 value containing a green color
  86059. * @returns a new Color3 object
  86060. */
  86061. static Green(): Color3;
  86062. /**
  86063. * Returns a Color3 value containing a blue color
  86064. * @returns a new Color3 object
  86065. */
  86066. static Blue(): Color3;
  86067. /**
  86068. * Returns a Color3 value containing a black color
  86069. * @returns a new Color3 object
  86070. */
  86071. static Black(): Color3;
  86072. /**
  86073. * Gets a Color3 value containing a black color that must not be updated
  86074. */
  86075. static get BlackReadOnly(): DeepImmutable<Color3>;
  86076. /**
  86077. * Returns a Color3 value containing a white color
  86078. * @returns a new Color3 object
  86079. */
  86080. static White(): Color3;
  86081. /**
  86082. * Returns a Color3 value containing a purple color
  86083. * @returns a new Color3 object
  86084. */
  86085. static Purple(): Color3;
  86086. /**
  86087. * Returns a Color3 value containing a magenta color
  86088. * @returns a new Color3 object
  86089. */
  86090. static Magenta(): Color3;
  86091. /**
  86092. * Returns a Color3 value containing a yellow color
  86093. * @returns a new Color3 object
  86094. */
  86095. static Yellow(): Color3;
  86096. /**
  86097. * Returns a Color3 value containing a gray color
  86098. * @returns a new Color3 object
  86099. */
  86100. static Gray(): Color3;
  86101. /**
  86102. * Returns a Color3 value containing a teal color
  86103. * @returns a new Color3 object
  86104. */
  86105. static Teal(): Color3;
  86106. /**
  86107. * Returns a Color3 value containing a random color
  86108. * @returns a new Color3 object
  86109. */
  86110. static Random(): Color3;
  86111. }
  86112. /**
  86113. * Class used to hold a RBGA color
  86114. */
  86115. export class Color4 {
  86116. /**
  86117. * Defines the red component (between 0 and 1, default is 0)
  86118. */
  86119. r: number;
  86120. /**
  86121. * Defines the green component (between 0 and 1, default is 0)
  86122. */
  86123. g: number;
  86124. /**
  86125. * Defines the blue component (between 0 and 1, default is 0)
  86126. */
  86127. b: number;
  86128. /**
  86129. * Defines the alpha component (between 0 and 1, default is 1)
  86130. */
  86131. a: number;
  86132. /**
  86133. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86134. * @param r defines the red component (between 0 and 1, default is 0)
  86135. * @param g defines the green component (between 0 and 1, default is 0)
  86136. * @param b defines the blue component (between 0 and 1, default is 0)
  86137. * @param a defines the alpha component (between 0 and 1, default is 1)
  86138. */
  86139. constructor(
  86140. /**
  86141. * Defines the red component (between 0 and 1, default is 0)
  86142. */
  86143. r?: number,
  86144. /**
  86145. * Defines the green component (between 0 and 1, default is 0)
  86146. */
  86147. g?: number,
  86148. /**
  86149. * Defines the blue component (between 0 and 1, default is 0)
  86150. */
  86151. b?: number,
  86152. /**
  86153. * Defines the alpha component (between 0 and 1, default is 1)
  86154. */
  86155. a?: number);
  86156. /**
  86157. * Adds in place the given Color4 values to the current Color4 object
  86158. * @param right defines the second operand
  86159. * @returns the current updated Color4 object
  86160. */
  86161. addInPlace(right: DeepImmutable<Color4>): Color4;
  86162. /**
  86163. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86164. * @returns the new array
  86165. */
  86166. asArray(): number[];
  86167. /**
  86168. * Stores from the starting index in the given array the Color4 successive values
  86169. * @param array defines the array where to store the r,g,b components
  86170. * @param index defines an optional index in the target array to define where to start storing values
  86171. * @returns the current Color4 object
  86172. */
  86173. toArray(array: number[], index?: number): Color4;
  86174. /**
  86175. * Update the current color with values stored in an array from the starting index of the given array
  86176. * @param array defines the source array
  86177. * @param offset defines an offset in the source array
  86178. * @returns the current Color4 object
  86179. */
  86180. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86181. /**
  86182. * Determines equality between Color4 objects
  86183. * @param otherColor defines the second operand
  86184. * @returns true if the rgba values are equal to the given ones
  86185. */
  86186. equals(otherColor: DeepImmutable<Color4>): boolean;
  86187. /**
  86188. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86189. * @param right defines the second operand
  86190. * @returns a new Color4 object
  86191. */
  86192. add(right: DeepImmutable<Color4>): Color4;
  86193. /**
  86194. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86195. * @param right defines the second operand
  86196. * @returns a new Color4 object
  86197. */
  86198. subtract(right: DeepImmutable<Color4>): Color4;
  86199. /**
  86200. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86201. * @param right defines the second operand
  86202. * @param result defines the Color4 object where to store the result
  86203. * @returns the current Color4 object
  86204. */
  86205. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86206. /**
  86207. * Creates a new Color4 with the current Color4 values multiplied by scale
  86208. * @param scale defines the scaling factor to apply
  86209. * @returns a new Color4 object
  86210. */
  86211. scale(scale: number): Color4;
  86212. /**
  86213. * Multiplies the current Color4 values by scale and stores the result in "result"
  86214. * @param scale defines the scaling factor to apply
  86215. * @param result defines the Color4 object where to store the result
  86216. * @returns the current unmodified Color4
  86217. */
  86218. scaleToRef(scale: number, result: Color4): Color4;
  86219. /**
  86220. * Scale the current Color4 values by a factor and add the result to a given Color4
  86221. * @param scale defines the scale factor
  86222. * @param result defines the Color4 object where to store the result
  86223. * @returns the unmodified current Color4
  86224. */
  86225. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86226. /**
  86227. * Clamps the rgb values by the min and max values and stores the result into "result"
  86228. * @param min defines minimum clamping value (default is 0)
  86229. * @param max defines maximum clamping value (default is 1)
  86230. * @param result defines color to store the result into.
  86231. * @returns the cuurent Color4
  86232. */
  86233. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86234. /**
  86235. * Multipy an Color4 value by another and return a new Color4 object
  86236. * @param color defines the Color4 value to multiply by
  86237. * @returns a new Color4 object
  86238. */
  86239. multiply(color: Color4): Color4;
  86240. /**
  86241. * Multipy a Color4 value by another and push the result in a reference value
  86242. * @param color defines the Color4 value to multiply by
  86243. * @param result defines the Color4 to fill the result in
  86244. * @returns the result Color4
  86245. */
  86246. multiplyToRef(color: Color4, result: Color4): Color4;
  86247. /**
  86248. * Creates a string with the Color4 current values
  86249. * @returns the string representation of the Color4 object
  86250. */
  86251. toString(): string;
  86252. /**
  86253. * Returns the string "Color4"
  86254. * @returns "Color4"
  86255. */
  86256. getClassName(): string;
  86257. /**
  86258. * Compute the Color4 hash code
  86259. * @returns an unique number that can be used to hash Color4 objects
  86260. */
  86261. getHashCode(): number;
  86262. /**
  86263. * Creates a new Color4 copied from the current one
  86264. * @returns a new Color4 object
  86265. */
  86266. clone(): Color4;
  86267. /**
  86268. * Copies the given Color4 values into the current one
  86269. * @param source defines the source Color4 object
  86270. * @returns the current updated Color4 object
  86271. */
  86272. copyFrom(source: Color4): Color4;
  86273. /**
  86274. * Copies the given float values into the current one
  86275. * @param r defines the red component to read from
  86276. * @param g defines the green component to read from
  86277. * @param b defines the blue component to read from
  86278. * @param a defines the alpha component to read from
  86279. * @returns the current updated Color4 object
  86280. */
  86281. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86282. /**
  86283. * Copies the given float values into the current one
  86284. * @param r defines the red component to read from
  86285. * @param g defines the green component to read from
  86286. * @param b defines the blue component to read from
  86287. * @param a defines the alpha component to read from
  86288. * @returns the current updated Color4 object
  86289. */
  86290. set(r: number, g: number, b: number, a: number): Color4;
  86291. /**
  86292. * Compute the Color4 hexadecimal code as a string
  86293. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86294. * @returns a string containing the hexadecimal representation of the Color4 object
  86295. */
  86296. toHexString(returnAsColor3?: boolean): string;
  86297. /**
  86298. * Computes a new Color4 converted from the current one to linear space
  86299. * @returns a new Color4 object
  86300. */
  86301. toLinearSpace(): Color4;
  86302. /**
  86303. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86304. * @param convertedColor defines the Color4 object where to store the linear space version
  86305. * @returns the unmodified Color4
  86306. */
  86307. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86308. /**
  86309. * Computes a new Color4 converted from the current one to gamma space
  86310. * @returns a new Color4 object
  86311. */
  86312. toGammaSpace(): Color4;
  86313. /**
  86314. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86315. * @param convertedColor defines the Color4 object where to store the gamma space version
  86316. * @returns the unmodified Color4
  86317. */
  86318. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86319. /**
  86320. * Creates a new Color4 from the string containing valid hexadecimal values
  86321. * @param hex defines a string containing valid hexadecimal values
  86322. * @returns a new Color4 object
  86323. */
  86324. static FromHexString(hex: string): Color4;
  86325. /**
  86326. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86327. * @param left defines the start value
  86328. * @param right defines the end value
  86329. * @param amount defines the gradient factor
  86330. * @returns a new Color4 object
  86331. */
  86332. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86333. /**
  86334. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86335. * @param left defines the start value
  86336. * @param right defines the end value
  86337. * @param amount defines the gradient factor
  86338. * @param result defines the Color4 object where to store data
  86339. */
  86340. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86341. /**
  86342. * Creates a new Color4 from a Color3 and an alpha value
  86343. * @param color3 defines the source Color3 to read from
  86344. * @param alpha defines the alpha component (1.0 by default)
  86345. * @returns a new Color4 object
  86346. */
  86347. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86348. /**
  86349. * Creates a new Color4 from the starting index element of the given array
  86350. * @param array defines the source array to read from
  86351. * @param offset defines the offset in the source array
  86352. * @returns a new Color4 object
  86353. */
  86354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86355. /**
  86356. * Creates a new Color4 from the starting index element of the given array
  86357. * @param array defines the source array to read from
  86358. * @param offset defines the offset in the source array
  86359. * @param result defines the target Color4 object
  86360. */
  86361. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86362. /**
  86363. * Creates a new Color3 from integer values (< 256)
  86364. * @param r defines the red component to read from (value between 0 and 255)
  86365. * @param g defines the green component to read from (value between 0 and 255)
  86366. * @param b defines the blue component to read from (value between 0 and 255)
  86367. * @param a defines the alpha component to read from (value between 0 and 255)
  86368. * @returns a new Color3 object
  86369. */
  86370. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86371. /**
  86372. * Check the content of a given array and convert it to an array containing RGBA data
  86373. * If the original array was already containing count * 4 values then it is returned directly
  86374. * @param colors defines the array to check
  86375. * @param count defines the number of RGBA data to expect
  86376. * @returns an array containing count * 4 values (RGBA)
  86377. */
  86378. static CheckColors4(colors: number[], count: number): number[];
  86379. }
  86380. /**
  86381. * @hidden
  86382. */
  86383. export class TmpColors {
  86384. static Color3: Color3[];
  86385. static Color4: Color4[];
  86386. }
  86387. }
  86388. declare module BABYLON {
  86389. /**
  86390. * Defines an interface which represents an animation key frame
  86391. */
  86392. export interface IAnimationKey {
  86393. /**
  86394. * Frame of the key frame
  86395. */
  86396. frame: number;
  86397. /**
  86398. * Value at the specifies key frame
  86399. */
  86400. value: any;
  86401. /**
  86402. * The input tangent for the cubic hermite spline
  86403. */
  86404. inTangent?: any;
  86405. /**
  86406. * The output tangent for the cubic hermite spline
  86407. */
  86408. outTangent?: any;
  86409. /**
  86410. * The animation interpolation type
  86411. */
  86412. interpolation?: AnimationKeyInterpolation;
  86413. }
  86414. /**
  86415. * Enum for the animation key frame interpolation type
  86416. */
  86417. export enum AnimationKeyInterpolation {
  86418. /**
  86419. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86420. */
  86421. STEP = 1
  86422. }
  86423. }
  86424. declare module BABYLON {
  86425. /**
  86426. * Represents the range of an animation
  86427. */
  86428. export class AnimationRange {
  86429. /**The name of the animation range**/
  86430. name: string;
  86431. /**The starting frame of the animation */
  86432. from: number;
  86433. /**The ending frame of the animation*/
  86434. to: number;
  86435. /**
  86436. * Initializes the range of an animation
  86437. * @param name The name of the animation range
  86438. * @param from The starting frame of the animation
  86439. * @param to The ending frame of the animation
  86440. */
  86441. constructor(
  86442. /**The name of the animation range**/
  86443. name: string,
  86444. /**The starting frame of the animation */
  86445. from: number,
  86446. /**The ending frame of the animation*/
  86447. to: number);
  86448. /**
  86449. * Makes a copy of the animation range
  86450. * @returns A copy of the animation range
  86451. */
  86452. clone(): AnimationRange;
  86453. }
  86454. }
  86455. declare module BABYLON {
  86456. /**
  86457. * Composed of a frame, and an action function
  86458. */
  86459. export class AnimationEvent {
  86460. /** The frame for which the event is triggered **/
  86461. frame: number;
  86462. /** The event to perform when triggered **/
  86463. action: (currentFrame: number) => void;
  86464. /** Specifies if the event should be triggered only once**/
  86465. onlyOnce?: boolean | undefined;
  86466. /**
  86467. * Specifies if the animation event is done
  86468. */
  86469. isDone: boolean;
  86470. /**
  86471. * Initializes the animation event
  86472. * @param frame The frame for which the event is triggered
  86473. * @param action The event to perform when triggered
  86474. * @param onlyOnce Specifies if the event should be triggered only once
  86475. */
  86476. constructor(
  86477. /** The frame for which the event is triggered **/
  86478. frame: number,
  86479. /** The event to perform when triggered **/
  86480. action: (currentFrame: number) => void,
  86481. /** Specifies if the event should be triggered only once**/
  86482. onlyOnce?: boolean | undefined);
  86483. /** @hidden */
  86484. _clone(): AnimationEvent;
  86485. }
  86486. }
  86487. declare module BABYLON {
  86488. /**
  86489. * Interface used to define a behavior
  86490. */
  86491. export interface Behavior<T> {
  86492. /** gets or sets behavior's name */
  86493. name: string;
  86494. /**
  86495. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86496. */
  86497. init(): void;
  86498. /**
  86499. * Called when the behavior is attached to a target
  86500. * @param target defines the target where the behavior is attached to
  86501. */
  86502. attach(target: T): void;
  86503. /**
  86504. * Called when the behavior is detached from its target
  86505. */
  86506. detach(): void;
  86507. }
  86508. /**
  86509. * Interface implemented by classes supporting behaviors
  86510. */
  86511. export interface IBehaviorAware<T> {
  86512. /**
  86513. * Attach a behavior
  86514. * @param behavior defines the behavior to attach
  86515. * @returns the current host
  86516. */
  86517. addBehavior(behavior: Behavior<T>): T;
  86518. /**
  86519. * Remove a behavior from the current object
  86520. * @param behavior defines the behavior to detach
  86521. * @returns the current host
  86522. */
  86523. removeBehavior(behavior: Behavior<T>): T;
  86524. /**
  86525. * Gets a behavior using its name to search
  86526. * @param name defines the name to search
  86527. * @returns the behavior or null if not found
  86528. */
  86529. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86530. }
  86531. }
  86532. declare module BABYLON {
  86533. /**
  86534. * Defines an array and its length.
  86535. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86536. */
  86537. export interface ISmartArrayLike<T> {
  86538. /**
  86539. * The data of the array.
  86540. */
  86541. data: Array<T>;
  86542. /**
  86543. * The active length of the array.
  86544. */
  86545. length: number;
  86546. }
  86547. /**
  86548. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86549. */
  86550. export class SmartArray<T> implements ISmartArrayLike<T> {
  86551. /**
  86552. * The full set of data from the array.
  86553. */
  86554. data: Array<T>;
  86555. /**
  86556. * The active length of the array.
  86557. */
  86558. length: number;
  86559. protected _id: number;
  86560. /**
  86561. * Instantiates a Smart Array.
  86562. * @param capacity defines the default capacity of the array.
  86563. */
  86564. constructor(capacity: number);
  86565. /**
  86566. * Pushes a value at the end of the active data.
  86567. * @param value defines the object to push in the array.
  86568. */
  86569. push(value: T): void;
  86570. /**
  86571. * Iterates over the active data and apply the lambda to them.
  86572. * @param func defines the action to apply on each value.
  86573. */
  86574. forEach(func: (content: T) => void): void;
  86575. /**
  86576. * Sorts the full sets of data.
  86577. * @param compareFn defines the comparison function to apply.
  86578. */
  86579. sort(compareFn: (a: T, b: T) => number): void;
  86580. /**
  86581. * Resets the active data to an empty array.
  86582. */
  86583. reset(): void;
  86584. /**
  86585. * Releases all the data from the array as well as the array.
  86586. */
  86587. dispose(): void;
  86588. /**
  86589. * Concats the active data with a given array.
  86590. * @param array defines the data to concatenate with.
  86591. */
  86592. concat(array: any): void;
  86593. /**
  86594. * Returns the position of a value in the active data.
  86595. * @param value defines the value to find the index for
  86596. * @returns the index if found in the active data otherwise -1
  86597. */
  86598. indexOf(value: T): number;
  86599. /**
  86600. * Returns whether an element is part of the active data.
  86601. * @param value defines the value to look for
  86602. * @returns true if found in the active data otherwise false
  86603. */
  86604. contains(value: T): boolean;
  86605. private static _GlobalId;
  86606. }
  86607. /**
  86608. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86609. * The data in this array can only be present once
  86610. */
  86611. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86612. private _duplicateId;
  86613. /**
  86614. * Pushes a value at the end of the active data.
  86615. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86616. * @param value defines the object to push in the array.
  86617. */
  86618. push(value: T): void;
  86619. /**
  86620. * Pushes a value at the end of the active data.
  86621. * If the data is already present, it won t be added again
  86622. * @param value defines the object to push in the array.
  86623. * @returns true if added false if it was already present
  86624. */
  86625. pushNoDuplicate(value: T): boolean;
  86626. /**
  86627. * Resets the active data to an empty array.
  86628. */
  86629. reset(): void;
  86630. /**
  86631. * Concats the active data with a given array.
  86632. * This ensures no dupplicate will be present in the result.
  86633. * @param array defines the data to concatenate with.
  86634. */
  86635. concatWithNoDuplicate(array: any): void;
  86636. }
  86637. }
  86638. declare module BABYLON {
  86639. /**
  86640. * @ignore
  86641. * This is a list of all the different input types that are available in the application.
  86642. * Fo instance: ArcRotateCameraGamepadInput...
  86643. */
  86644. export var CameraInputTypes: {};
  86645. /**
  86646. * This is the contract to implement in order to create a new input class.
  86647. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86648. */
  86649. export interface ICameraInput<TCamera extends Camera> {
  86650. /**
  86651. * Defines the camera the input is attached to.
  86652. */
  86653. camera: Nullable<TCamera>;
  86654. /**
  86655. * Gets the class name of the current intput.
  86656. * @returns the class name
  86657. */
  86658. getClassName(): string;
  86659. /**
  86660. * Get the friendly name associated with the input class.
  86661. * @returns the input friendly name
  86662. */
  86663. getSimpleName(): string;
  86664. /**
  86665. * Attach the input controls to a specific dom element to get the input from.
  86666. * @param element Defines the element the controls should be listened from
  86667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86668. */
  86669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86670. /**
  86671. * Detach the current controls from the specified dom element.
  86672. * @param element Defines the element to stop listening the inputs from
  86673. */
  86674. detachControl(element: Nullable<HTMLElement>): void;
  86675. /**
  86676. * Update the current camera state depending on the inputs that have been used this frame.
  86677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86678. */
  86679. checkInputs?: () => void;
  86680. }
  86681. /**
  86682. * Represents a map of input types to input instance or input index to input instance.
  86683. */
  86684. export interface CameraInputsMap<TCamera extends Camera> {
  86685. /**
  86686. * Accessor to the input by input type.
  86687. */
  86688. [name: string]: ICameraInput<TCamera>;
  86689. /**
  86690. * Accessor to the input by input index.
  86691. */
  86692. [idx: number]: ICameraInput<TCamera>;
  86693. }
  86694. /**
  86695. * This represents the input manager used within a camera.
  86696. * It helps dealing with all the different kind of input attached to a camera.
  86697. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86698. */
  86699. export class CameraInputsManager<TCamera extends Camera> {
  86700. /**
  86701. * Defines the list of inputs attahed to the camera.
  86702. */
  86703. attached: CameraInputsMap<TCamera>;
  86704. /**
  86705. * Defines the dom element the camera is collecting inputs from.
  86706. * This is null if the controls have not been attached.
  86707. */
  86708. attachedElement: Nullable<HTMLElement>;
  86709. /**
  86710. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86711. */
  86712. noPreventDefault: boolean;
  86713. /**
  86714. * Defined the camera the input manager belongs to.
  86715. */
  86716. camera: TCamera;
  86717. /**
  86718. * Update the current camera state depending on the inputs that have been used this frame.
  86719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86720. */
  86721. checkInputs: () => void;
  86722. /**
  86723. * Instantiate a new Camera Input Manager.
  86724. * @param camera Defines the camera the input manager blongs to
  86725. */
  86726. constructor(camera: TCamera);
  86727. /**
  86728. * Add an input method to a camera
  86729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86730. * @param input camera input method
  86731. */
  86732. add(input: ICameraInput<TCamera>): void;
  86733. /**
  86734. * Remove a specific input method from a camera
  86735. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86736. * @param inputToRemove camera input method
  86737. */
  86738. remove(inputToRemove: ICameraInput<TCamera>): void;
  86739. /**
  86740. * Remove a specific input type from a camera
  86741. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86742. * @param inputType the type of the input to remove
  86743. */
  86744. removeByType(inputType: string): void;
  86745. private _addCheckInputs;
  86746. /**
  86747. * Attach the input controls to the currently attached dom element to listen the events from.
  86748. * @param input Defines the input to attach
  86749. */
  86750. attachInput(input: ICameraInput<TCamera>): void;
  86751. /**
  86752. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86753. * @param element Defines the dom element to collect the events from
  86754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86755. */
  86756. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86757. /**
  86758. * Detach the current manager inputs controls from a specific dom element.
  86759. * @param element Defines the dom element to collect the events from
  86760. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86761. */
  86762. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86763. /**
  86764. * Rebuild the dynamic inputCheck function from the current list of
  86765. * defined inputs in the manager.
  86766. */
  86767. rebuildInputCheck(): void;
  86768. /**
  86769. * Remove all attached input methods from a camera
  86770. */
  86771. clear(): void;
  86772. /**
  86773. * Serialize the current input manager attached to a camera.
  86774. * This ensures than once parsed,
  86775. * the input associated to the camera will be identical to the current ones
  86776. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86777. */
  86778. serialize(serializedCamera: any): void;
  86779. /**
  86780. * Parses an input manager serialized JSON to restore the previous list of inputs
  86781. * and states associated to a camera.
  86782. * @param parsedCamera Defines the JSON to parse
  86783. */
  86784. parse(parsedCamera: any): void;
  86785. }
  86786. }
  86787. declare module BABYLON {
  86788. /**
  86789. * Class used to store data that will be store in GPU memory
  86790. */
  86791. export class Buffer {
  86792. private _engine;
  86793. private _buffer;
  86794. /** @hidden */
  86795. _data: Nullable<DataArray>;
  86796. private _updatable;
  86797. private _instanced;
  86798. private _divisor;
  86799. /**
  86800. * Gets the byte stride.
  86801. */
  86802. readonly byteStride: number;
  86803. /**
  86804. * Constructor
  86805. * @param engine the engine
  86806. * @param data the data to use for this buffer
  86807. * @param updatable whether the data is updatable
  86808. * @param stride the stride (optional)
  86809. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86810. * @param instanced whether the buffer is instanced (optional)
  86811. * @param useBytes set to true if the stride in in bytes (optional)
  86812. * @param divisor sets an optional divisor for instances (1 by default)
  86813. */
  86814. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86815. /**
  86816. * Create a new VertexBuffer based on the current buffer
  86817. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86818. * @param offset defines offset in the buffer (0 by default)
  86819. * @param size defines the size in floats of attributes (position is 3 for instance)
  86820. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86821. * @param instanced defines if the vertex buffer contains indexed data
  86822. * @param useBytes defines if the offset and stride are in bytes *
  86823. * @param divisor sets an optional divisor for instances (1 by default)
  86824. * @returns the new vertex buffer
  86825. */
  86826. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86827. /**
  86828. * Gets a boolean indicating if the Buffer is updatable?
  86829. * @returns true if the buffer is updatable
  86830. */
  86831. isUpdatable(): boolean;
  86832. /**
  86833. * Gets current buffer's data
  86834. * @returns a DataArray or null
  86835. */
  86836. getData(): Nullable<DataArray>;
  86837. /**
  86838. * Gets underlying native buffer
  86839. * @returns underlying native buffer
  86840. */
  86841. getBuffer(): Nullable<DataBuffer>;
  86842. /**
  86843. * Gets the stride in float32 units (i.e. byte stride / 4).
  86844. * May not be an integer if the byte stride is not divisible by 4.
  86845. * @returns the stride in float32 units
  86846. * @deprecated Please use byteStride instead.
  86847. */
  86848. getStrideSize(): number;
  86849. /**
  86850. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86851. * @param data defines the data to store
  86852. */
  86853. create(data?: Nullable<DataArray>): void;
  86854. /** @hidden */
  86855. _rebuild(): void;
  86856. /**
  86857. * Update current buffer data
  86858. * @param data defines the data to store
  86859. */
  86860. update(data: DataArray): void;
  86861. /**
  86862. * Updates the data directly.
  86863. * @param data the new data
  86864. * @param offset the new offset
  86865. * @param vertexCount the vertex count (optional)
  86866. * @param useBytes set to true if the offset is in bytes
  86867. */
  86868. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86869. /**
  86870. * Release all resources
  86871. */
  86872. dispose(): void;
  86873. }
  86874. /**
  86875. * Specialized buffer used to store vertex data
  86876. */
  86877. export class VertexBuffer {
  86878. /** @hidden */
  86879. _buffer: Buffer;
  86880. private _kind;
  86881. private _size;
  86882. private _ownsBuffer;
  86883. private _instanced;
  86884. private _instanceDivisor;
  86885. /**
  86886. * The byte type.
  86887. */
  86888. static readonly BYTE: number;
  86889. /**
  86890. * The unsigned byte type.
  86891. */
  86892. static readonly UNSIGNED_BYTE: number;
  86893. /**
  86894. * The short type.
  86895. */
  86896. static readonly SHORT: number;
  86897. /**
  86898. * The unsigned short type.
  86899. */
  86900. static readonly UNSIGNED_SHORT: number;
  86901. /**
  86902. * The integer type.
  86903. */
  86904. static readonly INT: number;
  86905. /**
  86906. * The unsigned integer type.
  86907. */
  86908. static readonly UNSIGNED_INT: number;
  86909. /**
  86910. * The float type.
  86911. */
  86912. static readonly FLOAT: number;
  86913. /**
  86914. * Gets or sets the instance divisor when in instanced mode
  86915. */
  86916. get instanceDivisor(): number;
  86917. set instanceDivisor(value: number);
  86918. /**
  86919. * Gets the byte stride.
  86920. */
  86921. readonly byteStride: number;
  86922. /**
  86923. * Gets the byte offset.
  86924. */
  86925. readonly byteOffset: number;
  86926. /**
  86927. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86928. */
  86929. readonly normalized: boolean;
  86930. /**
  86931. * Gets the data type of each component in the array.
  86932. */
  86933. readonly type: number;
  86934. /**
  86935. * Constructor
  86936. * @param engine the engine
  86937. * @param data the data to use for this vertex buffer
  86938. * @param kind the vertex buffer kind
  86939. * @param updatable whether the data is updatable
  86940. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86941. * @param stride the stride (optional)
  86942. * @param instanced whether the buffer is instanced (optional)
  86943. * @param offset the offset of the data (optional)
  86944. * @param size the number of components (optional)
  86945. * @param type the type of the component (optional)
  86946. * @param normalized whether the data contains normalized data (optional)
  86947. * @param useBytes set to true if stride and offset are in bytes (optional)
  86948. * @param divisor defines the instance divisor to use (1 by default)
  86949. */
  86950. 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);
  86951. /** @hidden */
  86952. _rebuild(): void;
  86953. /**
  86954. * Returns the kind of the VertexBuffer (string)
  86955. * @returns a string
  86956. */
  86957. getKind(): string;
  86958. /**
  86959. * Gets a boolean indicating if the VertexBuffer is updatable?
  86960. * @returns true if the buffer is updatable
  86961. */
  86962. isUpdatable(): boolean;
  86963. /**
  86964. * Gets current buffer's data
  86965. * @returns a DataArray or null
  86966. */
  86967. getData(): Nullable<DataArray>;
  86968. /**
  86969. * Gets underlying native buffer
  86970. * @returns underlying native buffer
  86971. */
  86972. getBuffer(): Nullable<DataBuffer>;
  86973. /**
  86974. * Gets the stride in float32 units (i.e. byte stride / 4).
  86975. * May not be an integer if the byte stride is not divisible by 4.
  86976. * @returns the stride in float32 units
  86977. * @deprecated Please use byteStride instead.
  86978. */
  86979. getStrideSize(): number;
  86980. /**
  86981. * Returns the offset as a multiple of the type byte length.
  86982. * @returns the offset in bytes
  86983. * @deprecated Please use byteOffset instead.
  86984. */
  86985. getOffset(): number;
  86986. /**
  86987. * Returns the number of components per vertex attribute (integer)
  86988. * @returns the size in float
  86989. */
  86990. getSize(): number;
  86991. /**
  86992. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86993. * @returns true if this buffer is instanced
  86994. */
  86995. getIsInstanced(): boolean;
  86996. /**
  86997. * Returns the instancing divisor, zero for non-instanced (integer).
  86998. * @returns a number
  86999. */
  87000. getInstanceDivisor(): number;
  87001. /**
  87002. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87003. * @param data defines the data to store
  87004. */
  87005. create(data?: DataArray): void;
  87006. /**
  87007. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87008. * This function will create a new buffer if the current one is not updatable
  87009. * @param data defines the data to store
  87010. */
  87011. update(data: DataArray): void;
  87012. /**
  87013. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87014. * Returns the directly updated WebGLBuffer.
  87015. * @param data the new data
  87016. * @param offset the new offset
  87017. * @param useBytes set to true if the offset is in bytes
  87018. */
  87019. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87020. /**
  87021. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87022. */
  87023. dispose(): void;
  87024. /**
  87025. * Enumerates each value of this vertex buffer as numbers.
  87026. * @param count the number of values to enumerate
  87027. * @param callback the callback function called for each value
  87028. */
  87029. forEach(count: number, callback: (value: number, index: number) => void): void;
  87030. /**
  87031. * Positions
  87032. */
  87033. static readonly PositionKind: string;
  87034. /**
  87035. * Normals
  87036. */
  87037. static readonly NormalKind: string;
  87038. /**
  87039. * Tangents
  87040. */
  87041. static readonly TangentKind: string;
  87042. /**
  87043. * Texture coordinates
  87044. */
  87045. static readonly UVKind: string;
  87046. /**
  87047. * Texture coordinates 2
  87048. */
  87049. static readonly UV2Kind: string;
  87050. /**
  87051. * Texture coordinates 3
  87052. */
  87053. static readonly UV3Kind: string;
  87054. /**
  87055. * Texture coordinates 4
  87056. */
  87057. static readonly UV4Kind: string;
  87058. /**
  87059. * Texture coordinates 5
  87060. */
  87061. static readonly UV5Kind: string;
  87062. /**
  87063. * Texture coordinates 6
  87064. */
  87065. static readonly UV6Kind: string;
  87066. /**
  87067. * Colors
  87068. */
  87069. static readonly ColorKind: string;
  87070. /**
  87071. * Matrix indices (for bones)
  87072. */
  87073. static readonly MatricesIndicesKind: string;
  87074. /**
  87075. * Matrix weights (for bones)
  87076. */
  87077. static readonly MatricesWeightsKind: string;
  87078. /**
  87079. * Additional matrix indices (for bones)
  87080. */
  87081. static readonly MatricesIndicesExtraKind: string;
  87082. /**
  87083. * Additional matrix weights (for bones)
  87084. */
  87085. static readonly MatricesWeightsExtraKind: string;
  87086. /**
  87087. * Deduces the stride given a kind.
  87088. * @param kind The kind string to deduce
  87089. * @returns The deduced stride
  87090. */
  87091. static DeduceStride(kind: string): number;
  87092. /**
  87093. * Gets the byte length of the given type.
  87094. * @param type the type
  87095. * @returns the number of bytes
  87096. */
  87097. static GetTypeByteLength(type: number): number;
  87098. /**
  87099. * Enumerates each value of the given parameters as numbers.
  87100. * @param data the data to enumerate
  87101. * @param byteOffset the byte offset of the data
  87102. * @param byteStride the byte stride of the data
  87103. * @param componentCount the number of components per element
  87104. * @param componentType the type of the component
  87105. * @param count the number of values to enumerate
  87106. * @param normalized whether the data is normalized
  87107. * @param callback the callback function called for each value
  87108. */
  87109. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87110. private static _GetFloatValue;
  87111. }
  87112. }
  87113. declare module BABYLON {
  87114. /**
  87115. * The options Interface for creating a Capsule Mesh
  87116. */
  87117. export interface ICreateCapsuleOptions {
  87118. /** The Orientation of the capsule. Default : Vector3.Up() */
  87119. orientation?: Vector3;
  87120. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87121. subdivisions: number;
  87122. /** Number of cylindrical segments on the capsule. */
  87123. tessellation: number;
  87124. /** Height or Length of the capsule. */
  87125. height: number;
  87126. /** Radius of the capsule. */
  87127. radius: number;
  87128. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87129. capSubdivisions: number;
  87130. /** Overwrite for the top radius. */
  87131. radiusTop?: number;
  87132. /** Overwrite for the bottom radius. */
  87133. radiusBottom?: number;
  87134. /** Overwrite for the top capSubdivisions. */
  87135. topCapSubdivisions?: number;
  87136. /** Overwrite for the bottom capSubdivisions. */
  87137. bottomCapSubdivisions?: number;
  87138. }
  87139. /**
  87140. * Class containing static functions to help procedurally build meshes
  87141. */
  87142. export class CapsuleBuilder {
  87143. /**
  87144. * Creates a capsule or a pill mesh
  87145. * @param name defines the name of the mesh
  87146. * @param options The constructors options.
  87147. * @param scene The scene the mesh is scoped to.
  87148. * @returns Capsule Mesh
  87149. */
  87150. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87151. }
  87152. }
  87153. declare module BABYLON {
  87154. /**
  87155. * @hidden
  87156. */
  87157. export class IntersectionInfo {
  87158. bu: Nullable<number>;
  87159. bv: Nullable<number>;
  87160. distance: number;
  87161. faceId: number;
  87162. subMeshId: number;
  87163. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87164. }
  87165. }
  87166. declare module BABYLON {
  87167. /**
  87168. * Class used to store bounding sphere information
  87169. */
  87170. export class BoundingSphere {
  87171. /**
  87172. * Gets the center of the bounding sphere in local space
  87173. */
  87174. readonly center: Vector3;
  87175. /**
  87176. * Radius of the bounding sphere in local space
  87177. */
  87178. radius: number;
  87179. /**
  87180. * Gets the center of the bounding sphere in world space
  87181. */
  87182. readonly centerWorld: Vector3;
  87183. /**
  87184. * Radius of the bounding sphere in world space
  87185. */
  87186. radiusWorld: number;
  87187. /**
  87188. * Gets the minimum vector in local space
  87189. */
  87190. readonly minimum: Vector3;
  87191. /**
  87192. * Gets the maximum vector in local space
  87193. */
  87194. readonly maximum: Vector3;
  87195. private _worldMatrix;
  87196. private static readonly TmpVector3;
  87197. /**
  87198. * Creates a new bounding sphere
  87199. * @param min defines the minimum vector (in local space)
  87200. * @param max defines the maximum vector (in local space)
  87201. * @param worldMatrix defines the new world matrix
  87202. */
  87203. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87204. /**
  87205. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87206. * @param min defines the new minimum vector (in local space)
  87207. * @param max defines the new maximum vector (in local space)
  87208. * @param worldMatrix defines the new world matrix
  87209. */
  87210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87211. /**
  87212. * Scale the current bounding sphere by applying a scale factor
  87213. * @param factor defines the scale factor to apply
  87214. * @returns the current bounding box
  87215. */
  87216. scale(factor: number): BoundingSphere;
  87217. /**
  87218. * Gets the world matrix of the bounding box
  87219. * @returns a matrix
  87220. */
  87221. getWorldMatrix(): DeepImmutable<Matrix>;
  87222. /** @hidden */
  87223. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87224. /**
  87225. * Tests if the bounding sphere is intersecting the frustum planes
  87226. * @param frustumPlanes defines the frustum planes to test
  87227. * @returns true if there is an intersection
  87228. */
  87229. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87230. /**
  87231. * Tests if the bounding sphere center is in between the frustum planes.
  87232. * Used for optimistic fast inclusion.
  87233. * @param frustumPlanes defines the frustum planes to test
  87234. * @returns true if the sphere center is in between the frustum planes
  87235. */
  87236. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87237. /**
  87238. * Tests if a point is inside the bounding sphere
  87239. * @param point defines the point to test
  87240. * @returns true if the point is inside the bounding sphere
  87241. */
  87242. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87243. /**
  87244. * Checks if two sphere intersct
  87245. * @param sphere0 sphere 0
  87246. * @param sphere1 sphere 1
  87247. * @returns true if the speres intersect
  87248. */
  87249. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87250. }
  87251. }
  87252. declare module BABYLON {
  87253. /**
  87254. * Class used to store bounding box information
  87255. */
  87256. export class BoundingBox implements ICullable {
  87257. /**
  87258. * Gets the 8 vectors representing the bounding box in local space
  87259. */
  87260. readonly vectors: Vector3[];
  87261. /**
  87262. * Gets the center of the bounding box in local space
  87263. */
  87264. readonly center: Vector3;
  87265. /**
  87266. * Gets the center of the bounding box in world space
  87267. */
  87268. readonly centerWorld: Vector3;
  87269. /**
  87270. * Gets the extend size in local space
  87271. */
  87272. readonly extendSize: Vector3;
  87273. /**
  87274. * Gets the extend size in world space
  87275. */
  87276. readonly extendSizeWorld: Vector3;
  87277. /**
  87278. * Gets the OBB (object bounding box) directions
  87279. */
  87280. readonly directions: Vector3[];
  87281. /**
  87282. * Gets the 8 vectors representing the bounding box in world space
  87283. */
  87284. readonly vectorsWorld: Vector3[];
  87285. /**
  87286. * Gets the minimum vector in world space
  87287. */
  87288. readonly minimumWorld: Vector3;
  87289. /**
  87290. * Gets the maximum vector in world space
  87291. */
  87292. readonly maximumWorld: Vector3;
  87293. /**
  87294. * Gets the minimum vector in local space
  87295. */
  87296. readonly minimum: Vector3;
  87297. /**
  87298. * Gets the maximum vector in local space
  87299. */
  87300. readonly maximum: Vector3;
  87301. private _worldMatrix;
  87302. private static readonly TmpVector3;
  87303. /**
  87304. * @hidden
  87305. */
  87306. _tag: number;
  87307. /**
  87308. * Creates a new bounding box
  87309. * @param min defines the minimum vector (in local space)
  87310. * @param max defines the maximum vector (in local space)
  87311. * @param worldMatrix defines the new world matrix
  87312. */
  87313. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87314. /**
  87315. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87316. * @param min defines the new minimum vector (in local space)
  87317. * @param max defines the new maximum vector (in local space)
  87318. * @param worldMatrix defines the new world matrix
  87319. */
  87320. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87321. /**
  87322. * Scale the current bounding box by applying a scale factor
  87323. * @param factor defines the scale factor to apply
  87324. * @returns the current bounding box
  87325. */
  87326. scale(factor: number): BoundingBox;
  87327. /**
  87328. * Gets the world matrix of the bounding box
  87329. * @returns a matrix
  87330. */
  87331. getWorldMatrix(): DeepImmutable<Matrix>;
  87332. /** @hidden */
  87333. _update(world: DeepImmutable<Matrix>): void;
  87334. /**
  87335. * Tests if the bounding box is intersecting the frustum planes
  87336. * @param frustumPlanes defines the frustum planes to test
  87337. * @returns true if there is an intersection
  87338. */
  87339. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87340. /**
  87341. * Tests if the bounding box is entirely inside the frustum planes
  87342. * @param frustumPlanes defines the frustum planes to test
  87343. * @returns true if there is an inclusion
  87344. */
  87345. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87346. /**
  87347. * Tests if a point is inside the bounding box
  87348. * @param point defines the point to test
  87349. * @returns true if the point is inside the bounding box
  87350. */
  87351. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87352. /**
  87353. * Tests if the bounding box intersects with a bounding sphere
  87354. * @param sphere defines the sphere to test
  87355. * @returns true if there is an intersection
  87356. */
  87357. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87358. /**
  87359. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87360. * @param min defines the min vector to use
  87361. * @param max defines the max vector to use
  87362. * @returns true if there is an intersection
  87363. */
  87364. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87365. /**
  87366. * Tests if two bounding boxes are intersections
  87367. * @param box0 defines the first box to test
  87368. * @param box1 defines the second box to test
  87369. * @returns true if there is an intersection
  87370. */
  87371. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87372. /**
  87373. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87374. * @param minPoint defines the minimum vector of the bounding box
  87375. * @param maxPoint defines the maximum vector of the bounding box
  87376. * @param sphereCenter defines the sphere center
  87377. * @param sphereRadius defines the sphere radius
  87378. * @returns true if there is an intersection
  87379. */
  87380. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87381. /**
  87382. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87383. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87384. * @param frustumPlanes defines the frustum planes to test
  87385. * @return true if there is an inclusion
  87386. */
  87387. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87388. /**
  87389. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87390. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87391. * @param frustumPlanes defines the frustum planes to test
  87392. * @return true if there is an intersection
  87393. */
  87394. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87395. }
  87396. }
  87397. declare module BABYLON {
  87398. /** @hidden */
  87399. export class Collider {
  87400. /** Define if a collision was found */
  87401. collisionFound: boolean;
  87402. /**
  87403. * Define last intersection point in local space
  87404. */
  87405. intersectionPoint: Vector3;
  87406. /**
  87407. * Define last collided mesh
  87408. */
  87409. collidedMesh: Nullable<AbstractMesh>;
  87410. private _collisionPoint;
  87411. private _planeIntersectionPoint;
  87412. private _tempVector;
  87413. private _tempVector2;
  87414. private _tempVector3;
  87415. private _tempVector4;
  87416. private _edge;
  87417. private _baseToVertex;
  87418. private _destinationPoint;
  87419. private _slidePlaneNormal;
  87420. private _displacementVector;
  87421. /** @hidden */
  87422. _radius: Vector3;
  87423. /** @hidden */
  87424. _retry: number;
  87425. private _velocity;
  87426. private _basePoint;
  87427. private _epsilon;
  87428. /** @hidden */
  87429. _velocityWorldLength: number;
  87430. /** @hidden */
  87431. _basePointWorld: Vector3;
  87432. private _velocityWorld;
  87433. private _normalizedVelocity;
  87434. /** @hidden */
  87435. _initialVelocity: Vector3;
  87436. /** @hidden */
  87437. _initialPosition: Vector3;
  87438. private _nearestDistance;
  87439. private _collisionMask;
  87440. get collisionMask(): number;
  87441. set collisionMask(mask: number);
  87442. /**
  87443. * Gets the plane normal used to compute the sliding response (in local space)
  87444. */
  87445. get slidePlaneNormal(): Vector3;
  87446. /** @hidden */
  87447. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87448. /** @hidden */
  87449. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87450. /** @hidden */
  87451. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87452. /** @hidden */
  87453. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87454. /** @hidden */
  87455. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87456. /** @hidden */
  87457. _getResponse(pos: Vector3, vel: Vector3): void;
  87458. }
  87459. }
  87460. declare module BABYLON {
  87461. /**
  87462. * Interface for cullable objects
  87463. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87464. */
  87465. export interface ICullable {
  87466. /**
  87467. * Checks if the object or part of the object is in the frustum
  87468. * @param frustumPlanes Camera near/planes
  87469. * @returns true if the object is in frustum otherwise false
  87470. */
  87471. isInFrustum(frustumPlanes: Plane[]): boolean;
  87472. /**
  87473. * Checks if a cullable object (mesh...) is in the camera frustum
  87474. * Unlike isInFrustum this cheks the full bounding box
  87475. * @param frustumPlanes Camera near/planes
  87476. * @returns true if the object is in frustum otherwise false
  87477. */
  87478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87479. }
  87480. /**
  87481. * Info for a bounding data of a mesh
  87482. */
  87483. export class BoundingInfo implements ICullable {
  87484. /**
  87485. * Bounding box for the mesh
  87486. */
  87487. readonly boundingBox: BoundingBox;
  87488. /**
  87489. * Bounding sphere for the mesh
  87490. */
  87491. readonly boundingSphere: BoundingSphere;
  87492. private _isLocked;
  87493. private static readonly TmpVector3;
  87494. /**
  87495. * Constructs bounding info
  87496. * @param minimum min vector of the bounding box/sphere
  87497. * @param maximum max vector of the bounding box/sphere
  87498. * @param worldMatrix defines the new world matrix
  87499. */
  87500. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87501. /**
  87502. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87503. * @param min defines the new minimum vector (in local space)
  87504. * @param max defines the new maximum vector (in local space)
  87505. * @param worldMatrix defines the new world matrix
  87506. */
  87507. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87508. /**
  87509. * min vector of the bounding box/sphere
  87510. */
  87511. get minimum(): Vector3;
  87512. /**
  87513. * max vector of the bounding box/sphere
  87514. */
  87515. get maximum(): Vector3;
  87516. /**
  87517. * If the info is locked and won't be updated to avoid perf overhead
  87518. */
  87519. get isLocked(): boolean;
  87520. set isLocked(value: boolean);
  87521. /**
  87522. * Updates the bounding sphere and box
  87523. * @param world world matrix to be used to update
  87524. */
  87525. update(world: DeepImmutable<Matrix>): void;
  87526. /**
  87527. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87528. * @param center New center of the bounding info
  87529. * @param extend New extend of the bounding info
  87530. * @returns the current bounding info
  87531. */
  87532. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87533. /**
  87534. * Scale the current bounding info by applying a scale factor
  87535. * @param factor defines the scale factor to apply
  87536. * @returns the current bounding info
  87537. */
  87538. scale(factor: number): BoundingInfo;
  87539. /**
  87540. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87541. * @param frustumPlanes defines the frustum to test
  87542. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87543. * @returns true if the bounding info is in the frustum planes
  87544. */
  87545. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87546. /**
  87547. * Gets the world distance between the min and max points of the bounding box
  87548. */
  87549. get diagonalLength(): number;
  87550. /**
  87551. * Checks if a cullable object (mesh...) is in the camera frustum
  87552. * Unlike isInFrustum this cheks the full bounding box
  87553. * @param frustumPlanes Camera near/planes
  87554. * @returns true if the object is in frustum otherwise false
  87555. */
  87556. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87557. /** @hidden */
  87558. _checkCollision(collider: Collider): boolean;
  87559. /**
  87560. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87561. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87562. * @param point the point to check intersection with
  87563. * @returns if the point intersects
  87564. */
  87565. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87566. /**
  87567. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87568. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87569. * @param boundingInfo the bounding info to check intersection with
  87570. * @param precise if the intersection should be done using OBB
  87571. * @returns if the bounding info intersects
  87572. */
  87573. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87574. }
  87575. }
  87576. declare module BABYLON {
  87577. /**
  87578. * Extracts minimum and maximum values from a list of indexed positions
  87579. * @param positions defines the positions to use
  87580. * @param indices defines the indices to the positions
  87581. * @param indexStart defines the start index
  87582. * @param indexCount defines the end index
  87583. * @param bias defines bias value to add to the result
  87584. * @return minimum and maximum values
  87585. */
  87586. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87587. minimum: Vector3;
  87588. maximum: Vector3;
  87589. };
  87590. /**
  87591. * Extracts minimum and maximum values from a list of positions
  87592. * @param positions defines the positions to use
  87593. * @param start defines the start index in the positions array
  87594. * @param count defines the number of positions to handle
  87595. * @param bias defines bias value to add to the result
  87596. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87597. * @return minimum and maximum values
  87598. */
  87599. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87600. minimum: Vector3;
  87601. maximum: Vector3;
  87602. };
  87603. }
  87604. declare module BABYLON {
  87605. /** @hidden */
  87606. export class WebGLDataBuffer extends DataBuffer {
  87607. private _buffer;
  87608. constructor(resource: WebGLBuffer);
  87609. get underlyingResource(): any;
  87610. }
  87611. }
  87612. declare module BABYLON {
  87613. /** @hidden */
  87614. export class WebGLPipelineContext implements IPipelineContext {
  87615. engine: ThinEngine;
  87616. program: Nullable<WebGLProgram>;
  87617. context?: WebGLRenderingContext;
  87618. vertexShader?: WebGLShader;
  87619. fragmentShader?: WebGLShader;
  87620. isParallelCompiled: boolean;
  87621. onCompiled?: () => void;
  87622. transformFeedback?: WebGLTransformFeedback | null;
  87623. vertexCompilationError: Nullable<string>;
  87624. fragmentCompilationError: Nullable<string>;
  87625. programLinkError: Nullable<string>;
  87626. programValidationError: Nullable<string>;
  87627. get isAsync(): boolean;
  87628. get isReady(): boolean;
  87629. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87630. _getVertexShaderCode(): string | null;
  87631. _getFragmentShaderCode(): string | null;
  87632. }
  87633. }
  87634. declare module BABYLON {
  87635. interface ThinEngine {
  87636. /**
  87637. * Create an uniform buffer
  87638. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87639. * @param elements defines the content of the uniform buffer
  87640. * @returns the webGL uniform buffer
  87641. */
  87642. createUniformBuffer(elements: FloatArray): DataBuffer;
  87643. /**
  87644. * Create a dynamic uniform buffer
  87645. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87646. * @param elements defines the content of the uniform buffer
  87647. * @returns the webGL uniform buffer
  87648. */
  87649. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87650. /**
  87651. * Update an existing uniform buffer
  87652. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87653. * @param uniformBuffer defines the target uniform buffer
  87654. * @param elements defines the content to update
  87655. * @param offset defines the offset in the uniform buffer where update should start
  87656. * @param count defines the size of the data to update
  87657. */
  87658. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87659. /**
  87660. * Bind an uniform buffer to the current webGL context
  87661. * @param buffer defines the buffer to bind
  87662. */
  87663. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87664. /**
  87665. * Bind a buffer to the current webGL context at a given location
  87666. * @param buffer defines the buffer to bind
  87667. * @param location defines the index where to bind the buffer
  87668. */
  87669. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87670. /**
  87671. * Bind a specific block at a given index in a specific shader program
  87672. * @param pipelineContext defines the pipeline context to use
  87673. * @param blockName defines the block name
  87674. * @param index defines the index where to bind the block
  87675. */
  87676. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87677. }
  87678. }
  87679. declare module BABYLON {
  87680. /**
  87681. * Uniform buffer objects.
  87682. *
  87683. * Handles blocks of uniform on the GPU.
  87684. *
  87685. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87686. *
  87687. * For more information, please refer to :
  87688. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87689. */
  87690. export class UniformBuffer {
  87691. private _engine;
  87692. private _buffer;
  87693. private _data;
  87694. private _bufferData;
  87695. private _dynamic?;
  87696. private _uniformLocations;
  87697. private _uniformSizes;
  87698. private _uniformLocationPointer;
  87699. private _needSync;
  87700. private _noUBO;
  87701. private _currentEffect;
  87702. /** @hidden */
  87703. _alreadyBound: boolean;
  87704. private static _MAX_UNIFORM_SIZE;
  87705. private static _tempBuffer;
  87706. /**
  87707. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87708. * This is dynamic to allow compat with webgl 1 and 2.
  87709. * You will need to pass the name of the uniform as well as the value.
  87710. */
  87711. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87712. /**
  87713. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87714. * This is dynamic to allow compat with webgl 1 and 2.
  87715. * You will need to pass the name of the uniform as well as the value.
  87716. */
  87717. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87718. /**
  87719. * Lambda to Update a single float in a uniform buffer.
  87720. * This is dynamic to allow compat with webgl 1 and 2.
  87721. * You will need to pass the name of the uniform as well as the value.
  87722. */
  87723. updateFloat: (name: string, x: number) => void;
  87724. /**
  87725. * Lambda to Update a vec2 of float in a uniform buffer.
  87726. * This is dynamic to allow compat with webgl 1 and 2.
  87727. * You will need to pass the name of the uniform as well as the value.
  87728. */
  87729. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87730. /**
  87731. * Lambda to Update a vec3 of float in a uniform buffer.
  87732. * This is dynamic to allow compat with webgl 1 and 2.
  87733. * You will need to pass the name of the uniform as well as the value.
  87734. */
  87735. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87736. /**
  87737. * Lambda to Update a vec4 of float in a uniform buffer.
  87738. * This is dynamic to allow compat with webgl 1 and 2.
  87739. * You will need to pass the name of the uniform as well as the value.
  87740. */
  87741. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87742. /**
  87743. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87744. * This is dynamic to allow compat with webgl 1 and 2.
  87745. * You will need to pass the name of the uniform as well as the value.
  87746. */
  87747. updateMatrix: (name: string, mat: Matrix) => void;
  87748. /**
  87749. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87750. * This is dynamic to allow compat with webgl 1 and 2.
  87751. * You will need to pass the name of the uniform as well as the value.
  87752. */
  87753. updateVector3: (name: string, vector: Vector3) => void;
  87754. /**
  87755. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87756. * This is dynamic to allow compat with webgl 1 and 2.
  87757. * You will need to pass the name of the uniform as well as the value.
  87758. */
  87759. updateVector4: (name: string, vector: Vector4) => void;
  87760. /**
  87761. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87762. * This is dynamic to allow compat with webgl 1 and 2.
  87763. * You will need to pass the name of the uniform as well as the value.
  87764. */
  87765. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87766. /**
  87767. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87768. * This is dynamic to allow compat with webgl 1 and 2.
  87769. * You will need to pass the name of the uniform as well as the value.
  87770. */
  87771. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87772. /**
  87773. * Instantiates a new Uniform buffer objects.
  87774. *
  87775. * Handles blocks of uniform on the GPU.
  87776. *
  87777. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87778. *
  87779. * For more information, please refer to :
  87780. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87781. * @param engine Define the engine the buffer is associated with
  87782. * @param data Define the data contained in the buffer
  87783. * @param dynamic Define if the buffer is updatable
  87784. */
  87785. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87786. /**
  87787. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87788. * or just falling back on setUniformXXX calls.
  87789. */
  87790. get useUbo(): boolean;
  87791. /**
  87792. * Indicates if the WebGL underlying uniform buffer is in sync
  87793. * with the javascript cache data.
  87794. */
  87795. get isSync(): boolean;
  87796. /**
  87797. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87798. * Also, a dynamic UniformBuffer will disable cache verification and always
  87799. * update the underlying WebGL uniform buffer to the GPU.
  87800. * @returns if Dynamic, otherwise false
  87801. */
  87802. isDynamic(): boolean;
  87803. /**
  87804. * The data cache on JS side.
  87805. * @returns the underlying data as a float array
  87806. */
  87807. getData(): Float32Array;
  87808. /**
  87809. * The underlying WebGL Uniform buffer.
  87810. * @returns the webgl buffer
  87811. */
  87812. getBuffer(): Nullable<DataBuffer>;
  87813. /**
  87814. * std140 layout specifies how to align data within an UBO structure.
  87815. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87816. * for specs.
  87817. */
  87818. private _fillAlignment;
  87819. /**
  87820. * Adds an uniform in the buffer.
  87821. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87822. * for the layout to be correct !
  87823. * @param name Name of the uniform, as used in the uniform block in the shader.
  87824. * @param size Data size, or data directly.
  87825. */
  87826. addUniform(name: string, size: number | number[]): void;
  87827. /**
  87828. * Adds a Matrix 4x4 to the uniform buffer.
  87829. * @param name Name of the uniform, as used in the uniform block in the shader.
  87830. * @param mat A 4x4 matrix.
  87831. */
  87832. addMatrix(name: string, mat: Matrix): void;
  87833. /**
  87834. * Adds a vec2 to the uniform buffer.
  87835. * @param name Name of the uniform, as used in the uniform block in the shader.
  87836. * @param x Define the x component value of the vec2
  87837. * @param y Define the y component value of the vec2
  87838. */
  87839. addFloat2(name: string, x: number, y: number): void;
  87840. /**
  87841. * Adds a vec3 to the uniform buffer.
  87842. * @param name Name of the uniform, as used in the uniform block in the shader.
  87843. * @param x Define the x component value of the vec3
  87844. * @param y Define the y component value of the vec3
  87845. * @param z Define the z component value of the vec3
  87846. */
  87847. addFloat3(name: string, x: number, y: number, z: number): void;
  87848. /**
  87849. * Adds a vec3 to the uniform buffer.
  87850. * @param name Name of the uniform, as used in the uniform block in the shader.
  87851. * @param color Define the vec3 from a Color
  87852. */
  87853. addColor3(name: string, color: Color3): void;
  87854. /**
  87855. * Adds a vec4 to the uniform buffer.
  87856. * @param name Name of the uniform, as used in the uniform block in the shader.
  87857. * @param color Define the rgb components from a Color
  87858. * @param alpha Define the a component of the vec4
  87859. */
  87860. addColor4(name: string, color: Color3, alpha: number): void;
  87861. /**
  87862. * Adds a vec3 to the uniform buffer.
  87863. * @param name Name of the uniform, as used in the uniform block in the shader.
  87864. * @param vector Define the vec3 components from a Vector
  87865. */
  87866. addVector3(name: string, vector: Vector3): void;
  87867. /**
  87868. * Adds a Matrix 3x3 to the uniform buffer.
  87869. * @param name Name of the uniform, as used in the uniform block in the shader.
  87870. */
  87871. addMatrix3x3(name: string): void;
  87872. /**
  87873. * Adds a Matrix 2x2 to the uniform buffer.
  87874. * @param name Name of the uniform, as used in the uniform block in the shader.
  87875. */
  87876. addMatrix2x2(name: string): void;
  87877. /**
  87878. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87879. */
  87880. create(): void;
  87881. /** @hidden */
  87882. _rebuild(): void;
  87883. /**
  87884. * Updates the WebGL Uniform Buffer on the GPU.
  87885. * If the `dynamic` flag is set to true, no cache comparison is done.
  87886. * Otherwise, the buffer will be updated only if the cache differs.
  87887. */
  87888. update(): void;
  87889. /**
  87890. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87891. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87892. * @param data Define the flattened data
  87893. * @param size Define the size of the data.
  87894. */
  87895. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87896. private _valueCache;
  87897. private _cacheMatrix;
  87898. private _updateMatrix3x3ForUniform;
  87899. private _updateMatrix3x3ForEffect;
  87900. private _updateMatrix2x2ForEffect;
  87901. private _updateMatrix2x2ForUniform;
  87902. private _updateFloatForEffect;
  87903. private _updateFloatForUniform;
  87904. private _updateFloat2ForEffect;
  87905. private _updateFloat2ForUniform;
  87906. private _updateFloat3ForEffect;
  87907. private _updateFloat3ForUniform;
  87908. private _updateFloat4ForEffect;
  87909. private _updateFloat4ForUniform;
  87910. private _updateMatrixForEffect;
  87911. private _updateMatrixForUniform;
  87912. private _updateVector3ForEffect;
  87913. private _updateVector3ForUniform;
  87914. private _updateVector4ForEffect;
  87915. private _updateVector4ForUniform;
  87916. private _updateColor3ForEffect;
  87917. private _updateColor3ForUniform;
  87918. private _updateColor4ForEffect;
  87919. private _updateColor4ForUniform;
  87920. /**
  87921. * Sets a sampler uniform on the effect.
  87922. * @param name Define the name of the sampler.
  87923. * @param texture Define the texture to set in the sampler
  87924. */
  87925. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87926. /**
  87927. * Directly updates the value of the uniform in the cache AND on the GPU.
  87928. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87929. * @param data Define the flattened data
  87930. */
  87931. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87932. /**
  87933. * Binds this uniform buffer to an effect.
  87934. * @param effect Define the effect to bind the buffer to
  87935. * @param name Name of the uniform block in the shader.
  87936. */
  87937. bindToEffect(effect: Effect, name: string): void;
  87938. /**
  87939. * Disposes the uniform buffer.
  87940. */
  87941. dispose(): void;
  87942. }
  87943. }
  87944. declare module BABYLON {
  87945. /**
  87946. * Enum that determines the text-wrapping mode to use.
  87947. */
  87948. export enum InspectableType {
  87949. /**
  87950. * Checkbox for booleans
  87951. */
  87952. Checkbox = 0,
  87953. /**
  87954. * Sliders for numbers
  87955. */
  87956. Slider = 1,
  87957. /**
  87958. * Vector3
  87959. */
  87960. Vector3 = 2,
  87961. /**
  87962. * Quaternions
  87963. */
  87964. Quaternion = 3,
  87965. /**
  87966. * Color3
  87967. */
  87968. Color3 = 4,
  87969. /**
  87970. * String
  87971. */
  87972. String = 5
  87973. }
  87974. /**
  87975. * Interface used to define custom inspectable properties.
  87976. * This interface is used by the inspector to display custom property grids
  87977. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87978. */
  87979. export interface IInspectable {
  87980. /**
  87981. * Gets the label to display
  87982. */
  87983. label: string;
  87984. /**
  87985. * Gets the name of the property to edit
  87986. */
  87987. propertyName: string;
  87988. /**
  87989. * Gets the type of the editor to use
  87990. */
  87991. type: InspectableType;
  87992. /**
  87993. * Gets the minimum value of the property when using in "slider" mode
  87994. */
  87995. min?: number;
  87996. /**
  87997. * Gets the maximum value of the property when using in "slider" mode
  87998. */
  87999. max?: number;
  88000. /**
  88001. * Gets the setp to use when using in "slider" mode
  88002. */
  88003. step?: number;
  88004. }
  88005. }
  88006. declare module BABYLON {
  88007. /**
  88008. * Class used to provide helper for timing
  88009. */
  88010. export class TimingTools {
  88011. /**
  88012. * Polyfill for setImmediate
  88013. * @param action defines the action to execute after the current execution block
  88014. */
  88015. static SetImmediate(action: () => void): void;
  88016. }
  88017. }
  88018. declare module BABYLON {
  88019. /**
  88020. * Class used to enable instatition of objects by class name
  88021. */
  88022. export class InstantiationTools {
  88023. /**
  88024. * Use this object to register external classes like custom textures or material
  88025. * to allow the laoders to instantiate them
  88026. */
  88027. static RegisteredExternalClasses: {
  88028. [key: string]: Object;
  88029. };
  88030. /**
  88031. * Tries to instantiate a new object from a given class name
  88032. * @param className defines the class name to instantiate
  88033. * @returns the new object or null if the system was not able to do the instantiation
  88034. */
  88035. static Instantiate(className: string): any;
  88036. }
  88037. }
  88038. declare module BABYLON {
  88039. /**
  88040. * Define options used to create a depth texture
  88041. */
  88042. export class DepthTextureCreationOptions {
  88043. /** Specifies whether or not a stencil should be allocated in the texture */
  88044. generateStencil?: boolean;
  88045. /** Specifies whether or not bilinear filtering is enable on the texture */
  88046. bilinearFiltering?: boolean;
  88047. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88048. comparisonFunction?: number;
  88049. /** Specifies if the created texture is a cube texture */
  88050. isCube?: boolean;
  88051. }
  88052. }
  88053. declare module BABYLON {
  88054. interface ThinEngine {
  88055. /**
  88056. * Creates a depth stencil cube texture.
  88057. * This is only available in WebGL 2.
  88058. * @param size The size of face edge in the cube texture.
  88059. * @param options The options defining the cube texture.
  88060. * @returns The cube texture
  88061. */
  88062. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88063. /**
  88064. * Creates a cube texture
  88065. * @param rootUrl defines the url where the files to load is located
  88066. * @param scene defines the current scene
  88067. * @param files defines the list of files to load (1 per face)
  88068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88069. * @param onLoad defines an optional callback raised when the texture is loaded
  88070. * @param onError defines an optional callback raised if there is an issue to load the texture
  88071. * @param format defines the format of the data
  88072. * @param forcedExtension defines the extension to use to pick the right loader
  88073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88076. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88077. * @returns the cube texture as an InternalTexture
  88078. */
  88079. 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;
  88080. /**
  88081. * Creates a cube texture
  88082. * @param rootUrl defines the url where the files to load is located
  88083. * @param scene defines the current scene
  88084. * @param files defines the list of files to load (1 per face)
  88085. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88086. * @param onLoad defines an optional callback raised when the texture is loaded
  88087. * @param onError defines an optional callback raised if there is an issue to load the texture
  88088. * @param format defines the format of the data
  88089. * @param forcedExtension defines the extension to use to pick the right loader
  88090. * @returns the cube texture as an InternalTexture
  88091. */
  88092. 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;
  88093. /**
  88094. * Creates a cube texture
  88095. * @param rootUrl defines the url where the files to load is located
  88096. * @param scene defines the current scene
  88097. * @param files defines the list of files to load (1 per face)
  88098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88099. * @param onLoad defines an optional callback raised when the texture is loaded
  88100. * @param onError defines an optional callback raised if there is an issue to load the texture
  88101. * @param format defines the format of the data
  88102. * @param forcedExtension defines the extension to use to pick the right loader
  88103. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88104. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88105. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88106. * @returns the cube texture as an InternalTexture
  88107. */
  88108. 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;
  88109. /** @hidden */
  88110. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88111. /** @hidden */
  88112. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88113. /** @hidden */
  88114. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88115. /** @hidden */
  88116. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88117. /**
  88118. * @hidden
  88119. */
  88120. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88121. }
  88122. }
  88123. declare module BABYLON {
  88124. /**
  88125. * Class for creating a cube texture
  88126. */
  88127. export class CubeTexture extends BaseTexture {
  88128. private _delayedOnLoad;
  88129. /**
  88130. * Observable triggered once the texture has been loaded.
  88131. */
  88132. onLoadObservable: Observable<CubeTexture>;
  88133. /**
  88134. * The url of the texture
  88135. */
  88136. url: string;
  88137. /**
  88138. * Gets or sets the center of the bounding box associated with the cube texture.
  88139. * It must define where the camera used to render the texture was set
  88140. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88141. */
  88142. boundingBoxPosition: Vector3;
  88143. private _boundingBoxSize;
  88144. /**
  88145. * Gets or sets the size of the bounding box associated with the cube texture
  88146. * When defined, the cubemap will switch to local mode
  88147. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88148. * @example https://www.babylonjs-playground.com/#RNASML
  88149. */
  88150. set boundingBoxSize(value: Vector3);
  88151. /**
  88152. * Returns the bounding box size
  88153. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88154. */
  88155. get boundingBoxSize(): Vector3;
  88156. protected _rotationY: number;
  88157. /**
  88158. * Sets texture matrix rotation angle around Y axis in radians.
  88159. */
  88160. set rotationY(value: number);
  88161. /**
  88162. * Gets texture matrix rotation angle around Y axis radians.
  88163. */
  88164. get rotationY(): number;
  88165. /**
  88166. * Are mip maps generated for this texture or not.
  88167. */
  88168. get noMipmap(): boolean;
  88169. private _noMipmap;
  88170. private _files;
  88171. protected _forcedExtension: Nullable<string>;
  88172. private _extensions;
  88173. private _textureMatrix;
  88174. private _format;
  88175. private _createPolynomials;
  88176. /**
  88177. * Creates a cube texture from an array of image urls
  88178. * @param files defines an array of image urls
  88179. * @param scene defines the hosting scene
  88180. * @param noMipmap specifies if mip maps are not used
  88181. * @returns a cube texture
  88182. */
  88183. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88184. /**
  88185. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88186. * @param url defines the url of the prefiltered texture
  88187. * @param scene defines the scene the texture is attached to
  88188. * @param forcedExtension defines the extension of the file if different from the url
  88189. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88190. * @return the prefiltered texture
  88191. */
  88192. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88193. /**
  88194. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88195. * as prefiltered data.
  88196. * @param rootUrl defines the url of the texture or the root name of the six images
  88197. * @param null defines the scene or engine the texture is attached to
  88198. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88199. * @param noMipmap defines if mipmaps should be created or not
  88200. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88201. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88202. * @param onError defines a callback triggered in case of error during load
  88203. * @param format defines the internal format to use for the texture once loaded
  88204. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88205. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88206. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88209. * @return the cube texture
  88210. */
  88211. 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);
  88212. /**
  88213. * Get the current class name of the texture useful for serialization or dynamic coding.
  88214. * @returns "CubeTexture"
  88215. */
  88216. getClassName(): string;
  88217. /**
  88218. * Update the url (and optional buffer) of this texture if url was null during construction.
  88219. * @param url the url of the texture
  88220. * @param forcedExtension defines the extension to use
  88221. * @param onLoad callback called when the texture is loaded (defaults to null)
  88222. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88223. */
  88224. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88225. /**
  88226. * Delays loading of the cube texture
  88227. * @param forcedExtension defines the extension to use
  88228. */
  88229. delayLoad(forcedExtension?: string): void;
  88230. /**
  88231. * Returns the reflection texture matrix
  88232. * @returns the reflection texture matrix
  88233. */
  88234. getReflectionTextureMatrix(): Matrix;
  88235. /**
  88236. * Sets the reflection texture matrix
  88237. * @param value Reflection texture matrix
  88238. */
  88239. setReflectionTextureMatrix(value: Matrix): void;
  88240. /**
  88241. * Parses text to create a cube texture
  88242. * @param parsedTexture define the serialized text to read from
  88243. * @param scene defines the hosting scene
  88244. * @param rootUrl defines the root url of the cube texture
  88245. * @returns a cube texture
  88246. */
  88247. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88248. /**
  88249. * Makes a clone, or deep copy, of the cube texture
  88250. * @returns a new cube texture
  88251. */
  88252. clone(): CubeTexture;
  88253. }
  88254. }
  88255. declare module BABYLON {
  88256. /**
  88257. * Manages the defines for the Material
  88258. */
  88259. export class MaterialDefines {
  88260. /** @hidden */
  88261. protected _keys: string[];
  88262. private _isDirty;
  88263. /** @hidden */
  88264. _renderId: number;
  88265. /** @hidden */
  88266. _areLightsDirty: boolean;
  88267. /** @hidden */
  88268. _areLightsDisposed: boolean;
  88269. /** @hidden */
  88270. _areAttributesDirty: boolean;
  88271. /** @hidden */
  88272. _areTexturesDirty: boolean;
  88273. /** @hidden */
  88274. _areFresnelDirty: boolean;
  88275. /** @hidden */
  88276. _areMiscDirty: boolean;
  88277. /** @hidden */
  88278. _areImageProcessingDirty: boolean;
  88279. /** @hidden */
  88280. _normals: boolean;
  88281. /** @hidden */
  88282. _uvs: boolean;
  88283. /** @hidden */
  88284. _needNormals: boolean;
  88285. /** @hidden */
  88286. _needUVs: boolean;
  88287. [id: string]: any;
  88288. /**
  88289. * Specifies if the material needs to be re-calculated
  88290. */
  88291. get isDirty(): boolean;
  88292. /**
  88293. * Marks the material to indicate that it has been re-calculated
  88294. */
  88295. markAsProcessed(): void;
  88296. /**
  88297. * Marks the material to indicate that it needs to be re-calculated
  88298. */
  88299. markAsUnprocessed(): void;
  88300. /**
  88301. * Marks the material to indicate all of its defines need to be re-calculated
  88302. */
  88303. markAllAsDirty(): void;
  88304. /**
  88305. * Marks the material to indicate that image processing needs to be re-calculated
  88306. */
  88307. markAsImageProcessingDirty(): void;
  88308. /**
  88309. * Marks the material to indicate the lights need to be re-calculated
  88310. * @param disposed Defines whether the light is dirty due to dispose or not
  88311. */
  88312. markAsLightDirty(disposed?: boolean): void;
  88313. /**
  88314. * Marks the attribute state as changed
  88315. */
  88316. markAsAttributesDirty(): void;
  88317. /**
  88318. * Marks the texture state as changed
  88319. */
  88320. markAsTexturesDirty(): void;
  88321. /**
  88322. * Marks the fresnel state as changed
  88323. */
  88324. markAsFresnelDirty(): void;
  88325. /**
  88326. * Marks the misc state as changed
  88327. */
  88328. markAsMiscDirty(): void;
  88329. /**
  88330. * Rebuilds the material defines
  88331. */
  88332. rebuild(): void;
  88333. /**
  88334. * Specifies if two material defines are equal
  88335. * @param other - A material define instance to compare to
  88336. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88337. */
  88338. isEqual(other: MaterialDefines): boolean;
  88339. /**
  88340. * Clones this instance's defines to another instance
  88341. * @param other - material defines to clone values to
  88342. */
  88343. cloneTo(other: MaterialDefines): void;
  88344. /**
  88345. * Resets the material define values
  88346. */
  88347. reset(): void;
  88348. /**
  88349. * Converts the material define values to a string
  88350. * @returns - String of material define information
  88351. */
  88352. toString(): string;
  88353. }
  88354. }
  88355. declare module BABYLON {
  88356. /**
  88357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88359. * 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;
  88360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88361. */
  88362. export class ColorCurves {
  88363. private _dirty;
  88364. private _tempColor;
  88365. private _globalCurve;
  88366. private _highlightsCurve;
  88367. private _midtonesCurve;
  88368. private _shadowsCurve;
  88369. private _positiveCurve;
  88370. private _negativeCurve;
  88371. private _globalHue;
  88372. private _globalDensity;
  88373. private _globalSaturation;
  88374. private _globalExposure;
  88375. /**
  88376. * Gets the global Hue value.
  88377. * 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).
  88378. */
  88379. get globalHue(): number;
  88380. /**
  88381. * Sets the global Hue value.
  88382. * 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).
  88383. */
  88384. set globalHue(value: number);
  88385. /**
  88386. * Gets the global Density value.
  88387. * 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.
  88388. * Values less than zero provide a filter of opposite hue.
  88389. */
  88390. get globalDensity(): number;
  88391. /**
  88392. * Sets the global Density value.
  88393. * 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.
  88394. * Values less than zero provide a filter of opposite hue.
  88395. */
  88396. set globalDensity(value: number);
  88397. /**
  88398. * Gets the global Saturation value.
  88399. * 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.
  88400. */
  88401. get globalSaturation(): number;
  88402. /**
  88403. * Sets the global Saturation value.
  88404. * 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.
  88405. */
  88406. set globalSaturation(value: number);
  88407. /**
  88408. * Gets the global Exposure value.
  88409. * 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.
  88410. */
  88411. get globalExposure(): number;
  88412. /**
  88413. * Sets the global Exposure value.
  88414. * 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.
  88415. */
  88416. set globalExposure(value: number);
  88417. private _highlightsHue;
  88418. private _highlightsDensity;
  88419. private _highlightsSaturation;
  88420. private _highlightsExposure;
  88421. /**
  88422. * Gets the highlights Hue value.
  88423. * 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).
  88424. */
  88425. get highlightsHue(): number;
  88426. /**
  88427. * Sets the highlights Hue value.
  88428. * 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).
  88429. */
  88430. set highlightsHue(value: number);
  88431. /**
  88432. * Gets the highlights Density value.
  88433. * 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.
  88434. * Values less than zero provide a filter of opposite hue.
  88435. */
  88436. get highlightsDensity(): number;
  88437. /**
  88438. * Sets the highlights Density value.
  88439. * 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.
  88440. * Values less than zero provide a filter of opposite hue.
  88441. */
  88442. set highlightsDensity(value: number);
  88443. /**
  88444. * Gets the highlights Saturation value.
  88445. * 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.
  88446. */
  88447. get highlightsSaturation(): number;
  88448. /**
  88449. * Sets the highlights Saturation value.
  88450. * 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.
  88451. */
  88452. set highlightsSaturation(value: number);
  88453. /**
  88454. * Gets the highlights Exposure value.
  88455. * 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.
  88456. */
  88457. get highlightsExposure(): number;
  88458. /**
  88459. * Sets the highlights Exposure value.
  88460. * 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.
  88461. */
  88462. set highlightsExposure(value: number);
  88463. private _midtonesHue;
  88464. private _midtonesDensity;
  88465. private _midtonesSaturation;
  88466. private _midtonesExposure;
  88467. /**
  88468. * Gets the midtones Hue value.
  88469. * 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).
  88470. */
  88471. get midtonesHue(): number;
  88472. /**
  88473. * Sets the midtones Hue value.
  88474. * 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).
  88475. */
  88476. set midtonesHue(value: number);
  88477. /**
  88478. * Gets the midtones Density value.
  88479. * 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.
  88480. * Values less than zero provide a filter of opposite hue.
  88481. */
  88482. get midtonesDensity(): number;
  88483. /**
  88484. * Sets the midtones Density value.
  88485. * 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.
  88486. * Values less than zero provide a filter of opposite hue.
  88487. */
  88488. set midtonesDensity(value: number);
  88489. /**
  88490. * Gets the midtones Saturation value.
  88491. * 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.
  88492. */
  88493. get midtonesSaturation(): number;
  88494. /**
  88495. * Sets the midtones Saturation value.
  88496. * 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.
  88497. */
  88498. set midtonesSaturation(value: number);
  88499. /**
  88500. * Gets the midtones Exposure value.
  88501. * 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.
  88502. */
  88503. get midtonesExposure(): number;
  88504. /**
  88505. * Sets the midtones Exposure value.
  88506. * 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.
  88507. */
  88508. set midtonesExposure(value: number);
  88509. private _shadowsHue;
  88510. private _shadowsDensity;
  88511. private _shadowsSaturation;
  88512. private _shadowsExposure;
  88513. /**
  88514. * Gets the shadows Hue value.
  88515. * 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).
  88516. */
  88517. get shadowsHue(): number;
  88518. /**
  88519. * Sets the shadows Hue value.
  88520. * 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).
  88521. */
  88522. set shadowsHue(value: number);
  88523. /**
  88524. * Gets the shadows Density value.
  88525. * 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.
  88526. * Values less than zero provide a filter of opposite hue.
  88527. */
  88528. get shadowsDensity(): number;
  88529. /**
  88530. * Sets the shadows Density value.
  88531. * 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.
  88532. * Values less than zero provide a filter of opposite hue.
  88533. */
  88534. set shadowsDensity(value: number);
  88535. /**
  88536. * Gets the shadows Saturation value.
  88537. * 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.
  88538. */
  88539. get shadowsSaturation(): number;
  88540. /**
  88541. * Sets the shadows Saturation value.
  88542. * 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.
  88543. */
  88544. set shadowsSaturation(value: number);
  88545. /**
  88546. * Gets the shadows Exposure value.
  88547. * 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.
  88548. */
  88549. get shadowsExposure(): number;
  88550. /**
  88551. * Sets the shadows Exposure value.
  88552. * 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.
  88553. */
  88554. set shadowsExposure(value: number);
  88555. /**
  88556. * Returns the class name
  88557. * @returns The class name
  88558. */
  88559. getClassName(): string;
  88560. /**
  88561. * Binds the color curves to the shader.
  88562. * @param colorCurves The color curve to bind
  88563. * @param effect The effect to bind to
  88564. * @param positiveUniform The positive uniform shader parameter
  88565. * @param neutralUniform The neutral uniform shader parameter
  88566. * @param negativeUniform The negative uniform shader parameter
  88567. */
  88568. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88569. /**
  88570. * Prepare the list of uniforms associated with the ColorCurves effects.
  88571. * @param uniformsList The list of uniforms used in the effect
  88572. */
  88573. static PrepareUniforms(uniformsList: string[]): void;
  88574. /**
  88575. * Returns color grading data based on a hue, density, saturation and exposure value.
  88576. * @param filterHue The hue of the color filter.
  88577. * @param filterDensity The density of the color filter.
  88578. * @param saturation The saturation.
  88579. * @param exposure The exposure.
  88580. * @param result The result data container.
  88581. */
  88582. private getColorGradingDataToRef;
  88583. /**
  88584. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88585. * @param value The input slider value in range [-100,100].
  88586. * @returns Adjusted value.
  88587. */
  88588. private static applyColorGradingSliderNonlinear;
  88589. /**
  88590. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88591. * @param hue The hue (H) input.
  88592. * @param saturation The saturation (S) input.
  88593. * @param brightness The brightness (B) input.
  88594. * @result An RGBA color represented as Vector4.
  88595. */
  88596. private static fromHSBToRef;
  88597. /**
  88598. * Returns a value clamped between min and max
  88599. * @param value The value to clamp
  88600. * @param min The minimum of value
  88601. * @param max The maximum of value
  88602. * @returns The clamped value.
  88603. */
  88604. private static clamp;
  88605. /**
  88606. * Clones the current color curve instance.
  88607. * @return The cloned curves
  88608. */
  88609. clone(): ColorCurves;
  88610. /**
  88611. * Serializes the current color curve instance to a json representation.
  88612. * @return a JSON representation
  88613. */
  88614. serialize(): any;
  88615. /**
  88616. * Parses the color curve from a json representation.
  88617. * @param source the JSON source to parse
  88618. * @return The parsed curves
  88619. */
  88620. static Parse(source: any): ColorCurves;
  88621. }
  88622. }
  88623. declare module BABYLON {
  88624. /**
  88625. * Interface to follow in your material defines to integrate easily the
  88626. * Image proccessing functions.
  88627. * @hidden
  88628. */
  88629. export interface IImageProcessingConfigurationDefines {
  88630. IMAGEPROCESSING: boolean;
  88631. VIGNETTE: boolean;
  88632. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88633. VIGNETTEBLENDMODEOPAQUE: boolean;
  88634. TONEMAPPING: boolean;
  88635. TONEMAPPING_ACES: boolean;
  88636. CONTRAST: boolean;
  88637. EXPOSURE: boolean;
  88638. COLORCURVES: boolean;
  88639. COLORGRADING: boolean;
  88640. COLORGRADING3D: boolean;
  88641. SAMPLER3DGREENDEPTH: boolean;
  88642. SAMPLER3DBGRMAP: boolean;
  88643. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88644. }
  88645. /**
  88646. * @hidden
  88647. */
  88648. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88649. IMAGEPROCESSING: boolean;
  88650. VIGNETTE: boolean;
  88651. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88652. VIGNETTEBLENDMODEOPAQUE: boolean;
  88653. TONEMAPPING: boolean;
  88654. TONEMAPPING_ACES: boolean;
  88655. CONTRAST: boolean;
  88656. COLORCURVES: boolean;
  88657. COLORGRADING: boolean;
  88658. COLORGRADING3D: boolean;
  88659. SAMPLER3DGREENDEPTH: boolean;
  88660. SAMPLER3DBGRMAP: boolean;
  88661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88662. EXPOSURE: boolean;
  88663. constructor();
  88664. }
  88665. /**
  88666. * This groups together the common properties used for image processing either in direct forward pass
  88667. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88668. * or not.
  88669. */
  88670. export class ImageProcessingConfiguration {
  88671. /**
  88672. * Default tone mapping applied in BabylonJS.
  88673. */
  88674. static readonly TONEMAPPING_STANDARD: number;
  88675. /**
  88676. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88677. * to other engines rendering to increase portability.
  88678. */
  88679. static readonly TONEMAPPING_ACES: number;
  88680. /**
  88681. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88682. */
  88683. colorCurves: Nullable<ColorCurves>;
  88684. private _colorCurvesEnabled;
  88685. /**
  88686. * Gets wether the color curves effect is enabled.
  88687. */
  88688. get colorCurvesEnabled(): boolean;
  88689. /**
  88690. * Sets wether the color curves effect is enabled.
  88691. */
  88692. set colorCurvesEnabled(value: boolean);
  88693. private _colorGradingTexture;
  88694. /**
  88695. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88696. */
  88697. get colorGradingTexture(): Nullable<BaseTexture>;
  88698. /**
  88699. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88700. */
  88701. set colorGradingTexture(value: Nullable<BaseTexture>);
  88702. private _colorGradingEnabled;
  88703. /**
  88704. * Gets wether the color grading effect is enabled.
  88705. */
  88706. get colorGradingEnabled(): boolean;
  88707. /**
  88708. * Sets wether the color grading effect is enabled.
  88709. */
  88710. set colorGradingEnabled(value: boolean);
  88711. private _colorGradingWithGreenDepth;
  88712. /**
  88713. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88714. */
  88715. get colorGradingWithGreenDepth(): boolean;
  88716. /**
  88717. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88718. */
  88719. set colorGradingWithGreenDepth(value: boolean);
  88720. private _colorGradingBGR;
  88721. /**
  88722. * Gets wether the color grading texture contains BGR values.
  88723. */
  88724. get colorGradingBGR(): boolean;
  88725. /**
  88726. * Sets wether the color grading texture contains BGR values.
  88727. */
  88728. set colorGradingBGR(value: boolean);
  88729. /** @hidden */
  88730. _exposure: number;
  88731. /**
  88732. * Gets the Exposure used in the effect.
  88733. */
  88734. get exposure(): number;
  88735. /**
  88736. * Sets the Exposure used in the effect.
  88737. */
  88738. set exposure(value: number);
  88739. private _toneMappingEnabled;
  88740. /**
  88741. * Gets wether the tone mapping effect is enabled.
  88742. */
  88743. get toneMappingEnabled(): boolean;
  88744. /**
  88745. * Sets wether the tone mapping effect is enabled.
  88746. */
  88747. set toneMappingEnabled(value: boolean);
  88748. private _toneMappingType;
  88749. /**
  88750. * Gets the type of tone mapping effect.
  88751. */
  88752. get toneMappingType(): number;
  88753. /**
  88754. * Sets the type of tone mapping effect used in BabylonJS.
  88755. */
  88756. set toneMappingType(value: number);
  88757. protected _contrast: number;
  88758. /**
  88759. * Gets the contrast used in the effect.
  88760. */
  88761. get contrast(): number;
  88762. /**
  88763. * Sets the contrast used in the effect.
  88764. */
  88765. set contrast(value: number);
  88766. /**
  88767. * Vignette stretch size.
  88768. */
  88769. vignetteStretch: number;
  88770. /**
  88771. * Vignette centre X Offset.
  88772. */
  88773. vignetteCentreX: number;
  88774. /**
  88775. * Vignette centre Y Offset.
  88776. */
  88777. vignetteCentreY: number;
  88778. /**
  88779. * Vignette weight or intensity of the vignette effect.
  88780. */
  88781. vignetteWeight: number;
  88782. /**
  88783. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88784. * if vignetteEnabled is set to true.
  88785. */
  88786. vignetteColor: Color4;
  88787. /**
  88788. * Camera field of view used by the Vignette effect.
  88789. */
  88790. vignetteCameraFov: number;
  88791. private _vignetteBlendMode;
  88792. /**
  88793. * Gets the vignette blend mode allowing different kind of effect.
  88794. */
  88795. get vignetteBlendMode(): number;
  88796. /**
  88797. * Sets the vignette blend mode allowing different kind of effect.
  88798. */
  88799. set vignetteBlendMode(value: number);
  88800. private _vignetteEnabled;
  88801. /**
  88802. * Gets wether the vignette effect is enabled.
  88803. */
  88804. get vignetteEnabled(): boolean;
  88805. /**
  88806. * Sets wether the vignette effect is enabled.
  88807. */
  88808. set vignetteEnabled(value: boolean);
  88809. private _applyByPostProcess;
  88810. /**
  88811. * Gets wether the image processing is applied through a post process or not.
  88812. */
  88813. get applyByPostProcess(): boolean;
  88814. /**
  88815. * Sets wether the image processing is applied through a post process or not.
  88816. */
  88817. set applyByPostProcess(value: boolean);
  88818. private _isEnabled;
  88819. /**
  88820. * Gets wether the image processing is enabled or not.
  88821. */
  88822. get isEnabled(): boolean;
  88823. /**
  88824. * Sets wether the image processing is enabled or not.
  88825. */
  88826. set isEnabled(value: boolean);
  88827. /**
  88828. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88829. */
  88830. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88831. /**
  88832. * Method called each time the image processing information changes requires to recompile the effect.
  88833. */
  88834. protected _updateParameters(): void;
  88835. /**
  88836. * Gets the current class name.
  88837. * @return "ImageProcessingConfiguration"
  88838. */
  88839. getClassName(): string;
  88840. /**
  88841. * Prepare the list of uniforms associated with the Image Processing effects.
  88842. * @param uniforms The list of uniforms used in the effect
  88843. * @param defines the list of defines currently in use
  88844. */
  88845. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88846. /**
  88847. * Prepare the list of samplers associated with the Image Processing effects.
  88848. * @param samplersList The list of uniforms used in the effect
  88849. * @param defines the list of defines currently in use
  88850. */
  88851. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88852. /**
  88853. * Prepare the list of defines associated to the shader.
  88854. * @param defines the list of defines to complete
  88855. * @param forPostProcess Define if we are currently in post process mode or not
  88856. */
  88857. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88858. /**
  88859. * Returns true if all the image processing information are ready.
  88860. * @returns True if ready, otherwise, false
  88861. */
  88862. isReady(): boolean;
  88863. /**
  88864. * Binds the image processing to the shader.
  88865. * @param effect The effect to bind to
  88866. * @param overrideAspectRatio Override the aspect ratio of the effect
  88867. */
  88868. bind(effect: Effect, overrideAspectRatio?: number): void;
  88869. /**
  88870. * Clones the current image processing instance.
  88871. * @return The cloned image processing
  88872. */
  88873. clone(): ImageProcessingConfiguration;
  88874. /**
  88875. * Serializes the current image processing instance to a json representation.
  88876. * @return a JSON representation
  88877. */
  88878. serialize(): any;
  88879. /**
  88880. * Parses the image processing from a json representation.
  88881. * @param source the JSON source to parse
  88882. * @return The parsed image processing
  88883. */
  88884. static Parse(source: any): ImageProcessingConfiguration;
  88885. private static _VIGNETTEMODE_MULTIPLY;
  88886. private static _VIGNETTEMODE_OPAQUE;
  88887. /**
  88888. * Used to apply the vignette as a mix with the pixel color.
  88889. */
  88890. static get VIGNETTEMODE_MULTIPLY(): number;
  88891. /**
  88892. * Used to apply the vignette as a replacement of the pixel color.
  88893. */
  88894. static get VIGNETTEMODE_OPAQUE(): number;
  88895. }
  88896. }
  88897. declare module BABYLON {
  88898. /** @hidden */
  88899. export var postprocessVertexShader: {
  88900. name: string;
  88901. shader: string;
  88902. };
  88903. }
  88904. declare module BABYLON {
  88905. /**
  88906. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88907. */
  88908. export type RenderTargetTextureSize = number | {
  88909. width: number;
  88910. height: number;
  88911. layers?: number;
  88912. };
  88913. interface ThinEngine {
  88914. /**
  88915. * Creates a new render target texture
  88916. * @param size defines the size of the texture
  88917. * @param options defines the options used to create the texture
  88918. * @returns a new render target texture stored in an InternalTexture
  88919. */
  88920. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88921. /**
  88922. * Creates a depth stencil texture.
  88923. * This is only available in WebGL 2 or with the depth texture extension available.
  88924. * @param size The size of face edge in the texture.
  88925. * @param options The options defining the texture.
  88926. * @returns The texture
  88927. */
  88928. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88929. /** @hidden */
  88930. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88931. }
  88932. }
  88933. declare module BABYLON {
  88934. /**
  88935. * Defines the kind of connection point for node based material
  88936. */
  88937. export enum NodeMaterialBlockConnectionPointTypes {
  88938. /** Float */
  88939. Float = 1,
  88940. /** Int */
  88941. Int = 2,
  88942. /** Vector2 */
  88943. Vector2 = 4,
  88944. /** Vector3 */
  88945. Vector3 = 8,
  88946. /** Vector4 */
  88947. Vector4 = 16,
  88948. /** Color3 */
  88949. Color3 = 32,
  88950. /** Color4 */
  88951. Color4 = 64,
  88952. /** Matrix */
  88953. Matrix = 128,
  88954. /** Custom object */
  88955. Object = 256,
  88956. /** Detect type based on connection */
  88957. AutoDetect = 1024,
  88958. /** Output type that will be defined by input type */
  88959. BasedOnInput = 2048
  88960. }
  88961. }
  88962. declare module BABYLON {
  88963. /**
  88964. * Enum used to define the target of a block
  88965. */
  88966. export enum NodeMaterialBlockTargets {
  88967. /** Vertex shader */
  88968. Vertex = 1,
  88969. /** Fragment shader */
  88970. Fragment = 2,
  88971. /** Neutral */
  88972. Neutral = 4,
  88973. /** Vertex and Fragment */
  88974. VertexAndFragment = 3
  88975. }
  88976. }
  88977. declare module BABYLON {
  88978. /**
  88979. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88980. */
  88981. export enum NodeMaterialBlockConnectionPointMode {
  88982. /** Value is an uniform */
  88983. Uniform = 0,
  88984. /** Value is a mesh attribute */
  88985. Attribute = 1,
  88986. /** Value is a varying between vertex and fragment shaders */
  88987. Varying = 2,
  88988. /** Mode is undefined */
  88989. Undefined = 3
  88990. }
  88991. }
  88992. declare module BABYLON {
  88993. /**
  88994. * Enum used to define system values e.g. values automatically provided by the system
  88995. */
  88996. export enum NodeMaterialSystemValues {
  88997. /** World */
  88998. World = 1,
  88999. /** View */
  89000. View = 2,
  89001. /** Projection */
  89002. Projection = 3,
  89003. /** ViewProjection */
  89004. ViewProjection = 4,
  89005. /** WorldView */
  89006. WorldView = 5,
  89007. /** WorldViewProjection */
  89008. WorldViewProjection = 6,
  89009. /** CameraPosition */
  89010. CameraPosition = 7,
  89011. /** Fog Color */
  89012. FogColor = 8,
  89013. /** Delta time */
  89014. DeltaTime = 9
  89015. }
  89016. }
  89017. declare module BABYLON {
  89018. /** Defines supported spaces */
  89019. export enum Space {
  89020. /** Local (object) space */
  89021. LOCAL = 0,
  89022. /** World space */
  89023. WORLD = 1,
  89024. /** Bone space */
  89025. BONE = 2
  89026. }
  89027. /** Defines the 3 main axes */
  89028. export class Axis {
  89029. /** X axis */
  89030. static X: Vector3;
  89031. /** Y axis */
  89032. static Y: Vector3;
  89033. /** Z axis */
  89034. static Z: Vector3;
  89035. }
  89036. }
  89037. declare module BABYLON {
  89038. /**
  89039. * Represents a camera frustum
  89040. */
  89041. export class Frustum {
  89042. /**
  89043. * Gets the planes representing the frustum
  89044. * @param transform matrix to be applied to the returned planes
  89045. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89046. */
  89047. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89048. /**
  89049. * Gets the near frustum plane transformed by the transform matrix
  89050. * @param transform transformation matrix to be applied to the resulting frustum plane
  89051. * @param frustumPlane the resuling frustum plane
  89052. */
  89053. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89054. /**
  89055. * Gets the far frustum plane transformed by the transform matrix
  89056. * @param transform transformation matrix to be applied to the resulting frustum plane
  89057. * @param frustumPlane the resuling frustum plane
  89058. */
  89059. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89060. /**
  89061. * Gets the left frustum plane transformed by the transform matrix
  89062. * @param transform transformation matrix to be applied to the resulting frustum plane
  89063. * @param frustumPlane the resuling frustum plane
  89064. */
  89065. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89066. /**
  89067. * Gets the right frustum plane transformed by the transform matrix
  89068. * @param transform transformation matrix to be applied to the resulting frustum plane
  89069. * @param frustumPlane the resuling frustum plane
  89070. */
  89071. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89072. /**
  89073. * Gets the top frustum plane transformed by the transform matrix
  89074. * @param transform transformation matrix to be applied to the resulting frustum plane
  89075. * @param frustumPlane the resuling frustum plane
  89076. */
  89077. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89078. /**
  89079. * Gets the bottom frustum plane transformed by the transform matrix
  89080. * @param transform transformation matrix to be applied to the resulting frustum plane
  89081. * @param frustumPlane the resuling frustum plane
  89082. */
  89083. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89084. /**
  89085. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89086. * @param transform transformation matrix to be applied to the resulting frustum planes
  89087. * @param frustumPlanes the resuling frustum planes
  89088. */
  89089. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89090. }
  89091. }
  89092. declare module BABYLON {
  89093. /**
  89094. * Interface for the size containing width and height
  89095. */
  89096. export interface ISize {
  89097. /**
  89098. * Width
  89099. */
  89100. width: number;
  89101. /**
  89102. * Heighht
  89103. */
  89104. height: number;
  89105. }
  89106. /**
  89107. * Size containing widht and height
  89108. */
  89109. export class Size implements ISize {
  89110. /**
  89111. * Width
  89112. */
  89113. width: number;
  89114. /**
  89115. * Height
  89116. */
  89117. height: number;
  89118. /**
  89119. * Creates a Size object from the given width and height (floats).
  89120. * @param width width of the new size
  89121. * @param height height of the new size
  89122. */
  89123. constructor(width: number, height: number);
  89124. /**
  89125. * Returns a string with the Size width and height
  89126. * @returns a string with the Size width and height
  89127. */
  89128. toString(): string;
  89129. /**
  89130. * "Size"
  89131. * @returns the string "Size"
  89132. */
  89133. getClassName(): string;
  89134. /**
  89135. * Returns the Size hash code.
  89136. * @returns a hash code for a unique width and height
  89137. */
  89138. getHashCode(): number;
  89139. /**
  89140. * Updates the current size from the given one.
  89141. * @param src the given size
  89142. */
  89143. copyFrom(src: Size): void;
  89144. /**
  89145. * Updates in place the current Size from the given floats.
  89146. * @param width width of the new size
  89147. * @param height height of the new size
  89148. * @returns the updated Size.
  89149. */
  89150. copyFromFloats(width: number, height: number): Size;
  89151. /**
  89152. * Updates in place the current Size from the given floats.
  89153. * @param width width to set
  89154. * @param height height to set
  89155. * @returns the updated Size.
  89156. */
  89157. set(width: number, height: number): Size;
  89158. /**
  89159. * Multiplies the width and height by numbers
  89160. * @param w factor to multiple the width by
  89161. * @param h factor to multiple the height by
  89162. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89163. */
  89164. multiplyByFloats(w: number, h: number): Size;
  89165. /**
  89166. * Clones the size
  89167. * @returns a new Size copied from the given one.
  89168. */
  89169. clone(): Size;
  89170. /**
  89171. * True if the current Size and the given one width and height are strictly equal.
  89172. * @param other the other size to compare against
  89173. * @returns True if the current Size and the given one width and height are strictly equal.
  89174. */
  89175. equals(other: Size): boolean;
  89176. /**
  89177. * The surface of the Size : width * height (float).
  89178. */
  89179. get surface(): number;
  89180. /**
  89181. * Create a new size of zero
  89182. * @returns a new Size set to (0.0, 0.0)
  89183. */
  89184. static Zero(): Size;
  89185. /**
  89186. * Sums the width and height of two sizes
  89187. * @param otherSize size to add to this size
  89188. * @returns a new Size set as the addition result of the current Size and the given one.
  89189. */
  89190. add(otherSize: Size): Size;
  89191. /**
  89192. * Subtracts the width and height of two
  89193. * @param otherSize size to subtract to this size
  89194. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89195. */
  89196. subtract(otherSize: Size): Size;
  89197. /**
  89198. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89199. * @param start starting size to lerp between
  89200. * @param end end size to lerp between
  89201. * @param amount amount to lerp between the start and end values
  89202. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89203. */
  89204. static Lerp(start: Size, end: Size, amount: number): Size;
  89205. }
  89206. }
  89207. declare module BABYLON {
  89208. /**
  89209. * Contains position and normal vectors for a vertex
  89210. */
  89211. export class PositionNormalVertex {
  89212. /** the position of the vertex (defaut: 0,0,0) */
  89213. position: Vector3;
  89214. /** the normal of the vertex (defaut: 0,1,0) */
  89215. normal: Vector3;
  89216. /**
  89217. * Creates a PositionNormalVertex
  89218. * @param position the position of the vertex (defaut: 0,0,0)
  89219. * @param normal the normal of the vertex (defaut: 0,1,0)
  89220. */
  89221. constructor(
  89222. /** the position of the vertex (defaut: 0,0,0) */
  89223. position?: Vector3,
  89224. /** the normal of the vertex (defaut: 0,1,0) */
  89225. normal?: Vector3);
  89226. /**
  89227. * Clones the PositionNormalVertex
  89228. * @returns the cloned PositionNormalVertex
  89229. */
  89230. clone(): PositionNormalVertex;
  89231. }
  89232. /**
  89233. * Contains position, normal and uv vectors for a vertex
  89234. */
  89235. export class PositionNormalTextureVertex {
  89236. /** the position of the vertex (defaut: 0,0,0) */
  89237. position: Vector3;
  89238. /** the normal of the vertex (defaut: 0,1,0) */
  89239. normal: Vector3;
  89240. /** the uv of the vertex (default: 0,0) */
  89241. uv: Vector2;
  89242. /**
  89243. * Creates a PositionNormalTextureVertex
  89244. * @param position the position of the vertex (defaut: 0,0,0)
  89245. * @param normal the normal of the vertex (defaut: 0,1,0)
  89246. * @param uv the uv of the vertex (default: 0,0)
  89247. */
  89248. constructor(
  89249. /** the position of the vertex (defaut: 0,0,0) */
  89250. position?: Vector3,
  89251. /** the normal of the vertex (defaut: 0,1,0) */
  89252. normal?: Vector3,
  89253. /** the uv of the vertex (default: 0,0) */
  89254. uv?: Vector2);
  89255. /**
  89256. * Clones the PositionNormalTextureVertex
  89257. * @returns the cloned PositionNormalTextureVertex
  89258. */
  89259. clone(): PositionNormalTextureVertex;
  89260. }
  89261. }
  89262. declare module BABYLON {
  89263. /**
  89264. * Enum defining the type of animations supported by InputBlock
  89265. */
  89266. export enum AnimatedInputBlockTypes {
  89267. /** No animation */
  89268. None = 0,
  89269. /** Time based animation. Will only work for floats */
  89270. Time = 1
  89271. }
  89272. }
  89273. declare module BABYLON {
  89274. /**
  89275. * Interface describing all the common properties and methods a shadow light needs to implement.
  89276. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89277. * as well as binding the different shadow properties to the effects.
  89278. */
  89279. export interface IShadowLight extends Light {
  89280. /**
  89281. * The light id in the scene (used in scene.findLighById for instance)
  89282. */
  89283. id: string;
  89284. /**
  89285. * The position the shdow will be casted from.
  89286. */
  89287. position: Vector3;
  89288. /**
  89289. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89290. */
  89291. direction: Vector3;
  89292. /**
  89293. * The transformed position. Position of the light in world space taking parenting in account.
  89294. */
  89295. transformedPosition: Vector3;
  89296. /**
  89297. * The transformed direction. Direction of the light in world space taking parenting in account.
  89298. */
  89299. transformedDirection: Vector3;
  89300. /**
  89301. * The friendly name of the light in the scene.
  89302. */
  89303. name: string;
  89304. /**
  89305. * Defines the shadow projection clipping minimum z value.
  89306. */
  89307. shadowMinZ: number;
  89308. /**
  89309. * Defines the shadow projection clipping maximum z value.
  89310. */
  89311. shadowMaxZ: number;
  89312. /**
  89313. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89314. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89315. */
  89316. computeTransformedInformation(): boolean;
  89317. /**
  89318. * Gets the scene the light belongs to.
  89319. * @returns The scene
  89320. */
  89321. getScene(): Scene;
  89322. /**
  89323. * Callback defining a custom Projection Matrix Builder.
  89324. * This can be used to override the default projection matrix computation.
  89325. */
  89326. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89327. /**
  89328. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89329. * @param matrix The materix to updated with the projection information
  89330. * @param viewMatrix The transform matrix of the light
  89331. * @param renderList The list of mesh to render in the map
  89332. * @returns The current light
  89333. */
  89334. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89335. /**
  89336. * Gets the current depth scale used in ESM.
  89337. * @returns The scale
  89338. */
  89339. getDepthScale(): number;
  89340. /**
  89341. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89342. * @returns true if a cube texture needs to be use
  89343. */
  89344. needCube(): boolean;
  89345. /**
  89346. * Detects if the projection matrix requires to be recomputed this frame.
  89347. * @returns true if it requires to be recomputed otherwise, false.
  89348. */
  89349. needProjectionMatrixCompute(): boolean;
  89350. /**
  89351. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89352. */
  89353. forceProjectionMatrixCompute(): void;
  89354. /**
  89355. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89356. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89357. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89358. */
  89359. getShadowDirection(faceIndex?: number): Vector3;
  89360. /**
  89361. * Gets the minZ used for shadow according to both the scene and the light.
  89362. * @param activeCamera The camera we are returning the min for
  89363. * @returns the depth min z
  89364. */
  89365. getDepthMinZ(activeCamera: Camera): number;
  89366. /**
  89367. * Gets the maxZ used for shadow according to both the scene and the light.
  89368. * @param activeCamera The camera we are returning the max for
  89369. * @returns the depth max z
  89370. */
  89371. getDepthMaxZ(activeCamera: Camera): number;
  89372. }
  89373. /**
  89374. * Base implementation IShadowLight
  89375. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89376. */
  89377. export abstract class ShadowLight extends Light implements IShadowLight {
  89378. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89379. protected _position: Vector3;
  89380. protected _setPosition(value: Vector3): void;
  89381. /**
  89382. * Sets the position the shadow will be casted from. Also use as the light position for both
  89383. * point and spot lights.
  89384. */
  89385. get position(): Vector3;
  89386. /**
  89387. * Sets the position the shadow will be casted from. Also use as the light position for both
  89388. * point and spot lights.
  89389. */
  89390. set position(value: Vector3);
  89391. protected _direction: Vector3;
  89392. protected _setDirection(value: Vector3): void;
  89393. /**
  89394. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89395. * Also use as the light direction on spot and directional lights.
  89396. */
  89397. get direction(): Vector3;
  89398. /**
  89399. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89400. * Also use as the light direction on spot and directional lights.
  89401. */
  89402. set direction(value: Vector3);
  89403. protected _shadowMinZ: number;
  89404. /**
  89405. * Gets the shadow projection clipping minimum z value.
  89406. */
  89407. get shadowMinZ(): number;
  89408. /**
  89409. * Sets the shadow projection clipping minimum z value.
  89410. */
  89411. set shadowMinZ(value: number);
  89412. protected _shadowMaxZ: number;
  89413. /**
  89414. * Sets the shadow projection clipping maximum z value.
  89415. */
  89416. get shadowMaxZ(): number;
  89417. /**
  89418. * Gets the shadow projection clipping maximum z value.
  89419. */
  89420. set shadowMaxZ(value: number);
  89421. /**
  89422. * Callback defining a custom Projection Matrix Builder.
  89423. * This can be used to override the default projection matrix computation.
  89424. */
  89425. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89426. /**
  89427. * The transformed position. Position of the light in world space taking parenting in account.
  89428. */
  89429. transformedPosition: Vector3;
  89430. /**
  89431. * The transformed direction. Direction of the light in world space taking parenting in account.
  89432. */
  89433. transformedDirection: Vector3;
  89434. private _needProjectionMatrixCompute;
  89435. /**
  89436. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89437. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89438. */
  89439. computeTransformedInformation(): boolean;
  89440. /**
  89441. * Return the depth scale used for the shadow map.
  89442. * @returns the depth scale.
  89443. */
  89444. getDepthScale(): number;
  89445. /**
  89446. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89447. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89448. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89449. */
  89450. getShadowDirection(faceIndex?: number): Vector3;
  89451. /**
  89452. * Returns the ShadowLight absolute position in the World.
  89453. * @returns the position vector in world space
  89454. */
  89455. getAbsolutePosition(): Vector3;
  89456. /**
  89457. * Sets the ShadowLight direction toward the passed target.
  89458. * @param target The point to target in local space
  89459. * @returns the updated ShadowLight direction
  89460. */
  89461. setDirectionToTarget(target: Vector3): Vector3;
  89462. /**
  89463. * Returns the light rotation in euler definition.
  89464. * @returns the x y z rotation in local space.
  89465. */
  89466. getRotation(): Vector3;
  89467. /**
  89468. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89469. * @returns true if a cube texture needs to be use
  89470. */
  89471. needCube(): boolean;
  89472. /**
  89473. * Detects if the projection matrix requires to be recomputed this frame.
  89474. * @returns true if it requires to be recomputed otherwise, false.
  89475. */
  89476. needProjectionMatrixCompute(): boolean;
  89477. /**
  89478. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89479. */
  89480. forceProjectionMatrixCompute(): void;
  89481. /** @hidden */
  89482. _initCache(): void;
  89483. /** @hidden */
  89484. _isSynchronized(): boolean;
  89485. /**
  89486. * Computes the world matrix of the node
  89487. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89488. * @returns the world matrix
  89489. */
  89490. computeWorldMatrix(force?: boolean): Matrix;
  89491. /**
  89492. * Gets the minZ used for shadow according to both the scene and the light.
  89493. * @param activeCamera The camera we are returning the min for
  89494. * @returns the depth min z
  89495. */
  89496. getDepthMinZ(activeCamera: Camera): number;
  89497. /**
  89498. * Gets the maxZ used for shadow according to both the scene and the light.
  89499. * @param activeCamera The camera we are returning the max for
  89500. * @returns the depth max z
  89501. */
  89502. getDepthMaxZ(activeCamera: Camera): number;
  89503. /**
  89504. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89505. * @param matrix The materix to updated with the projection information
  89506. * @param viewMatrix The transform matrix of the light
  89507. * @param renderList The list of mesh to render in the map
  89508. * @returns The current light
  89509. */
  89510. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89511. }
  89512. }
  89513. declare module BABYLON {
  89514. /** @hidden */
  89515. export var packingFunctions: {
  89516. name: string;
  89517. shader: string;
  89518. };
  89519. }
  89520. declare module BABYLON {
  89521. /** @hidden */
  89522. export var bayerDitherFunctions: {
  89523. name: string;
  89524. shader: string;
  89525. };
  89526. }
  89527. declare module BABYLON {
  89528. /** @hidden */
  89529. export var shadowMapFragmentDeclaration: {
  89530. name: string;
  89531. shader: string;
  89532. };
  89533. }
  89534. declare module BABYLON {
  89535. /** @hidden */
  89536. export var clipPlaneFragmentDeclaration: {
  89537. name: string;
  89538. shader: string;
  89539. };
  89540. }
  89541. declare module BABYLON {
  89542. /** @hidden */
  89543. export var clipPlaneFragment: {
  89544. name: string;
  89545. shader: string;
  89546. };
  89547. }
  89548. declare module BABYLON {
  89549. /** @hidden */
  89550. export var shadowMapFragment: {
  89551. name: string;
  89552. shader: string;
  89553. };
  89554. }
  89555. declare module BABYLON {
  89556. /** @hidden */
  89557. export var shadowMapPixelShader: {
  89558. name: string;
  89559. shader: string;
  89560. };
  89561. }
  89562. declare module BABYLON {
  89563. /** @hidden */
  89564. export var bonesDeclaration: {
  89565. name: string;
  89566. shader: string;
  89567. };
  89568. }
  89569. declare module BABYLON {
  89570. /** @hidden */
  89571. export var morphTargetsVertexGlobalDeclaration: {
  89572. name: string;
  89573. shader: string;
  89574. };
  89575. }
  89576. declare module BABYLON {
  89577. /** @hidden */
  89578. export var morphTargetsVertexDeclaration: {
  89579. name: string;
  89580. shader: string;
  89581. };
  89582. }
  89583. declare module BABYLON {
  89584. /** @hidden */
  89585. export var instancesDeclaration: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON {
  89591. /** @hidden */
  89592. export var helperFunctions: {
  89593. name: string;
  89594. shader: string;
  89595. };
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var shadowMapVertexDeclaration: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /** @hidden */
  89606. export var clipPlaneVertexDeclaration: {
  89607. name: string;
  89608. shader: string;
  89609. };
  89610. }
  89611. declare module BABYLON {
  89612. /** @hidden */
  89613. export var morphTargetsVertex: {
  89614. name: string;
  89615. shader: string;
  89616. };
  89617. }
  89618. declare module BABYLON {
  89619. /** @hidden */
  89620. export var instancesVertex: {
  89621. name: string;
  89622. shader: string;
  89623. };
  89624. }
  89625. declare module BABYLON {
  89626. /** @hidden */
  89627. export var bonesVertex: {
  89628. name: string;
  89629. shader: string;
  89630. };
  89631. }
  89632. declare module BABYLON {
  89633. /** @hidden */
  89634. export var shadowMapVertexNormalBias: {
  89635. name: string;
  89636. shader: string;
  89637. };
  89638. }
  89639. declare module BABYLON {
  89640. /** @hidden */
  89641. export var shadowMapVertexMetric: {
  89642. name: string;
  89643. shader: string;
  89644. };
  89645. }
  89646. declare module BABYLON {
  89647. /** @hidden */
  89648. export var clipPlaneVertex: {
  89649. name: string;
  89650. shader: string;
  89651. };
  89652. }
  89653. declare module BABYLON {
  89654. /** @hidden */
  89655. export var shadowMapVertexShader: {
  89656. name: string;
  89657. shader: string;
  89658. };
  89659. }
  89660. declare module BABYLON {
  89661. /** @hidden */
  89662. export var depthBoxBlurPixelShader: {
  89663. name: string;
  89664. shader: string;
  89665. };
  89666. }
  89667. declare module BABYLON {
  89668. /** @hidden */
  89669. export var shadowMapFragmentSoftTransparentShadow: {
  89670. name: string;
  89671. shader: string;
  89672. };
  89673. }
  89674. declare module BABYLON {
  89675. /**
  89676. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89677. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89678. */
  89679. export class EffectFallbacks implements IEffectFallbacks {
  89680. private _defines;
  89681. private _currentRank;
  89682. private _maxRank;
  89683. private _mesh;
  89684. /**
  89685. * Removes the fallback from the bound mesh.
  89686. */
  89687. unBindMesh(): void;
  89688. /**
  89689. * Adds a fallback on the specified property.
  89690. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89691. * @param define The name of the define in the shader
  89692. */
  89693. addFallback(rank: number, define: string): void;
  89694. /**
  89695. * Sets the mesh to use CPU skinning when needing to fallback.
  89696. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89697. * @param mesh The mesh to use the fallbacks.
  89698. */
  89699. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89700. /**
  89701. * Checks to see if more fallbacks are still availible.
  89702. */
  89703. get hasMoreFallbacks(): boolean;
  89704. /**
  89705. * Removes the defines that should be removed when falling back.
  89706. * @param currentDefines defines the current define statements for the shader.
  89707. * @param effect defines the current effect we try to compile
  89708. * @returns The resulting defines with defines of the current rank removed.
  89709. */
  89710. reduce(currentDefines: string, effect: Effect): string;
  89711. }
  89712. }
  89713. declare module BABYLON {
  89714. /**
  89715. * Interface used to define Action
  89716. */
  89717. export interface IAction {
  89718. /**
  89719. * Trigger for the action
  89720. */
  89721. trigger: number;
  89722. /** Options of the trigger */
  89723. triggerOptions: any;
  89724. /**
  89725. * Gets the trigger parameters
  89726. * @returns the trigger parameters
  89727. */
  89728. getTriggerParameter(): any;
  89729. /**
  89730. * Internal only - executes current action event
  89731. * @hidden
  89732. */
  89733. _executeCurrent(evt?: ActionEvent): void;
  89734. /**
  89735. * Serialize placeholder for child classes
  89736. * @param parent of child
  89737. * @returns the serialized object
  89738. */
  89739. serialize(parent: any): any;
  89740. /**
  89741. * Internal only
  89742. * @hidden
  89743. */
  89744. _prepare(): void;
  89745. /**
  89746. * Internal only - manager for action
  89747. * @hidden
  89748. */
  89749. _actionManager: Nullable<AbstractActionManager>;
  89750. /**
  89751. * Adds action to chain of actions, may be a DoNothingAction
  89752. * @param action defines the next action to execute
  89753. * @returns The action passed in
  89754. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89755. */
  89756. then(action: IAction): IAction;
  89757. }
  89758. /**
  89759. * The action to be carried out following a trigger
  89760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89761. */
  89762. export class Action implements IAction {
  89763. /** the trigger, with or without parameters, for the action */
  89764. triggerOptions: any;
  89765. /**
  89766. * Trigger for the action
  89767. */
  89768. trigger: number;
  89769. /**
  89770. * Internal only - manager for action
  89771. * @hidden
  89772. */
  89773. _actionManager: ActionManager;
  89774. private _nextActiveAction;
  89775. private _child;
  89776. private _condition?;
  89777. private _triggerParameter;
  89778. /**
  89779. * An event triggered prior to action being executed.
  89780. */
  89781. onBeforeExecuteObservable: Observable<Action>;
  89782. /**
  89783. * Creates a new Action
  89784. * @param triggerOptions the trigger, with or without parameters, for the action
  89785. * @param condition an optional determinant of action
  89786. */
  89787. constructor(
  89788. /** the trigger, with or without parameters, for the action */
  89789. triggerOptions: any, condition?: Condition);
  89790. /**
  89791. * Internal only
  89792. * @hidden
  89793. */
  89794. _prepare(): void;
  89795. /**
  89796. * Gets the trigger parameters
  89797. * @returns the trigger parameters
  89798. */
  89799. getTriggerParameter(): any;
  89800. /**
  89801. * Internal only - executes current action event
  89802. * @hidden
  89803. */
  89804. _executeCurrent(evt?: ActionEvent): void;
  89805. /**
  89806. * Execute placeholder for child classes
  89807. * @param evt optional action event
  89808. */
  89809. execute(evt?: ActionEvent): void;
  89810. /**
  89811. * Skips to next active action
  89812. */
  89813. skipToNextActiveAction(): void;
  89814. /**
  89815. * Adds action to chain of actions, may be a DoNothingAction
  89816. * @param action defines the next action to execute
  89817. * @returns The action passed in
  89818. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89819. */
  89820. then(action: Action): Action;
  89821. /**
  89822. * Internal only
  89823. * @hidden
  89824. */
  89825. _getProperty(propertyPath: string): string;
  89826. /**
  89827. * Internal only
  89828. * @hidden
  89829. */
  89830. _getEffectiveTarget(target: any, propertyPath: string): any;
  89831. /**
  89832. * Serialize placeholder for child classes
  89833. * @param parent of child
  89834. * @returns the serialized object
  89835. */
  89836. serialize(parent: any): any;
  89837. /**
  89838. * Internal only called by serialize
  89839. * @hidden
  89840. */
  89841. protected _serialize(serializedAction: any, parent?: any): any;
  89842. /**
  89843. * Internal only
  89844. * @hidden
  89845. */
  89846. static _SerializeValueAsString: (value: any) => string;
  89847. /**
  89848. * Internal only
  89849. * @hidden
  89850. */
  89851. static _GetTargetProperty: (target: Scene | Node) => {
  89852. name: string;
  89853. targetType: string;
  89854. value: string;
  89855. };
  89856. }
  89857. }
  89858. declare module BABYLON {
  89859. /**
  89860. * A Condition applied to an Action
  89861. */
  89862. export class Condition {
  89863. /**
  89864. * Internal only - manager for action
  89865. * @hidden
  89866. */
  89867. _actionManager: ActionManager;
  89868. /**
  89869. * Internal only
  89870. * @hidden
  89871. */
  89872. _evaluationId: number;
  89873. /**
  89874. * Internal only
  89875. * @hidden
  89876. */
  89877. _currentResult: boolean;
  89878. /**
  89879. * Creates a new Condition
  89880. * @param actionManager the manager of the action the condition is applied to
  89881. */
  89882. constructor(actionManager: ActionManager);
  89883. /**
  89884. * Check if the current condition is valid
  89885. * @returns a boolean
  89886. */
  89887. isValid(): boolean;
  89888. /**
  89889. * Internal only
  89890. * @hidden
  89891. */
  89892. _getProperty(propertyPath: string): string;
  89893. /**
  89894. * Internal only
  89895. * @hidden
  89896. */
  89897. _getEffectiveTarget(target: any, propertyPath: string): any;
  89898. /**
  89899. * Serialize placeholder for child classes
  89900. * @returns the serialized object
  89901. */
  89902. serialize(): any;
  89903. /**
  89904. * Internal only
  89905. * @hidden
  89906. */
  89907. protected _serialize(serializedCondition: any): any;
  89908. }
  89909. /**
  89910. * Defines specific conditional operators as extensions of Condition
  89911. */
  89912. export class ValueCondition extends Condition {
  89913. /** path to specify the property of the target the conditional operator uses */
  89914. propertyPath: string;
  89915. /** the value compared by the conditional operator against the current value of the property */
  89916. value: any;
  89917. /** the conditional operator, default ValueCondition.IsEqual */
  89918. operator: number;
  89919. /**
  89920. * Internal only
  89921. * @hidden
  89922. */
  89923. private static _IsEqual;
  89924. /**
  89925. * Internal only
  89926. * @hidden
  89927. */
  89928. private static _IsDifferent;
  89929. /**
  89930. * Internal only
  89931. * @hidden
  89932. */
  89933. private static _IsGreater;
  89934. /**
  89935. * Internal only
  89936. * @hidden
  89937. */
  89938. private static _IsLesser;
  89939. /**
  89940. * returns the number for IsEqual
  89941. */
  89942. static get IsEqual(): number;
  89943. /**
  89944. * Returns the number for IsDifferent
  89945. */
  89946. static get IsDifferent(): number;
  89947. /**
  89948. * Returns the number for IsGreater
  89949. */
  89950. static get IsGreater(): number;
  89951. /**
  89952. * Returns the number for IsLesser
  89953. */
  89954. static get IsLesser(): number;
  89955. /**
  89956. * Internal only The action manager for the condition
  89957. * @hidden
  89958. */
  89959. _actionManager: ActionManager;
  89960. /**
  89961. * Internal only
  89962. * @hidden
  89963. */
  89964. private _target;
  89965. /**
  89966. * Internal only
  89967. * @hidden
  89968. */
  89969. private _effectiveTarget;
  89970. /**
  89971. * Internal only
  89972. * @hidden
  89973. */
  89974. private _property;
  89975. /**
  89976. * Creates a new ValueCondition
  89977. * @param actionManager manager for the action the condition applies to
  89978. * @param target for the action
  89979. * @param propertyPath path to specify the property of the target the conditional operator uses
  89980. * @param value the value compared by the conditional operator against the current value of the property
  89981. * @param operator the conditional operator, default ValueCondition.IsEqual
  89982. */
  89983. constructor(actionManager: ActionManager, target: any,
  89984. /** path to specify the property of the target the conditional operator uses */
  89985. propertyPath: string,
  89986. /** the value compared by the conditional operator against the current value of the property */
  89987. value: any,
  89988. /** the conditional operator, default ValueCondition.IsEqual */
  89989. operator?: number);
  89990. /**
  89991. * Compares the given value with the property value for the specified conditional operator
  89992. * @returns the result of the comparison
  89993. */
  89994. isValid(): boolean;
  89995. /**
  89996. * Serialize the ValueCondition into a JSON compatible object
  89997. * @returns serialization object
  89998. */
  89999. serialize(): any;
  90000. /**
  90001. * Gets the name of the conditional operator for the ValueCondition
  90002. * @param operator the conditional operator
  90003. * @returns the name
  90004. */
  90005. static GetOperatorName(operator: number): string;
  90006. }
  90007. /**
  90008. * Defines a predicate condition as an extension of Condition
  90009. */
  90010. export class PredicateCondition extends Condition {
  90011. /** defines the predicate function used to validate the condition */
  90012. predicate: () => boolean;
  90013. /**
  90014. * Internal only - manager for action
  90015. * @hidden
  90016. */
  90017. _actionManager: ActionManager;
  90018. /**
  90019. * Creates a new PredicateCondition
  90020. * @param actionManager manager for the action the condition applies to
  90021. * @param predicate defines the predicate function used to validate the condition
  90022. */
  90023. constructor(actionManager: ActionManager,
  90024. /** defines the predicate function used to validate the condition */
  90025. predicate: () => boolean);
  90026. /**
  90027. * @returns the validity of the predicate condition
  90028. */
  90029. isValid(): boolean;
  90030. }
  90031. /**
  90032. * Defines a state condition as an extension of Condition
  90033. */
  90034. export class StateCondition extends Condition {
  90035. /** Value to compare with target state */
  90036. value: string;
  90037. /**
  90038. * Internal only - manager for action
  90039. * @hidden
  90040. */
  90041. _actionManager: ActionManager;
  90042. /**
  90043. * Internal only
  90044. * @hidden
  90045. */
  90046. private _target;
  90047. /**
  90048. * Creates a new StateCondition
  90049. * @param actionManager manager for the action the condition applies to
  90050. * @param target of the condition
  90051. * @param value to compare with target state
  90052. */
  90053. constructor(actionManager: ActionManager, target: any,
  90054. /** Value to compare with target state */
  90055. value: string);
  90056. /**
  90057. * Gets a boolean indicating if the current condition is met
  90058. * @returns the validity of the state
  90059. */
  90060. isValid(): boolean;
  90061. /**
  90062. * Serialize the StateCondition into a JSON compatible object
  90063. * @returns serialization object
  90064. */
  90065. serialize(): any;
  90066. }
  90067. }
  90068. declare module BABYLON {
  90069. /**
  90070. * This defines an action responsible to toggle a boolean once triggered.
  90071. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90072. */
  90073. export class SwitchBooleanAction extends Action {
  90074. /**
  90075. * The path to the boolean property in the target object
  90076. */
  90077. propertyPath: string;
  90078. private _target;
  90079. private _effectiveTarget;
  90080. private _property;
  90081. /**
  90082. * Instantiate the action
  90083. * @param triggerOptions defines the trigger options
  90084. * @param target defines the object containing the boolean
  90085. * @param propertyPath defines the path to the boolean property in the target object
  90086. * @param condition defines the trigger related conditions
  90087. */
  90088. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90089. /** @hidden */
  90090. _prepare(): void;
  90091. /**
  90092. * Execute the action toggle the boolean value.
  90093. */
  90094. execute(): void;
  90095. /**
  90096. * Serializes the actions and its related information.
  90097. * @param parent defines the object to serialize in
  90098. * @returns the serialized object
  90099. */
  90100. serialize(parent: any): any;
  90101. }
  90102. /**
  90103. * This defines an action responsible to set a the state field of the target
  90104. * to a desired value once triggered.
  90105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90106. */
  90107. export class SetStateAction extends Action {
  90108. /**
  90109. * The value to store in the state field.
  90110. */
  90111. value: string;
  90112. private _target;
  90113. /**
  90114. * Instantiate the action
  90115. * @param triggerOptions defines the trigger options
  90116. * @param target defines the object containing the state property
  90117. * @param value defines the value to store in the state field
  90118. * @param condition defines the trigger related conditions
  90119. */
  90120. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90121. /**
  90122. * Execute the action and store the value on the target state property.
  90123. */
  90124. execute(): void;
  90125. /**
  90126. * Serializes the actions and its related information.
  90127. * @param parent defines the object to serialize in
  90128. * @returns the serialized object
  90129. */
  90130. serialize(parent: any): any;
  90131. }
  90132. /**
  90133. * This defines an action responsible to set a property of the target
  90134. * to a desired value once triggered.
  90135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90136. */
  90137. export class SetValueAction extends Action {
  90138. /**
  90139. * The path of the property to set in the target.
  90140. */
  90141. propertyPath: string;
  90142. /**
  90143. * The value to set in the property
  90144. */
  90145. value: any;
  90146. private _target;
  90147. private _effectiveTarget;
  90148. private _property;
  90149. /**
  90150. * Instantiate the action
  90151. * @param triggerOptions defines the trigger options
  90152. * @param target defines the object containing the property
  90153. * @param propertyPath defines the path of the property to set in the target
  90154. * @param value defines the value to set in the property
  90155. * @param condition defines the trigger related conditions
  90156. */
  90157. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90158. /** @hidden */
  90159. _prepare(): void;
  90160. /**
  90161. * Execute the action and set the targetted property to the desired value.
  90162. */
  90163. execute(): void;
  90164. /**
  90165. * Serializes the actions and its related information.
  90166. * @param parent defines the object to serialize in
  90167. * @returns the serialized object
  90168. */
  90169. serialize(parent: any): any;
  90170. }
  90171. /**
  90172. * This defines an action responsible to increment the target value
  90173. * to a desired value once triggered.
  90174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90175. */
  90176. export class IncrementValueAction extends Action {
  90177. /**
  90178. * The path of the property to increment in the target.
  90179. */
  90180. propertyPath: string;
  90181. /**
  90182. * The value we should increment the property by.
  90183. */
  90184. value: any;
  90185. private _target;
  90186. private _effectiveTarget;
  90187. private _property;
  90188. /**
  90189. * Instantiate the action
  90190. * @param triggerOptions defines the trigger options
  90191. * @param target defines the object containing the property
  90192. * @param propertyPath defines the path of the property to increment in the target
  90193. * @param value defines the value value we should increment the property by
  90194. * @param condition defines the trigger related conditions
  90195. */
  90196. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90197. /** @hidden */
  90198. _prepare(): void;
  90199. /**
  90200. * Execute the action and increment the target of the value amount.
  90201. */
  90202. execute(): void;
  90203. /**
  90204. * Serializes the actions and its related information.
  90205. * @param parent defines the object to serialize in
  90206. * @returns the serialized object
  90207. */
  90208. serialize(parent: any): any;
  90209. }
  90210. /**
  90211. * This defines an action responsible to start an animation once triggered.
  90212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90213. */
  90214. export class PlayAnimationAction extends Action {
  90215. /**
  90216. * Where the animation should start (animation frame)
  90217. */
  90218. from: number;
  90219. /**
  90220. * Where the animation should stop (animation frame)
  90221. */
  90222. to: number;
  90223. /**
  90224. * Define if the animation should loop or stop after the first play.
  90225. */
  90226. loop?: boolean;
  90227. private _target;
  90228. /**
  90229. * Instantiate the action
  90230. * @param triggerOptions defines the trigger options
  90231. * @param target defines the target animation or animation name
  90232. * @param from defines from where the animation should start (animation frame)
  90233. * @param end defines where the animation should stop (animation frame)
  90234. * @param loop defines if the animation should loop or stop after the first play
  90235. * @param condition defines the trigger related conditions
  90236. */
  90237. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90238. /** @hidden */
  90239. _prepare(): void;
  90240. /**
  90241. * Execute the action and play the animation.
  90242. */
  90243. execute(): void;
  90244. /**
  90245. * Serializes the actions and its related information.
  90246. * @param parent defines the object to serialize in
  90247. * @returns the serialized object
  90248. */
  90249. serialize(parent: any): any;
  90250. }
  90251. /**
  90252. * This defines an action responsible to stop an animation once triggered.
  90253. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90254. */
  90255. export class StopAnimationAction extends Action {
  90256. private _target;
  90257. /**
  90258. * Instantiate the action
  90259. * @param triggerOptions defines the trigger options
  90260. * @param target defines the target animation or animation name
  90261. * @param condition defines the trigger related conditions
  90262. */
  90263. constructor(triggerOptions: any, target: any, condition?: Condition);
  90264. /** @hidden */
  90265. _prepare(): void;
  90266. /**
  90267. * Execute the action and stop the animation.
  90268. */
  90269. execute(): void;
  90270. /**
  90271. * Serializes the actions and its related information.
  90272. * @param parent defines the object to serialize in
  90273. * @returns the serialized object
  90274. */
  90275. serialize(parent: any): any;
  90276. }
  90277. /**
  90278. * This defines an action responsible that does nothing once triggered.
  90279. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90280. */
  90281. export class DoNothingAction extends Action {
  90282. /**
  90283. * Instantiate the action
  90284. * @param triggerOptions defines the trigger options
  90285. * @param condition defines the trigger related conditions
  90286. */
  90287. constructor(triggerOptions?: any, condition?: Condition);
  90288. /**
  90289. * Execute the action and do nothing.
  90290. */
  90291. execute(): void;
  90292. /**
  90293. * Serializes the actions and its related information.
  90294. * @param parent defines the object to serialize in
  90295. * @returns the serialized object
  90296. */
  90297. serialize(parent: any): any;
  90298. }
  90299. /**
  90300. * This defines an action responsible to trigger several actions once triggered.
  90301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90302. */
  90303. export class CombineAction extends Action {
  90304. /**
  90305. * The list of aggregated animations to run.
  90306. */
  90307. children: Action[];
  90308. /**
  90309. * Instantiate the action
  90310. * @param triggerOptions defines the trigger options
  90311. * @param children defines the list of aggregated animations to run
  90312. * @param condition defines the trigger related conditions
  90313. */
  90314. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90315. /** @hidden */
  90316. _prepare(): void;
  90317. /**
  90318. * Execute the action and executes all the aggregated actions.
  90319. */
  90320. execute(evt: ActionEvent): void;
  90321. /**
  90322. * Serializes the actions and its related information.
  90323. * @param parent defines the object to serialize in
  90324. * @returns the serialized object
  90325. */
  90326. serialize(parent: any): any;
  90327. }
  90328. /**
  90329. * This defines an action responsible to run code (external event) once triggered.
  90330. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90331. */
  90332. export class ExecuteCodeAction extends Action {
  90333. /**
  90334. * The callback function to run.
  90335. */
  90336. func: (evt: ActionEvent) => void;
  90337. /**
  90338. * Instantiate the action
  90339. * @param triggerOptions defines the trigger options
  90340. * @param func defines the callback function to run
  90341. * @param condition defines the trigger related conditions
  90342. */
  90343. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90344. /**
  90345. * Execute the action and run the attached code.
  90346. */
  90347. execute(evt: ActionEvent): void;
  90348. }
  90349. /**
  90350. * This defines an action responsible to set the parent property of the target once triggered.
  90351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90352. */
  90353. export class SetParentAction extends Action {
  90354. private _parent;
  90355. private _target;
  90356. /**
  90357. * Instantiate the action
  90358. * @param triggerOptions defines the trigger options
  90359. * @param target defines the target containing the parent property
  90360. * @param parent defines from where the animation should start (animation frame)
  90361. * @param condition defines the trigger related conditions
  90362. */
  90363. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90364. /** @hidden */
  90365. _prepare(): void;
  90366. /**
  90367. * Execute the action and set the parent property.
  90368. */
  90369. execute(): void;
  90370. /**
  90371. * Serializes the actions and its related information.
  90372. * @param parent defines the object to serialize in
  90373. * @returns the serialized object
  90374. */
  90375. serialize(parent: any): any;
  90376. }
  90377. }
  90378. declare module BABYLON {
  90379. /**
  90380. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90381. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90382. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90383. */
  90384. export class ActionManager extends AbstractActionManager {
  90385. /**
  90386. * Nothing
  90387. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90388. */
  90389. static readonly NothingTrigger: number;
  90390. /**
  90391. * On pick
  90392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90393. */
  90394. static readonly OnPickTrigger: number;
  90395. /**
  90396. * On left pick
  90397. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90398. */
  90399. static readonly OnLeftPickTrigger: number;
  90400. /**
  90401. * On right pick
  90402. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90403. */
  90404. static readonly OnRightPickTrigger: number;
  90405. /**
  90406. * On center pick
  90407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90408. */
  90409. static readonly OnCenterPickTrigger: number;
  90410. /**
  90411. * On pick down
  90412. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90413. */
  90414. static readonly OnPickDownTrigger: number;
  90415. /**
  90416. * On double pick
  90417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90418. */
  90419. static readonly OnDoublePickTrigger: number;
  90420. /**
  90421. * On pick up
  90422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90423. */
  90424. static readonly OnPickUpTrigger: number;
  90425. /**
  90426. * On pick out.
  90427. * This trigger will only be raised if you also declared a OnPickDown
  90428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90429. */
  90430. static readonly OnPickOutTrigger: number;
  90431. /**
  90432. * On long press
  90433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90434. */
  90435. static readonly OnLongPressTrigger: number;
  90436. /**
  90437. * On pointer over
  90438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90439. */
  90440. static readonly OnPointerOverTrigger: number;
  90441. /**
  90442. * On pointer out
  90443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90444. */
  90445. static readonly OnPointerOutTrigger: number;
  90446. /**
  90447. * On every frame
  90448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90449. */
  90450. static readonly OnEveryFrameTrigger: number;
  90451. /**
  90452. * On intersection enter
  90453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90454. */
  90455. static readonly OnIntersectionEnterTrigger: number;
  90456. /**
  90457. * On intersection exit
  90458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90459. */
  90460. static readonly OnIntersectionExitTrigger: number;
  90461. /**
  90462. * On key down
  90463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90464. */
  90465. static readonly OnKeyDownTrigger: number;
  90466. /**
  90467. * On key up
  90468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90469. */
  90470. static readonly OnKeyUpTrigger: number;
  90471. private _scene;
  90472. /**
  90473. * Creates a new action manager
  90474. * @param scene defines the hosting scene
  90475. */
  90476. constructor(scene: Scene);
  90477. /**
  90478. * Releases all associated resources
  90479. */
  90480. dispose(): void;
  90481. /**
  90482. * Gets hosting scene
  90483. * @returns the hosting scene
  90484. */
  90485. getScene(): Scene;
  90486. /**
  90487. * Does this action manager handles actions of any of the given triggers
  90488. * @param triggers defines the triggers to be tested
  90489. * @return a boolean indicating whether one (or more) of the triggers is handled
  90490. */
  90491. hasSpecificTriggers(triggers: number[]): boolean;
  90492. /**
  90493. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90494. * speed.
  90495. * @param triggerA defines the trigger to be tested
  90496. * @param triggerB defines the trigger to be tested
  90497. * @return a boolean indicating whether one (or more) of the triggers is handled
  90498. */
  90499. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90500. /**
  90501. * Does this action manager handles actions of a given trigger
  90502. * @param trigger defines the trigger to be tested
  90503. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90504. * @return whether the trigger is handled
  90505. */
  90506. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90507. /**
  90508. * Does this action manager has pointer triggers
  90509. */
  90510. get hasPointerTriggers(): boolean;
  90511. /**
  90512. * Does this action manager has pick triggers
  90513. */
  90514. get hasPickTriggers(): boolean;
  90515. /**
  90516. * Registers an action to this action manager
  90517. * @param action defines the action to be registered
  90518. * @return the action amended (prepared) after registration
  90519. */
  90520. registerAction(action: IAction): Nullable<IAction>;
  90521. /**
  90522. * Unregisters an action to this action manager
  90523. * @param action defines the action to be unregistered
  90524. * @return a boolean indicating whether the action has been unregistered
  90525. */
  90526. unregisterAction(action: IAction): Boolean;
  90527. /**
  90528. * Process a specific trigger
  90529. * @param trigger defines the trigger to process
  90530. * @param evt defines the event details to be processed
  90531. */
  90532. processTrigger(trigger: number, evt?: IActionEvent): void;
  90533. /** @hidden */
  90534. _getEffectiveTarget(target: any, propertyPath: string): any;
  90535. /** @hidden */
  90536. _getProperty(propertyPath: string): string;
  90537. /**
  90538. * Serialize this manager to a JSON object
  90539. * @param name defines the property name to store this manager
  90540. * @returns a JSON representation of this manager
  90541. */
  90542. serialize(name: string): any;
  90543. /**
  90544. * Creates a new ActionManager from a JSON data
  90545. * @param parsedActions defines the JSON data to read from
  90546. * @param object defines the hosting mesh
  90547. * @param scene defines the hosting scene
  90548. */
  90549. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90550. /**
  90551. * Get a trigger name by index
  90552. * @param trigger defines the trigger index
  90553. * @returns a trigger name
  90554. */
  90555. static GetTriggerName(trigger: number): string;
  90556. }
  90557. }
  90558. declare module BABYLON {
  90559. /**
  90560. * Class used to represent a sprite
  90561. * @see https://doc.babylonjs.com/babylon101/sprites
  90562. */
  90563. export class Sprite implements IAnimatable {
  90564. /** defines the name */
  90565. name: string;
  90566. /** Gets or sets the current world position */
  90567. position: Vector3;
  90568. /** Gets or sets the main color */
  90569. color: Color4;
  90570. /** Gets or sets the width */
  90571. width: number;
  90572. /** Gets or sets the height */
  90573. height: number;
  90574. /** Gets or sets rotation angle */
  90575. angle: number;
  90576. /** Gets or sets the cell index in the sprite sheet */
  90577. cellIndex: number;
  90578. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90579. cellRef: string;
  90580. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90581. invertU: boolean;
  90582. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90583. invertV: boolean;
  90584. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90585. disposeWhenFinishedAnimating: boolean;
  90586. /** Gets the list of attached animations */
  90587. animations: Nullable<Array<Animation>>;
  90588. /** Gets or sets a boolean indicating if the sprite can be picked */
  90589. isPickable: boolean;
  90590. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90591. useAlphaForPicking: boolean;
  90592. /** @hidden */
  90593. _xOffset: number;
  90594. /** @hidden */
  90595. _yOffset: number;
  90596. /** @hidden */
  90597. _xSize: number;
  90598. /** @hidden */
  90599. _ySize: number;
  90600. /**
  90601. * Gets or sets the associated action manager
  90602. */
  90603. actionManager: Nullable<ActionManager>;
  90604. /**
  90605. * An event triggered when the control has been disposed
  90606. */
  90607. onDisposeObservable: Observable<Sprite>;
  90608. private _animationStarted;
  90609. private _loopAnimation;
  90610. private _fromIndex;
  90611. private _toIndex;
  90612. private _delay;
  90613. private _direction;
  90614. private _manager;
  90615. private _time;
  90616. private _onAnimationEnd;
  90617. /**
  90618. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90619. */
  90620. isVisible: boolean;
  90621. /**
  90622. * Gets or sets the sprite size
  90623. */
  90624. get size(): number;
  90625. set size(value: number);
  90626. /**
  90627. * Returns a boolean indicating if the animation is started
  90628. */
  90629. get animationStarted(): boolean;
  90630. /**
  90631. * Gets or sets the unique id of the sprite
  90632. */
  90633. uniqueId: number;
  90634. /**
  90635. * Gets the manager of this sprite
  90636. */
  90637. get manager(): ISpriteManager;
  90638. /**
  90639. * Creates a new Sprite
  90640. * @param name defines the name
  90641. * @param manager defines the manager
  90642. */
  90643. constructor(
  90644. /** defines the name */
  90645. name: string, manager: ISpriteManager);
  90646. /**
  90647. * Returns the string "Sprite"
  90648. * @returns "Sprite"
  90649. */
  90650. getClassName(): string;
  90651. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90652. get fromIndex(): number;
  90653. set fromIndex(value: number);
  90654. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90655. get toIndex(): number;
  90656. set toIndex(value: number);
  90657. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90658. get loopAnimation(): boolean;
  90659. set loopAnimation(value: boolean);
  90660. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90661. get delay(): number;
  90662. set delay(value: number);
  90663. /**
  90664. * Starts an animation
  90665. * @param from defines the initial key
  90666. * @param to defines the end key
  90667. * @param loop defines if the animation must loop
  90668. * @param delay defines the start delay (in ms)
  90669. * @param onAnimationEnd defines a callback to call when animation ends
  90670. */
  90671. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90672. /** Stops current animation (if any) */
  90673. stopAnimation(): void;
  90674. /** @hidden */
  90675. _animate(deltaTime: number): void;
  90676. /** Release associated resources */
  90677. dispose(): void;
  90678. /**
  90679. * Serializes the sprite to a JSON object
  90680. * @returns the JSON object
  90681. */
  90682. serialize(): any;
  90683. /**
  90684. * Parses a JSON object to create a new sprite
  90685. * @param parsedSprite The JSON object to parse
  90686. * @param manager defines the hosting manager
  90687. * @returns the new sprite
  90688. */
  90689. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90690. }
  90691. }
  90692. declare module BABYLON {
  90693. /**
  90694. * Information about the result of picking within a scene
  90695. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90696. */
  90697. export class PickingInfo {
  90698. /** @hidden */
  90699. _pickingUnavailable: boolean;
  90700. /**
  90701. * If the pick collided with an object
  90702. */
  90703. hit: boolean;
  90704. /**
  90705. * Distance away where the pick collided
  90706. */
  90707. distance: number;
  90708. /**
  90709. * The location of pick collision
  90710. */
  90711. pickedPoint: Nullable<Vector3>;
  90712. /**
  90713. * The mesh corresponding the the pick collision
  90714. */
  90715. pickedMesh: Nullable<AbstractMesh>;
  90716. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90717. bu: number;
  90718. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90719. bv: number;
  90720. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90721. faceId: number;
  90722. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90723. subMeshFaceId: number;
  90724. /** Id of the the submesh that was picked */
  90725. subMeshId: number;
  90726. /** If a sprite was picked, this will be the sprite the pick collided with */
  90727. pickedSprite: Nullable<Sprite>;
  90728. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90729. thinInstanceIndex: number;
  90730. /**
  90731. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90732. */
  90733. originMesh: Nullable<AbstractMesh>;
  90734. /**
  90735. * The ray that was used to perform the picking.
  90736. */
  90737. ray: Nullable<Ray>;
  90738. /**
  90739. * Gets the normal correspodning to the face the pick collided with
  90740. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90741. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90742. * @returns The normal correspodning to the face the pick collided with
  90743. */
  90744. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90745. /**
  90746. * Gets the texture coordinates of where the pick occured
  90747. * @returns the vector containing the coordnates of the texture
  90748. */
  90749. getTextureCoordinates(): Nullable<Vector2>;
  90750. }
  90751. }
  90752. declare module BABYLON {
  90753. /**
  90754. * Class representing a ray with position and direction
  90755. */
  90756. export class Ray {
  90757. /** origin point */
  90758. origin: Vector3;
  90759. /** direction */
  90760. direction: Vector3;
  90761. /** length of the ray */
  90762. length: number;
  90763. private static readonly _TmpVector3;
  90764. private _tmpRay;
  90765. /**
  90766. * Creates a new ray
  90767. * @param origin origin point
  90768. * @param direction direction
  90769. * @param length length of the ray
  90770. */
  90771. constructor(
  90772. /** origin point */
  90773. origin: Vector3,
  90774. /** direction */
  90775. direction: Vector3,
  90776. /** length of the ray */
  90777. length?: number);
  90778. /**
  90779. * Checks if the ray intersects a box
  90780. * This does not account for the ray lenght by design to improve perfs.
  90781. * @param minimum bound of the box
  90782. * @param maximum bound of the box
  90783. * @param intersectionTreshold extra extend to be added to the box in all direction
  90784. * @returns if the box was hit
  90785. */
  90786. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90787. /**
  90788. * Checks if the ray intersects a box
  90789. * This does not account for the ray lenght by design to improve perfs.
  90790. * @param box the bounding box to check
  90791. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90792. * @returns if the box was hit
  90793. */
  90794. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90795. /**
  90796. * If the ray hits a sphere
  90797. * @param sphere the bounding sphere to check
  90798. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90799. * @returns true if it hits the sphere
  90800. */
  90801. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90802. /**
  90803. * If the ray hits a triange
  90804. * @param vertex0 triangle vertex
  90805. * @param vertex1 triangle vertex
  90806. * @param vertex2 triangle vertex
  90807. * @returns intersection information if hit
  90808. */
  90809. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90810. /**
  90811. * Checks if ray intersects a plane
  90812. * @param plane the plane to check
  90813. * @returns the distance away it was hit
  90814. */
  90815. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90816. /**
  90817. * Calculate the intercept of a ray on a given axis
  90818. * @param axis to check 'x' | 'y' | 'z'
  90819. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90820. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90821. */
  90822. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90823. /**
  90824. * Checks if ray intersects a mesh
  90825. * @param mesh the mesh to check
  90826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90827. * @returns picking info of the intersecton
  90828. */
  90829. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90830. /**
  90831. * Checks if ray intersects a mesh
  90832. * @param meshes the meshes to check
  90833. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90834. * @param results array to store result in
  90835. * @returns Array of picking infos
  90836. */
  90837. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90838. private _comparePickingInfo;
  90839. private static smallnum;
  90840. private static rayl;
  90841. /**
  90842. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90843. * @param sega the first point of the segment to test the intersection against
  90844. * @param segb the second point of the segment to test the intersection against
  90845. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90846. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90847. */
  90848. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90849. /**
  90850. * Update the ray from viewport position
  90851. * @param x position
  90852. * @param y y position
  90853. * @param viewportWidth viewport width
  90854. * @param viewportHeight viewport height
  90855. * @param world world matrix
  90856. * @param view view matrix
  90857. * @param projection projection matrix
  90858. * @returns this ray updated
  90859. */
  90860. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90861. /**
  90862. * Creates a ray with origin and direction of 0,0,0
  90863. * @returns the new ray
  90864. */
  90865. static Zero(): Ray;
  90866. /**
  90867. * Creates a new ray from screen space and viewport
  90868. * @param x position
  90869. * @param y y position
  90870. * @param viewportWidth viewport width
  90871. * @param viewportHeight viewport height
  90872. * @param world world matrix
  90873. * @param view view matrix
  90874. * @param projection projection matrix
  90875. * @returns new ray
  90876. */
  90877. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90878. /**
  90879. * 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
  90880. * transformed to the given world matrix.
  90881. * @param origin The origin point
  90882. * @param end The end point
  90883. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90884. * @returns the new ray
  90885. */
  90886. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90887. /**
  90888. * Transforms a ray by a matrix
  90889. * @param ray ray to transform
  90890. * @param matrix matrix to apply
  90891. * @returns the resulting new ray
  90892. */
  90893. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90894. /**
  90895. * Transforms a ray by a matrix
  90896. * @param ray ray to transform
  90897. * @param matrix matrix to apply
  90898. * @param result ray to store result in
  90899. */
  90900. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90901. /**
  90902. * Unproject a ray from screen space to object space
  90903. * @param sourceX defines the screen space x coordinate to use
  90904. * @param sourceY defines the screen space y coordinate to use
  90905. * @param viewportWidth defines the current width of the viewport
  90906. * @param viewportHeight defines the current height of the viewport
  90907. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90908. * @param view defines the view matrix to use
  90909. * @param projection defines the projection matrix to use
  90910. */
  90911. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90912. }
  90913. /**
  90914. * Type used to define predicate used to select faces when a mesh intersection is detected
  90915. */
  90916. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90917. interface Scene {
  90918. /** @hidden */
  90919. _tempPickingRay: Nullable<Ray>;
  90920. /** @hidden */
  90921. _cachedRayForTransform: Ray;
  90922. /** @hidden */
  90923. _pickWithRayInverseMatrix: Matrix;
  90924. /** @hidden */
  90925. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90926. /** @hidden */
  90927. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90928. /** @hidden */
  90929. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90930. }
  90931. }
  90932. declare module BABYLON {
  90933. /**
  90934. * Groups all the scene component constants in one place to ease maintenance.
  90935. * @hidden
  90936. */
  90937. export class SceneComponentConstants {
  90938. static readonly NAME_EFFECTLAYER: string;
  90939. static readonly NAME_LAYER: string;
  90940. static readonly NAME_LENSFLARESYSTEM: string;
  90941. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90942. static readonly NAME_PARTICLESYSTEM: string;
  90943. static readonly NAME_GAMEPAD: string;
  90944. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90945. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90946. static readonly NAME_PREPASSRENDERER: string;
  90947. static readonly NAME_DEPTHRENDERER: string;
  90948. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90949. static readonly NAME_SPRITE: string;
  90950. static readonly NAME_SUBSURFACE: string;
  90951. static readonly NAME_OUTLINERENDERER: string;
  90952. static readonly NAME_PROCEDURALTEXTURE: string;
  90953. static readonly NAME_SHADOWGENERATOR: string;
  90954. static readonly NAME_OCTREE: string;
  90955. static readonly NAME_PHYSICSENGINE: string;
  90956. static readonly NAME_AUDIO: string;
  90957. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90958. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90959. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90960. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90961. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90962. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90963. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90964. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90965. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90966. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90967. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90968. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90969. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90970. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90971. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90972. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90973. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90974. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90975. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90976. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90977. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90978. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90979. static readonly STEP_AFTERRENDER_AUDIO: number;
  90980. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90981. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90982. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90983. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90984. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90985. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90986. static readonly STEP_POINTERMOVE_SPRITE: number;
  90987. static readonly STEP_POINTERDOWN_SPRITE: number;
  90988. static readonly STEP_POINTERUP_SPRITE: number;
  90989. }
  90990. /**
  90991. * This represents a scene component.
  90992. *
  90993. * This is used to decouple the dependency the scene is having on the different workloads like
  90994. * layers, post processes...
  90995. */
  90996. export interface ISceneComponent {
  90997. /**
  90998. * The name of the component. Each component must have a unique name.
  90999. */
  91000. name: string;
  91001. /**
  91002. * The scene the component belongs to.
  91003. */
  91004. scene: Scene;
  91005. /**
  91006. * Register the component to one instance of a scene.
  91007. */
  91008. register(): void;
  91009. /**
  91010. * Rebuilds the elements related to this component in case of
  91011. * context lost for instance.
  91012. */
  91013. rebuild(): void;
  91014. /**
  91015. * Disposes the component and the associated ressources.
  91016. */
  91017. dispose(): void;
  91018. }
  91019. /**
  91020. * This represents a SERIALIZABLE scene component.
  91021. *
  91022. * This extends Scene Component to add Serialization methods on top.
  91023. */
  91024. export interface ISceneSerializableComponent extends ISceneComponent {
  91025. /**
  91026. * Adds all the elements from the container to the scene
  91027. * @param container the container holding the elements
  91028. */
  91029. addFromContainer(container: AbstractScene): void;
  91030. /**
  91031. * Removes all the elements in the container from the scene
  91032. * @param container contains the elements to remove
  91033. * @param dispose if the removed element should be disposed (default: false)
  91034. */
  91035. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91036. /**
  91037. * Serializes the component data to the specified json object
  91038. * @param serializationObject The object to serialize to
  91039. */
  91040. serialize(serializationObject: any): void;
  91041. }
  91042. /**
  91043. * Strong typing of a Mesh related stage step action
  91044. */
  91045. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91046. /**
  91047. * Strong typing of a Evaluate Sub Mesh related stage step action
  91048. */
  91049. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91050. /**
  91051. * Strong typing of a Active Mesh related stage step action
  91052. */
  91053. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91054. /**
  91055. * Strong typing of a Camera related stage step action
  91056. */
  91057. export type CameraStageAction = (camera: Camera) => void;
  91058. /**
  91059. * Strong typing of a Camera Frame buffer related stage step action
  91060. */
  91061. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91062. /**
  91063. * Strong typing of a Render Target related stage step action
  91064. */
  91065. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91066. /**
  91067. * Strong typing of a RenderingGroup related stage step action
  91068. */
  91069. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91070. /**
  91071. * Strong typing of a Mesh Render related stage step action
  91072. */
  91073. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91074. /**
  91075. * Strong typing of a simple stage step action
  91076. */
  91077. export type SimpleStageAction = () => void;
  91078. /**
  91079. * Strong typing of a render target action.
  91080. */
  91081. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91082. /**
  91083. * Strong typing of a pointer move action.
  91084. */
  91085. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91086. /**
  91087. * Strong typing of a pointer up/down action.
  91088. */
  91089. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91090. /**
  91091. * Representation of a stage in the scene (Basically a list of ordered steps)
  91092. * @hidden
  91093. */
  91094. export class Stage<T extends Function> extends Array<{
  91095. index: number;
  91096. component: ISceneComponent;
  91097. action: T;
  91098. }> {
  91099. /**
  91100. * Hide ctor from the rest of the world.
  91101. * @param items The items to add.
  91102. */
  91103. private constructor();
  91104. /**
  91105. * Creates a new Stage.
  91106. * @returns A new instance of a Stage
  91107. */
  91108. static Create<T extends Function>(): Stage<T>;
  91109. /**
  91110. * Registers a step in an ordered way in the targeted stage.
  91111. * @param index Defines the position to register the step in
  91112. * @param component Defines the component attached to the step
  91113. * @param action Defines the action to launch during the step
  91114. */
  91115. registerStep(index: number, component: ISceneComponent, action: T): void;
  91116. /**
  91117. * Clears all the steps from the stage.
  91118. */
  91119. clear(): void;
  91120. }
  91121. }
  91122. declare module BABYLON {
  91123. interface Scene {
  91124. /** @hidden */
  91125. _pointerOverSprite: Nullable<Sprite>;
  91126. /** @hidden */
  91127. _pickedDownSprite: Nullable<Sprite>;
  91128. /** @hidden */
  91129. _tempSpritePickingRay: Nullable<Ray>;
  91130. /**
  91131. * All of the sprite managers added to this scene
  91132. * @see https://doc.babylonjs.com/babylon101/sprites
  91133. */
  91134. spriteManagers: Array<ISpriteManager>;
  91135. /**
  91136. * An event triggered when sprites rendering is about to start
  91137. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91138. */
  91139. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91140. /**
  91141. * An event triggered when sprites rendering is done
  91142. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91143. */
  91144. onAfterSpritesRenderingObservable: Observable<Scene>;
  91145. /** @hidden */
  91146. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91147. /** Launch a ray to try to pick a sprite in the scene
  91148. * @param x position on screen
  91149. * @param y position on screen
  91150. * @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
  91151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91152. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91153. * @returns a PickingInfo
  91154. */
  91155. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91156. /** Use the given ray to pick a sprite in the scene
  91157. * @param ray The ray (in world space) to use to pick meshes
  91158. * @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
  91159. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91160. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91161. * @returns a PickingInfo
  91162. */
  91163. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91164. /** @hidden */
  91165. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91166. /** Launch a ray to try to pick sprites in the scene
  91167. * @param x position on screen
  91168. * @param y position on screen
  91169. * @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
  91170. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91171. * @returns a PickingInfo array
  91172. */
  91173. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91174. /** Use the given ray to pick sprites in the scene
  91175. * @param ray The ray (in world space) to use to pick meshes
  91176. * @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
  91177. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91178. * @returns a PickingInfo array
  91179. */
  91180. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91181. /**
  91182. * Force the sprite under the pointer
  91183. * @param sprite defines the sprite to use
  91184. */
  91185. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91186. /**
  91187. * Gets the sprite under the pointer
  91188. * @returns a Sprite or null if no sprite is under the pointer
  91189. */
  91190. getPointerOverSprite(): Nullable<Sprite>;
  91191. }
  91192. /**
  91193. * Defines the sprite scene component responsible to manage sprites
  91194. * in a given scene.
  91195. */
  91196. export class SpriteSceneComponent implements ISceneComponent {
  91197. /**
  91198. * The component name helpfull to identify the component in the list of scene components.
  91199. */
  91200. readonly name: string;
  91201. /**
  91202. * The scene the component belongs to.
  91203. */
  91204. scene: Scene;
  91205. /** @hidden */
  91206. private _spritePredicate;
  91207. /**
  91208. * Creates a new instance of the component for the given scene
  91209. * @param scene Defines the scene to register the component in
  91210. */
  91211. constructor(scene: Scene);
  91212. /**
  91213. * Registers the component in a given scene
  91214. */
  91215. register(): void;
  91216. /**
  91217. * Rebuilds the elements related to this component in case of
  91218. * context lost for instance.
  91219. */
  91220. rebuild(): void;
  91221. /**
  91222. * Disposes the component and the associated ressources.
  91223. */
  91224. dispose(): void;
  91225. private _pickSpriteButKeepRay;
  91226. private _pointerMove;
  91227. private _pointerDown;
  91228. private _pointerUp;
  91229. }
  91230. }
  91231. declare module BABYLON {
  91232. /** @hidden */
  91233. export var fogFragmentDeclaration: {
  91234. name: string;
  91235. shader: string;
  91236. };
  91237. }
  91238. declare module BABYLON {
  91239. /** @hidden */
  91240. export var fogFragment: {
  91241. name: string;
  91242. shader: string;
  91243. };
  91244. }
  91245. declare module BABYLON {
  91246. /** @hidden */
  91247. export var spritesPixelShader: {
  91248. name: string;
  91249. shader: string;
  91250. };
  91251. }
  91252. declare module BABYLON {
  91253. /** @hidden */
  91254. export var fogVertexDeclaration: {
  91255. name: string;
  91256. shader: string;
  91257. };
  91258. }
  91259. declare module BABYLON {
  91260. /** @hidden */
  91261. export var spritesVertexShader: {
  91262. name: string;
  91263. shader: string;
  91264. };
  91265. }
  91266. declare module BABYLON {
  91267. /**
  91268. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91269. */
  91270. export interface ISpriteManager extends IDisposable {
  91271. /**
  91272. * Gets manager's name
  91273. */
  91274. name: string;
  91275. /**
  91276. * Restricts the camera to viewing objects with the same layerMask.
  91277. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91278. */
  91279. layerMask: number;
  91280. /**
  91281. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91282. */
  91283. isPickable: boolean;
  91284. /**
  91285. * Gets the hosting scene
  91286. */
  91287. scene: Scene;
  91288. /**
  91289. * Specifies the rendering group id for this mesh (0 by default)
  91290. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91291. */
  91292. renderingGroupId: number;
  91293. /**
  91294. * Defines the list of sprites managed by the manager.
  91295. */
  91296. sprites: Array<Sprite>;
  91297. /**
  91298. * Gets or sets the spritesheet texture
  91299. */
  91300. texture: Texture;
  91301. /** Defines the default width of a cell in the spritesheet */
  91302. cellWidth: number;
  91303. /** Defines the default height of a cell in the spritesheet */
  91304. cellHeight: number;
  91305. /**
  91306. * Tests the intersection of a sprite with a specific ray.
  91307. * @param ray The ray we are sending to test the collision
  91308. * @param camera The camera space we are sending rays in
  91309. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91310. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91311. * @returns picking info or null.
  91312. */
  91313. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91314. /**
  91315. * Intersects the sprites with a ray
  91316. * @param ray defines the ray to intersect with
  91317. * @param camera defines the current active camera
  91318. * @param predicate defines a predicate used to select candidate sprites
  91319. * @returns null if no hit or a PickingInfo array
  91320. */
  91321. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91322. /**
  91323. * Renders the list of sprites on screen.
  91324. */
  91325. render(): void;
  91326. }
  91327. /**
  91328. * Class used to manage multiple sprites on the same spritesheet
  91329. * @see https://doc.babylonjs.com/babylon101/sprites
  91330. */
  91331. export class SpriteManager implements ISpriteManager {
  91332. /** defines the manager's name */
  91333. name: string;
  91334. /** Define the Url to load snippets */
  91335. static SnippetUrl: string;
  91336. /** Snippet ID if the manager was created from the snippet server */
  91337. snippetId: string;
  91338. /** Gets the list of sprites */
  91339. sprites: Sprite[];
  91340. /** Gets or sets the rendering group id (0 by default) */
  91341. renderingGroupId: number;
  91342. /** Gets or sets camera layer mask */
  91343. layerMask: number;
  91344. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91345. fogEnabled: boolean;
  91346. /** Gets or sets a boolean indicating if the sprites are pickable */
  91347. isPickable: boolean;
  91348. /** Defines the default width of a cell in the spritesheet */
  91349. cellWidth: number;
  91350. /** Defines the default height of a cell in the spritesheet */
  91351. cellHeight: number;
  91352. /** Associative array from JSON sprite data file */
  91353. private _cellData;
  91354. /** Array of sprite names from JSON sprite data file */
  91355. private _spriteMap;
  91356. /** True when packed cell data from JSON file is ready*/
  91357. private _packedAndReady;
  91358. private _textureContent;
  91359. private _useInstancing;
  91360. /**
  91361. * An event triggered when the manager is disposed.
  91362. */
  91363. onDisposeObservable: Observable<SpriteManager>;
  91364. private _onDisposeObserver;
  91365. /**
  91366. * Callback called when the manager is disposed
  91367. */
  91368. set onDispose(callback: () => void);
  91369. private _capacity;
  91370. private _fromPacked;
  91371. private _spriteTexture;
  91372. private _epsilon;
  91373. private _scene;
  91374. private _vertexData;
  91375. private _buffer;
  91376. private _vertexBuffers;
  91377. private _spriteBuffer;
  91378. private _indexBuffer;
  91379. private _effectBase;
  91380. private _effectFog;
  91381. private _vertexBufferSize;
  91382. /**
  91383. * Gets or sets the unique id of the sprite
  91384. */
  91385. uniqueId: number;
  91386. /**
  91387. * Gets the array of sprites
  91388. */
  91389. get children(): Sprite[];
  91390. /**
  91391. * Gets the hosting scene
  91392. */
  91393. get scene(): Scene;
  91394. /**
  91395. * Gets the capacity of the manager
  91396. */
  91397. get capacity(): number;
  91398. /**
  91399. * Gets or sets the spritesheet texture
  91400. */
  91401. get texture(): Texture;
  91402. set texture(value: Texture);
  91403. private _blendMode;
  91404. /**
  91405. * Blend mode use to render the particle, it can be any of
  91406. * the static Constants.ALPHA_x properties provided in this class.
  91407. * Default value is Constants.ALPHA_COMBINE
  91408. */
  91409. get blendMode(): number;
  91410. set blendMode(blendMode: number);
  91411. /** Disables writing to the depth buffer when rendering the sprites.
  91412. * It can be handy to disable depth writing when using textures without alpha channel
  91413. * and setting some specific blend modes.
  91414. */
  91415. disableDepthWrite: boolean;
  91416. /**
  91417. * Creates a new sprite manager
  91418. * @param name defines the manager's name
  91419. * @param imgUrl defines the sprite sheet url
  91420. * @param capacity defines the maximum allowed number of sprites
  91421. * @param cellSize defines the size of a sprite cell
  91422. * @param scene defines the hosting scene
  91423. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91424. * @param samplingMode defines the smapling mode to use with spritesheet
  91425. * @param fromPacked set to false; do not alter
  91426. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91427. */
  91428. constructor(
  91429. /** defines the manager's name */
  91430. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91431. /**
  91432. * Returns the string "SpriteManager"
  91433. * @returns "SpriteManager"
  91434. */
  91435. getClassName(): string;
  91436. private _makePacked;
  91437. private _appendSpriteVertex;
  91438. private _checkTextureAlpha;
  91439. /**
  91440. * Intersects the sprites with a ray
  91441. * @param ray defines the ray to intersect with
  91442. * @param camera defines the current active camera
  91443. * @param predicate defines a predicate used to select candidate sprites
  91444. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91445. * @returns null if no hit or a PickingInfo
  91446. */
  91447. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91448. /**
  91449. * Intersects the sprites with a ray
  91450. * @param ray defines the ray to intersect with
  91451. * @param camera defines the current active camera
  91452. * @param predicate defines a predicate used to select candidate sprites
  91453. * @returns null if no hit or a PickingInfo array
  91454. */
  91455. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91456. /**
  91457. * Render all child sprites
  91458. */
  91459. render(): void;
  91460. /**
  91461. * Release associated resources
  91462. */
  91463. dispose(): void;
  91464. /**
  91465. * Serializes the sprite manager to a JSON object
  91466. * @param serializeTexture defines if the texture must be serialized as well
  91467. * @returns the JSON object
  91468. */
  91469. serialize(serializeTexture?: boolean): any;
  91470. /**
  91471. * Parses a JSON object to create a new sprite manager.
  91472. * @param parsedManager The JSON object to parse
  91473. * @param scene The scene to create the sprite managerin
  91474. * @param rootUrl The root url to use to load external dependencies like texture
  91475. * @returns the new sprite manager
  91476. */
  91477. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91478. /**
  91479. * Creates a sprite manager from a snippet saved in a remote file
  91480. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91481. * @param url defines the url to load from
  91482. * @param scene defines the hosting scene
  91483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91484. * @returns a promise that will resolve to the new sprite manager
  91485. */
  91486. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91487. /**
  91488. * Creates a sprite manager from a snippet saved by the sprite editor
  91489. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91490. * @param scene defines the hosting scene
  91491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91492. * @returns a promise that will resolve to the new sprite manager
  91493. */
  91494. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91495. }
  91496. }
  91497. declare module BABYLON {
  91498. /** Interface used by value gradients (color, factor, ...) */
  91499. export interface IValueGradient {
  91500. /**
  91501. * Gets or sets the gradient value (between 0 and 1)
  91502. */
  91503. gradient: number;
  91504. }
  91505. /** Class used to store color4 gradient */
  91506. export class ColorGradient implements IValueGradient {
  91507. /**
  91508. * Gets or sets the gradient value (between 0 and 1)
  91509. */
  91510. gradient: number;
  91511. /**
  91512. * Gets or sets first associated color
  91513. */
  91514. color1: Color4;
  91515. /**
  91516. * Gets or sets second associated color
  91517. */
  91518. color2?: Color4 | undefined;
  91519. /**
  91520. * Creates a new color4 gradient
  91521. * @param gradient gets or sets the gradient value (between 0 and 1)
  91522. * @param color1 gets or sets first associated color
  91523. * @param color2 gets or sets first second color
  91524. */
  91525. constructor(
  91526. /**
  91527. * Gets or sets the gradient value (between 0 and 1)
  91528. */
  91529. gradient: number,
  91530. /**
  91531. * Gets or sets first associated color
  91532. */
  91533. color1: Color4,
  91534. /**
  91535. * Gets or sets second associated color
  91536. */
  91537. color2?: Color4 | undefined);
  91538. /**
  91539. * Will get a color picked randomly between color1 and color2.
  91540. * If color2 is undefined then color1 will be used
  91541. * @param result defines the target Color4 to store the result in
  91542. */
  91543. getColorToRef(result: Color4): void;
  91544. }
  91545. /** Class used to store color 3 gradient */
  91546. export class Color3Gradient implements IValueGradient {
  91547. /**
  91548. * Gets or sets the gradient value (between 0 and 1)
  91549. */
  91550. gradient: number;
  91551. /**
  91552. * Gets or sets the associated color
  91553. */
  91554. color: Color3;
  91555. /**
  91556. * Creates a new color3 gradient
  91557. * @param gradient gets or sets the gradient value (between 0 and 1)
  91558. * @param color gets or sets associated color
  91559. */
  91560. constructor(
  91561. /**
  91562. * Gets or sets the gradient value (between 0 and 1)
  91563. */
  91564. gradient: number,
  91565. /**
  91566. * Gets or sets the associated color
  91567. */
  91568. color: Color3);
  91569. }
  91570. /** Class used to store factor gradient */
  91571. export class FactorGradient implements IValueGradient {
  91572. /**
  91573. * Gets or sets the gradient value (between 0 and 1)
  91574. */
  91575. gradient: number;
  91576. /**
  91577. * Gets or sets first associated factor
  91578. */
  91579. factor1: number;
  91580. /**
  91581. * Gets or sets second associated factor
  91582. */
  91583. factor2?: number | undefined;
  91584. /**
  91585. * Creates a new factor gradient
  91586. * @param gradient gets or sets the gradient value (between 0 and 1)
  91587. * @param factor1 gets or sets first associated factor
  91588. * @param factor2 gets or sets second associated factor
  91589. */
  91590. constructor(
  91591. /**
  91592. * Gets or sets the gradient value (between 0 and 1)
  91593. */
  91594. gradient: number,
  91595. /**
  91596. * Gets or sets first associated factor
  91597. */
  91598. factor1: number,
  91599. /**
  91600. * Gets or sets second associated factor
  91601. */
  91602. factor2?: number | undefined);
  91603. /**
  91604. * Will get a number picked randomly between factor1 and factor2.
  91605. * If factor2 is undefined then factor1 will be used
  91606. * @returns the picked number
  91607. */
  91608. getFactor(): number;
  91609. }
  91610. /**
  91611. * Helper used to simplify some generic gradient tasks
  91612. */
  91613. export class GradientHelper {
  91614. /**
  91615. * Gets the current gradient from an array of IValueGradient
  91616. * @param ratio defines the current ratio to get
  91617. * @param gradients defines the array of IValueGradient
  91618. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91619. */
  91620. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91621. }
  91622. }
  91623. declare module BABYLON {
  91624. interface ThinEngine {
  91625. /**
  91626. * Creates a raw texture
  91627. * @param data defines the data to store in the texture
  91628. * @param width defines the width of the texture
  91629. * @param height defines the height of the texture
  91630. * @param format defines the format of the data
  91631. * @param generateMipMaps defines if the engine should generate the mip levels
  91632. * @param invertY defines if data must be stored with Y axis inverted
  91633. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91634. * @param compression defines the compression used (null by default)
  91635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91636. * @returns the raw texture inside an InternalTexture
  91637. */
  91638. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91639. /**
  91640. * Update a raw texture
  91641. * @param texture defines the texture to update
  91642. * @param data defines the data to store in the texture
  91643. * @param format defines the format of the data
  91644. * @param invertY defines if data must be stored with Y axis inverted
  91645. */
  91646. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91647. /**
  91648. * Update a raw texture
  91649. * @param texture defines the texture to update
  91650. * @param data defines the data to store in the texture
  91651. * @param format defines the format of the data
  91652. * @param invertY defines if data must be stored with Y axis inverted
  91653. * @param compression defines the compression used (null by default)
  91654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91655. */
  91656. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91657. /**
  91658. * Creates a new raw cube texture
  91659. * @param data defines the array of data to use to create each face
  91660. * @param size defines the size of the textures
  91661. * @param format defines the format of the data
  91662. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91663. * @param generateMipMaps defines if the engine should generate the mip levels
  91664. * @param invertY defines if data must be stored with Y axis inverted
  91665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91666. * @param compression defines the compression used (null by default)
  91667. * @returns the cube texture as an InternalTexture
  91668. */
  91669. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91670. /**
  91671. * Update a raw cube texture
  91672. * @param texture defines the texture to udpdate
  91673. * @param data defines the data to store
  91674. * @param format defines the data format
  91675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91676. * @param invertY defines if data must be stored with Y axis inverted
  91677. */
  91678. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91679. /**
  91680. * Update a raw cube texture
  91681. * @param texture defines the texture to udpdate
  91682. * @param data defines the data to store
  91683. * @param format defines the data format
  91684. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91685. * @param invertY defines if data must be stored with Y axis inverted
  91686. * @param compression defines the compression used (null by default)
  91687. */
  91688. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91689. /**
  91690. * Update a raw cube texture
  91691. * @param texture defines the texture to udpdate
  91692. * @param data defines the data to store
  91693. * @param format defines the data format
  91694. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91695. * @param invertY defines if data must be stored with Y axis inverted
  91696. * @param compression defines the compression used (null by default)
  91697. * @param level defines which level of the texture to update
  91698. */
  91699. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91700. /**
  91701. * Creates a new raw cube texture from a specified url
  91702. * @param url defines the url where the data is located
  91703. * @param scene defines the current scene
  91704. * @param size defines the size of the textures
  91705. * @param format defines the format of the data
  91706. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91707. * @param noMipmap defines if the engine should avoid generating the mip levels
  91708. * @param callback defines a callback used to extract texture data from loaded data
  91709. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91710. * @param onLoad defines a callback called when texture is loaded
  91711. * @param onError defines a callback called if there is an error
  91712. * @returns the cube texture as an InternalTexture
  91713. */
  91714. 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;
  91715. /**
  91716. * Creates a new raw cube texture from a specified url
  91717. * @param url defines the url where the data is located
  91718. * @param scene defines the current scene
  91719. * @param size defines the size of the textures
  91720. * @param format defines the format of the data
  91721. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91722. * @param noMipmap defines if the engine should avoid generating the mip levels
  91723. * @param callback defines a callback used to extract texture data from loaded data
  91724. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91725. * @param onLoad defines a callback called when texture is loaded
  91726. * @param onError defines a callback called if there is an error
  91727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91728. * @param invertY defines if data must be stored with Y axis inverted
  91729. * @returns the cube texture as an InternalTexture
  91730. */
  91731. 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;
  91732. /**
  91733. * Creates a new raw 3D texture
  91734. * @param data defines the data used to create the texture
  91735. * @param width defines the width of the texture
  91736. * @param height defines the height of the texture
  91737. * @param depth defines the depth of the texture
  91738. * @param format defines the format of the texture
  91739. * @param generateMipMaps defines if the engine must generate mip levels
  91740. * @param invertY defines if data must be stored with Y axis inverted
  91741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91742. * @param compression defines the compressed used (can be null)
  91743. * @param textureType defines the compressed used (can be null)
  91744. * @returns a new raw 3D texture (stored in an InternalTexture)
  91745. */
  91746. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91747. /**
  91748. * Update a raw 3D texture
  91749. * @param texture defines the texture to update
  91750. * @param data defines the data to store
  91751. * @param format defines the data format
  91752. * @param invertY defines if data must be stored with Y axis inverted
  91753. */
  91754. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91755. /**
  91756. * Update a raw 3D texture
  91757. * @param texture defines the texture to update
  91758. * @param data defines the data to store
  91759. * @param format defines the data format
  91760. * @param invertY defines if data must be stored with Y axis inverted
  91761. * @param compression defines the used compression (can be null)
  91762. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91763. */
  91764. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91765. /**
  91766. * Creates a new raw 2D array texture
  91767. * @param data defines the data used to create the texture
  91768. * @param width defines the width of the texture
  91769. * @param height defines the height of the texture
  91770. * @param depth defines the number of layers of the texture
  91771. * @param format defines the format of the texture
  91772. * @param generateMipMaps defines if the engine must generate mip levels
  91773. * @param invertY defines if data must be stored with Y axis inverted
  91774. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91775. * @param compression defines the compressed used (can be null)
  91776. * @param textureType defines the compressed used (can be null)
  91777. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91778. */
  91779. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91780. /**
  91781. * Update a raw 2D array texture
  91782. * @param texture defines the texture to update
  91783. * @param data defines the data to store
  91784. * @param format defines the data format
  91785. * @param invertY defines if data must be stored with Y axis inverted
  91786. */
  91787. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91788. /**
  91789. * Update a raw 2D array texture
  91790. * @param texture defines the texture to update
  91791. * @param data defines the data to store
  91792. * @param format defines the data format
  91793. * @param invertY defines if data must be stored with Y axis inverted
  91794. * @param compression defines the used compression (can be null)
  91795. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91796. */
  91797. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91798. }
  91799. }
  91800. declare module BABYLON {
  91801. /**
  91802. * Raw texture can help creating a texture directly from an array of data.
  91803. * This can be super useful if you either get the data from an uncompressed source or
  91804. * if you wish to create your texture pixel by pixel.
  91805. */
  91806. export class RawTexture extends Texture {
  91807. /**
  91808. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91809. */
  91810. format: number;
  91811. /**
  91812. * Instantiates a new RawTexture.
  91813. * Raw texture can help creating a texture directly from an array of data.
  91814. * This can be super useful if you either get the data from an uncompressed source or
  91815. * if you wish to create your texture pixel by pixel.
  91816. * @param data define the array of data to use to create the texture
  91817. * @param width define the width of the texture
  91818. * @param height define the height of the texture
  91819. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91820. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91821. * @param generateMipMaps define whether mip maps should be generated or not
  91822. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91823. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91824. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91825. */
  91826. constructor(data: ArrayBufferView, width: number, height: number,
  91827. /**
  91828. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91829. */
  91830. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91831. /**
  91832. * Updates the texture underlying data.
  91833. * @param data Define the new data of the texture
  91834. */
  91835. update(data: ArrayBufferView): void;
  91836. /**
  91837. * Creates a luminance texture from some data.
  91838. * @param data Define the texture data
  91839. * @param width Define the width of the texture
  91840. * @param height Define the height of the texture
  91841. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91845. * @returns the luminance texture
  91846. */
  91847. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91848. /**
  91849. * Creates a luminance alpha texture from some data.
  91850. * @param data Define the texture data
  91851. * @param width Define the width of the texture
  91852. * @param height Define the height of the texture
  91853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91857. * @returns the luminance alpha texture
  91858. */
  91859. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91860. /**
  91861. * Creates an alpha texture from some data.
  91862. * @param data Define the texture data
  91863. * @param width Define the width of the texture
  91864. * @param height Define the height of the texture
  91865. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91866. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91867. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91868. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91869. * @returns the alpha texture
  91870. */
  91871. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91872. /**
  91873. * Creates a RGB texture from some data.
  91874. * @param data Define the texture data
  91875. * @param width Define the width of the texture
  91876. * @param height Define the height of the texture
  91877. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91882. * @returns the RGB alpha texture
  91883. */
  91884. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91885. /**
  91886. * Creates a RGBA texture from some data.
  91887. * @param data Define the texture data
  91888. * @param width Define the width of the texture
  91889. * @param height Define the height of the texture
  91890. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91895. * @returns the RGBA texture
  91896. */
  91897. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91898. /**
  91899. * Creates a R texture from some data.
  91900. * @param data Define the texture data
  91901. * @param width Define the width of the texture
  91902. * @param height Define the height of the texture
  91903. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91904. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91905. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91906. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91907. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91908. * @returns the R texture
  91909. */
  91910. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91911. }
  91912. }
  91913. declare module BABYLON {
  91914. interface ThinEngine {
  91915. /**
  91916. * Update a dynamic index buffer
  91917. * @param indexBuffer defines the target index buffer
  91918. * @param indices defines the data to update
  91919. * @param offset defines the offset in the target index buffer where update should start
  91920. */
  91921. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91922. /**
  91923. * Updates a dynamic vertex buffer.
  91924. * @param vertexBuffer the vertex buffer to update
  91925. * @param data the data used to update the vertex buffer
  91926. * @param byteOffset the byte offset of the data
  91927. * @param byteLength the byte length of the data
  91928. */
  91929. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91930. }
  91931. }
  91932. declare module BABYLON {
  91933. interface AbstractScene {
  91934. /**
  91935. * The list of procedural textures added to the scene
  91936. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91937. */
  91938. proceduralTextures: Array<ProceduralTexture>;
  91939. }
  91940. /**
  91941. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91942. * in a given scene.
  91943. */
  91944. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91945. /**
  91946. * The component name helpfull to identify the component in the list of scene components.
  91947. */
  91948. readonly name: string;
  91949. /**
  91950. * The scene the component belongs to.
  91951. */
  91952. scene: Scene;
  91953. /**
  91954. * Creates a new instance of the component for the given scene
  91955. * @param scene Defines the scene to register the component in
  91956. */
  91957. constructor(scene: Scene);
  91958. /**
  91959. * Registers the component in a given scene
  91960. */
  91961. register(): void;
  91962. /**
  91963. * Rebuilds the elements related to this component in case of
  91964. * context lost for instance.
  91965. */
  91966. rebuild(): void;
  91967. /**
  91968. * Disposes the component and the associated ressources.
  91969. */
  91970. dispose(): void;
  91971. private _beforeClear;
  91972. }
  91973. }
  91974. declare module BABYLON {
  91975. interface ThinEngine {
  91976. /**
  91977. * Creates a new render target cube texture
  91978. * @param size defines the size of the texture
  91979. * @param options defines the options used to create the texture
  91980. * @returns a new render target cube texture stored in an InternalTexture
  91981. */
  91982. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91983. }
  91984. }
  91985. declare module BABYLON {
  91986. /** @hidden */
  91987. export var proceduralVertexShader: {
  91988. name: string;
  91989. shader: string;
  91990. };
  91991. }
  91992. declare module BABYLON {
  91993. /**
  91994. * 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.
  91995. * This is the base class of any Procedural texture and contains most of the shareable code.
  91996. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91997. */
  91998. export class ProceduralTexture extends Texture {
  91999. /**
  92000. * Define if the texture is enabled or not (disabled texture will not render)
  92001. */
  92002. isEnabled: boolean;
  92003. /**
  92004. * Define if the texture must be cleared before rendering (default is true)
  92005. */
  92006. autoClear: boolean;
  92007. /**
  92008. * Callback called when the texture is generated
  92009. */
  92010. onGenerated: () => void;
  92011. /**
  92012. * Event raised when the texture is generated
  92013. */
  92014. onGeneratedObservable: Observable<ProceduralTexture>;
  92015. /**
  92016. * Event raised before the texture is generated
  92017. */
  92018. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92019. /**
  92020. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92021. */
  92022. nodeMaterialSource: Nullable<NodeMaterial>;
  92023. /** @hidden */
  92024. _generateMipMaps: boolean;
  92025. /** @hidden **/
  92026. _effect: Effect;
  92027. /** @hidden */
  92028. _textures: {
  92029. [key: string]: Texture;
  92030. };
  92031. /** @hidden */
  92032. protected _fallbackTexture: Nullable<Texture>;
  92033. private _size;
  92034. private _currentRefreshId;
  92035. private _frameId;
  92036. private _refreshRate;
  92037. private _vertexBuffers;
  92038. private _indexBuffer;
  92039. private _uniforms;
  92040. private _samplers;
  92041. private _fragment;
  92042. private _floats;
  92043. private _ints;
  92044. private _floatsArrays;
  92045. private _colors3;
  92046. private _colors4;
  92047. private _vectors2;
  92048. private _vectors3;
  92049. private _matrices;
  92050. private _fallbackTextureUsed;
  92051. private _fullEngine;
  92052. private _cachedDefines;
  92053. private _contentUpdateId;
  92054. private _contentData;
  92055. /**
  92056. * Instantiates a new procedural texture.
  92057. * 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.
  92058. * This is the base class of any Procedural texture and contains most of the shareable code.
  92059. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92060. * @param name Define the name of the texture
  92061. * @param size Define the size of the texture to create
  92062. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92063. * @param scene Define the scene the texture belongs to
  92064. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92065. * @param generateMipMaps Define if the texture should creates mip maps or not
  92066. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92067. */
  92068. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92069. /**
  92070. * The effect that is created when initializing the post process.
  92071. * @returns The created effect corresponding the the postprocess.
  92072. */
  92073. getEffect(): Effect;
  92074. /**
  92075. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92076. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92077. */
  92078. getContent(): Nullable<ArrayBufferView>;
  92079. private _createIndexBuffer;
  92080. /** @hidden */
  92081. _rebuild(): void;
  92082. /**
  92083. * Resets the texture in order to recreate its associated resources.
  92084. * This can be called in case of context loss
  92085. */
  92086. reset(): void;
  92087. protected _getDefines(): string;
  92088. /**
  92089. * Is the texture ready to be used ? (rendered at least once)
  92090. * @returns true if ready, otherwise, false.
  92091. */
  92092. isReady(): boolean;
  92093. /**
  92094. * Resets the refresh counter of the texture and start bak from scratch.
  92095. * Could be useful to regenerate the texture if it is setup to render only once.
  92096. */
  92097. resetRefreshCounter(): void;
  92098. /**
  92099. * Set the fragment shader to use in order to render the texture.
  92100. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92101. */
  92102. setFragment(fragment: any): void;
  92103. /**
  92104. * Define the refresh rate of the texture or the rendering frequency.
  92105. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92106. */
  92107. get refreshRate(): number;
  92108. set refreshRate(value: number);
  92109. /** @hidden */
  92110. _shouldRender(): boolean;
  92111. /**
  92112. * Get the size the texture is rendering at.
  92113. * @returns the size (on cube texture it is always squared)
  92114. */
  92115. getRenderSize(): RenderTargetTextureSize;
  92116. /**
  92117. * Resize the texture to new value.
  92118. * @param size Define the new size the texture should have
  92119. * @param generateMipMaps Define whether the new texture should create mip maps
  92120. */
  92121. resize(size: number, generateMipMaps: boolean): void;
  92122. private _checkUniform;
  92123. /**
  92124. * Set a texture in the shader program used to render.
  92125. * @param name Define the name of the uniform samplers as defined in the shader
  92126. * @param texture Define the texture to bind to this sampler
  92127. * @return the texture itself allowing "fluent" like uniform updates
  92128. */
  92129. setTexture(name: string, texture: Texture): ProceduralTexture;
  92130. /**
  92131. * Set a float in the shader.
  92132. * @param name Define the name of the uniform as defined in the shader
  92133. * @param value Define the value to give to the uniform
  92134. * @return the texture itself allowing "fluent" like uniform updates
  92135. */
  92136. setFloat(name: string, value: number): ProceduralTexture;
  92137. /**
  92138. * Set a int in the shader.
  92139. * @param name Define the name of the uniform as defined in the shader
  92140. * @param value Define the value to give to the uniform
  92141. * @return the texture itself allowing "fluent" like uniform updates
  92142. */
  92143. setInt(name: string, value: number): ProceduralTexture;
  92144. /**
  92145. * Set an array of floats in the shader.
  92146. * @param name Define the name of the uniform as defined in the shader
  92147. * @param value Define the value to give to the uniform
  92148. * @return the texture itself allowing "fluent" like uniform updates
  92149. */
  92150. setFloats(name: string, value: number[]): ProceduralTexture;
  92151. /**
  92152. * Set a vec3 in the shader from a Color3.
  92153. * @param name Define the name of the uniform as defined in the shader
  92154. * @param value Define the value to give to the uniform
  92155. * @return the texture itself allowing "fluent" like uniform updates
  92156. */
  92157. setColor3(name: string, value: Color3): ProceduralTexture;
  92158. /**
  92159. * Set a vec4 in the shader from a Color4.
  92160. * @param name Define the name of the uniform as defined in the shader
  92161. * @param value Define the value to give to the uniform
  92162. * @return the texture itself allowing "fluent" like uniform updates
  92163. */
  92164. setColor4(name: string, value: Color4): ProceduralTexture;
  92165. /**
  92166. * Set a vec2 in the shader from a Vector2.
  92167. * @param name Define the name of the uniform as defined in the shader
  92168. * @param value Define the value to give to the uniform
  92169. * @return the texture itself allowing "fluent" like uniform updates
  92170. */
  92171. setVector2(name: string, value: Vector2): ProceduralTexture;
  92172. /**
  92173. * Set a vec3 in the shader from a Vector3.
  92174. * @param name Define the name of the uniform as defined in the shader
  92175. * @param value Define the value to give to the uniform
  92176. * @return the texture itself allowing "fluent" like uniform updates
  92177. */
  92178. setVector3(name: string, value: Vector3): ProceduralTexture;
  92179. /**
  92180. * Set a mat4 in the shader from a MAtrix.
  92181. * @param name Define the name of the uniform as defined in the shader
  92182. * @param value Define the value to give to the uniform
  92183. * @return the texture itself allowing "fluent" like uniform updates
  92184. */
  92185. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92186. /**
  92187. * Render the texture to its associated render target.
  92188. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92189. */
  92190. render(useCameraPostProcess?: boolean): void;
  92191. /**
  92192. * Clone the texture.
  92193. * @returns the cloned texture
  92194. */
  92195. clone(): ProceduralTexture;
  92196. /**
  92197. * Dispose the texture and release its asoociated resources.
  92198. */
  92199. dispose(): void;
  92200. }
  92201. }
  92202. declare module BABYLON {
  92203. /**
  92204. * This represents the base class for particle system in Babylon.
  92205. * 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.
  92206. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92207. * @example https://doc.babylonjs.com/babylon101/particles
  92208. */
  92209. export class BaseParticleSystem {
  92210. /**
  92211. * Source color is added to the destination color without alpha affecting the result
  92212. */
  92213. static BLENDMODE_ONEONE: number;
  92214. /**
  92215. * Blend current color and particle color using particle’s alpha
  92216. */
  92217. static BLENDMODE_STANDARD: number;
  92218. /**
  92219. * Add current color and particle color multiplied by particle’s alpha
  92220. */
  92221. static BLENDMODE_ADD: number;
  92222. /**
  92223. * Multiply current color with particle color
  92224. */
  92225. static BLENDMODE_MULTIPLY: number;
  92226. /**
  92227. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92228. */
  92229. static BLENDMODE_MULTIPLYADD: number;
  92230. /**
  92231. * List of animations used by the particle system.
  92232. */
  92233. animations: Animation[];
  92234. /**
  92235. * Gets or sets the unique id of the particle system
  92236. */
  92237. uniqueId: number;
  92238. /**
  92239. * The id of the Particle system.
  92240. */
  92241. id: string;
  92242. /**
  92243. * The friendly name of the Particle system.
  92244. */
  92245. name: string;
  92246. /**
  92247. * Snippet ID if the particle system was created from the snippet server
  92248. */
  92249. snippetId: string;
  92250. /**
  92251. * The rendering group used by the Particle system to chose when to render.
  92252. */
  92253. renderingGroupId: number;
  92254. /**
  92255. * The emitter represents the Mesh or position we are attaching the particle system to.
  92256. */
  92257. emitter: Nullable<AbstractMesh | Vector3>;
  92258. /**
  92259. * The maximum number of particles to emit per frame
  92260. */
  92261. emitRate: number;
  92262. /**
  92263. * If you want to launch only a few particles at once, that can be done, as well.
  92264. */
  92265. manualEmitCount: number;
  92266. /**
  92267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92268. */
  92269. updateSpeed: number;
  92270. /**
  92271. * The amount of time the particle system is running (depends of the overall update speed).
  92272. */
  92273. targetStopDuration: number;
  92274. /**
  92275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92276. */
  92277. disposeOnStop: boolean;
  92278. /**
  92279. * Minimum power of emitting particles.
  92280. */
  92281. minEmitPower: number;
  92282. /**
  92283. * Maximum power of emitting particles.
  92284. */
  92285. maxEmitPower: number;
  92286. /**
  92287. * Minimum life time of emitting particles.
  92288. */
  92289. minLifeTime: number;
  92290. /**
  92291. * Maximum life time of emitting particles.
  92292. */
  92293. maxLifeTime: number;
  92294. /**
  92295. * Minimum Size of emitting particles.
  92296. */
  92297. minSize: number;
  92298. /**
  92299. * Maximum Size of emitting particles.
  92300. */
  92301. maxSize: number;
  92302. /**
  92303. * Minimum scale of emitting particles on X axis.
  92304. */
  92305. minScaleX: number;
  92306. /**
  92307. * Maximum scale of emitting particles on X axis.
  92308. */
  92309. maxScaleX: number;
  92310. /**
  92311. * Minimum scale of emitting particles on Y axis.
  92312. */
  92313. minScaleY: number;
  92314. /**
  92315. * Maximum scale of emitting particles on Y axis.
  92316. */
  92317. maxScaleY: number;
  92318. /**
  92319. * Gets or sets the minimal initial rotation in radians.
  92320. */
  92321. minInitialRotation: number;
  92322. /**
  92323. * Gets or sets the maximal initial rotation in radians.
  92324. */
  92325. maxInitialRotation: number;
  92326. /**
  92327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92328. */
  92329. minAngularSpeed: number;
  92330. /**
  92331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92332. */
  92333. maxAngularSpeed: number;
  92334. /**
  92335. * The texture used to render each particle. (this can be a spritesheet)
  92336. */
  92337. particleTexture: Nullable<BaseTexture>;
  92338. /**
  92339. * The layer mask we are rendering the particles through.
  92340. */
  92341. layerMask: number;
  92342. /**
  92343. * This can help using your own shader to render the particle system.
  92344. * The according effect will be created
  92345. */
  92346. customShader: any;
  92347. /**
  92348. * By default particle system starts as soon as they are created. This prevents the
  92349. * automatic start to happen and let you decide when to start emitting particles.
  92350. */
  92351. preventAutoStart: boolean;
  92352. private _noiseTexture;
  92353. /**
  92354. * Gets or sets a texture used to add random noise to particle positions
  92355. */
  92356. get noiseTexture(): Nullable<ProceduralTexture>;
  92357. set noiseTexture(value: Nullable<ProceduralTexture>);
  92358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92359. noiseStrength: Vector3;
  92360. /**
  92361. * Callback triggered when the particle animation is ending.
  92362. */
  92363. onAnimationEnd: Nullable<() => void>;
  92364. /**
  92365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92366. */
  92367. blendMode: number;
  92368. /**
  92369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92370. * to override the particles.
  92371. */
  92372. forceDepthWrite: boolean;
  92373. /** 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 */
  92374. preWarmCycles: number;
  92375. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92376. preWarmStepOffset: number;
  92377. /**
  92378. * 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)
  92379. */
  92380. spriteCellChangeSpeed: number;
  92381. /**
  92382. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92383. */
  92384. startSpriteCellID: number;
  92385. /**
  92386. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92387. */
  92388. endSpriteCellID: number;
  92389. /**
  92390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92391. */
  92392. spriteCellWidth: number;
  92393. /**
  92394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92395. */
  92396. spriteCellHeight: number;
  92397. /**
  92398. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92399. */
  92400. spriteRandomStartCell: boolean;
  92401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92402. translationPivot: Vector2;
  92403. /** @hidden */
  92404. protected _isAnimationSheetEnabled: boolean;
  92405. /**
  92406. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92407. */
  92408. beginAnimationOnStart: boolean;
  92409. /**
  92410. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92411. */
  92412. beginAnimationFrom: number;
  92413. /**
  92414. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92415. */
  92416. beginAnimationTo: number;
  92417. /**
  92418. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92419. */
  92420. beginAnimationLoop: boolean;
  92421. /**
  92422. * Gets or sets a world offset applied to all particles
  92423. */
  92424. worldOffset: Vector3;
  92425. /**
  92426. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92427. */
  92428. get isAnimationSheetEnabled(): boolean;
  92429. set isAnimationSheetEnabled(value: boolean);
  92430. /**
  92431. * Get hosting scene
  92432. * @returns the scene
  92433. */
  92434. getScene(): Nullable<Scene>;
  92435. /**
  92436. * You can use gravity if you want to give an orientation to your particles.
  92437. */
  92438. gravity: Vector3;
  92439. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92440. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92441. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92442. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92443. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92444. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92445. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92446. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92447. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92448. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92449. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92450. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92451. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92452. /**
  92453. * Defines the delay in milliseconds before starting the system (0 by default)
  92454. */
  92455. startDelay: number;
  92456. /**
  92457. * Gets the current list of drag gradients.
  92458. * You must use addDragGradient and removeDragGradient to udpate this list
  92459. * @returns the list of drag gradients
  92460. */
  92461. getDragGradients(): Nullable<Array<FactorGradient>>;
  92462. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92463. limitVelocityDamping: number;
  92464. /**
  92465. * Gets the current list of limit velocity gradients.
  92466. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92467. * @returns the list of limit velocity gradients
  92468. */
  92469. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92470. /**
  92471. * Gets the current list of color gradients.
  92472. * You must use addColorGradient and removeColorGradient to udpate this list
  92473. * @returns the list of color gradients
  92474. */
  92475. getColorGradients(): Nullable<Array<ColorGradient>>;
  92476. /**
  92477. * Gets the current list of size gradients.
  92478. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92479. * @returns the list of size gradients
  92480. */
  92481. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92482. /**
  92483. * Gets the current list of color remap gradients.
  92484. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92485. * @returns the list of color remap gradients
  92486. */
  92487. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92488. /**
  92489. * Gets the current list of alpha remap gradients.
  92490. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92491. * @returns the list of alpha remap gradients
  92492. */
  92493. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92494. /**
  92495. * Gets the current list of life time gradients.
  92496. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92497. * @returns the list of life time gradients
  92498. */
  92499. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92500. /**
  92501. * Gets the current list of angular speed gradients.
  92502. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92503. * @returns the list of angular speed gradients
  92504. */
  92505. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92506. /**
  92507. * Gets the current list of velocity gradients.
  92508. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92509. * @returns the list of velocity gradients
  92510. */
  92511. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92512. /**
  92513. * Gets the current list of start size gradients.
  92514. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92515. * @returns the list of start size gradients
  92516. */
  92517. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92518. /**
  92519. * Gets the current list of emit rate gradients.
  92520. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92521. * @returns the list of emit rate gradients
  92522. */
  92523. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92524. /**
  92525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92527. */
  92528. get direction1(): Vector3;
  92529. set direction1(value: Vector3);
  92530. /**
  92531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92532. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92533. */
  92534. get direction2(): Vector3;
  92535. set direction2(value: Vector3);
  92536. /**
  92537. * 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.
  92538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92539. */
  92540. get minEmitBox(): Vector3;
  92541. set minEmitBox(value: Vector3);
  92542. /**
  92543. * 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.
  92544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92545. */
  92546. get maxEmitBox(): Vector3;
  92547. set maxEmitBox(value: Vector3);
  92548. /**
  92549. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92550. */
  92551. color1: Color4;
  92552. /**
  92553. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92554. */
  92555. color2: Color4;
  92556. /**
  92557. * Color the particle will have at the end of its lifetime
  92558. */
  92559. colorDead: Color4;
  92560. /**
  92561. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92562. */
  92563. textureMask: Color4;
  92564. /**
  92565. * The particle emitter type defines the emitter used by the particle system.
  92566. * It can be for example box, sphere, or cone...
  92567. */
  92568. particleEmitterType: IParticleEmitterType;
  92569. /** @hidden */
  92570. _isSubEmitter: boolean;
  92571. /**
  92572. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92573. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92574. */
  92575. billboardMode: number;
  92576. protected _isBillboardBased: boolean;
  92577. /**
  92578. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92579. */
  92580. get isBillboardBased(): boolean;
  92581. set isBillboardBased(value: boolean);
  92582. /**
  92583. * The scene the particle system belongs to.
  92584. */
  92585. protected _scene: Nullable<Scene>;
  92586. /**
  92587. * The engine the particle system belongs to.
  92588. */
  92589. protected _engine: ThinEngine;
  92590. /**
  92591. * Local cache of defines for image processing.
  92592. */
  92593. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92594. /**
  92595. * Default configuration related to image processing available in the standard Material.
  92596. */
  92597. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92598. /**
  92599. * Gets the image processing configuration used either in this material.
  92600. */
  92601. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92602. /**
  92603. * Sets the Default image processing configuration used either in the this material.
  92604. *
  92605. * If sets to null, the scene one is in use.
  92606. */
  92607. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92608. /**
  92609. * Attaches a new image processing configuration to the Standard Material.
  92610. * @param configuration
  92611. */
  92612. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92613. /** @hidden */
  92614. protected _reset(): void;
  92615. /** @hidden */
  92616. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92617. /**
  92618. * Instantiates a particle system.
  92619. * 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.
  92620. * @param name The name of the particle system
  92621. */
  92622. constructor(name: string);
  92623. /**
  92624. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92627. * @returns the emitter
  92628. */
  92629. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92630. /**
  92631. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92632. * @param radius The radius of the hemisphere to emit from
  92633. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92634. * @returns the emitter
  92635. */
  92636. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92637. /**
  92638. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92639. * @param radius The radius of the sphere to emit from
  92640. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92641. * @returns the emitter
  92642. */
  92643. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92644. /**
  92645. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92646. * @param radius The radius of the sphere to emit from
  92647. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92648. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92649. * @returns the emitter
  92650. */
  92651. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92652. /**
  92653. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92654. * @param radius The radius of the emission cylinder
  92655. * @param height The height of the emission cylinder
  92656. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92657. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92658. * @returns the emitter
  92659. */
  92660. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92661. /**
  92662. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92663. * @param radius The radius of the cylinder to emit from
  92664. * @param height The height of the emission cylinder
  92665. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92668. * @returns the emitter
  92669. */
  92670. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92671. /**
  92672. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92673. * @param radius The radius of the cone to emit from
  92674. * @param angle The base angle of the cone
  92675. * @returns the emitter
  92676. */
  92677. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92678. /**
  92679. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92682. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92683. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92684. * @returns the emitter
  92685. */
  92686. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92687. }
  92688. }
  92689. declare module BABYLON {
  92690. /**
  92691. * Type of sub emitter
  92692. */
  92693. export enum SubEmitterType {
  92694. /**
  92695. * Attached to the particle over it's lifetime
  92696. */
  92697. ATTACHED = 0,
  92698. /**
  92699. * Created when the particle dies
  92700. */
  92701. END = 1
  92702. }
  92703. /**
  92704. * Sub emitter class used to emit particles from an existing particle
  92705. */
  92706. export class SubEmitter {
  92707. /**
  92708. * the particle system to be used by the sub emitter
  92709. */
  92710. particleSystem: ParticleSystem;
  92711. /**
  92712. * Type of the submitter (Default: END)
  92713. */
  92714. type: SubEmitterType;
  92715. /**
  92716. * 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)
  92717. * Note: This only is supported when using an emitter of type Mesh
  92718. */
  92719. inheritDirection: boolean;
  92720. /**
  92721. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92722. */
  92723. inheritedVelocityAmount: number;
  92724. /**
  92725. * Creates a sub emitter
  92726. * @param particleSystem the particle system to be used by the sub emitter
  92727. */
  92728. constructor(
  92729. /**
  92730. * the particle system to be used by the sub emitter
  92731. */
  92732. particleSystem: ParticleSystem);
  92733. /**
  92734. * Clones the sub emitter
  92735. * @returns the cloned sub emitter
  92736. */
  92737. clone(): SubEmitter;
  92738. /**
  92739. * Serialize current object to a JSON object
  92740. * @returns the serialized object
  92741. */
  92742. serialize(): any;
  92743. /** @hidden */
  92744. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92745. /**
  92746. * Creates a new SubEmitter from a serialized JSON version
  92747. * @param serializationObject defines the JSON object to read from
  92748. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92749. * @param rootUrl defines the rootUrl for data loading
  92750. * @returns a new SubEmitter
  92751. */
  92752. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92753. /** Release associated resources */
  92754. dispose(): void;
  92755. }
  92756. }
  92757. declare module BABYLON {
  92758. /** @hidden */
  92759. export var imageProcessingDeclaration: {
  92760. name: string;
  92761. shader: string;
  92762. };
  92763. }
  92764. declare module BABYLON {
  92765. /** @hidden */
  92766. export var imageProcessingFunctions: {
  92767. name: string;
  92768. shader: string;
  92769. };
  92770. }
  92771. declare module BABYLON {
  92772. /** @hidden */
  92773. export var particlesPixelShader: {
  92774. name: string;
  92775. shader: string;
  92776. };
  92777. }
  92778. declare module BABYLON {
  92779. /** @hidden */
  92780. export var particlesVertexShader: {
  92781. name: string;
  92782. shader: string;
  92783. };
  92784. }
  92785. declare module BABYLON {
  92786. /**
  92787. * Interface used to define entities containing multiple clip planes
  92788. */
  92789. export interface IClipPlanesHolder {
  92790. /**
  92791. * Gets or sets the active clipplane 1
  92792. */
  92793. clipPlane: Nullable<Plane>;
  92794. /**
  92795. * Gets or sets the active clipplane 2
  92796. */
  92797. clipPlane2: Nullable<Plane>;
  92798. /**
  92799. * Gets or sets the active clipplane 3
  92800. */
  92801. clipPlane3: Nullable<Plane>;
  92802. /**
  92803. * Gets or sets the active clipplane 4
  92804. */
  92805. clipPlane4: Nullable<Plane>;
  92806. /**
  92807. * Gets or sets the active clipplane 5
  92808. */
  92809. clipPlane5: Nullable<Plane>;
  92810. /**
  92811. * Gets or sets the active clipplane 6
  92812. */
  92813. clipPlane6: Nullable<Plane>;
  92814. }
  92815. }
  92816. declare module BABYLON {
  92817. /**
  92818. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92819. *
  92820. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92821. *
  92822. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92823. */
  92824. export class ThinMaterialHelper {
  92825. /**
  92826. * Binds the clip plane information from the holder to the effect.
  92827. * @param effect The effect we are binding the data to
  92828. * @param holder The entity containing the clip plane information
  92829. */
  92830. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92831. }
  92832. }
  92833. declare module BABYLON {
  92834. interface ThinEngine {
  92835. /**
  92836. * Sets alpha constants used by some alpha blending modes
  92837. * @param r defines the red component
  92838. * @param g defines the green component
  92839. * @param b defines the blue component
  92840. * @param a defines the alpha component
  92841. */
  92842. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92843. /**
  92844. * Sets the current alpha mode
  92845. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92846. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92847. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92848. */
  92849. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92850. /**
  92851. * Gets the current alpha mode
  92852. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92853. * @returns the current alpha mode
  92854. */
  92855. getAlphaMode(): number;
  92856. /**
  92857. * Sets the current alpha equation
  92858. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92859. */
  92860. setAlphaEquation(equation: number): void;
  92861. /**
  92862. * Gets the current alpha equation.
  92863. * @returns the current alpha equation
  92864. */
  92865. getAlphaEquation(): number;
  92866. }
  92867. }
  92868. declare module BABYLON {
  92869. /**
  92870. * This represents a particle system in Babylon.
  92871. * 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.
  92872. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92873. * @example https://doc.babylonjs.com/babylon101/particles
  92874. */
  92875. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92876. /**
  92877. * Billboard mode will only apply to Y axis
  92878. */
  92879. static readonly BILLBOARDMODE_Y: number;
  92880. /**
  92881. * Billboard mode will apply to all axes
  92882. */
  92883. static readonly BILLBOARDMODE_ALL: number;
  92884. /**
  92885. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92886. */
  92887. static readonly BILLBOARDMODE_STRETCHED: number;
  92888. /**
  92889. * This function can be defined to provide custom update for active particles.
  92890. * This function will be called instead of regular update (age, position, color, etc.).
  92891. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92892. */
  92893. updateFunction: (particles: Particle[]) => void;
  92894. private _emitterWorldMatrix;
  92895. /**
  92896. * This function can be defined to specify initial direction for every new particle.
  92897. * It by default use the emitterType defined function
  92898. */
  92899. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92900. /**
  92901. * This function can be defined to specify initial position for every new particle.
  92902. * It by default use the emitterType defined function
  92903. */
  92904. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92905. /**
  92906. * @hidden
  92907. */
  92908. _inheritedVelocityOffset: Vector3;
  92909. /**
  92910. * An event triggered when the system is disposed
  92911. */
  92912. onDisposeObservable: Observable<IParticleSystem>;
  92913. private _onDisposeObserver;
  92914. /**
  92915. * Sets a callback that will be triggered when the system is disposed
  92916. */
  92917. set onDispose(callback: () => void);
  92918. private _particles;
  92919. private _epsilon;
  92920. private _capacity;
  92921. private _stockParticles;
  92922. private _newPartsExcess;
  92923. private _vertexData;
  92924. private _vertexBuffer;
  92925. private _vertexBuffers;
  92926. private _spriteBuffer;
  92927. private _indexBuffer;
  92928. private _effect;
  92929. private _customEffect;
  92930. private _cachedDefines;
  92931. private _scaledColorStep;
  92932. private _colorDiff;
  92933. private _scaledDirection;
  92934. private _scaledGravity;
  92935. private _currentRenderId;
  92936. private _alive;
  92937. private _useInstancing;
  92938. private _started;
  92939. private _stopped;
  92940. private _actualFrame;
  92941. private _scaledUpdateSpeed;
  92942. private _vertexBufferSize;
  92943. /** @hidden */
  92944. _currentEmitRateGradient: Nullable<FactorGradient>;
  92945. /** @hidden */
  92946. _currentEmitRate1: number;
  92947. /** @hidden */
  92948. _currentEmitRate2: number;
  92949. /** @hidden */
  92950. _currentStartSizeGradient: Nullable<FactorGradient>;
  92951. /** @hidden */
  92952. _currentStartSize1: number;
  92953. /** @hidden */
  92954. _currentStartSize2: number;
  92955. private readonly _rawTextureWidth;
  92956. private _rampGradientsTexture;
  92957. private _useRampGradients;
  92958. /** Gets or sets a matrix to use to compute projection */
  92959. defaultProjectionMatrix: Matrix;
  92960. /** Gets or sets a matrix to use to compute view */
  92961. defaultViewMatrix: Matrix;
  92962. /** Gets or sets a boolean indicating that ramp gradients must be used
  92963. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92964. */
  92965. get useRampGradients(): boolean;
  92966. set useRampGradients(value: boolean);
  92967. /**
  92968. * 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.
  92969. * 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: [])
  92970. */
  92971. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92972. private _subEmitters;
  92973. /**
  92974. * @hidden
  92975. * If the particle systems emitter should be disposed when the particle system is disposed
  92976. */
  92977. _disposeEmitterOnDispose: boolean;
  92978. /**
  92979. * The current active Sub-systems, this property is used by the root particle system only.
  92980. */
  92981. activeSubSystems: Array<ParticleSystem>;
  92982. /**
  92983. * Specifies if the particles are updated in emitter local space or world space
  92984. */
  92985. isLocal: boolean;
  92986. private _rootParticleSystem;
  92987. /**
  92988. * Gets the current list of active particles
  92989. */
  92990. get particles(): Particle[];
  92991. /**
  92992. * Gets the number of particles active at the same time.
  92993. * @returns The number of active particles.
  92994. */
  92995. getActiveCount(): number;
  92996. /**
  92997. * Returns the string "ParticleSystem"
  92998. * @returns a string containing the class name
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Gets a boolean indicating that the system is stopping
  93003. * @returns true if the system is currently stopping
  93004. */
  93005. isStopping(): boolean;
  93006. /**
  93007. * Gets the custom effect used to render the particles
  93008. * @param blendMode Blend mode for which the effect should be retrieved
  93009. * @returns The effect
  93010. */
  93011. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93012. /**
  93013. * Sets the custom effect used to render the particles
  93014. * @param effect The effect to set
  93015. * @param blendMode Blend mode for which the effect should be set
  93016. */
  93017. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93018. /** @hidden */
  93019. private _onBeforeDrawParticlesObservable;
  93020. /**
  93021. * Observable that will be called just before the particles are drawn
  93022. */
  93023. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93024. /**
  93025. * Gets the name of the particle vertex shader
  93026. */
  93027. get vertexShaderName(): string;
  93028. /**
  93029. * Instantiates a particle system.
  93030. * 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.
  93031. * @param name The name of the particle system
  93032. * @param capacity The max number of particles alive at the same time
  93033. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93034. * @param customEffect a custom effect used to change the way particles are rendered by default
  93035. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93036. * @param epsilon Offset used to render the particles
  93037. */
  93038. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93039. private _addFactorGradient;
  93040. private _removeFactorGradient;
  93041. /**
  93042. * Adds a new life time gradient
  93043. * @param gradient defines the gradient to use (between 0 and 1)
  93044. * @param factor defines the life time factor to affect to the specified gradient
  93045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93046. * @returns the current particle system
  93047. */
  93048. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93049. /**
  93050. * Remove a specific life time gradient
  93051. * @param gradient defines the gradient to remove
  93052. * @returns the current particle system
  93053. */
  93054. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93055. /**
  93056. * Adds a new size gradient
  93057. * @param gradient defines the gradient to use (between 0 and 1)
  93058. * @param factor defines the size factor to affect to the specified gradient
  93059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93060. * @returns the current particle system
  93061. */
  93062. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93063. /**
  93064. * Remove a specific size gradient
  93065. * @param gradient defines the gradient to remove
  93066. * @returns the current particle system
  93067. */
  93068. removeSizeGradient(gradient: number): IParticleSystem;
  93069. /**
  93070. * Adds a new color remap gradient
  93071. * @param gradient defines the gradient to use (between 0 and 1)
  93072. * @param min defines the color remap minimal range
  93073. * @param max defines the color remap maximal range
  93074. * @returns the current particle system
  93075. */
  93076. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93077. /**
  93078. * Remove a specific color remap gradient
  93079. * @param gradient defines the gradient to remove
  93080. * @returns the current particle system
  93081. */
  93082. removeColorRemapGradient(gradient: number): IParticleSystem;
  93083. /**
  93084. * Adds a new alpha remap gradient
  93085. * @param gradient defines the gradient to use (between 0 and 1)
  93086. * @param min defines the alpha remap minimal range
  93087. * @param max defines the alpha remap maximal range
  93088. * @returns the current particle system
  93089. */
  93090. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93091. /**
  93092. * Remove a specific alpha remap gradient
  93093. * @param gradient defines the gradient to remove
  93094. * @returns the current particle system
  93095. */
  93096. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93097. /**
  93098. * Adds a new angular speed gradient
  93099. * @param gradient defines the gradient to use (between 0 and 1)
  93100. * @param factor defines the angular speed to affect to the specified gradient
  93101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93102. * @returns the current particle system
  93103. */
  93104. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93105. /**
  93106. * Remove a specific angular speed gradient
  93107. * @param gradient defines the gradient to remove
  93108. * @returns the current particle system
  93109. */
  93110. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93111. /**
  93112. * Adds a new velocity gradient
  93113. * @param gradient defines the gradient to use (between 0 and 1)
  93114. * @param factor defines the velocity to affect to the specified gradient
  93115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93116. * @returns the current particle system
  93117. */
  93118. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93119. /**
  93120. * Remove a specific velocity gradient
  93121. * @param gradient defines the gradient to remove
  93122. * @returns the current particle system
  93123. */
  93124. removeVelocityGradient(gradient: number): IParticleSystem;
  93125. /**
  93126. * Adds a new limit velocity gradient
  93127. * @param gradient defines the gradient to use (between 0 and 1)
  93128. * @param factor defines the limit velocity value to affect to the specified gradient
  93129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93130. * @returns the current particle system
  93131. */
  93132. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93133. /**
  93134. * Remove a specific limit velocity gradient
  93135. * @param gradient defines the gradient to remove
  93136. * @returns the current particle system
  93137. */
  93138. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93139. /**
  93140. * Adds a new drag gradient
  93141. * @param gradient defines the gradient to use (between 0 and 1)
  93142. * @param factor defines the drag value to affect to the specified gradient
  93143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93144. * @returns the current particle system
  93145. */
  93146. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93147. /**
  93148. * Remove a specific drag gradient
  93149. * @param gradient defines the gradient to remove
  93150. * @returns the current particle system
  93151. */
  93152. removeDragGradient(gradient: number): IParticleSystem;
  93153. /**
  93154. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93155. * @param gradient defines the gradient to use (between 0 and 1)
  93156. * @param factor defines the emit rate value to affect to the specified gradient
  93157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93158. * @returns the current particle system
  93159. */
  93160. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93161. /**
  93162. * Remove a specific emit rate gradient
  93163. * @param gradient defines the gradient to remove
  93164. * @returns the current particle system
  93165. */
  93166. removeEmitRateGradient(gradient: number): IParticleSystem;
  93167. /**
  93168. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93169. * @param gradient defines the gradient to use (between 0 and 1)
  93170. * @param factor defines the start size value to affect to the specified gradient
  93171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93172. * @returns the current particle system
  93173. */
  93174. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93175. /**
  93176. * Remove a specific start size gradient
  93177. * @param gradient defines the gradient to remove
  93178. * @returns the current particle system
  93179. */
  93180. removeStartSizeGradient(gradient: number): IParticleSystem;
  93181. private _createRampGradientTexture;
  93182. /**
  93183. * Gets the current list of ramp gradients.
  93184. * You must use addRampGradient and removeRampGradient to udpate this list
  93185. * @returns the list of ramp gradients
  93186. */
  93187. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93188. /** Force the system to rebuild all gradients that need to be resync */
  93189. forceRefreshGradients(): void;
  93190. private _syncRampGradientTexture;
  93191. /**
  93192. * Adds a new ramp gradient used to remap particle colors
  93193. * @param gradient defines the gradient to use (between 0 and 1)
  93194. * @param color defines the color to affect to the specified gradient
  93195. * @returns the current particle system
  93196. */
  93197. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93198. /**
  93199. * Remove a specific ramp gradient
  93200. * @param gradient defines the gradient to remove
  93201. * @returns the current particle system
  93202. */
  93203. removeRampGradient(gradient: number): ParticleSystem;
  93204. /**
  93205. * Adds a new color gradient
  93206. * @param gradient defines the gradient to use (between 0 and 1)
  93207. * @param color1 defines the color to affect to the specified gradient
  93208. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93209. * @returns this particle system
  93210. */
  93211. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93212. /**
  93213. * Remove a specific color gradient
  93214. * @param gradient defines the gradient to remove
  93215. * @returns this particle system
  93216. */
  93217. removeColorGradient(gradient: number): IParticleSystem;
  93218. private _fetchR;
  93219. protected _reset(): void;
  93220. private _resetEffect;
  93221. private _createVertexBuffers;
  93222. private _createIndexBuffer;
  93223. /**
  93224. * Gets the maximum number of particles active at the same time.
  93225. * @returns The max number of active particles.
  93226. */
  93227. getCapacity(): number;
  93228. /**
  93229. * Gets whether there are still active particles in the system.
  93230. * @returns True if it is alive, otherwise false.
  93231. */
  93232. isAlive(): boolean;
  93233. /**
  93234. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93235. * @returns True if it has been started, otherwise false.
  93236. */
  93237. isStarted(): boolean;
  93238. private _prepareSubEmitterInternalArray;
  93239. /**
  93240. * Starts the particle system and begins to emit
  93241. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93242. */
  93243. start(delay?: number): void;
  93244. /**
  93245. * Stops the particle system.
  93246. * @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.
  93247. */
  93248. stop(stopSubEmitters?: boolean): void;
  93249. /**
  93250. * Remove all active particles
  93251. */
  93252. reset(): void;
  93253. /**
  93254. * @hidden (for internal use only)
  93255. */
  93256. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93257. /**
  93258. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93259. * Its lifetime will start back at 0.
  93260. */
  93261. recycleParticle: (particle: Particle) => void;
  93262. private _stopSubEmitters;
  93263. private _createParticle;
  93264. private _removeFromRoot;
  93265. private _emitFromParticle;
  93266. private _update;
  93267. /** @hidden */
  93268. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93269. /** @hidden */
  93270. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93271. /**
  93272. * Fill the defines array according to the current settings of the particle system
  93273. * @param defines Array to be updated
  93274. * @param blendMode blend mode to take into account when updating the array
  93275. */
  93276. fillDefines(defines: Array<string>, blendMode: number): void;
  93277. /**
  93278. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93279. * @param uniforms Uniforms array to fill
  93280. * @param attributes Attributes array to fill
  93281. * @param samplers Samplers array to fill
  93282. */
  93283. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93284. /** @hidden */
  93285. private _getEffect;
  93286. /**
  93287. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93288. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93289. */
  93290. animate(preWarmOnly?: boolean): void;
  93291. private _appendParticleVertices;
  93292. /**
  93293. * Rebuilds the particle system.
  93294. */
  93295. rebuild(): void;
  93296. /**
  93297. * Is this system ready to be used/rendered
  93298. * @return true if the system is ready
  93299. */
  93300. isReady(): boolean;
  93301. private _render;
  93302. /**
  93303. * Renders the particle system in its current state.
  93304. * @returns the current number of particles
  93305. */
  93306. render(): number;
  93307. /**
  93308. * Disposes the particle system and free the associated resources
  93309. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93310. */
  93311. dispose(disposeTexture?: boolean): void;
  93312. /**
  93313. * Clones the particle system.
  93314. * @param name The name of the cloned object
  93315. * @param newEmitter The new emitter to use
  93316. * @returns the cloned particle system
  93317. */
  93318. clone(name: string, newEmitter: any): ParticleSystem;
  93319. /**
  93320. * Serializes the particle system to a JSON object
  93321. * @param serializeTexture defines if the texture must be serialized as well
  93322. * @returns the JSON object
  93323. */
  93324. serialize(serializeTexture?: boolean): any;
  93325. /** @hidden */
  93326. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93327. /** @hidden */
  93328. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93329. /**
  93330. * Parses a JSON object to create a particle system.
  93331. * @param parsedParticleSystem The JSON object to parse
  93332. * @param sceneOrEngine The scene or the engine to create the particle system in
  93333. * @param rootUrl The root url to use to load external dependencies like texture
  93334. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93335. * @returns the Parsed particle system
  93336. */
  93337. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93338. }
  93339. }
  93340. declare module BABYLON {
  93341. /**
  93342. * A particle represents one of the element emitted by a particle system.
  93343. * This is mainly define by its coordinates, direction, velocity and age.
  93344. */
  93345. export class Particle {
  93346. /**
  93347. * The particle system the particle belongs to.
  93348. */
  93349. particleSystem: ParticleSystem;
  93350. private static _Count;
  93351. /**
  93352. * Unique ID of the particle
  93353. */
  93354. id: number;
  93355. /**
  93356. * The world position of the particle in the scene.
  93357. */
  93358. position: Vector3;
  93359. /**
  93360. * The world direction of the particle in the scene.
  93361. */
  93362. direction: Vector3;
  93363. /**
  93364. * The color of the particle.
  93365. */
  93366. color: Color4;
  93367. /**
  93368. * The color change of the particle per step.
  93369. */
  93370. colorStep: Color4;
  93371. /**
  93372. * Defines how long will the life of the particle be.
  93373. */
  93374. lifeTime: number;
  93375. /**
  93376. * The current age of the particle.
  93377. */
  93378. age: number;
  93379. /**
  93380. * The current size of the particle.
  93381. */
  93382. size: number;
  93383. /**
  93384. * The current scale of the particle.
  93385. */
  93386. scale: Vector2;
  93387. /**
  93388. * The current angle of the particle.
  93389. */
  93390. angle: number;
  93391. /**
  93392. * Defines how fast is the angle changing.
  93393. */
  93394. angularSpeed: number;
  93395. /**
  93396. * Defines the cell index used by the particle to be rendered from a sprite.
  93397. */
  93398. cellIndex: number;
  93399. /**
  93400. * The information required to support color remapping
  93401. */
  93402. remapData: Vector4;
  93403. /** @hidden */
  93404. _randomCellOffset?: number;
  93405. /** @hidden */
  93406. _initialDirection: Nullable<Vector3>;
  93407. /** @hidden */
  93408. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93409. /** @hidden */
  93410. _initialStartSpriteCellID: number;
  93411. /** @hidden */
  93412. _initialEndSpriteCellID: number;
  93413. /** @hidden */
  93414. _currentColorGradient: Nullable<ColorGradient>;
  93415. /** @hidden */
  93416. _currentColor1: Color4;
  93417. /** @hidden */
  93418. _currentColor2: Color4;
  93419. /** @hidden */
  93420. _currentSizeGradient: Nullable<FactorGradient>;
  93421. /** @hidden */
  93422. _currentSize1: number;
  93423. /** @hidden */
  93424. _currentSize2: number;
  93425. /** @hidden */
  93426. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93427. /** @hidden */
  93428. _currentAngularSpeed1: number;
  93429. /** @hidden */
  93430. _currentAngularSpeed2: number;
  93431. /** @hidden */
  93432. _currentVelocityGradient: Nullable<FactorGradient>;
  93433. /** @hidden */
  93434. _currentVelocity1: number;
  93435. /** @hidden */
  93436. _currentVelocity2: number;
  93437. /** @hidden */
  93438. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93439. /** @hidden */
  93440. _currentLimitVelocity1: number;
  93441. /** @hidden */
  93442. _currentLimitVelocity2: number;
  93443. /** @hidden */
  93444. _currentDragGradient: Nullable<FactorGradient>;
  93445. /** @hidden */
  93446. _currentDrag1: number;
  93447. /** @hidden */
  93448. _currentDrag2: number;
  93449. /** @hidden */
  93450. _randomNoiseCoordinates1: Vector3;
  93451. /** @hidden */
  93452. _randomNoiseCoordinates2: Vector3;
  93453. /** @hidden */
  93454. _localPosition?: Vector3;
  93455. /**
  93456. * Creates a new instance Particle
  93457. * @param particleSystem the particle system the particle belongs to
  93458. */
  93459. constructor(
  93460. /**
  93461. * The particle system the particle belongs to.
  93462. */
  93463. particleSystem: ParticleSystem);
  93464. private updateCellInfoFromSystem;
  93465. /**
  93466. * Defines how the sprite cell index is updated for the particle
  93467. */
  93468. updateCellIndex(): void;
  93469. /** @hidden */
  93470. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93471. /** @hidden */
  93472. _inheritParticleInfoToSubEmitters(): void;
  93473. /** @hidden */
  93474. _reset(): void;
  93475. /**
  93476. * Copy the properties of particle to another one.
  93477. * @param other the particle to copy the information to.
  93478. */
  93479. copyTo(other: Particle): void;
  93480. }
  93481. }
  93482. declare module BABYLON {
  93483. /**
  93484. * Particle emitter represents a volume emitting particles.
  93485. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93486. */
  93487. export interface IParticleEmitterType {
  93488. /**
  93489. * Called by the particle System when the direction is computed for the created particle.
  93490. * @param worldMatrix is the world matrix of the particle system
  93491. * @param directionToUpdate is the direction vector to update with the result
  93492. * @param particle is the particle we are computed the direction for
  93493. * @param isLocal defines if the direction should be set in local space
  93494. */
  93495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93496. /**
  93497. * Called by the particle System when the position is computed for the created particle.
  93498. * @param worldMatrix is the world matrix of the particle system
  93499. * @param positionToUpdate is the position vector to update with the result
  93500. * @param particle is the particle we are computed the position for
  93501. * @param isLocal defines if the position should be set in local space
  93502. */
  93503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93504. /**
  93505. * Clones the current emitter and returns a copy of it
  93506. * @returns the new emitter
  93507. */
  93508. clone(): IParticleEmitterType;
  93509. /**
  93510. * Called by the GPUParticleSystem to setup the update shader
  93511. * @param effect defines the update shader
  93512. */
  93513. applyToShader(effect: Effect): void;
  93514. /**
  93515. * Returns a string to use to update the GPU particles update shader
  93516. * @returns the effect defines string
  93517. */
  93518. getEffectDefines(): string;
  93519. /**
  93520. * Returns a string representing the class name
  93521. * @returns a string containing the class name
  93522. */
  93523. getClassName(): string;
  93524. /**
  93525. * Serializes the particle system to a JSON object.
  93526. * @returns the JSON object
  93527. */
  93528. serialize(): any;
  93529. /**
  93530. * Parse properties from a JSON object
  93531. * @param serializationObject defines the JSON object
  93532. * @param scene defines the hosting scene
  93533. */
  93534. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93535. }
  93536. }
  93537. declare module BABYLON {
  93538. /**
  93539. * Particle emitter emitting particles from the inside of a box.
  93540. * It emits the particles randomly between 2 given directions.
  93541. */
  93542. export class BoxParticleEmitter implements IParticleEmitterType {
  93543. /**
  93544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93545. */
  93546. direction1: Vector3;
  93547. /**
  93548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93549. */
  93550. direction2: Vector3;
  93551. /**
  93552. * 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.
  93553. */
  93554. minEmitBox: Vector3;
  93555. /**
  93556. * 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.
  93557. */
  93558. maxEmitBox: Vector3;
  93559. /**
  93560. * Creates a new instance BoxParticleEmitter
  93561. */
  93562. constructor();
  93563. /**
  93564. * Called by the particle System when the direction is computed for the created particle.
  93565. * @param worldMatrix is the world matrix of the particle system
  93566. * @param directionToUpdate is the direction vector to update with the result
  93567. * @param particle is the particle we are computed the direction for
  93568. * @param isLocal defines if the direction should be set in local space
  93569. */
  93570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93571. /**
  93572. * Called by the particle System when the position is computed for the created particle.
  93573. * @param worldMatrix is the world matrix of the particle system
  93574. * @param positionToUpdate is the position vector to update with the result
  93575. * @param particle is the particle we are computed the position for
  93576. * @param isLocal defines if the position should be set in local space
  93577. */
  93578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93579. /**
  93580. * Clones the current emitter and returns a copy of it
  93581. * @returns the new emitter
  93582. */
  93583. clone(): BoxParticleEmitter;
  93584. /**
  93585. * Called by the GPUParticleSystem to setup the update shader
  93586. * @param effect defines the update shader
  93587. */
  93588. applyToShader(effect: Effect): void;
  93589. /**
  93590. * Returns a string to use to update the GPU particles update shader
  93591. * @returns a string containng the defines string
  93592. */
  93593. getEffectDefines(): string;
  93594. /**
  93595. * Returns the string "BoxParticleEmitter"
  93596. * @returns a string containing the class name
  93597. */
  93598. getClassName(): string;
  93599. /**
  93600. * Serializes the particle system to a JSON object.
  93601. * @returns the JSON object
  93602. */
  93603. serialize(): any;
  93604. /**
  93605. * Parse properties from a JSON object
  93606. * @param serializationObject defines the JSON object
  93607. */
  93608. parse(serializationObject: any): void;
  93609. }
  93610. }
  93611. declare module BABYLON {
  93612. /**
  93613. * Particle emitter emitting particles from the inside of a cone.
  93614. * It emits the particles alongside the cone volume from the base to the particle.
  93615. * The emission direction might be randomized.
  93616. */
  93617. export class ConeParticleEmitter implements IParticleEmitterType {
  93618. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93619. directionRandomizer: number;
  93620. private _radius;
  93621. private _angle;
  93622. private _height;
  93623. /**
  93624. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93625. */
  93626. radiusRange: number;
  93627. /**
  93628. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93629. */
  93630. heightRange: number;
  93631. /**
  93632. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93633. */
  93634. emitFromSpawnPointOnly: boolean;
  93635. /**
  93636. * Gets or sets the radius of the emission cone
  93637. */
  93638. get radius(): number;
  93639. set radius(value: number);
  93640. /**
  93641. * Gets or sets the angle of the emission cone
  93642. */
  93643. get angle(): number;
  93644. set angle(value: number);
  93645. private _buildHeight;
  93646. /**
  93647. * Creates a new instance ConeParticleEmitter
  93648. * @param radius the radius of the emission cone (1 by default)
  93649. * @param angle the cone base angle (PI by default)
  93650. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93651. */
  93652. constructor(radius?: number, angle?: number,
  93653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93654. directionRandomizer?: number);
  93655. /**
  93656. * Called by the particle System when the direction is computed for the created particle.
  93657. * @param worldMatrix is the world matrix of the particle system
  93658. * @param directionToUpdate is the direction vector to update with the result
  93659. * @param particle is the particle we are computed the direction for
  93660. * @param isLocal defines if the direction should be set in local space
  93661. */
  93662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93663. /**
  93664. * Called by the particle System when the position is computed for the created particle.
  93665. * @param worldMatrix is the world matrix of the particle system
  93666. * @param positionToUpdate is the position vector to update with the result
  93667. * @param particle is the particle we are computed the position for
  93668. * @param isLocal defines if the position should be set in local space
  93669. */
  93670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93671. /**
  93672. * Clones the current emitter and returns a copy of it
  93673. * @returns the new emitter
  93674. */
  93675. clone(): ConeParticleEmitter;
  93676. /**
  93677. * Called by the GPUParticleSystem to setup the update shader
  93678. * @param effect defines the update shader
  93679. */
  93680. applyToShader(effect: Effect): void;
  93681. /**
  93682. * Returns a string to use to update the GPU particles update shader
  93683. * @returns a string containng the defines string
  93684. */
  93685. getEffectDefines(): string;
  93686. /**
  93687. * Returns the string "ConeParticleEmitter"
  93688. * @returns a string containing the class name
  93689. */
  93690. getClassName(): string;
  93691. /**
  93692. * Serializes the particle system to a JSON object.
  93693. * @returns the JSON object
  93694. */
  93695. serialize(): any;
  93696. /**
  93697. * Parse properties from a JSON object
  93698. * @param serializationObject defines the JSON object
  93699. */
  93700. parse(serializationObject: any): void;
  93701. }
  93702. }
  93703. declare module BABYLON {
  93704. /**
  93705. * Particle emitter emitting particles from the inside of a cylinder.
  93706. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93707. */
  93708. export class CylinderParticleEmitter implements IParticleEmitterType {
  93709. /**
  93710. * The radius of the emission cylinder.
  93711. */
  93712. radius: number;
  93713. /**
  93714. * The height of the emission cylinder.
  93715. */
  93716. height: number;
  93717. /**
  93718. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93719. */
  93720. radiusRange: number;
  93721. /**
  93722. * How much to randomize the particle direction [0-1].
  93723. */
  93724. directionRandomizer: number;
  93725. /**
  93726. * Creates a new instance CylinderParticleEmitter
  93727. * @param radius the radius of the emission cylinder (1 by default)
  93728. * @param height the height of the emission cylinder (1 by default)
  93729. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93730. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93731. */
  93732. constructor(
  93733. /**
  93734. * The radius of the emission cylinder.
  93735. */
  93736. radius?: number,
  93737. /**
  93738. * The height of the emission cylinder.
  93739. */
  93740. height?: number,
  93741. /**
  93742. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93743. */
  93744. radiusRange?: number,
  93745. /**
  93746. * How much to randomize the particle direction [0-1].
  93747. */
  93748. directionRandomizer?: number);
  93749. /**
  93750. * Called by the particle System when the direction is computed for the created particle.
  93751. * @param worldMatrix is the world matrix of the particle system
  93752. * @param directionToUpdate is the direction vector to update with the result
  93753. * @param particle is the particle we are computed the direction for
  93754. * @param isLocal defines if the direction should be set in local space
  93755. */
  93756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93757. /**
  93758. * Called by the particle System when the position is computed for the created particle.
  93759. * @param worldMatrix is the world matrix of the particle system
  93760. * @param positionToUpdate is the position vector to update with the result
  93761. * @param particle is the particle we are computed the position for
  93762. * @param isLocal defines if the position should be set in local space
  93763. */
  93764. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93765. /**
  93766. * Clones the current emitter and returns a copy of it
  93767. * @returns the new emitter
  93768. */
  93769. clone(): CylinderParticleEmitter;
  93770. /**
  93771. * Called by the GPUParticleSystem to setup the update shader
  93772. * @param effect defines the update shader
  93773. */
  93774. applyToShader(effect: Effect): void;
  93775. /**
  93776. * Returns a string to use to update the GPU particles update shader
  93777. * @returns a string containng the defines string
  93778. */
  93779. getEffectDefines(): string;
  93780. /**
  93781. * Returns the string "CylinderParticleEmitter"
  93782. * @returns a string containing the class name
  93783. */
  93784. getClassName(): string;
  93785. /**
  93786. * Serializes the particle system to a JSON object.
  93787. * @returns the JSON object
  93788. */
  93789. serialize(): any;
  93790. /**
  93791. * Parse properties from a JSON object
  93792. * @param serializationObject defines the JSON object
  93793. */
  93794. parse(serializationObject: any): void;
  93795. }
  93796. /**
  93797. * Particle emitter emitting particles from the inside of a cylinder.
  93798. * It emits the particles randomly between two vectors.
  93799. */
  93800. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93801. /**
  93802. * The min limit of the emission direction.
  93803. */
  93804. direction1: Vector3;
  93805. /**
  93806. * The max limit of the emission direction.
  93807. */
  93808. direction2: Vector3;
  93809. /**
  93810. * Creates a new instance CylinderDirectedParticleEmitter
  93811. * @param radius the radius of the emission cylinder (1 by default)
  93812. * @param height the height of the emission cylinder (1 by default)
  93813. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93814. * @param direction1 the min limit of the emission direction (up vector by default)
  93815. * @param direction2 the max limit of the emission direction (up vector by default)
  93816. */
  93817. constructor(radius?: number, height?: number, radiusRange?: number,
  93818. /**
  93819. * The min limit of the emission direction.
  93820. */
  93821. direction1?: Vector3,
  93822. /**
  93823. * The max limit of the emission direction.
  93824. */
  93825. direction2?: Vector3);
  93826. /**
  93827. * Called by the particle System when the direction is computed for the created particle.
  93828. * @param worldMatrix is the world matrix of the particle system
  93829. * @param directionToUpdate is the direction vector to update with the result
  93830. * @param particle is the particle we are computed the direction for
  93831. */
  93832. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93833. /**
  93834. * Clones the current emitter and returns a copy of it
  93835. * @returns the new emitter
  93836. */
  93837. clone(): CylinderDirectedParticleEmitter;
  93838. /**
  93839. * Called by the GPUParticleSystem to setup the update shader
  93840. * @param effect defines the update shader
  93841. */
  93842. applyToShader(effect: Effect): void;
  93843. /**
  93844. * Returns a string to use to update the GPU particles update shader
  93845. * @returns a string containng the defines string
  93846. */
  93847. getEffectDefines(): string;
  93848. /**
  93849. * Returns the string "CylinderDirectedParticleEmitter"
  93850. * @returns a string containing the class name
  93851. */
  93852. getClassName(): string;
  93853. /**
  93854. * Serializes the particle system to a JSON object.
  93855. * @returns the JSON object
  93856. */
  93857. serialize(): any;
  93858. /**
  93859. * Parse properties from a JSON object
  93860. * @param serializationObject defines the JSON object
  93861. */
  93862. parse(serializationObject: any): void;
  93863. }
  93864. }
  93865. declare module BABYLON {
  93866. /**
  93867. * Particle emitter emitting particles from the inside of a hemisphere.
  93868. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93869. */
  93870. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93871. /**
  93872. * The radius of the emission hemisphere.
  93873. */
  93874. radius: number;
  93875. /**
  93876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93877. */
  93878. radiusRange: number;
  93879. /**
  93880. * How much to randomize the particle direction [0-1].
  93881. */
  93882. directionRandomizer: number;
  93883. /**
  93884. * Creates a new instance HemisphericParticleEmitter
  93885. * @param radius the radius of the emission hemisphere (1 by default)
  93886. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93887. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93888. */
  93889. constructor(
  93890. /**
  93891. * The radius of the emission hemisphere.
  93892. */
  93893. radius?: number,
  93894. /**
  93895. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93896. */
  93897. radiusRange?: number,
  93898. /**
  93899. * How much to randomize the particle direction [0-1].
  93900. */
  93901. directionRandomizer?: number);
  93902. /**
  93903. * Called by the particle System when the direction is computed for the created particle.
  93904. * @param worldMatrix is the world matrix of the particle system
  93905. * @param directionToUpdate is the direction vector to update with the result
  93906. * @param particle is the particle we are computed the direction for
  93907. * @param isLocal defines if the direction should be set in local space
  93908. */
  93909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93910. /**
  93911. * Called by the particle System when the position is computed for the created particle.
  93912. * @param worldMatrix is the world matrix of the particle system
  93913. * @param positionToUpdate is the position vector to update with the result
  93914. * @param particle is the particle we are computed the position for
  93915. * @param isLocal defines if the position should be set in local space
  93916. */
  93917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93918. /**
  93919. * Clones the current emitter and returns a copy of it
  93920. * @returns the new emitter
  93921. */
  93922. clone(): HemisphericParticleEmitter;
  93923. /**
  93924. * Called by the GPUParticleSystem to setup the update shader
  93925. * @param effect defines the update shader
  93926. */
  93927. applyToShader(effect: Effect): void;
  93928. /**
  93929. * Returns a string to use to update the GPU particles update shader
  93930. * @returns a string containng the defines string
  93931. */
  93932. getEffectDefines(): string;
  93933. /**
  93934. * Returns the string "HemisphericParticleEmitter"
  93935. * @returns a string containing the class name
  93936. */
  93937. getClassName(): string;
  93938. /**
  93939. * Serializes the particle system to a JSON object.
  93940. * @returns the JSON object
  93941. */
  93942. serialize(): any;
  93943. /**
  93944. * Parse properties from a JSON object
  93945. * @param serializationObject defines the JSON object
  93946. */
  93947. parse(serializationObject: any): void;
  93948. }
  93949. }
  93950. declare module BABYLON {
  93951. /**
  93952. * Particle emitter emitting particles from a point.
  93953. * It emits the particles randomly between 2 given directions.
  93954. */
  93955. export class PointParticleEmitter implements IParticleEmitterType {
  93956. /**
  93957. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93958. */
  93959. direction1: Vector3;
  93960. /**
  93961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93962. */
  93963. direction2: Vector3;
  93964. /**
  93965. * Creates a new instance PointParticleEmitter
  93966. */
  93967. constructor();
  93968. /**
  93969. * Called by the particle System when the direction is computed for the created particle.
  93970. * @param worldMatrix is the world matrix of the particle system
  93971. * @param directionToUpdate is the direction vector to update with the result
  93972. * @param particle is the particle we are computed the direction for
  93973. * @param isLocal defines if the direction should be set in local space
  93974. */
  93975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93976. /**
  93977. * Called by the particle System when the position is computed for the created particle.
  93978. * @param worldMatrix is the world matrix of the particle system
  93979. * @param positionToUpdate is the position vector to update with the result
  93980. * @param particle is the particle we are computed the position for
  93981. * @param isLocal defines if the position should be set in local space
  93982. */
  93983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93984. /**
  93985. * Clones the current emitter and returns a copy of it
  93986. * @returns the new emitter
  93987. */
  93988. clone(): PointParticleEmitter;
  93989. /**
  93990. * Called by the GPUParticleSystem to setup the update shader
  93991. * @param effect defines the update shader
  93992. */
  93993. applyToShader(effect: Effect): void;
  93994. /**
  93995. * Returns a string to use to update the GPU particles update shader
  93996. * @returns a string containng the defines string
  93997. */
  93998. getEffectDefines(): string;
  93999. /**
  94000. * Returns the string "PointParticleEmitter"
  94001. * @returns a string containing the class name
  94002. */
  94003. getClassName(): string;
  94004. /**
  94005. * Serializes the particle system to a JSON object.
  94006. * @returns the JSON object
  94007. */
  94008. serialize(): any;
  94009. /**
  94010. * Parse properties from a JSON object
  94011. * @param serializationObject defines the JSON object
  94012. */
  94013. parse(serializationObject: any): void;
  94014. }
  94015. }
  94016. declare module BABYLON {
  94017. /**
  94018. * Particle emitter emitting particles from the inside of a sphere.
  94019. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94020. */
  94021. export class SphereParticleEmitter implements IParticleEmitterType {
  94022. /**
  94023. * The radius of the emission sphere.
  94024. */
  94025. radius: number;
  94026. /**
  94027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94028. */
  94029. radiusRange: number;
  94030. /**
  94031. * How much to randomize the particle direction [0-1].
  94032. */
  94033. directionRandomizer: number;
  94034. /**
  94035. * Creates a new instance SphereParticleEmitter
  94036. * @param radius the radius of the emission sphere (1 by default)
  94037. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94038. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94039. */
  94040. constructor(
  94041. /**
  94042. * The radius of the emission sphere.
  94043. */
  94044. radius?: number,
  94045. /**
  94046. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94047. */
  94048. radiusRange?: number,
  94049. /**
  94050. * How much to randomize the particle direction [0-1].
  94051. */
  94052. directionRandomizer?: number);
  94053. /**
  94054. * Called by the particle System when the direction is computed for the created particle.
  94055. * @param worldMatrix is the world matrix of the particle system
  94056. * @param directionToUpdate is the direction vector to update with the result
  94057. * @param particle is the particle we are computed the direction for
  94058. * @param isLocal defines if the direction should be set in local space
  94059. */
  94060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94061. /**
  94062. * Called by the particle System when the position is computed for the created particle.
  94063. * @param worldMatrix is the world matrix of the particle system
  94064. * @param positionToUpdate is the position vector to update with the result
  94065. * @param particle is the particle we are computed the position for
  94066. * @param isLocal defines if the position should be set in local space
  94067. */
  94068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94069. /**
  94070. * Clones the current emitter and returns a copy of it
  94071. * @returns the new emitter
  94072. */
  94073. clone(): SphereParticleEmitter;
  94074. /**
  94075. * Called by the GPUParticleSystem to setup the update shader
  94076. * @param effect defines the update shader
  94077. */
  94078. applyToShader(effect: Effect): void;
  94079. /**
  94080. * Returns a string to use to update the GPU particles update shader
  94081. * @returns a string containng the defines string
  94082. */
  94083. getEffectDefines(): string;
  94084. /**
  94085. * Returns the string "SphereParticleEmitter"
  94086. * @returns a string containing the class name
  94087. */
  94088. getClassName(): string;
  94089. /**
  94090. * Serializes the particle system to a JSON object.
  94091. * @returns the JSON object
  94092. */
  94093. serialize(): any;
  94094. /**
  94095. * Parse properties from a JSON object
  94096. * @param serializationObject defines the JSON object
  94097. */
  94098. parse(serializationObject: any): void;
  94099. }
  94100. /**
  94101. * Particle emitter emitting particles from the inside of a sphere.
  94102. * It emits the particles randomly between two vectors.
  94103. */
  94104. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94105. /**
  94106. * The min limit of the emission direction.
  94107. */
  94108. direction1: Vector3;
  94109. /**
  94110. * The max limit of the emission direction.
  94111. */
  94112. direction2: Vector3;
  94113. /**
  94114. * Creates a new instance SphereDirectedParticleEmitter
  94115. * @param radius the radius of the emission sphere (1 by default)
  94116. * @param direction1 the min limit of the emission direction (up vector by default)
  94117. * @param direction2 the max limit of the emission direction (up vector by default)
  94118. */
  94119. constructor(radius?: number,
  94120. /**
  94121. * The min limit of the emission direction.
  94122. */
  94123. direction1?: Vector3,
  94124. /**
  94125. * The max limit of the emission direction.
  94126. */
  94127. direction2?: Vector3);
  94128. /**
  94129. * Called by the particle System when the direction is computed for the created particle.
  94130. * @param worldMatrix is the world matrix of the particle system
  94131. * @param directionToUpdate is the direction vector to update with the result
  94132. * @param particle is the particle we are computed the direction for
  94133. */
  94134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94135. /**
  94136. * Clones the current emitter and returns a copy of it
  94137. * @returns the new emitter
  94138. */
  94139. clone(): SphereDirectedParticleEmitter;
  94140. /**
  94141. * Called by the GPUParticleSystem to setup the update shader
  94142. * @param effect defines the update shader
  94143. */
  94144. applyToShader(effect: Effect): void;
  94145. /**
  94146. * Returns a string to use to update the GPU particles update shader
  94147. * @returns a string containng the defines string
  94148. */
  94149. getEffectDefines(): string;
  94150. /**
  94151. * Returns the string "SphereDirectedParticleEmitter"
  94152. * @returns a string containing the class name
  94153. */
  94154. getClassName(): string;
  94155. /**
  94156. * Serializes the particle system to a JSON object.
  94157. * @returns the JSON object
  94158. */
  94159. serialize(): any;
  94160. /**
  94161. * Parse properties from a JSON object
  94162. * @param serializationObject defines the JSON object
  94163. */
  94164. parse(serializationObject: any): void;
  94165. }
  94166. }
  94167. declare module BABYLON {
  94168. /**
  94169. * Particle emitter emitting particles from a custom list of positions.
  94170. */
  94171. export class CustomParticleEmitter implements IParticleEmitterType {
  94172. /**
  94173. * Gets or sets the position generator that will create the inital position of each particle.
  94174. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94175. */
  94176. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94177. /**
  94178. * Gets or sets the destination generator that will create the final destination of each particle.
  94179. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94180. */
  94181. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94182. /**
  94183. * Creates a new instance CustomParticleEmitter
  94184. */
  94185. constructor();
  94186. /**
  94187. * Called by the particle System when the direction is computed for the created particle.
  94188. * @param worldMatrix is the world matrix of the particle system
  94189. * @param directionToUpdate is the direction vector to update with the result
  94190. * @param particle is the particle we are computed the direction for
  94191. * @param isLocal defines if the direction should be set in local space
  94192. */
  94193. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94194. /**
  94195. * Called by the particle System when the position is computed for the created particle.
  94196. * @param worldMatrix is the world matrix of the particle system
  94197. * @param positionToUpdate is the position vector to update with the result
  94198. * @param particle is the particle we are computed the position for
  94199. * @param isLocal defines if the position should be set in local space
  94200. */
  94201. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94202. /**
  94203. * Clones the current emitter and returns a copy of it
  94204. * @returns the new emitter
  94205. */
  94206. clone(): CustomParticleEmitter;
  94207. /**
  94208. * Called by the GPUParticleSystem to setup the update shader
  94209. * @param effect defines the update shader
  94210. */
  94211. applyToShader(effect: Effect): void;
  94212. /**
  94213. * Returns a string to use to update the GPU particles update shader
  94214. * @returns a string containng the defines string
  94215. */
  94216. getEffectDefines(): string;
  94217. /**
  94218. * Returns the string "PointParticleEmitter"
  94219. * @returns a string containing the class name
  94220. */
  94221. getClassName(): string;
  94222. /**
  94223. * Serializes the particle system to a JSON object.
  94224. * @returns the JSON object
  94225. */
  94226. serialize(): any;
  94227. /**
  94228. * Parse properties from a JSON object
  94229. * @param serializationObject defines the JSON object
  94230. */
  94231. parse(serializationObject: any): void;
  94232. }
  94233. }
  94234. declare module BABYLON {
  94235. /**
  94236. * Particle emitter emitting particles from the inside of a box.
  94237. * It emits the particles randomly between 2 given directions.
  94238. */
  94239. export class MeshParticleEmitter implements IParticleEmitterType {
  94240. private _indices;
  94241. private _positions;
  94242. private _normals;
  94243. private _storedNormal;
  94244. private _mesh;
  94245. /**
  94246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94247. */
  94248. direction1: Vector3;
  94249. /**
  94250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94251. */
  94252. direction2: Vector3;
  94253. /**
  94254. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94255. */
  94256. useMeshNormalsForDirection: boolean;
  94257. /** Defines the mesh to use as source */
  94258. get mesh(): Nullable<AbstractMesh>;
  94259. set mesh(value: Nullable<AbstractMesh>);
  94260. /**
  94261. * Creates a new instance MeshParticleEmitter
  94262. * @param mesh defines the mesh to use as source
  94263. */
  94264. constructor(mesh?: Nullable<AbstractMesh>);
  94265. /**
  94266. * Called by the particle System when the direction is computed for the created particle.
  94267. * @param worldMatrix is the world matrix of the particle system
  94268. * @param directionToUpdate is the direction vector to update with the result
  94269. * @param particle is the particle we are computed the direction for
  94270. * @param isLocal defines if the direction should be set in local space
  94271. */
  94272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94273. /**
  94274. * Called by the particle System when the position is computed for the created particle.
  94275. * @param worldMatrix is the world matrix of the particle system
  94276. * @param positionToUpdate is the position vector to update with the result
  94277. * @param particle is the particle we are computed the position for
  94278. * @param isLocal defines if the position should be set in local space
  94279. */
  94280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94281. /**
  94282. * Clones the current emitter and returns a copy of it
  94283. * @returns the new emitter
  94284. */
  94285. clone(): MeshParticleEmitter;
  94286. /**
  94287. * Called by the GPUParticleSystem to setup the update shader
  94288. * @param effect defines the update shader
  94289. */
  94290. applyToShader(effect: Effect): void;
  94291. /**
  94292. * Returns a string to use to update the GPU particles update shader
  94293. * @returns a string containng the defines string
  94294. */
  94295. getEffectDefines(): string;
  94296. /**
  94297. * Returns the string "BoxParticleEmitter"
  94298. * @returns a string containing the class name
  94299. */
  94300. getClassName(): string;
  94301. /**
  94302. * Serializes the particle system to a JSON object.
  94303. * @returns the JSON object
  94304. */
  94305. serialize(): any;
  94306. /**
  94307. * Parse properties from a JSON object
  94308. * @param serializationObject defines the JSON object
  94309. * @param scene defines the hosting scene
  94310. */
  94311. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94312. }
  94313. }
  94314. declare module BABYLON {
  94315. /**
  94316. * Interface representing a particle system in Babylon.js.
  94317. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94318. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94319. */
  94320. export interface IParticleSystem {
  94321. /**
  94322. * List of animations used by the particle system.
  94323. */
  94324. animations: Animation[];
  94325. /**
  94326. * The id of the Particle system.
  94327. */
  94328. id: string;
  94329. /**
  94330. * The name of the Particle system.
  94331. */
  94332. name: string;
  94333. /**
  94334. * The emitter represents the Mesh or position we are attaching the particle system to.
  94335. */
  94336. emitter: Nullable<AbstractMesh | Vector3>;
  94337. /**
  94338. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94339. */
  94340. isBillboardBased: boolean;
  94341. /**
  94342. * The rendering group used by the Particle system to chose when to render.
  94343. */
  94344. renderingGroupId: number;
  94345. /**
  94346. * The layer mask we are rendering the particles through.
  94347. */
  94348. layerMask: number;
  94349. /**
  94350. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94351. */
  94352. updateSpeed: number;
  94353. /**
  94354. * The amount of time the particle system is running (depends of the overall update speed).
  94355. */
  94356. targetStopDuration: number;
  94357. /**
  94358. * The texture used to render each particle. (this can be a spritesheet)
  94359. */
  94360. particleTexture: Nullable<BaseTexture>;
  94361. /**
  94362. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94363. */
  94364. blendMode: number;
  94365. /**
  94366. * Minimum life time of emitting particles.
  94367. */
  94368. minLifeTime: number;
  94369. /**
  94370. * Maximum life time of emitting particles.
  94371. */
  94372. maxLifeTime: number;
  94373. /**
  94374. * Minimum Size of emitting particles.
  94375. */
  94376. minSize: number;
  94377. /**
  94378. * Maximum Size of emitting particles.
  94379. */
  94380. maxSize: number;
  94381. /**
  94382. * Minimum scale of emitting particles on X axis.
  94383. */
  94384. minScaleX: number;
  94385. /**
  94386. * Maximum scale of emitting particles on X axis.
  94387. */
  94388. maxScaleX: number;
  94389. /**
  94390. * Minimum scale of emitting particles on Y axis.
  94391. */
  94392. minScaleY: number;
  94393. /**
  94394. * Maximum scale of emitting particles on Y axis.
  94395. */
  94396. maxScaleY: number;
  94397. /**
  94398. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94399. */
  94400. color1: Color4;
  94401. /**
  94402. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94403. */
  94404. color2: Color4;
  94405. /**
  94406. * Color the particle will have at the end of its lifetime.
  94407. */
  94408. colorDead: Color4;
  94409. /**
  94410. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94411. */
  94412. emitRate: number;
  94413. /**
  94414. * You can use gravity if you want to give an orientation to your particles.
  94415. */
  94416. gravity: Vector3;
  94417. /**
  94418. * Minimum power of emitting particles.
  94419. */
  94420. minEmitPower: number;
  94421. /**
  94422. * Maximum power of emitting particles.
  94423. */
  94424. maxEmitPower: number;
  94425. /**
  94426. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94427. */
  94428. minAngularSpeed: number;
  94429. /**
  94430. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94431. */
  94432. maxAngularSpeed: number;
  94433. /**
  94434. * Gets or sets the minimal initial rotation in radians.
  94435. */
  94436. minInitialRotation: number;
  94437. /**
  94438. * Gets or sets the maximal initial rotation in radians.
  94439. */
  94440. maxInitialRotation: number;
  94441. /**
  94442. * The particle emitter type defines the emitter used by the particle system.
  94443. * It can be for example box, sphere, or cone...
  94444. */
  94445. particleEmitterType: Nullable<IParticleEmitterType>;
  94446. /**
  94447. * Defines the delay in milliseconds before starting the system (0 by default)
  94448. */
  94449. startDelay: number;
  94450. /**
  94451. * 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
  94452. */
  94453. preWarmCycles: number;
  94454. /**
  94455. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94456. */
  94457. preWarmStepOffset: number;
  94458. /**
  94459. * 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)
  94460. */
  94461. spriteCellChangeSpeed: number;
  94462. /**
  94463. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94464. */
  94465. startSpriteCellID: number;
  94466. /**
  94467. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94468. */
  94469. endSpriteCellID: number;
  94470. /**
  94471. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94472. */
  94473. spriteCellWidth: number;
  94474. /**
  94475. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94476. */
  94477. spriteCellHeight: number;
  94478. /**
  94479. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94480. */
  94481. spriteRandomStartCell: boolean;
  94482. /**
  94483. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94484. */
  94485. isAnimationSheetEnabled: boolean;
  94486. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94487. translationPivot: Vector2;
  94488. /**
  94489. * Gets or sets a texture used to add random noise to particle positions
  94490. */
  94491. noiseTexture: Nullable<BaseTexture>;
  94492. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94493. noiseStrength: Vector3;
  94494. /**
  94495. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94496. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94497. */
  94498. billboardMode: number;
  94499. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94500. limitVelocityDamping: number;
  94501. /**
  94502. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94503. */
  94504. beginAnimationOnStart: boolean;
  94505. /**
  94506. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94507. */
  94508. beginAnimationFrom: number;
  94509. /**
  94510. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94511. */
  94512. beginAnimationTo: number;
  94513. /**
  94514. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94515. */
  94516. beginAnimationLoop: boolean;
  94517. /**
  94518. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94519. */
  94520. disposeOnStop: boolean;
  94521. /**
  94522. * Specifies if the particles are updated in emitter local space or world space
  94523. */
  94524. isLocal: boolean;
  94525. /** Snippet ID if the particle system was created from the snippet server */
  94526. snippetId: string;
  94527. /** Gets or sets a matrix to use to compute projection */
  94528. defaultProjectionMatrix: Matrix;
  94529. /**
  94530. * Gets the maximum number of particles active at the same time.
  94531. * @returns The max number of active particles.
  94532. */
  94533. getCapacity(): number;
  94534. /**
  94535. * Gets the number of particles active at the same time.
  94536. * @returns The number of active particles.
  94537. */
  94538. getActiveCount(): number;
  94539. /**
  94540. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94541. * @returns True if it has been started, otherwise false.
  94542. */
  94543. isStarted(): boolean;
  94544. /**
  94545. * Animates the particle system for this frame.
  94546. */
  94547. animate(): void;
  94548. /**
  94549. * Renders the particle system in its current state.
  94550. * @returns the current number of particles
  94551. */
  94552. render(): number;
  94553. /**
  94554. * Dispose the particle system and frees its associated resources.
  94555. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94556. */
  94557. dispose(disposeTexture?: boolean): void;
  94558. /**
  94559. * An event triggered when the system is disposed
  94560. */
  94561. onDisposeObservable: Observable<IParticleSystem>;
  94562. /**
  94563. * Clones the particle system.
  94564. * @param name The name of the cloned object
  94565. * @param newEmitter The new emitter to use
  94566. * @returns the cloned particle system
  94567. */
  94568. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94569. /**
  94570. * Serializes the particle system to a JSON object
  94571. * @param serializeTexture defines if the texture must be serialized as well
  94572. * @returns the JSON object
  94573. */
  94574. serialize(serializeTexture: boolean): any;
  94575. /**
  94576. * Rebuild the particle system
  94577. */
  94578. rebuild(): void;
  94579. /** Force the system to rebuild all gradients that need to be resync */
  94580. forceRefreshGradients(): void;
  94581. /**
  94582. * Starts the particle system and begins to emit
  94583. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94584. */
  94585. start(delay?: number): void;
  94586. /**
  94587. * Stops the particle system.
  94588. */
  94589. stop(): void;
  94590. /**
  94591. * Remove all active particles
  94592. */
  94593. reset(): void;
  94594. /**
  94595. * Gets a boolean indicating that the system is stopping
  94596. * @returns true if the system is currently stopping
  94597. */
  94598. isStopping(): boolean;
  94599. /**
  94600. * Is this system ready to be used/rendered
  94601. * @return true if the system is ready
  94602. */
  94603. isReady(): boolean;
  94604. /**
  94605. * Returns the string "ParticleSystem"
  94606. * @returns a string containing the class name
  94607. */
  94608. getClassName(): string;
  94609. /**
  94610. * Gets the custom effect used to render the particles
  94611. * @param blendMode Blend mode for which the effect should be retrieved
  94612. * @returns The effect
  94613. */
  94614. getCustomEffect(blendMode: number): Nullable<Effect>;
  94615. /**
  94616. * Sets the custom effect used to render the particles
  94617. * @param effect The effect to set
  94618. * @param blendMode Blend mode for which the effect should be set
  94619. */
  94620. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94621. /**
  94622. * Fill the defines array according to the current settings of the particle system
  94623. * @param defines Array to be updated
  94624. * @param blendMode blend mode to take into account when updating the array
  94625. */
  94626. fillDefines(defines: Array<string>, blendMode: number): void;
  94627. /**
  94628. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94629. * @param uniforms Uniforms array to fill
  94630. * @param attributes Attributes array to fill
  94631. * @param samplers Samplers array to fill
  94632. */
  94633. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94634. /**
  94635. * Observable that will be called just before the particles are drawn
  94636. */
  94637. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94638. /**
  94639. * Gets the name of the particle vertex shader
  94640. */
  94641. vertexShaderName: string;
  94642. /**
  94643. * Adds a new color gradient
  94644. * @param gradient defines the gradient to use (between 0 and 1)
  94645. * @param color1 defines the color to affect to the specified gradient
  94646. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94647. * @returns the current particle system
  94648. */
  94649. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94650. /**
  94651. * Remove a specific color gradient
  94652. * @param gradient defines the gradient to remove
  94653. * @returns the current particle system
  94654. */
  94655. removeColorGradient(gradient: number): IParticleSystem;
  94656. /**
  94657. * Adds a new size gradient
  94658. * @param gradient defines the gradient to use (between 0 and 1)
  94659. * @param factor defines the size factor to affect to the specified gradient
  94660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94661. * @returns the current particle system
  94662. */
  94663. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94664. /**
  94665. * Remove a specific size gradient
  94666. * @param gradient defines the gradient to remove
  94667. * @returns the current particle system
  94668. */
  94669. removeSizeGradient(gradient: number): IParticleSystem;
  94670. /**
  94671. * Gets the current list of color gradients.
  94672. * You must use addColorGradient and removeColorGradient to udpate this list
  94673. * @returns the list of color gradients
  94674. */
  94675. getColorGradients(): Nullable<Array<ColorGradient>>;
  94676. /**
  94677. * Gets the current list of size gradients.
  94678. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94679. * @returns the list of size gradients
  94680. */
  94681. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94682. /**
  94683. * Gets the current list of angular speed gradients.
  94684. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94685. * @returns the list of angular speed gradients
  94686. */
  94687. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94688. /**
  94689. * Adds a new angular speed gradient
  94690. * @param gradient defines the gradient to use (between 0 and 1)
  94691. * @param factor defines the angular speed to affect to the specified gradient
  94692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94693. * @returns the current particle system
  94694. */
  94695. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94696. /**
  94697. * Remove a specific angular speed gradient
  94698. * @param gradient defines the gradient to remove
  94699. * @returns the current particle system
  94700. */
  94701. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94702. /**
  94703. * Gets the current list of velocity gradients.
  94704. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94705. * @returns the list of velocity gradients
  94706. */
  94707. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94708. /**
  94709. * Adds a new velocity gradient
  94710. * @param gradient defines the gradient to use (between 0 and 1)
  94711. * @param factor defines the velocity to affect to the specified gradient
  94712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94713. * @returns the current particle system
  94714. */
  94715. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94716. /**
  94717. * Remove a specific velocity gradient
  94718. * @param gradient defines the gradient to remove
  94719. * @returns the current particle system
  94720. */
  94721. removeVelocityGradient(gradient: number): IParticleSystem;
  94722. /**
  94723. * Gets the current list of limit velocity gradients.
  94724. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94725. * @returns the list of limit velocity gradients
  94726. */
  94727. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94728. /**
  94729. * Adds a new limit velocity gradient
  94730. * @param gradient defines the gradient to use (between 0 and 1)
  94731. * @param factor defines the limit velocity to affect to the specified gradient
  94732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94733. * @returns the current particle system
  94734. */
  94735. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94736. /**
  94737. * Remove a specific limit velocity gradient
  94738. * @param gradient defines the gradient to remove
  94739. * @returns the current particle system
  94740. */
  94741. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94742. /**
  94743. * Adds a new drag gradient
  94744. * @param gradient defines the gradient to use (between 0 and 1)
  94745. * @param factor defines the drag to affect to the specified gradient
  94746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94747. * @returns the current particle system
  94748. */
  94749. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94750. /**
  94751. * Remove a specific drag gradient
  94752. * @param gradient defines the gradient to remove
  94753. * @returns the current particle system
  94754. */
  94755. removeDragGradient(gradient: number): IParticleSystem;
  94756. /**
  94757. * Gets the current list of drag gradients.
  94758. * You must use addDragGradient and removeDragGradient to udpate this list
  94759. * @returns the list of drag gradients
  94760. */
  94761. getDragGradients(): Nullable<Array<FactorGradient>>;
  94762. /**
  94763. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94764. * @param gradient defines the gradient to use (between 0 and 1)
  94765. * @param factor defines the emit rate to affect to the specified gradient
  94766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94767. * @returns the current particle system
  94768. */
  94769. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94770. /**
  94771. * Remove a specific emit rate gradient
  94772. * @param gradient defines the gradient to remove
  94773. * @returns the current particle system
  94774. */
  94775. removeEmitRateGradient(gradient: number): IParticleSystem;
  94776. /**
  94777. * Gets the current list of emit rate gradients.
  94778. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94779. * @returns the list of emit rate gradients
  94780. */
  94781. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94782. /**
  94783. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94784. * @param gradient defines the gradient to use (between 0 and 1)
  94785. * @param factor defines the start size to affect to the specified gradient
  94786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94787. * @returns the current particle system
  94788. */
  94789. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94790. /**
  94791. * Remove a specific start size gradient
  94792. * @param gradient defines the gradient to remove
  94793. * @returns the current particle system
  94794. */
  94795. removeStartSizeGradient(gradient: number): IParticleSystem;
  94796. /**
  94797. * Gets the current list of start size gradients.
  94798. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94799. * @returns the list of start size gradients
  94800. */
  94801. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94802. /**
  94803. * Adds a new life time gradient
  94804. * @param gradient defines the gradient to use (between 0 and 1)
  94805. * @param factor defines the life time factor to affect to the specified gradient
  94806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94807. * @returns the current particle system
  94808. */
  94809. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94810. /**
  94811. * Remove a specific life time gradient
  94812. * @param gradient defines the gradient to remove
  94813. * @returns the current particle system
  94814. */
  94815. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94816. /**
  94817. * Gets the current list of life time gradients.
  94818. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94819. * @returns the list of life time gradients
  94820. */
  94821. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94822. /**
  94823. * Gets the current list of color gradients.
  94824. * You must use addColorGradient and removeColorGradient to udpate this list
  94825. * @returns the list of color gradients
  94826. */
  94827. getColorGradients(): Nullable<Array<ColorGradient>>;
  94828. /**
  94829. * Adds a new ramp gradient used to remap particle colors
  94830. * @param gradient defines the gradient to use (between 0 and 1)
  94831. * @param color defines the color to affect to the specified gradient
  94832. * @returns the current particle system
  94833. */
  94834. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94835. /**
  94836. * Gets the current list of ramp gradients.
  94837. * You must use addRampGradient and removeRampGradient to udpate this list
  94838. * @returns the list of ramp gradients
  94839. */
  94840. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94841. /** Gets or sets a boolean indicating that ramp gradients must be used
  94842. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94843. */
  94844. useRampGradients: boolean;
  94845. /**
  94846. * Adds a new color remap gradient
  94847. * @param gradient defines the gradient to use (between 0 and 1)
  94848. * @param min defines the color remap minimal range
  94849. * @param max defines the color remap maximal range
  94850. * @returns the current particle system
  94851. */
  94852. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94853. /**
  94854. * Gets the current list of color remap gradients.
  94855. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94856. * @returns the list of color remap gradients
  94857. */
  94858. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94859. /**
  94860. * Adds a new alpha remap gradient
  94861. * @param gradient defines the gradient to use (between 0 and 1)
  94862. * @param min defines the alpha remap minimal range
  94863. * @param max defines the alpha remap maximal range
  94864. * @returns the current particle system
  94865. */
  94866. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94867. /**
  94868. * Gets the current list of alpha remap gradients.
  94869. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94870. * @returns the list of alpha remap gradients
  94871. */
  94872. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94873. /**
  94874. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94877. * @returns the emitter
  94878. */
  94879. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94880. /**
  94881. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94882. * @param radius The radius of the hemisphere to emit from
  94883. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94884. * @returns the emitter
  94885. */
  94886. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94887. /**
  94888. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94889. * @param radius The radius of the sphere to emit from
  94890. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94891. * @returns the emitter
  94892. */
  94893. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94894. /**
  94895. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94896. * @param radius The radius of the sphere to emit from
  94897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94899. * @returns the emitter
  94900. */
  94901. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94902. /**
  94903. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94904. * @param radius The radius of the emission cylinder
  94905. * @param height The height of the emission cylinder
  94906. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94907. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94908. * @returns the emitter
  94909. */
  94910. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94911. /**
  94912. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94913. * @param radius The radius of the cylinder to emit from
  94914. * @param height The height of the emission cylinder
  94915. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94916. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94917. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94918. * @returns the emitter
  94919. */
  94920. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94921. /**
  94922. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94923. * @param radius The radius of the cone to emit from
  94924. * @param angle The base angle of the cone
  94925. * @returns the emitter
  94926. */
  94927. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94928. /**
  94929. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94930. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94931. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94932. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94933. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94934. * @returns the emitter
  94935. */
  94936. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94937. /**
  94938. * Get hosting scene
  94939. * @returns the scene
  94940. */
  94941. getScene(): Nullable<Scene>;
  94942. }
  94943. }
  94944. declare module BABYLON {
  94945. /**
  94946. * 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.
  94947. * @see https://doc.babylonjs.com/how_to/transformnode
  94948. */
  94949. export class TransformNode extends Node {
  94950. /**
  94951. * Object will not rotate to face the camera
  94952. */
  94953. static BILLBOARDMODE_NONE: number;
  94954. /**
  94955. * Object will rotate to face the camera but only on the x axis
  94956. */
  94957. static BILLBOARDMODE_X: number;
  94958. /**
  94959. * Object will rotate to face the camera but only on the y axis
  94960. */
  94961. static BILLBOARDMODE_Y: number;
  94962. /**
  94963. * Object will rotate to face the camera but only on the z axis
  94964. */
  94965. static BILLBOARDMODE_Z: number;
  94966. /**
  94967. * Object will rotate to face the camera
  94968. */
  94969. static BILLBOARDMODE_ALL: number;
  94970. /**
  94971. * Object will rotate to face the camera's position instead of orientation
  94972. */
  94973. static BILLBOARDMODE_USE_POSITION: number;
  94974. private static _TmpRotation;
  94975. private static _TmpScaling;
  94976. private static _TmpTranslation;
  94977. private _forward;
  94978. private _forwardInverted;
  94979. private _up;
  94980. private _right;
  94981. private _rightInverted;
  94982. private _position;
  94983. private _rotation;
  94984. private _rotationQuaternion;
  94985. protected _scaling: Vector3;
  94986. protected _isDirty: boolean;
  94987. private _transformToBoneReferal;
  94988. private _isAbsoluteSynced;
  94989. private _billboardMode;
  94990. /**
  94991. * Gets or sets the billboard mode. Default is 0.
  94992. *
  94993. * | Value | Type | Description |
  94994. * | --- | --- | --- |
  94995. * | 0 | BILLBOARDMODE_NONE | |
  94996. * | 1 | BILLBOARDMODE_X | |
  94997. * | 2 | BILLBOARDMODE_Y | |
  94998. * | 4 | BILLBOARDMODE_Z | |
  94999. * | 7 | BILLBOARDMODE_ALL | |
  95000. *
  95001. */
  95002. get billboardMode(): number;
  95003. set billboardMode(value: number);
  95004. private _preserveParentRotationForBillboard;
  95005. /**
  95006. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95007. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95008. */
  95009. get preserveParentRotationForBillboard(): boolean;
  95010. set preserveParentRotationForBillboard(value: boolean);
  95011. /**
  95012. * 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
  95013. */
  95014. scalingDeterminant: number;
  95015. private _infiniteDistance;
  95016. /**
  95017. * Gets or sets the distance of the object to max, often used by skybox
  95018. */
  95019. get infiniteDistance(): boolean;
  95020. set infiniteDistance(value: boolean);
  95021. /**
  95022. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95023. * By default the system will update normals to compensate
  95024. */
  95025. ignoreNonUniformScaling: boolean;
  95026. /**
  95027. * 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
  95028. */
  95029. reIntegrateRotationIntoRotationQuaternion: boolean;
  95030. /** @hidden */
  95031. _poseMatrix: Nullable<Matrix>;
  95032. /** @hidden */
  95033. _localMatrix: Matrix;
  95034. private _usePivotMatrix;
  95035. private _absolutePosition;
  95036. private _absoluteScaling;
  95037. private _absoluteRotationQuaternion;
  95038. private _pivotMatrix;
  95039. private _pivotMatrixInverse;
  95040. /** @hidden */
  95041. _postMultiplyPivotMatrix: boolean;
  95042. protected _isWorldMatrixFrozen: boolean;
  95043. /** @hidden */
  95044. _indexInSceneTransformNodesArray: number;
  95045. /**
  95046. * An event triggered after the world matrix is updated
  95047. */
  95048. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95049. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95050. /**
  95051. * Gets a string identifying the name of the class
  95052. * @returns "TransformNode" string
  95053. */
  95054. getClassName(): string;
  95055. /**
  95056. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95057. */
  95058. get position(): Vector3;
  95059. set position(newPosition: Vector3);
  95060. /**
  95061. * 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)).
  95062. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95063. */
  95064. get rotation(): Vector3;
  95065. set rotation(newRotation: Vector3);
  95066. /**
  95067. * 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)).
  95068. */
  95069. get scaling(): Vector3;
  95070. set scaling(newScaling: Vector3);
  95071. /**
  95072. * 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).
  95073. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95074. */
  95075. get rotationQuaternion(): Nullable<Quaternion>;
  95076. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95077. /**
  95078. * The forward direction of that transform in world space.
  95079. */
  95080. get forward(): Vector3;
  95081. /**
  95082. * The up direction of that transform in world space.
  95083. */
  95084. get up(): Vector3;
  95085. /**
  95086. * The right direction of that transform in world space.
  95087. */
  95088. get right(): Vector3;
  95089. /**
  95090. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95091. * @param matrix the matrix to copy the pose from
  95092. * @returns this TransformNode.
  95093. */
  95094. updatePoseMatrix(matrix: Matrix): TransformNode;
  95095. /**
  95096. * Returns the mesh Pose matrix.
  95097. * @returns the pose matrix
  95098. */
  95099. getPoseMatrix(): Matrix;
  95100. /** @hidden */
  95101. _isSynchronized(): boolean;
  95102. /** @hidden */
  95103. _initCache(): void;
  95104. /**
  95105. * Flag the transform node as dirty (Forcing it to update everything)
  95106. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95107. * @returns this transform node
  95108. */
  95109. markAsDirty(property: string): TransformNode;
  95110. /**
  95111. * Returns the current mesh absolute position.
  95112. * Returns a Vector3.
  95113. */
  95114. get absolutePosition(): Vector3;
  95115. /**
  95116. * Returns the current mesh absolute scaling.
  95117. * Returns a Vector3.
  95118. */
  95119. get absoluteScaling(): Vector3;
  95120. /**
  95121. * Returns the current mesh absolute rotation.
  95122. * Returns a Quaternion.
  95123. */
  95124. get absoluteRotationQuaternion(): Quaternion;
  95125. /**
  95126. * Sets a new matrix to apply before all other transformation
  95127. * @param matrix defines the transform matrix
  95128. * @returns the current TransformNode
  95129. */
  95130. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95131. /**
  95132. * Sets a new pivot matrix to the current node
  95133. * @param matrix defines the new pivot matrix to use
  95134. * @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
  95135. * @returns the current TransformNode
  95136. */
  95137. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95138. /**
  95139. * Returns the mesh pivot matrix.
  95140. * Default : Identity.
  95141. * @returns the matrix
  95142. */
  95143. getPivotMatrix(): Matrix;
  95144. /**
  95145. * Instantiate (when possible) or clone that node with its hierarchy
  95146. * @param newParent defines the new parent to use for the instance (or clone)
  95147. * @param options defines options to configure how copy is done
  95148. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95149. * @returns an instance (or a clone) of the current node with its hiearchy
  95150. */
  95151. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95152. doNotInstantiate: boolean;
  95153. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95154. /**
  95155. * Prevents the World matrix to be computed any longer
  95156. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95157. * @returns the TransformNode.
  95158. */
  95159. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95160. /**
  95161. * Allows back the World matrix computation.
  95162. * @returns the TransformNode.
  95163. */
  95164. unfreezeWorldMatrix(): this;
  95165. /**
  95166. * True if the World matrix has been frozen.
  95167. */
  95168. get isWorldMatrixFrozen(): boolean;
  95169. /**
  95170. * Retuns the mesh absolute position in the World.
  95171. * @returns a Vector3.
  95172. */
  95173. getAbsolutePosition(): Vector3;
  95174. /**
  95175. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95176. * @param absolutePosition the absolute position to set
  95177. * @returns the TransformNode.
  95178. */
  95179. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95180. /**
  95181. * Sets the mesh position in its local space.
  95182. * @param vector3 the position to set in localspace
  95183. * @returns the TransformNode.
  95184. */
  95185. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95186. /**
  95187. * Returns the mesh position in the local space from the current World matrix values.
  95188. * @returns a new Vector3.
  95189. */
  95190. getPositionExpressedInLocalSpace(): Vector3;
  95191. /**
  95192. * Translates the mesh along the passed Vector3 in its local space.
  95193. * @param vector3 the distance to translate in localspace
  95194. * @returns the TransformNode.
  95195. */
  95196. locallyTranslate(vector3: Vector3): TransformNode;
  95197. private static _lookAtVectorCache;
  95198. /**
  95199. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95200. * @param targetPoint the position (must be in same space as current mesh) to look at
  95201. * @param yawCor optional yaw (y-axis) correction in radians
  95202. * @param pitchCor optional pitch (x-axis) correction in radians
  95203. * @param rollCor optional roll (z-axis) correction in radians
  95204. * @param space the choosen space of the target
  95205. * @returns the TransformNode.
  95206. */
  95207. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95208. /**
  95209. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95210. * This Vector3 is expressed in the World space.
  95211. * @param localAxis axis to rotate
  95212. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95213. */
  95214. getDirection(localAxis: Vector3): Vector3;
  95215. /**
  95216. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95217. * localAxis is expressed in the mesh local space.
  95218. * result is computed in the Wordl space from the mesh World matrix.
  95219. * @param localAxis axis to rotate
  95220. * @param result the resulting transformnode
  95221. * @returns this TransformNode.
  95222. */
  95223. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95224. /**
  95225. * Sets this transform node rotation to the given local axis.
  95226. * @param localAxis the axis in local space
  95227. * @param yawCor optional yaw (y-axis) correction in radians
  95228. * @param pitchCor optional pitch (x-axis) correction in radians
  95229. * @param rollCor optional roll (z-axis) correction in radians
  95230. * @returns this TransformNode
  95231. */
  95232. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95233. /**
  95234. * Sets a new pivot point to the current node
  95235. * @param point defines the new pivot point to use
  95236. * @param space defines if the point is in world or local space (local by default)
  95237. * @returns the current TransformNode
  95238. */
  95239. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95240. /**
  95241. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95242. * @returns the pivot point
  95243. */
  95244. getPivotPoint(): Vector3;
  95245. /**
  95246. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95247. * @param result the vector3 to store the result
  95248. * @returns this TransformNode.
  95249. */
  95250. getPivotPointToRef(result: Vector3): TransformNode;
  95251. /**
  95252. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95253. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95254. */
  95255. getAbsolutePivotPoint(): Vector3;
  95256. /**
  95257. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95258. * @param result vector3 to store the result
  95259. * @returns this TransformNode.
  95260. */
  95261. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95262. /**
  95263. * Defines the passed node as the parent of the current node.
  95264. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95265. * @see https://doc.babylonjs.com/how_to/parenting
  95266. * @param node the node ot set as the parent
  95267. * @returns this TransformNode.
  95268. */
  95269. setParent(node: Nullable<Node>): TransformNode;
  95270. private _nonUniformScaling;
  95271. /**
  95272. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95273. */
  95274. get nonUniformScaling(): boolean;
  95275. /** @hidden */
  95276. _updateNonUniformScalingState(value: boolean): boolean;
  95277. /**
  95278. * Attach the current TransformNode to another TransformNode associated with a bone
  95279. * @param bone Bone affecting the TransformNode
  95280. * @param affectedTransformNode TransformNode associated with the bone
  95281. * @returns this object
  95282. */
  95283. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95284. /**
  95285. * Detach the transform node if its associated with a bone
  95286. * @returns this object
  95287. */
  95288. detachFromBone(): TransformNode;
  95289. private static _rotationAxisCache;
  95290. /**
  95291. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95292. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95293. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95294. * The passed axis is also normalized.
  95295. * @param axis the axis to rotate around
  95296. * @param amount the amount to rotate in radians
  95297. * @param space Space to rotate in (Default: local)
  95298. * @returns the TransformNode.
  95299. */
  95300. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95301. /**
  95302. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95303. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95304. * The passed axis is also normalized. .
  95305. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95306. * @param point the point to rotate around
  95307. * @param axis the axis to rotate around
  95308. * @param amount the amount to rotate in radians
  95309. * @returns the TransformNode
  95310. */
  95311. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95312. /**
  95313. * Translates the mesh along the axis vector for the passed distance in the given space.
  95314. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95315. * @param axis the axis to translate in
  95316. * @param distance the distance to translate
  95317. * @param space Space to rotate in (Default: local)
  95318. * @returns the TransformNode.
  95319. */
  95320. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95321. /**
  95322. * Adds a rotation step to the mesh current rotation.
  95323. * x, y, z are Euler angles expressed in radians.
  95324. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95325. * This means this rotation is made in the mesh local space only.
  95326. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95327. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95328. * ```javascript
  95329. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95330. * ```
  95331. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95332. * 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.
  95333. * @param x Rotation to add
  95334. * @param y Rotation to add
  95335. * @param z Rotation to add
  95336. * @returns the TransformNode.
  95337. */
  95338. addRotation(x: number, y: number, z: number): TransformNode;
  95339. /**
  95340. * @hidden
  95341. */
  95342. protected _getEffectiveParent(): Nullable<Node>;
  95343. /**
  95344. * Computes the world matrix of the node
  95345. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95346. * @returns the world matrix
  95347. */
  95348. computeWorldMatrix(force?: boolean): Matrix;
  95349. /**
  95350. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95351. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95352. */
  95353. resetLocalMatrix(independentOfChildren?: boolean): void;
  95354. protected _afterComputeWorldMatrix(): void;
  95355. /**
  95356. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95357. * @param func callback function to add
  95358. *
  95359. * @returns the TransformNode.
  95360. */
  95361. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95362. /**
  95363. * Removes a registered callback function.
  95364. * @param func callback function to remove
  95365. * @returns the TransformNode.
  95366. */
  95367. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95368. /**
  95369. * Gets the position of the current mesh in camera space
  95370. * @param camera defines the camera to use
  95371. * @returns a position
  95372. */
  95373. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95374. /**
  95375. * Returns the distance from the mesh to the active camera
  95376. * @param camera defines the camera to use
  95377. * @returns the distance
  95378. */
  95379. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95380. /**
  95381. * Clone the current transform node
  95382. * @param name Name of the new clone
  95383. * @param newParent New parent for the clone
  95384. * @param doNotCloneChildren Do not clone children hierarchy
  95385. * @returns the new transform node
  95386. */
  95387. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95388. /**
  95389. * Serializes the objects information.
  95390. * @param currentSerializationObject defines the object to serialize in
  95391. * @returns the serialized object
  95392. */
  95393. serialize(currentSerializationObject?: any): any;
  95394. /**
  95395. * Returns a new TransformNode object parsed from the source provided.
  95396. * @param parsedTransformNode is the source.
  95397. * @param scene the scne the object belongs to
  95398. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95399. * @returns a new TransformNode object parsed from the source provided.
  95400. */
  95401. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95402. /**
  95403. * Get all child-transformNodes of this node
  95404. * @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
  95405. * @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
  95406. * @returns an array of TransformNode
  95407. */
  95408. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95409. /**
  95410. * Releases resources associated with this transform node.
  95411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95413. */
  95414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95415. /**
  95416. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95417. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95418. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95419. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95420. * @returns the current mesh
  95421. */
  95422. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95423. private _syncAbsoluteScalingAndRotation;
  95424. }
  95425. }
  95426. declare module BABYLON {
  95427. /**
  95428. * Class used to override all child animations of a given target
  95429. */
  95430. export class AnimationPropertiesOverride {
  95431. /**
  95432. * Gets or sets a value indicating if animation blending must be used
  95433. */
  95434. enableBlending: boolean;
  95435. /**
  95436. * Gets or sets the blending speed to use when enableBlending is true
  95437. */
  95438. blendingSpeed: number;
  95439. /**
  95440. * Gets or sets the default loop mode to use
  95441. */
  95442. loopMode: number;
  95443. }
  95444. }
  95445. declare module BABYLON {
  95446. /**
  95447. * Class used to store bone information
  95448. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95449. */
  95450. export class Bone extends Node {
  95451. /**
  95452. * defines the bone name
  95453. */
  95454. name: string;
  95455. private static _tmpVecs;
  95456. private static _tmpQuat;
  95457. private static _tmpMats;
  95458. /**
  95459. * Gets the list of child bones
  95460. */
  95461. children: Bone[];
  95462. /** Gets the animations associated with this bone */
  95463. animations: Animation[];
  95464. /**
  95465. * Gets or sets bone length
  95466. */
  95467. length: number;
  95468. /**
  95469. * @hidden Internal only
  95470. * Set this value to map this bone to a different index in the transform matrices
  95471. * Set this value to -1 to exclude the bone from the transform matrices
  95472. */
  95473. _index: Nullable<number>;
  95474. private _skeleton;
  95475. private _localMatrix;
  95476. private _restPose;
  95477. private _bindPose;
  95478. private _baseMatrix;
  95479. private _absoluteTransform;
  95480. private _invertedAbsoluteTransform;
  95481. private _parent;
  95482. private _scalingDeterminant;
  95483. private _worldTransform;
  95484. private _localScaling;
  95485. private _localRotation;
  95486. private _localPosition;
  95487. private _needToDecompose;
  95488. private _needToCompose;
  95489. /** @hidden */
  95490. _linkedTransformNode: Nullable<TransformNode>;
  95491. /** @hidden */
  95492. _waitingTransformNodeId: Nullable<string>;
  95493. /** @hidden */
  95494. get _matrix(): Matrix;
  95495. /** @hidden */
  95496. set _matrix(value: Matrix);
  95497. /**
  95498. * Create a new bone
  95499. * @param name defines the bone name
  95500. * @param skeleton defines the parent skeleton
  95501. * @param parentBone defines the parent (can be null if the bone is the root)
  95502. * @param localMatrix defines the local matrix
  95503. * @param restPose defines the rest pose matrix
  95504. * @param baseMatrix defines the base matrix
  95505. * @param index defines index of the bone in the hiearchy
  95506. */
  95507. constructor(
  95508. /**
  95509. * defines the bone name
  95510. */
  95511. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95512. /**
  95513. * Gets the current object class name.
  95514. * @return the class name
  95515. */
  95516. getClassName(): string;
  95517. /**
  95518. * Gets the parent skeleton
  95519. * @returns a skeleton
  95520. */
  95521. getSkeleton(): Skeleton;
  95522. /**
  95523. * Gets parent bone
  95524. * @returns a bone or null if the bone is the root of the bone hierarchy
  95525. */
  95526. getParent(): Nullable<Bone>;
  95527. /**
  95528. * Returns an array containing the root bones
  95529. * @returns an array containing the root bones
  95530. */
  95531. getChildren(): Array<Bone>;
  95532. /**
  95533. * Gets the node index in matrix array generated for rendering
  95534. * @returns the node index
  95535. */
  95536. getIndex(): number;
  95537. /**
  95538. * Sets the parent bone
  95539. * @param parent defines the parent (can be null if the bone is the root)
  95540. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95541. */
  95542. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95543. /**
  95544. * Gets the local matrix
  95545. * @returns a matrix
  95546. */
  95547. getLocalMatrix(): Matrix;
  95548. /**
  95549. * Gets the base matrix (initial matrix which remains unchanged)
  95550. * @returns a matrix
  95551. */
  95552. getBaseMatrix(): Matrix;
  95553. /**
  95554. * Gets the rest pose matrix
  95555. * @returns a matrix
  95556. */
  95557. getRestPose(): Matrix;
  95558. /**
  95559. * Sets the rest pose matrix
  95560. * @param matrix the local-space rest pose to set for this bone
  95561. */
  95562. setRestPose(matrix: Matrix): void;
  95563. /**
  95564. * Gets the bind pose matrix
  95565. * @returns the bind pose matrix
  95566. */
  95567. getBindPose(): Matrix;
  95568. /**
  95569. * Sets the bind pose matrix
  95570. * @param matrix the local-space bind pose to set for this bone
  95571. */
  95572. setBindPose(matrix: Matrix): void;
  95573. /**
  95574. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95575. */
  95576. getWorldMatrix(): Matrix;
  95577. /**
  95578. * Sets the local matrix to rest pose matrix
  95579. */
  95580. returnToRest(): void;
  95581. /**
  95582. * Gets the inverse of the absolute transform matrix.
  95583. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95584. * @returns a matrix
  95585. */
  95586. getInvertedAbsoluteTransform(): Matrix;
  95587. /**
  95588. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95589. * @returns a matrix
  95590. */
  95591. getAbsoluteTransform(): Matrix;
  95592. /**
  95593. * Links with the given transform node.
  95594. * The local matrix of this bone is copied from the transform node every frame.
  95595. * @param transformNode defines the transform node to link to
  95596. */
  95597. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95598. /**
  95599. * Gets the node used to drive the bone's transformation
  95600. * @returns a transform node or null
  95601. */
  95602. getTransformNode(): Nullable<TransformNode>;
  95603. /** Gets or sets current position (in local space) */
  95604. get position(): Vector3;
  95605. set position(newPosition: Vector3);
  95606. /** Gets or sets current rotation (in local space) */
  95607. get rotation(): Vector3;
  95608. set rotation(newRotation: Vector3);
  95609. /** Gets or sets current rotation quaternion (in local space) */
  95610. get rotationQuaternion(): Quaternion;
  95611. set rotationQuaternion(newRotation: Quaternion);
  95612. /** Gets or sets current scaling (in local space) */
  95613. get scaling(): Vector3;
  95614. set scaling(newScaling: Vector3);
  95615. /**
  95616. * Gets the animation properties override
  95617. */
  95618. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95619. private _decompose;
  95620. private _compose;
  95621. /**
  95622. * Update the base and local matrices
  95623. * @param matrix defines the new base or local matrix
  95624. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95625. * @param updateLocalMatrix defines if the local matrix should be updated
  95626. */
  95627. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95628. /** @hidden */
  95629. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95630. /**
  95631. * Flag the bone as dirty (Forcing it to update everything)
  95632. */
  95633. markAsDirty(): void;
  95634. /** @hidden */
  95635. _markAsDirtyAndCompose(): void;
  95636. private _markAsDirtyAndDecompose;
  95637. /**
  95638. * Translate the bone in local or world space
  95639. * @param vec The amount to translate the bone
  95640. * @param space The space that the translation is in
  95641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95642. */
  95643. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95644. /**
  95645. * Set the postion of the bone in local or world space
  95646. * @param position The position to set the bone
  95647. * @param space The space that the position is in
  95648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95649. */
  95650. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95651. /**
  95652. * Set the absolute position of the bone (world space)
  95653. * @param position The position to set the bone
  95654. * @param mesh The mesh that this bone is attached to
  95655. */
  95656. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95657. /**
  95658. * Scale the bone on the x, y and z axes (in local space)
  95659. * @param x The amount to scale the bone on the x axis
  95660. * @param y The amount to scale the bone on the y axis
  95661. * @param z The amount to scale the bone on the z axis
  95662. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95663. */
  95664. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95665. /**
  95666. * Set the bone scaling in local space
  95667. * @param scale defines the scaling vector
  95668. */
  95669. setScale(scale: Vector3): void;
  95670. /**
  95671. * Gets the current scaling in local space
  95672. * @returns the current scaling vector
  95673. */
  95674. getScale(): Vector3;
  95675. /**
  95676. * Gets the current scaling in local space and stores it in a target vector
  95677. * @param result defines the target vector
  95678. */
  95679. getScaleToRef(result: Vector3): void;
  95680. /**
  95681. * Set the yaw, pitch, and roll of the bone in local or world space
  95682. * @param yaw The rotation of the bone on the y axis
  95683. * @param pitch The rotation of the bone on the x axis
  95684. * @param roll The rotation of the bone on the z axis
  95685. * @param space The space that the axes of rotation are in
  95686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95687. */
  95688. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95689. /**
  95690. * Add a rotation to the bone on an axis in local or world space
  95691. * @param axis The axis to rotate the bone on
  95692. * @param amount The amount to rotate the bone
  95693. * @param space The space that the axis is in
  95694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95695. */
  95696. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95697. /**
  95698. * Set the rotation of the bone to a particular axis angle in local or world space
  95699. * @param axis The axis to rotate the bone on
  95700. * @param angle The angle that the bone should be rotated to
  95701. * @param space The space that the axis is in
  95702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95703. */
  95704. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95705. /**
  95706. * Set the euler rotation of the bone in local or world space
  95707. * @param rotation The euler rotation that the bone should be set to
  95708. * @param space The space that the rotation is in
  95709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95710. */
  95711. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95712. /**
  95713. * Set the quaternion rotation of the bone in local or world space
  95714. * @param quat The quaternion rotation that the bone should be set to
  95715. * @param space The space that the rotation is in
  95716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95717. */
  95718. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95719. /**
  95720. * Set the rotation matrix of the bone in local or world space
  95721. * @param rotMat The rotation matrix that the bone should be set to
  95722. * @param space The space that the rotation is in
  95723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95724. */
  95725. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95726. private _rotateWithMatrix;
  95727. private _getNegativeRotationToRef;
  95728. /**
  95729. * Get the position of the bone in local or world space
  95730. * @param space The space that the returned position is in
  95731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95732. * @returns The position of the bone
  95733. */
  95734. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95735. /**
  95736. * Copy the position of the bone to a vector3 in local or world space
  95737. * @param space The space that the returned position is in
  95738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95739. * @param result The vector3 to copy the position to
  95740. */
  95741. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95742. /**
  95743. * Get the absolute position of the bone (world space)
  95744. * @param mesh The mesh that this bone is attached to
  95745. * @returns The absolute position of the bone
  95746. */
  95747. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95748. /**
  95749. * Copy the absolute position of the bone (world space) to the result param
  95750. * @param mesh The mesh that this bone is attached to
  95751. * @param result The vector3 to copy the absolute position to
  95752. */
  95753. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95754. /**
  95755. * Compute the absolute transforms of this bone and its children
  95756. */
  95757. computeAbsoluteTransforms(): void;
  95758. /**
  95759. * Get the world direction from an axis that is in the local space of the bone
  95760. * @param localAxis The local direction that is used to compute the world direction
  95761. * @param mesh The mesh that this bone is attached to
  95762. * @returns The world direction
  95763. */
  95764. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95765. /**
  95766. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95767. * @param localAxis The local direction that is used to compute the world direction
  95768. * @param mesh The mesh that this bone is attached to
  95769. * @param result The vector3 that the world direction will be copied to
  95770. */
  95771. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95772. /**
  95773. * Get the euler rotation of the bone in local or world space
  95774. * @param space The space that the rotation should be in
  95775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95776. * @returns The euler rotation
  95777. */
  95778. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95779. /**
  95780. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95781. * @param space The space that the rotation should be in
  95782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95783. * @param result The vector3 that the rotation should be copied to
  95784. */
  95785. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95786. /**
  95787. * Get the quaternion rotation of the bone in either local or world space
  95788. * @param space The space that the rotation should be in
  95789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95790. * @returns The quaternion rotation
  95791. */
  95792. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95793. /**
  95794. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95795. * @param space The space that the rotation should be in
  95796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95797. * @param result The quaternion that the rotation should be copied to
  95798. */
  95799. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95800. /**
  95801. * Get the rotation matrix of the bone in local or world space
  95802. * @param space The space that the rotation should be in
  95803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95804. * @returns The rotation matrix
  95805. */
  95806. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95807. /**
  95808. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95809. * @param space The space that the rotation should be in
  95810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95811. * @param result The quaternion that the rotation should be copied to
  95812. */
  95813. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95814. /**
  95815. * Get the world position of a point that is in the local space of the bone
  95816. * @param position The local position
  95817. * @param mesh The mesh that this bone is attached to
  95818. * @returns The world position
  95819. */
  95820. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95821. /**
  95822. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95823. * @param position The local position
  95824. * @param mesh The mesh that this bone is attached to
  95825. * @param result The vector3 that the world position should be copied to
  95826. */
  95827. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95828. /**
  95829. * Get the local position of a point that is in world space
  95830. * @param position The world position
  95831. * @param mesh The mesh that this bone is attached to
  95832. * @returns The local position
  95833. */
  95834. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95835. /**
  95836. * Get the local position of a point that is in world space and copy it to the result param
  95837. * @param position The world position
  95838. * @param mesh The mesh that this bone is attached to
  95839. * @param result The vector3 that the local position should be copied to
  95840. */
  95841. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95842. /**
  95843. * Set the current local matrix as the restPose for this bone.
  95844. */
  95845. setCurrentPoseAsRest(): void;
  95846. }
  95847. }
  95848. declare module BABYLON {
  95849. /**
  95850. * Defines a runtime animation
  95851. */
  95852. export class RuntimeAnimation {
  95853. private _events;
  95854. /**
  95855. * The current frame of the runtime animation
  95856. */
  95857. private _currentFrame;
  95858. /**
  95859. * The animation used by the runtime animation
  95860. */
  95861. private _animation;
  95862. /**
  95863. * The target of the runtime animation
  95864. */
  95865. private _target;
  95866. /**
  95867. * The initiating animatable
  95868. */
  95869. private _host;
  95870. /**
  95871. * The original value of the runtime animation
  95872. */
  95873. private _originalValue;
  95874. /**
  95875. * The original blend value of the runtime animation
  95876. */
  95877. private _originalBlendValue;
  95878. /**
  95879. * The offsets cache of the runtime animation
  95880. */
  95881. private _offsetsCache;
  95882. /**
  95883. * The high limits cache of the runtime animation
  95884. */
  95885. private _highLimitsCache;
  95886. /**
  95887. * Specifies if the runtime animation has been stopped
  95888. */
  95889. private _stopped;
  95890. /**
  95891. * The blending factor of the runtime animation
  95892. */
  95893. private _blendingFactor;
  95894. /**
  95895. * The BabylonJS scene
  95896. */
  95897. private _scene;
  95898. /**
  95899. * The current value of the runtime animation
  95900. */
  95901. private _currentValue;
  95902. /** @hidden */
  95903. _animationState: _IAnimationState;
  95904. /**
  95905. * The active target of the runtime animation
  95906. */
  95907. private _activeTargets;
  95908. private _currentActiveTarget;
  95909. private _directTarget;
  95910. /**
  95911. * The target path of the runtime animation
  95912. */
  95913. private _targetPath;
  95914. /**
  95915. * The weight of the runtime animation
  95916. */
  95917. private _weight;
  95918. /**
  95919. * The ratio offset of the runtime animation
  95920. */
  95921. private _ratioOffset;
  95922. /**
  95923. * The previous delay of the runtime animation
  95924. */
  95925. private _previousDelay;
  95926. /**
  95927. * The previous ratio of the runtime animation
  95928. */
  95929. private _previousRatio;
  95930. private _enableBlending;
  95931. private _keys;
  95932. private _minFrame;
  95933. private _maxFrame;
  95934. private _minValue;
  95935. private _maxValue;
  95936. private _targetIsArray;
  95937. /**
  95938. * Gets the current frame of the runtime animation
  95939. */
  95940. get currentFrame(): number;
  95941. /**
  95942. * Gets the weight of the runtime animation
  95943. */
  95944. get weight(): number;
  95945. /**
  95946. * Gets the current value of the runtime animation
  95947. */
  95948. get currentValue(): any;
  95949. /**
  95950. * Gets the target path of the runtime animation
  95951. */
  95952. get targetPath(): string;
  95953. /**
  95954. * Gets the actual target of the runtime animation
  95955. */
  95956. get target(): any;
  95957. /**
  95958. * Gets the additive state of the runtime animation
  95959. */
  95960. get isAdditive(): boolean;
  95961. /** @hidden */
  95962. _onLoop: () => void;
  95963. /**
  95964. * Create a new RuntimeAnimation object
  95965. * @param target defines the target of the animation
  95966. * @param animation defines the source animation object
  95967. * @param scene defines the hosting scene
  95968. * @param host defines the initiating Animatable
  95969. */
  95970. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95971. private _preparePath;
  95972. /**
  95973. * Gets the animation from the runtime animation
  95974. */
  95975. get animation(): Animation;
  95976. /**
  95977. * Resets the runtime animation to the beginning
  95978. * @param restoreOriginal defines whether to restore the target property to the original value
  95979. */
  95980. reset(restoreOriginal?: boolean): void;
  95981. /**
  95982. * Specifies if the runtime animation is stopped
  95983. * @returns Boolean specifying if the runtime animation is stopped
  95984. */
  95985. isStopped(): boolean;
  95986. /**
  95987. * Disposes of the runtime animation
  95988. */
  95989. dispose(): void;
  95990. /**
  95991. * Apply the interpolated value to the target
  95992. * @param currentValue defines the value computed by the animation
  95993. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95994. */
  95995. setValue(currentValue: any, weight: number): void;
  95996. private _getOriginalValues;
  95997. private _setValue;
  95998. /**
  95999. * Gets the loop pmode of the runtime animation
  96000. * @returns Loop Mode
  96001. */
  96002. private _getCorrectLoopMode;
  96003. /**
  96004. * Move the current animation to a given frame
  96005. * @param frame defines the frame to move to
  96006. */
  96007. goToFrame(frame: number): void;
  96008. /**
  96009. * @hidden Internal use only
  96010. */
  96011. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96012. /**
  96013. * Execute the current animation
  96014. * @param delay defines the delay to add to the current frame
  96015. * @param from defines the lower bound of the animation range
  96016. * @param to defines the upper bound of the animation range
  96017. * @param loop defines if the current animation must loop
  96018. * @param speedRatio defines the current speed ratio
  96019. * @param weight defines the weight of the animation (default is -1 so no weight)
  96020. * @param onLoop optional callback called when animation loops
  96021. * @returns a boolean indicating if the animation is running
  96022. */
  96023. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96024. }
  96025. }
  96026. declare module BABYLON {
  96027. /**
  96028. * Class used to store an actual running animation
  96029. */
  96030. export class Animatable {
  96031. /** defines the target object */
  96032. target: any;
  96033. /** defines the starting frame number (default is 0) */
  96034. fromFrame: number;
  96035. /** defines the ending frame number (default is 100) */
  96036. toFrame: number;
  96037. /** defines if the animation must loop (default is false) */
  96038. loopAnimation: boolean;
  96039. /** defines a callback to call when animation ends if it is not looping */
  96040. onAnimationEnd?: (() => void) | null | undefined;
  96041. /** defines a callback to call when animation loops */
  96042. onAnimationLoop?: (() => void) | null | undefined;
  96043. /** defines whether the animation should be evaluated additively */
  96044. isAdditive: boolean;
  96045. private _localDelayOffset;
  96046. private _pausedDelay;
  96047. private _runtimeAnimations;
  96048. private _paused;
  96049. private _scene;
  96050. private _speedRatio;
  96051. private _weight;
  96052. private _syncRoot;
  96053. /**
  96054. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96055. * This will only apply for non looping animation (default is true)
  96056. */
  96057. disposeOnEnd: boolean;
  96058. /**
  96059. * Gets a boolean indicating if the animation has started
  96060. */
  96061. animationStarted: boolean;
  96062. /**
  96063. * Observer raised when the animation ends
  96064. */
  96065. onAnimationEndObservable: Observable<Animatable>;
  96066. /**
  96067. * Observer raised when the animation loops
  96068. */
  96069. onAnimationLoopObservable: Observable<Animatable>;
  96070. /**
  96071. * Gets the root Animatable used to synchronize and normalize animations
  96072. */
  96073. get syncRoot(): Nullable<Animatable>;
  96074. /**
  96075. * Gets the current frame of the first RuntimeAnimation
  96076. * Used to synchronize Animatables
  96077. */
  96078. get masterFrame(): number;
  96079. /**
  96080. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96081. */
  96082. get weight(): number;
  96083. set weight(value: number);
  96084. /**
  96085. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96086. */
  96087. get speedRatio(): number;
  96088. set speedRatio(value: number);
  96089. /**
  96090. * Creates a new Animatable
  96091. * @param scene defines the hosting scene
  96092. * @param target defines the target object
  96093. * @param fromFrame defines the starting frame number (default is 0)
  96094. * @param toFrame defines the ending frame number (default is 100)
  96095. * @param loopAnimation defines if the animation must loop (default is false)
  96096. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96097. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96098. * @param animations defines a group of animation to add to the new Animatable
  96099. * @param onAnimationLoop defines a callback to call when animation loops
  96100. * @param isAdditive defines whether the animation should be evaluated additively
  96101. */
  96102. constructor(scene: Scene,
  96103. /** defines the target object */
  96104. target: any,
  96105. /** defines the starting frame number (default is 0) */
  96106. fromFrame?: number,
  96107. /** defines the ending frame number (default is 100) */
  96108. toFrame?: number,
  96109. /** defines if the animation must loop (default is false) */
  96110. loopAnimation?: boolean, speedRatio?: number,
  96111. /** defines a callback to call when animation ends if it is not looping */
  96112. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96113. /** defines a callback to call when animation loops */
  96114. onAnimationLoop?: (() => void) | null | undefined,
  96115. /** defines whether the animation should be evaluated additively */
  96116. isAdditive?: boolean);
  96117. /**
  96118. * Synchronize and normalize current Animatable with a source Animatable
  96119. * This is useful when using animation weights and when animations are not of the same length
  96120. * @param root defines the root Animatable to synchronize with
  96121. * @returns the current Animatable
  96122. */
  96123. syncWith(root: Animatable): Animatable;
  96124. /**
  96125. * Gets the list of runtime animations
  96126. * @returns an array of RuntimeAnimation
  96127. */
  96128. getAnimations(): RuntimeAnimation[];
  96129. /**
  96130. * Adds more animations to the current animatable
  96131. * @param target defines the target of the animations
  96132. * @param animations defines the new animations to add
  96133. */
  96134. appendAnimations(target: any, animations: Animation[]): void;
  96135. /**
  96136. * Gets the source animation for a specific property
  96137. * @param property defines the propertyu to look for
  96138. * @returns null or the source animation for the given property
  96139. */
  96140. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96141. /**
  96142. * Gets the runtime animation for a specific property
  96143. * @param property defines the propertyu to look for
  96144. * @returns null or the runtime animation for the given property
  96145. */
  96146. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96147. /**
  96148. * Resets the animatable to its original state
  96149. */
  96150. reset(): void;
  96151. /**
  96152. * Allows the animatable to blend with current running animations
  96153. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96154. * @param blendingSpeed defines the blending speed to use
  96155. */
  96156. enableBlending(blendingSpeed: number): void;
  96157. /**
  96158. * Disable animation blending
  96159. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96160. */
  96161. disableBlending(): void;
  96162. /**
  96163. * Jump directly to a given frame
  96164. * @param frame defines the frame to jump to
  96165. */
  96166. goToFrame(frame: number): void;
  96167. /**
  96168. * Pause the animation
  96169. */
  96170. pause(): void;
  96171. /**
  96172. * Restart the animation
  96173. */
  96174. restart(): void;
  96175. private _raiseOnAnimationEnd;
  96176. /**
  96177. * Stop and delete the current animation
  96178. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96179. * @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)
  96180. */
  96181. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96182. /**
  96183. * Wait asynchronously for the animation to end
  96184. * @returns a promise which will be fullfilled when the animation ends
  96185. */
  96186. waitAsync(): Promise<Animatable>;
  96187. /** @hidden */
  96188. _animate(delay: number): boolean;
  96189. }
  96190. interface Scene {
  96191. /** @hidden */
  96192. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96193. /** @hidden */
  96194. _processLateAnimationBindingsForMatrices(holder: {
  96195. totalWeight: number;
  96196. totalAdditiveWeight: number;
  96197. animations: RuntimeAnimation[];
  96198. additiveAnimations: RuntimeAnimation[];
  96199. originalValue: Matrix;
  96200. }): any;
  96201. /** @hidden */
  96202. _processLateAnimationBindingsForQuaternions(holder: {
  96203. totalWeight: number;
  96204. totalAdditiveWeight: number;
  96205. animations: RuntimeAnimation[];
  96206. additiveAnimations: RuntimeAnimation[];
  96207. originalValue: Quaternion;
  96208. }, refQuaternion: Quaternion): Quaternion;
  96209. /** @hidden */
  96210. _processLateAnimationBindings(): void;
  96211. /**
  96212. * Will start the animation sequence of a given target
  96213. * @param target defines the target
  96214. * @param from defines from which frame should animation start
  96215. * @param to defines until which frame should animation run.
  96216. * @param weight defines the weight to apply to the animation (1.0 by default)
  96217. * @param loop defines if the animation loops
  96218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96219. * @param onAnimationEnd defines the function to be executed when the animation ends
  96220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96221. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96222. * @param onAnimationLoop defines the callback to call when an animation loops
  96223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96224. * @returns the animatable object created for this animation
  96225. */
  96226. 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;
  96227. /**
  96228. * Will start the animation sequence of a given target
  96229. * @param target defines the target
  96230. * @param from defines from which frame should animation start
  96231. * @param to defines until which frame should animation run.
  96232. * @param loop defines if the animation loops
  96233. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96234. * @param onAnimationEnd defines the function to be executed when the animation ends
  96235. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96236. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96237. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96238. * @param onAnimationLoop defines the callback to call when an animation loops
  96239. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96240. * @returns the animatable object created for this animation
  96241. */
  96242. 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;
  96243. /**
  96244. * Will start the animation sequence of a given target and its hierarchy
  96245. * @param target defines the target
  96246. * @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.
  96247. * @param from defines from which frame should animation start
  96248. * @param to defines until which frame should animation run.
  96249. * @param loop defines if the animation loops
  96250. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96251. * @param onAnimationEnd defines the function to be executed when the animation ends
  96252. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96253. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96254. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96255. * @param onAnimationLoop defines the callback to call when an animation loops
  96256. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96257. * @returns the list of created animatables
  96258. */
  96259. 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[];
  96260. /**
  96261. * Begin a new animation on a given node
  96262. * @param target defines the target where the animation will take place
  96263. * @param animations defines the list of animations to start
  96264. * @param from defines the initial value
  96265. * @param to defines the final value
  96266. * @param loop defines if you want animation to loop (off by default)
  96267. * @param speedRatio defines the speed ratio to apply to all animations
  96268. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96269. * @param onAnimationLoop defines the callback to call when an animation loops
  96270. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96271. * @returns the list of created animatables
  96272. */
  96273. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96274. /**
  96275. * Begin a new animation on a given node and its hierarchy
  96276. * @param target defines the root node where the animation will take place
  96277. * @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.
  96278. * @param animations defines the list of animations to start
  96279. * @param from defines the initial value
  96280. * @param to defines the final value
  96281. * @param loop defines if you want animation to loop (off by default)
  96282. * @param speedRatio defines the speed ratio to apply to all animations
  96283. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96284. * @param onAnimationLoop defines the callback to call when an animation loops
  96285. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96286. * @returns the list of animatables created for all nodes
  96287. */
  96288. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96289. /**
  96290. * Gets the animatable associated with a specific target
  96291. * @param target defines the target of the animatable
  96292. * @returns the required animatable if found
  96293. */
  96294. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96295. /**
  96296. * Gets all animatables associated with a given target
  96297. * @param target defines the target to look animatables for
  96298. * @returns an array of Animatables
  96299. */
  96300. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96301. /**
  96302. * Stops and removes all animations that have been applied to the scene
  96303. */
  96304. stopAllAnimations(): void;
  96305. /**
  96306. * Gets the current delta time used by animation engine
  96307. */
  96308. deltaTime: number;
  96309. }
  96310. interface Bone {
  96311. /**
  96312. * Copy an animation range from another bone
  96313. * @param source defines the source bone
  96314. * @param rangeName defines the range name to copy
  96315. * @param frameOffset defines the frame offset
  96316. * @param rescaleAsRequired defines if rescaling must be applied if required
  96317. * @param skelDimensionsRatio defines the scaling ratio
  96318. * @returns true if operation was successful
  96319. */
  96320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96321. }
  96322. }
  96323. declare module BABYLON {
  96324. /**
  96325. * Class used to handle skinning animations
  96326. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96327. */
  96328. export class Skeleton implements IAnimatable {
  96329. /** defines the skeleton name */
  96330. name: string;
  96331. /** defines the skeleton Id */
  96332. id: string;
  96333. /**
  96334. * Defines the list of child bones
  96335. */
  96336. bones: Bone[];
  96337. /**
  96338. * Defines an estimate of the dimension of the skeleton at rest
  96339. */
  96340. dimensionsAtRest: Vector3;
  96341. /**
  96342. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96343. */
  96344. needInitialSkinMatrix: boolean;
  96345. /**
  96346. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96347. */
  96348. overrideMesh: Nullable<AbstractMesh>;
  96349. /**
  96350. * Gets the list of animations attached to this skeleton
  96351. */
  96352. animations: Array<Animation>;
  96353. private _scene;
  96354. private _isDirty;
  96355. private _transformMatrices;
  96356. private _transformMatrixTexture;
  96357. private _meshesWithPoseMatrix;
  96358. private _animatables;
  96359. private _identity;
  96360. private _synchronizedWithMesh;
  96361. private _ranges;
  96362. private _lastAbsoluteTransformsUpdateId;
  96363. private _canUseTextureForBones;
  96364. private _uniqueId;
  96365. /** @hidden */
  96366. _numBonesWithLinkedTransformNode: number;
  96367. /** @hidden */
  96368. _hasWaitingData: Nullable<boolean>;
  96369. /** @hidden */
  96370. _waitingOverrideMeshId: Nullable<string>;
  96371. /**
  96372. * Specifies if the skeleton should be serialized
  96373. */
  96374. doNotSerialize: boolean;
  96375. private _useTextureToStoreBoneMatrices;
  96376. /**
  96377. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96378. * Please note that this option is not available if the hardware does not support it
  96379. */
  96380. get useTextureToStoreBoneMatrices(): boolean;
  96381. set useTextureToStoreBoneMatrices(value: boolean);
  96382. private _animationPropertiesOverride;
  96383. /**
  96384. * Gets or sets the animation properties override
  96385. */
  96386. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96387. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96388. /**
  96389. * List of inspectable custom properties (used by the Inspector)
  96390. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96391. */
  96392. inspectableCustomProperties: IInspectable[];
  96393. /**
  96394. * An observable triggered before computing the skeleton's matrices
  96395. */
  96396. onBeforeComputeObservable: Observable<Skeleton>;
  96397. /**
  96398. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96399. */
  96400. get isUsingTextureForMatrices(): boolean;
  96401. /**
  96402. * Gets the unique ID of this skeleton
  96403. */
  96404. get uniqueId(): number;
  96405. /**
  96406. * Creates a new skeleton
  96407. * @param name defines the skeleton name
  96408. * @param id defines the skeleton Id
  96409. * @param scene defines the hosting scene
  96410. */
  96411. constructor(
  96412. /** defines the skeleton name */
  96413. name: string,
  96414. /** defines the skeleton Id */
  96415. id: string, scene: Scene);
  96416. /**
  96417. * Gets the current object class name.
  96418. * @return the class name
  96419. */
  96420. getClassName(): string;
  96421. /**
  96422. * Returns an array containing the root bones
  96423. * @returns an array containing the root bones
  96424. */
  96425. getChildren(): Array<Bone>;
  96426. /**
  96427. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96428. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96429. * @returns a Float32Array containing matrices data
  96430. */
  96431. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96432. /**
  96433. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96434. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96435. * @returns a raw texture containing the data
  96436. */
  96437. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96438. /**
  96439. * Gets the current hosting scene
  96440. * @returns a scene object
  96441. */
  96442. getScene(): Scene;
  96443. /**
  96444. * Gets a string representing the current skeleton data
  96445. * @param fullDetails defines a boolean indicating if we want a verbose version
  96446. * @returns a string representing the current skeleton data
  96447. */
  96448. toString(fullDetails?: boolean): string;
  96449. /**
  96450. * Get bone's index searching by name
  96451. * @param name defines bone's name to search for
  96452. * @return the indice of the bone. Returns -1 if not found
  96453. */
  96454. getBoneIndexByName(name: string): number;
  96455. /**
  96456. * Creater a new animation range
  96457. * @param name defines the name of the range
  96458. * @param from defines the start key
  96459. * @param to defines the end key
  96460. */
  96461. createAnimationRange(name: string, from: number, to: number): void;
  96462. /**
  96463. * Delete a specific animation range
  96464. * @param name defines the name of the range
  96465. * @param deleteFrames defines if frames must be removed as well
  96466. */
  96467. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96468. /**
  96469. * Gets a specific animation range
  96470. * @param name defines the name of the range to look for
  96471. * @returns the requested animation range or null if not found
  96472. */
  96473. getAnimationRange(name: string): Nullable<AnimationRange>;
  96474. /**
  96475. * Gets the list of all animation ranges defined on this skeleton
  96476. * @returns an array
  96477. */
  96478. getAnimationRanges(): Nullable<AnimationRange>[];
  96479. /**
  96480. * Copy animation range from a source skeleton.
  96481. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96482. * @param source defines the source skeleton
  96483. * @param name defines the name of the range to copy
  96484. * @param rescaleAsRequired defines if rescaling must be applied if required
  96485. * @returns true if operation was successful
  96486. */
  96487. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96488. /**
  96489. * Forces the skeleton to go to rest pose
  96490. */
  96491. returnToRest(): void;
  96492. private _getHighestAnimationFrame;
  96493. /**
  96494. * Begin a specific animation range
  96495. * @param name defines the name of the range to start
  96496. * @param loop defines if looping must be turned on (false by default)
  96497. * @param speedRatio defines the speed ratio to apply (1 by default)
  96498. * @param onAnimationEnd defines a callback which will be called when animation will end
  96499. * @returns a new animatable
  96500. */
  96501. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96502. /**
  96503. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96504. * @param skeleton defines the Skeleton containing the animation range to convert
  96505. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96506. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96507. * @returns the original skeleton
  96508. */
  96509. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96510. /** @hidden */
  96511. _markAsDirty(): void;
  96512. /** @hidden */
  96513. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96514. /** @hidden */
  96515. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96516. private _computeTransformMatrices;
  96517. /**
  96518. * Build all resources required to render a skeleton
  96519. */
  96520. prepare(): void;
  96521. /**
  96522. * Gets the list of animatables currently running for this skeleton
  96523. * @returns an array of animatables
  96524. */
  96525. getAnimatables(): IAnimatable[];
  96526. /**
  96527. * Clone the current skeleton
  96528. * @param name defines the name of the new skeleton
  96529. * @param id defines the id of the new skeleton
  96530. * @returns the new skeleton
  96531. */
  96532. clone(name: string, id?: string): Skeleton;
  96533. /**
  96534. * Enable animation blending for this skeleton
  96535. * @param blendingSpeed defines the blending speed to apply
  96536. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96537. */
  96538. enableBlending(blendingSpeed?: number): void;
  96539. /**
  96540. * Releases all resources associated with the current skeleton
  96541. */
  96542. dispose(): void;
  96543. /**
  96544. * Serialize the skeleton in a JSON object
  96545. * @returns a JSON object
  96546. */
  96547. serialize(): any;
  96548. /**
  96549. * Creates a new skeleton from serialized data
  96550. * @param parsedSkeleton defines the serialized data
  96551. * @param scene defines the hosting scene
  96552. * @returns a new skeleton
  96553. */
  96554. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96555. /**
  96556. * Compute all node absolute transforms
  96557. * @param forceUpdate defines if computation must be done even if cache is up to date
  96558. */
  96559. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96560. /**
  96561. * Gets the root pose matrix
  96562. * @returns a matrix
  96563. */
  96564. getPoseMatrix(): Nullable<Matrix>;
  96565. /**
  96566. * Sorts bones per internal index
  96567. */
  96568. sortBones(): void;
  96569. private _sortBones;
  96570. /**
  96571. * Set the current local matrix as the restPose for all bones in the skeleton.
  96572. */
  96573. setCurrentPoseAsRest(): void;
  96574. }
  96575. }
  96576. declare module BABYLON {
  96577. /**
  96578. * Creates an instance based on a source mesh.
  96579. */
  96580. export class InstancedMesh extends AbstractMesh {
  96581. private _sourceMesh;
  96582. private _currentLOD;
  96583. /** @hidden */
  96584. _indexInSourceMeshInstanceArray: number;
  96585. constructor(name: string, source: Mesh);
  96586. /**
  96587. * Returns the string "InstancedMesh".
  96588. */
  96589. getClassName(): string;
  96590. /** Gets the list of lights affecting that mesh */
  96591. get lightSources(): Light[];
  96592. _resyncLightSources(): void;
  96593. _resyncLightSource(light: Light): void;
  96594. _removeLightSource(light: Light, dispose: boolean): void;
  96595. /**
  96596. * If the source mesh receives shadows
  96597. */
  96598. get receiveShadows(): boolean;
  96599. /**
  96600. * The material of the source mesh
  96601. */
  96602. get material(): Nullable<Material>;
  96603. /**
  96604. * Visibility of the source mesh
  96605. */
  96606. get visibility(): number;
  96607. /**
  96608. * Skeleton of the source mesh
  96609. */
  96610. get skeleton(): Nullable<Skeleton>;
  96611. /**
  96612. * Rendering ground id of the source mesh
  96613. */
  96614. get renderingGroupId(): number;
  96615. set renderingGroupId(value: number);
  96616. /**
  96617. * Returns the total number of vertices (integer).
  96618. */
  96619. getTotalVertices(): number;
  96620. /**
  96621. * Returns a positive integer : the total number of indices in this mesh geometry.
  96622. * @returns the numner of indices or zero if the mesh has no geometry.
  96623. */
  96624. getTotalIndices(): number;
  96625. /**
  96626. * The source mesh of the instance
  96627. */
  96628. get sourceMesh(): Mesh;
  96629. /**
  96630. * Creates a new InstancedMesh object from the mesh model.
  96631. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96632. * @param name defines the name of the new instance
  96633. * @returns a new InstancedMesh
  96634. */
  96635. createInstance(name: string): InstancedMesh;
  96636. /**
  96637. * Is this node ready to be used/rendered
  96638. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96639. * @return {boolean} is it ready
  96640. */
  96641. isReady(completeCheck?: boolean): boolean;
  96642. /**
  96643. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96644. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96645. * @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.
  96646. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96647. */
  96648. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96649. /**
  96650. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96651. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96652. * The `data` are either a numeric array either a Float32Array.
  96653. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96654. * 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).
  96655. * Note that a new underlying VertexBuffer object is created each call.
  96656. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96657. *
  96658. * Possible `kind` values :
  96659. * - VertexBuffer.PositionKind
  96660. * - VertexBuffer.UVKind
  96661. * - VertexBuffer.UV2Kind
  96662. * - VertexBuffer.UV3Kind
  96663. * - VertexBuffer.UV4Kind
  96664. * - VertexBuffer.UV5Kind
  96665. * - VertexBuffer.UV6Kind
  96666. * - VertexBuffer.ColorKind
  96667. * - VertexBuffer.MatricesIndicesKind
  96668. * - VertexBuffer.MatricesIndicesExtraKind
  96669. * - VertexBuffer.MatricesWeightsKind
  96670. * - VertexBuffer.MatricesWeightsExtraKind
  96671. *
  96672. * Returns the Mesh.
  96673. */
  96674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96675. /**
  96676. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96677. * If the mesh has no geometry, it is simply returned as it is.
  96678. * The `data` are either a numeric array either a Float32Array.
  96679. * No new underlying VertexBuffer object is created.
  96680. * 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.
  96681. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96682. *
  96683. * Possible `kind` values :
  96684. * - VertexBuffer.PositionKind
  96685. * - VertexBuffer.UVKind
  96686. * - VertexBuffer.UV2Kind
  96687. * - VertexBuffer.UV3Kind
  96688. * - VertexBuffer.UV4Kind
  96689. * - VertexBuffer.UV5Kind
  96690. * - VertexBuffer.UV6Kind
  96691. * - VertexBuffer.ColorKind
  96692. * - VertexBuffer.MatricesIndicesKind
  96693. * - VertexBuffer.MatricesIndicesExtraKind
  96694. * - VertexBuffer.MatricesWeightsKind
  96695. * - VertexBuffer.MatricesWeightsExtraKind
  96696. *
  96697. * Returns the Mesh.
  96698. */
  96699. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96700. /**
  96701. * Sets the mesh indices.
  96702. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96703. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96704. * This method creates a new index buffer each call.
  96705. * Returns the Mesh.
  96706. */
  96707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96708. /**
  96709. * Boolean : True if the mesh owns the requested kind of data.
  96710. */
  96711. isVerticesDataPresent(kind: string): boolean;
  96712. /**
  96713. * Returns an array of indices (IndicesArray).
  96714. */
  96715. getIndices(): Nullable<IndicesArray>;
  96716. get _positions(): Nullable<Vector3[]>;
  96717. /**
  96718. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96719. * This means the mesh underlying bounding box and sphere are recomputed.
  96720. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96721. * @returns the current mesh
  96722. */
  96723. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96724. /** @hidden */
  96725. _preActivate(): InstancedMesh;
  96726. /** @hidden */
  96727. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96728. /** @hidden */
  96729. _postActivate(): void;
  96730. getWorldMatrix(): Matrix;
  96731. get isAnInstance(): boolean;
  96732. /**
  96733. * Returns the current associated LOD AbstractMesh.
  96734. */
  96735. getLOD(camera: Camera): AbstractMesh;
  96736. /** @hidden */
  96737. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96738. /** @hidden */
  96739. _syncSubMeshes(): InstancedMesh;
  96740. /** @hidden */
  96741. _generatePointsArray(): boolean;
  96742. /** @hidden */
  96743. _updateBoundingInfo(): AbstractMesh;
  96744. /**
  96745. * Creates a new InstancedMesh from the current mesh.
  96746. * - name (string) : the cloned mesh name
  96747. * - newParent (optional Node) : the optional Node to parent the clone to.
  96748. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96749. *
  96750. * Returns the clone.
  96751. */
  96752. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96753. /**
  96754. * Disposes the InstancedMesh.
  96755. * Returns nothing.
  96756. */
  96757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96758. }
  96759. interface Mesh {
  96760. /**
  96761. * Register a custom buffer that will be instanced
  96762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96763. * @param kind defines the buffer kind
  96764. * @param stride defines the stride in floats
  96765. */
  96766. registerInstancedBuffer(kind: string, stride: number): void;
  96767. /**
  96768. * true to use the edge renderer for all instances of this mesh
  96769. */
  96770. edgesShareWithInstances: boolean;
  96771. /** @hidden */
  96772. _userInstancedBuffersStorage: {
  96773. data: {
  96774. [key: string]: Float32Array;
  96775. };
  96776. sizes: {
  96777. [key: string]: number;
  96778. };
  96779. vertexBuffers: {
  96780. [key: string]: Nullable<VertexBuffer>;
  96781. };
  96782. strides: {
  96783. [key: string]: number;
  96784. };
  96785. };
  96786. }
  96787. interface AbstractMesh {
  96788. /**
  96789. * Object used to store instanced buffers defined by user
  96790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96791. */
  96792. instancedBuffers: {
  96793. [key: string]: any;
  96794. };
  96795. }
  96796. }
  96797. declare module BABYLON {
  96798. /**
  96799. * Defines the options associated with the creation of a shader material.
  96800. */
  96801. export interface IShaderMaterialOptions {
  96802. /**
  96803. * Does the material work in alpha blend mode
  96804. */
  96805. needAlphaBlending: boolean;
  96806. /**
  96807. * Does the material work in alpha test mode
  96808. */
  96809. needAlphaTesting: boolean;
  96810. /**
  96811. * The list of attribute names used in the shader
  96812. */
  96813. attributes: string[];
  96814. /**
  96815. * The list of unifrom names used in the shader
  96816. */
  96817. uniforms: string[];
  96818. /**
  96819. * The list of UBO names used in the shader
  96820. */
  96821. uniformBuffers: string[];
  96822. /**
  96823. * The list of sampler names used in the shader
  96824. */
  96825. samplers: string[];
  96826. /**
  96827. * The list of defines used in the shader
  96828. */
  96829. defines: string[];
  96830. }
  96831. /**
  96832. * 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.
  96833. *
  96834. * This returned material effects how the mesh will look based on the code in the shaders.
  96835. *
  96836. * @see https://doc.babylonjs.com/how_to/shader_material
  96837. */
  96838. export class ShaderMaterial extends Material {
  96839. private _shaderPath;
  96840. private _options;
  96841. private _textures;
  96842. private _textureArrays;
  96843. private _floats;
  96844. private _ints;
  96845. private _floatsArrays;
  96846. private _colors3;
  96847. private _colors3Arrays;
  96848. private _colors4;
  96849. private _colors4Arrays;
  96850. private _vectors2;
  96851. private _vectors3;
  96852. private _vectors4;
  96853. private _matrices;
  96854. private _matrixArrays;
  96855. private _matrices3x3;
  96856. private _matrices2x2;
  96857. private _vectors2Arrays;
  96858. private _vectors3Arrays;
  96859. private _vectors4Arrays;
  96860. private _cachedWorldViewMatrix;
  96861. private _cachedWorldViewProjectionMatrix;
  96862. private _renderId;
  96863. private _multiview;
  96864. private _cachedDefines;
  96865. /** Define the Url to load snippets */
  96866. static SnippetUrl: string;
  96867. /** Snippet ID if the material was created from the snippet server */
  96868. snippetId: string;
  96869. /**
  96870. * Instantiate a new shader material.
  96871. * 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.
  96872. * This returned material effects how the mesh will look based on the code in the shaders.
  96873. * @see https://doc.babylonjs.com/how_to/shader_material
  96874. * @param name Define the name of the material in the scene
  96875. * @param scene Define the scene the material belongs to
  96876. * @param shaderPath Defines the route to the shader code in one of three ways:
  96877. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96878. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96879. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96880. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96881. * @param options Define the options used to create the shader
  96882. */
  96883. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96884. /**
  96885. * Gets the shader path used to define the shader code
  96886. * It can be modified to trigger a new compilation
  96887. */
  96888. get shaderPath(): any;
  96889. /**
  96890. * Sets the shader path used to define the shader code
  96891. * It can be modified to trigger a new compilation
  96892. */
  96893. set shaderPath(shaderPath: any);
  96894. /**
  96895. * Gets the options used to compile the shader.
  96896. * They can be modified to trigger a new compilation
  96897. */
  96898. get options(): IShaderMaterialOptions;
  96899. /**
  96900. * Gets the current class name of the material e.g. "ShaderMaterial"
  96901. * Mainly use in serialization.
  96902. * @returns the class name
  96903. */
  96904. getClassName(): string;
  96905. /**
  96906. * Specifies if the material will require alpha blending
  96907. * @returns a boolean specifying if alpha blending is needed
  96908. */
  96909. needAlphaBlending(): boolean;
  96910. /**
  96911. * Specifies if this material should be rendered in alpha test mode
  96912. * @returns a boolean specifying if an alpha test is needed.
  96913. */
  96914. needAlphaTesting(): boolean;
  96915. private _checkUniform;
  96916. /**
  96917. * Set a texture in the shader.
  96918. * @param name Define the name of the uniform samplers as defined in the shader
  96919. * @param texture Define the texture to bind to this sampler
  96920. * @return the material itself allowing "fluent" like uniform updates
  96921. */
  96922. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96923. /**
  96924. * Set a texture array in the shader.
  96925. * @param name Define the name of the uniform sampler array as defined in the shader
  96926. * @param textures Define the list of textures to bind to this sampler
  96927. * @return the material itself allowing "fluent" like uniform updates
  96928. */
  96929. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96930. /**
  96931. * Set a float in the shader.
  96932. * @param name Define the name of the uniform as defined in the shader
  96933. * @param value Define the value to give to the uniform
  96934. * @return the material itself allowing "fluent" like uniform updates
  96935. */
  96936. setFloat(name: string, value: number): ShaderMaterial;
  96937. /**
  96938. * Set a int in the shader.
  96939. * @param name Define the name of the uniform as defined in the shader
  96940. * @param value Define the value to give to the uniform
  96941. * @return the material itself allowing "fluent" like uniform updates
  96942. */
  96943. setInt(name: string, value: number): ShaderMaterial;
  96944. /**
  96945. * Set an array of floats in the shader.
  96946. * @param name Define the name of the uniform as defined in the shader
  96947. * @param value Define the value to give to the uniform
  96948. * @return the material itself allowing "fluent" like uniform updates
  96949. */
  96950. setFloats(name: string, value: number[]): ShaderMaterial;
  96951. /**
  96952. * Set a vec3 in the shader from a Color3.
  96953. * @param name Define the name of the uniform as defined in the shader
  96954. * @param value Define the value to give to the uniform
  96955. * @return the material itself allowing "fluent" like uniform updates
  96956. */
  96957. setColor3(name: string, value: Color3): ShaderMaterial;
  96958. /**
  96959. * Set a vec3 array in the shader from a Color3 array.
  96960. * @param name Define the name of the uniform as defined in the shader
  96961. * @param value Define the value to give to the uniform
  96962. * @return the material itself allowing "fluent" like uniform updates
  96963. */
  96964. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96965. /**
  96966. * Set a vec4 in the shader from a Color4.
  96967. * @param name Define the name of the uniform as defined in the shader
  96968. * @param value Define the value to give to the uniform
  96969. * @return the material itself allowing "fluent" like uniform updates
  96970. */
  96971. setColor4(name: string, value: Color4): ShaderMaterial;
  96972. /**
  96973. * Set a vec4 array in the shader from a Color4 array.
  96974. * @param name Define the name of the uniform as defined in the shader
  96975. * @param value Define the value to give to the uniform
  96976. * @return the material itself allowing "fluent" like uniform updates
  96977. */
  96978. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96979. /**
  96980. * Set a vec2 in the shader from a Vector2.
  96981. * @param name Define the name of the uniform as defined in the shader
  96982. * @param value Define the value to give to the uniform
  96983. * @return the material itself allowing "fluent" like uniform updates
  96984. */
  96985. setVector2(name: string, value: Vector2): ShaderMaterial;
  96986. /**
  96987. * Set a vec3 in the shader from a Vector3.
  96988. * @param name Define the name of the uniform as defined in the shader
  96989. * @param value Define the value to give to the uniform
  96990. * @return the material itself allowing "fluent" like uniform updates
  96991. */
  96992. setVector3(name: string, value: Vector3): ShaderMaterial;
  96993. /**
  96994. * Set a vec4 in the shader from a Vector4.
  96995. * @param name Define the name of the uniform as defined in the shader
  96996. * @param value Define the value to give to the uniform
  96997. * @return the material itself allowing "fluent" like uniform updates
  96998. */
  96999. setVector4(name: string, value: Vector4): ShaderMaterial;
  97000. /**
  97001. * Set a mat4 in the shader from a Matrix.
  97002. * @param name Define the name of the uniform as defined in the shader
  97003. * @param value Define the value to give to the uniform
  97004. * @return the material itself allowing "fluent" like uniform updates
  97005. */
  97006. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97007. /**
  97008. * Set a float32Array in the shader from a matrix array.
  97009. * @param name Define the name of the uniform as defined in the shader
  97010. * @param value Define the value to give to the uniform
  97011. * @return the material itself allowing "fluent" like uniform updates
  97012. */
  97013. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97014. /**
  97015. * Set a mat3 in the shader from a Float32Array.
  97016. * @param name Define the name of the uniform as defined in the shader
  97017. * @param value Define the value to give to the uniform
  97018. * @return the material itself allowing "fluent" like uniform updates
  97019. */
  97020. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97021. /**
  97022. * Set a mat2 in the shader from a Float32Array.
  97023. * @param name Define the name of the uniform as defined in the shader
  97024. * @param value Define the value to give to the uniform
  97025. * @return the material itself allowing "fluent" like uniform updates
  97026. */
  97027. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97028. /**
  97029. * Set a vec2 array in the shader from a number array.
  97030. * @param name Define the name of the uniform as defined in the shader
  97031. * @param value Define the value to give to the uniform
  97032. * @return the material itself allowing "fluent" like uniform updates
  97033. */
  97034. setArray2(name: string, value: number[]): ShaderMaterial;
  97035. /**
  97036. * Set a vec3 array in the shader from a number array.
  97037. * @param name Define the name of the uniform as defined in the shader
  97038. * @param value Define the value to give to the uniform
  97039. * @return the material itself allowing "fluent" like uniform updates
  97040. */
  97041. setArray3(name: string, value: number[]): ShaderMaterial;
  97042. /**
  97043. * Set a vec4 array in the shader from a number array.
  97044. * @param name Define the name of the uniform as defined in the shader
  97045. * @param value Define the value to give to the uniform
  97046. * @return the material itself allowing "fluent" like uniform updates
  97047. */
  97048. setArray4(name: string, value: number[]): ShaderMaterial;
  97049. private _checkCache;
  97050. /**
  97051. * Specifies that the submesh is ready to be used
  97052. * @param mesh defines the mesh to check
  97053. * @param subMesh defines which submesh to check
  97054. * @param useInstances specifies that instances should be used
  97055. * @returns a boolean indicating that the submesh is ready or not
  97056. */
  97057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97058. /**
  97059. * Checks if the material is ready to render the requested mesh
  97060. * @param mesh Define the mesh to render
  97061. * @param useInstances Define whether or not the material is used with instances
  97062. * @returns true if ready, otherwise false
  97063. */
  97064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97065. /**
  97066. * Binds the world matrix to the material
  97067. * @param world defines the world transformation matrix
  97068. * @param effectOverride - If provided, use this effect instead of internal effect
  97069. */
  97070. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97071. /**
  97072. * Binds the submesh to this material by preparing the effect and shader to draw
  97073. * @param world defines the world transformation matrix
  97074. * @param mesh defines the mesh containing the submesh
  97075. * @param subMesh defines the submesh to bind the material to
  97076. */
  97077. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97078. /**
  97079. * Binds the material to the mesh
  97080. * @param world defines the world transformation matrix
  97081. * @param mesh defines the mesh to bind the material to
  97082. * @param effectOverride - If provided, use this effect instead of internal effect
  97083. */
  97084. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97085. protected _afterBind(mesh?: Mesh): void;
  97086. /**
  97087. * Gets the active textures from the material
  97088. * @returns an array of textures
  97089. */
  97090. getActiveTextures(): BaseTexture[];
  97091. /**
  97092. * Specifies if the material uses a texture
  97093. * @param texture defines the texture to check against the material
  97094. * @returns a boolean specifying if the material uses the texture
  97095. */
  97096. hasTexture(texture: BaseTexture): boolean;
  97097. /**
  97098. * Makes a duplicate of the material, and gives it a new name
  97099. * @param name defines the new name for the duplicated material
  97100. * @returns the cloned material
  97101. */
  97102. clone(name: string): ShaderMaterial;
  97103. /**
  97104. * Disposes the material
  97105. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97106. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97107. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97108. */
  97109. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97110. /**
  97111. * Serializes this material in a JSON representation
  97112. * @returns the serialized material object
  97113. */
  97114. serialize(): any;
  97115. /**
  97116. * Creates a shader material from parsed shader material data
  97117. * @param source defines the JSON represnetation of the material
  97118. * @param scene defines the hosting scene
  97119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97120. * @returns a new material
  97121. */
  97122. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97123. /**
  97124. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97125. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97126. * @param url defines the url to load from
  97127. * @param scene defines the hosting scene
  97128. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97129. * @returns a promise that will resolve to the new ShaderMaterial
  97130. */
  97131. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97132. /**
  97133. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97134. * @param snippetId defines the snippet to load
  97135. * @param scene defines the hosting scene
  97136. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97137. * @returns a promise that will resolve to the new ShaderMaterial
  97138. */
  97139. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97140. }
  97141. }
  97142. declare module BABYLON {
  97143. /** @hidden */
  97144. export var colorPixelShader: {
  97145. name: string;
  97146. shader: string;
  97147. };
  97148. }
  97149. declare module BABYLON {
  97150. /** @hidden */
  97151. export var colorVertexShader: {
  97152. name: string;
  97153. shader: string;
  97154. };
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Line mesh
  97159. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97160. */
  97161. export class LinesMesh extends Mesh {
  97162. /**
  97163. * If vertex color should be applied to the mesh
  97164. */
  97165. readonly useVertexColor?: boolean | undefined;
  97166. /**
  97167. * If vertex alpha should be applied to the mesh
  97168. */
  97169. readonly useVertexAlpha?: boolean | undefined;
  97170. /**
  97171. * Color of the line (Default: White)
  97172. */
  97173. color: Color3;
  97174. /**
  97175. * Alpha of the line (Default: 1)
  97176. */
  97177. alpha: number;
  97178. /**
  97179. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97180. * This margin is expressed in world space coordinates, so its value may vary.
  97181. * Default value is 0.1
  97182. */
  97183. intersectionThreshold: number;
  97184. private _colorShader;
  97185. private color4;
  97186. /**
  97187. * Creates a new LinesMesh
  97188. * @param name defines the name
  97189. * @param scene defines the hosting scene
  97190. * @param parent defines the parent mesh if any
  97191. * @param source defines the optional source LinesMesh used to clone data from
  97192. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97193. * When false, achieved by calling a clone(), also passing False.
  97194. * This will make creation of children, recursive.
  97195. * @param useVertexColor defines if this LinesMesh supports vertex color
  97196. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97197. */
  97198. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97199. /**
  97200. * If vertex color should be applied to the mesh
  97201. */
  97202. useVertexColor?: boolean | undefined,
  97203. /**
  97204. * If vertex alpha should be applied to the mesh
  97205. */
  97206. useVertexAlpha?: boolean | undefined);
  97207. private _addClipPlaneDefine;
  97208. private _removeClipPlaneDefine;
  97209. isReady(): boolean;
  97210. /**
  97211. * Returns the string "LineMesh"
  97212. */
  97213. getClassName(): string;
  97214. /**
  97215. * @hidden
  97216. */
  97217. get material(): Material;
  97218. /**
  97219. * @hidden
  97220. */
  97221. set material(value: Material);
  97222. /**
  97223. * @hidden
  97224. */
  97225. get checkCollisions(): boolean;
  97226. /** @hidden */
  97227. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97228. /** @hidden */
  97229. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97230. /**
  97231. * Disposes of the line mesh
  97232. * @param doNotRecurse If children should be disposed
  97233. */
  97234. dispose(doNotRecurse?: boolean): void;
  97235. /**
  97236. * Returns a new LineMesh object cloned from the current one.
  97237. */
  97238. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97239. /**
  97240. * Creates a new InstancedLinesMesh object from the mesh model.
  97241. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97242. * @param name defines the name of the new instance
  97243. * @returns a new InstancedLinesMesh
  97244. */
  97245. createInstance(name: string): InstancedLinesMesh;
  97246. }
  97247. /**
  97248. * Creates an instance based on a source LinesMesh
  97249. */
  97250. export class InstancedLinesMesh extends InstancedMesh {
  97251. /**
  97252. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97253. * This margin is expressed in world space coordinates, so its value may vary.
  97254. * Initilized with the intersectionThreshold value of the source LinesMesh
  97255. */
  97256. intersectionThreshold: number;
  97257. constructor(name: string, source: LinesMesh);
  97258. /**
  97259. * Returns the string "InstancedLinesMesh".
  97260. */
  97261. getClassName(): string;
  97262. }
  97263. }
  97264. declare module BABYLON {
  97265. /** @hidden */
  97266. export var linePixelShader: {
  97267. name: string;
  97268. shader: string;
  97269. };
  97270. }
  97271. declare module BABYLON {
  97272. /** @hidden */
  97273. export var lineVertexShader: {
  97274. name: string;
  97275. shader: string;
  97276. };
  97277. }
  97278. declare module BABYLON {
  97279. interface Scene {
  97280. /** @hidden */
  97281. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97282. }
  97283. interface AbstractMesh {
  97284. /**
  97285. * Gets the edgesRenderer associated with the mesh
  97286. */
  97287. edgesRenderer: Nullable<EdgesRenderer>;
  97288. }
  97289. interface LinesMesh {
  97290. /**
  97291. * Enables the edge rendering mode on the mesh.
  97292. * This mode makes the mesh edges visible
  97293. * @param epsilon defines the maximal distance between two angles to detect a face
  97294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97295. * @returns the currentAbstractMesh
  97296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97297. */
  97298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97299. }
  97300. interface InstancedLinesMesh {
  97301. /**
  97302. * Enables the edge rendering mode on the mesh.
  97303. * This mode makes the mesh edges visible
  97304. * @param epsilon defines the maximal distance between two angles to detect a face
  97305. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97306. * @returns the current InstancedLinesMesh
  97307. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97308. */
  97309. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97310. }
  97311. /**
  97312. * Defines the minimum contract an Edges renderer should follow.
  97313. */
  97314. export interface IEdgesRenderer extends IDisposable {
  97315. /**
  97316. * Gets or sets a boolean indicating if the edgesRenderer is active
  97317. */
  97318. isEnabled: boolean;
  97319. /**
  97320. * Renders the edges of the attached mesh,
  97321. */
  97322. render(): void;
  97323. /**
  97324. * Checks wether or not the edges renderer is ready to render.
  97325. * @return true if ready, otherwise false.
  97326. */
  97327. isReady(): boolean;
  97328. /**
  97329. * List of instances to render in case the source mesh has instances
  97330. */
  97331. customInstances: SmartArray<Matrix>;
  97332. }
  97333. /**
  97334. * Defines the additional options of the edges renderer
  97335. */
  97336. export interface IEdgesRendererOptions {
  97337. /**
  97338. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97339. * If not defined, the default value is true
  97340. */
  97341. useAlternateEdgeFinder?: boolean;
  97342. /**
  97343. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97344. * If not defined, the default value is true.
  97345. * 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)
  97346. * This option is used only if useAlternateEdgeFinder = true
  97347. */
  97348. useFastVertexMerger?: boolean;
  97349. /**
  97350. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97351. * The default value is 1e-6
  97352. * This option is used only if useAlternateEdgeFinder = true
  97353. */
  97354. epsilonVertexMerge?: number;
  97355. /**
  97356. * 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
  97357. * 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.
  97358. * This option is used only if useAlternateEdgeFinder = true
  97359. */
  97360. applyTessellation?: boolean;
  97361. /**
  97362. * 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
  97363. * The default value is 1e-6
  97364. * This option is used only if useAlternateEdgeFinder = true
  97365. */
  97366. epsilonVertexAligned?: number;
  97367. }
  97368. /**
  97369. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97370. */
  97371. export class EdgesRenderer implements IEdgesRenderer {
  97372. /**
  97373. * Define the size of the edges with an orthographic camera
  97374. */
  97375. edgesWidthScalerForOrthographic: number;
  97376. /**
  97377. * Define the size of the edges with a perspective camera
  97378. */
  97379. edgesWidthScalerForPerspective: number;
  97380. protected _source: AbstractMesh;
  97381. protected _linesPositions: number[];
  97382. protected _linesNormals: number[];
  97383. protected _linesIndices: number[];
  97384. protected _epsilon: number;
  97385. protected _indicesCount: number;
  97386. protected _lineShader: ShaderMaterial;
  97387. protected _ib: DataBuffer;
  97388. protected _buffers: {
  97389. [key: string]: Nullable<VertexBuffer>;
  97390. };
  97391. protected _buffersForInstances: {
  97392. [key: string]: Nullable<VertexBuffer>;
  97393. };
  97394. protected _checkVerticesInsteadOfIndices: boolean;
  97395. protected _options: Nullable<IEdgesRendererOptions>;
  97396. private _meshRebuildObserver;
  97397. private _meshDisposeObserver;
  97398. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97399. isEnabled: boolean;
  97400. /**
  97401. * List of instances to render in case the source mesh has instances
  97402. */
  97403. customInstances: SmartArray<Matrix>;
  97404. private static GetShader;
  97405. /**
  97406. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97407. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97408. * @param source Mesh used to create edges
  97409. * @param epsilon sum of angles in adjacency to check for edge
  97410. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97411. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97412. * @param options The options to apply when generating the edges
  97413. */
  97414. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97415. protected _prepareRessources(): void;
  97416. /** @hidden */
  97417. _rebuild(): void;
  97418. /**
  97419. * Releases the required resources for the edges renderer
  97420. */
  97421. dispose(): void;
  97422. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97423. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97424. /**
  97425. * Checks if the pair of p0 and p1 is en edge
  97426. * @param faceIndex
  97427. * @param edge
  97428. * @param faceNormals
  97429. * @param p0
  97430. * @param p1
  97431. * @private
  97432. */
  97433. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97434. /**
  97435. * push line into the position, normal and index buffer
  97436. * @protected
  97437. */
  97438. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97439. /**
  97440. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97441. */
  97442. private _tessellateTriangle;
  97443. private _generateEdgesLinesAlternate;
  97444. /**
  97445. * Generates lines edges from adjacencjes
  97446. * @private
  97447. */
  97448. _generateEdgesLines(): void;
  97449. /**
  97450. * Checks wether or not the edges renderer is ready to render.
  97451. * @return true if ready, otherwise false.
  97452. */
  97453. isReady(): boolean;
  97454. /**
  97455. * Renders the edges of the attached mesh,
  97456. */
  97457. render(): void;
  97458. }
  97459. /**
  97460. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97461. */
  97462. export class LineEdgesRenderer extends EdgesRenderer {
  97463. /**
  97464. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97465. * @param source LineMesh used to generate edges
  97466. * @param epsilon not important (specified angle for edge detection)
  97467. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97468. */
  97469. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97470. /**
  97471. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97472. */
  97473. _generateEdgesLines(): void;
  97474. }
  97475. }
  97476. declare module BABYLON {
  97477. /**
  97478. * This represents the object necessary to create a rendering group.
  97479. * This is exclusively used and created by the rendering manager.
  97480. * To modify the behavior, you use the available helpers in your scene or meshes.
  97481. * @hidden
  97482. */
  97483. export class RenderingGroup {
  97484. index: number;
  97485. private static _zeroVector;
  97486. private _scene;
  97487. private _opaqueSubMeshes;
  97488. private _transparentSubMeshes;
  97489. private _alphaTestSubMeshes;
  97490. private _depthOnlySubMeshes;
  97491. private _particleSystems;
  97492. private _spriteManagers;
  97493. private _opaqueSortCompareFn;
  97494. private _alphaTestSortCompareFn;
  97495. private _transparentSortCompareFn;
  97496. private _renderOpaque;
  97497. private _renderAlphaTest;
  97498. private _renderTransparent;
  97499. /** @hidden */
  97500. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97501. onBeforeTransparentRendering: () => void;
  97502. /**
  97503. * Set the opaque sort comparison function.
  97504. * If null the sub meshes will be render in the order they were created
  97505. */
  97506. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97507. /**
  97508. * Set the alpha test sort comparison function.
  97509. * If null the sub meshes will be render in the order they were created
  97510. */
  97511. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97512. /**
  97513. * Set the transparent sort comparison function.
  97514. * If null the sub meshes will be render in the order they were created
  97515. */
  97516. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97517. /**
  97518. * Creates a new rendering group.
  97519. * @param index The rendering group index
  97520. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97521. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97522. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97523. */
  97524. 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>);
  97525. /**
  97526. * Render all the sub meshes contained in the group.
  97527. * @param customRenderFunction Used to override the default render behaviour of the group.
  97528. * @returns true if rendered some submeshes.
  97529. */
  97530. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97531. /**
  97532. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97533. * @param subMeshes The submeshes to render
  97534. */
  97535. private renderOpaqueSorted;
  97536. /**
  97537. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97538. * @param subMeshes The submeshes to render
  97539. */
  97540. private renderAlphaTestSorted;
  97541. /**
  97542. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97543. * @param subMeshes The submeshes to render
  97544. */
  97545. private renderTransparentSorted;
  97546. /**
  97547. * Renders the submeshes in a specified order.
  97548. * @param subMeshes The submeshes to sort before render
  97549. * @param sortCompareFn The comparison function use to sort
  97550. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97551. * @param transparent Specifies to activate blending if true
  97552. */
  97553. private static renderSorted;
  97554. /**
  97555. * Renders the submeshes in the order they were dispatched (no sort applied).
  97556. * @param subMeshes The submeshes to render
  97557. */
  97558. private static renderUnsorted;
  97559. /**
  97560. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97561. * are rendered back to front if in the same alpha index.
  97562. *
  97563. * @param a The first submesh
  97564. * @param b The second submesh
  97565. * @returns The result of the comparison
  97566. */
  97567. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97568. /**
  97569. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97570. * are rendered back to front.
  97571. *
  97572. * @param a The first submesh
  97573. * @param b The second submesh
  97574. * @returns The result of the comparison
  97575. */
  97576. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97577. /**
  97578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97579. * are rendered front to back (prevent overdraw).
  97580. *
  97581. * @param a The first submesh
  97582. * @param b The second submesh
  97583. * @returns The result of the comparison
  97584. */
  97585. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97586. /**
  97587. * Resets the different lists of submeshes to prepare a new frame.
  97588. */
  97589. prepare(): void;
  97590. dispose(): void;
  97591. /**
  97592. * Inserts the submesh in its correct queue depending on its material.
  97593. * @param subMesh The submesh to dispatch
  97594. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97595. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97596. */
  97597. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97598. dispatchSprites(spriteManager: ISpriteManager): void;
  97599. dispatchParticles(particleSystem: IParticleSystem): void;
  97600. private _renderParticles;
  97601. private _renderSprites;
  97602. }
  97603. }
  97604. declare module BABYLON {
  97605. /**
  97606. * Interface describing the different options available in the rendering manager
  97607. * regarding Auto Clear between groups.
  97608. */
  97609. export interface IRenderingManagerAutoClearSetup {
  97610. /**
  97611. * Defines whether or not autoclear is enable.
  97612. */
  97613. autoClear: boolean;
  97614. /**
  97615. * Defines whether or not to autoclear the depth buffer.
  97616. */
  97617. depth: boolean;
  97618. /**
  97619. * Defines whether or not to autoclear the stencil buffer.
  97620. */
  97621. stencil: boolean;
  97622. }
  97623. /**
  97624. * This class is used by the onRenderingGroupObservable
  97625. */
  97626. export class RenderingGroupInfo {
  97627. /**
  97628. * The Scene that being rendered
  97629. */
  97630. scene: Scene;
  97631. /**
  97632. * The camera currently used for the rendering pass
  97633. */
  97634. camera: Nullable<Camera>;
  97635. /**
  97636. * The ID of the renderingGroup being processed
  97637. */
  97638. renderingGroupId: number;
  97639. }
  97640. /**
  97641. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97642. * It is enable to manage the different groups as well as the different necessary sort functions.
  97643. * This should not be used directly aside of the few static configurations
  97644. */
  97645. export class RenderingManager {
  97646. /**
  97647. * The max id used for rendering groups (not included)
  97648. */
  97649. static MAX_RENDERINGGROUPS: number;
  97650. /**
  97651. * The min id used for rendering groups (included)
  97652. */
  97653. static MIN_RENDERINGGROUPS: number;
  97654. /**
  97655. * Used to globally prevent autoclearing scenes.
  97656. */
  97657. static AUTOCLEAR: boolean;
  97658. /**
  97659. * @hidden
  97660. */
  97661. _useSceneAutoClearSetup: boolean;
  97662. private _scene;
  97663. private _renderingGroups;
  97664. private _depthStencilBufferAlreadyCleaned;
  97665. private _autoClearDepthStencil;
  97666. private _customOpaqueSortCompareFn;
  97667. private _customAlphaTestSortCompareFn;
  97668. private _customTransparentSortCompareFn;
  97669. private _renderingGroupInfo;
  97670. /**
  97671. * Instantiates a new rendering group for a particular scene
  97672. * @param scene Defines the scene the groups belongs to
  97673. */
  97674. constructor(scene: Scene);
  97675. private _clearDepthStencilBuffer;
  97676. /**
  97677. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97678. * @hidden
  97679. */
  97680. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97681. /**
  97682. * Resets the different information of the group to prepare a new frame
  97683. * @hidden
  97684. */
  97685. reset(): void;
  97686. /**
  97687. * Dispose and release the group and its associated resources.
  97688. * @hidden
  97689. */
  97690. dispose(): void;
  97691. /**
  97692. * Clear the info related to rendering groups preventing retention points during dispose.
  97693. */
  97694. freeRenderingGroups(): void;
  97695. private _prepareRenderingGroup;
  97696. /**
  97697. * Add a sprite manager to the rendering manager in order to render it this frame.
  97698. * @param spriteManager Define the sprite manager to render
  97699. */
  97700. dispatchSprites(spriteManager: ISpriteManager): void;
  97701. /**
  97702. * Add a particle system to the rendering manager in order to render it this frame.
  97703. * @param particleSystem Define the particle system to render
  97704. */
  97705. dispatchParticles(particleSystem: IParticleSystem): void;
  97706. /**
  97707. * Add a submesh to the manager in order to render it this frame
  97708. * @param subMesh The submesh to dispatch
  97709. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97710. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97711. */
  97712. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97713. /**
  97714. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97715. * This allowed control for front to back rendering or reversly depending of the special needs.
  97716. *
  97717. * @param renderingGroupId The rendering group id corresponding to its index
  97718. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97719. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97720. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97721. */
  97722. 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;
  97723. /**
  97724. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97725. *
  97726. * @param renderingGroupId The rendering group id corresponding to its index
  97727. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97728. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97729. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97730. */
  97731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97732. /**
  97733. * Gets the current auto clear configuration for one rendering group of the rendering
  97734. * manager.
  97735. * @param index the rendering group index to get the information for
  97736. * @returns The auto clear setup for the requested rendering group
  97737. */
  97738. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97739. }
  97740. }
  97741. declare module BABYLON {
  97742. /**
  97743. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97744. */
  97745. export interface ICustomShaderOptions {
  97746. /**
  97747. * Gets or sets the custom shader name to use
  97748. */
  97749. shaderName: string;
  97750. /**
  97751. * The list of attribute names used in the shader
  97752. */
  97753. attributes?: string[];
  97754. /**
  97755. * The list of unifrom names used in the shader
  97756. */
  97757. uniforms?: string[];
  97758. /**
  97759. * The list of sampler names used in the shader
  97760. */
  97761. samplers?: string[];
  97762. /**
  97763. * The list of defines used in the shader
  97764. */
  97765. defines?: string[];
  97766. }
  97767. /**
  97768. * Interface to implement to create a shadow generator compatible with BJS.
  97769. */
  97770. export interface IShadowGenerator {
  97771. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97772. id: string;
  97773. /**
  97774. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97775. * @returns The render target texture if present otherwise, null
  97776. */
  97777. getShadowMap(): Nullable<RenderTargetTexture>;
  97778. /**
  97779. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97780. * @param subMesh The submesh we want to render in the shadow map
  97781. * @param useInstances Defines wether will draw in the map using instances
  97782. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97783. * @returns true if ready otherwise, false
  97784. */
  97785. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97786. /**
  97787. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97788. * @param defines Defines of the material we want to update
  97789. * @param lightIndex Index of the light in the enabled light list of the material
  97790. */
  97791. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97792. /**
  97793. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97794. * defined in the generator but impacting the effect).
  97795. * It implies the unifroms available on the materials are the standard BJS ones.
  97796. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97797. * @param effect The effect we are binfing the information for
  97798. */
  97799. bindShadowLight(lightIndex: string, effect: Effect): void;
  97800. /**
  97801. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97802. * (eq to shadow prjection matrix * light transform matrix)
  97803. * @returns The transform matrix used to create the shadow map
  97804. */
  97805. getTransformMatrix(): Matrix;
  97806. /**
  97807. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97808. * Cube and 2D textures for instance.
  97809. */
  97810. recreateShadowMap(): void;
  97811. /**
  97812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97813. * @param onCompiled Callback triggered at the and of the effects compilation
  97814. * @param options Sets of optional options forcing the compilation with different modes
  97815. */
  97816. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97817. useInstances: boolean;
  97818. }>): void;
  97819. /**
  97820. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97821. * @param options Sets of optional options forcing the compilation with different modes
  97822. * @returns A promise that resolves when the compilation completes
  97823. */
  97824. forceCompilationAsync(options?: Partial<{
  97825. useInstances: boolean;
  97826. }>): Promise<void>;
  97827. /**
  97828. * Serializes the shadow generator setup to a json object.
  97829. * @returns The serialized JSON object
  97830. */
  97831. serialize(): any;
  97832. /**
  97833. * Disposes the Shadow map and related Textures and effects.
  97834. */
  97835. dispose(): void;
  97836. }
  97837. /**
  97838. * Default implementation IShadowGenerator.
  97839. * This is the main object responsible of generating shadows in the framework.
  97840. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97841. */
  97842. export class ShadowGenerator implements IShadowGenerator {
  97843. /**
  97844. * Name of the shadow generator class
  97845. */
  97846. static CLASSNAME: string;
  97847. /**
  97848. * Shadow generator mode None: no filtering applied.
  97849. */
  97850. static readonly FILTER_NONE: number;
  97851. /**
  97852. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97853. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97854. */
  97855. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97856. /**
  97857. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97858. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97859. */
  97860. static readonly FILTER_POISSONSAMPLING: number;
  97861. /**
  97862. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97863. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97864. */
  97865. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97866. /**
  97867. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97868. * edge artifacts on steep falloff.
  97869. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97870. */
  97871. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97872. /**
  97873. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97874. * edge artifacts on steep falloff.
  97875. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97876. */
  97877. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97878. /**
  97879. * Shadow generator mode PCF: Percentage Closer Filtering
  97880. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97881. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97882. */
  97883. static readonly FILTER_PCF: number;
  97884. /**
  97885. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97886. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97887. * Contact Hardening
  97888. */
  97889. static readonly FILTER_PCSS: number;
  97890. /**
  97891. * Reserved for PCF and PCSS
  97892. * Highest Quality.
  97893. *
  97894. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97895. *
  97896. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97897. */
  97898. static readonly QUALITY_HIGH: number;
  97899. /**
  97900. * Reserved for PCF and PCSS
  97901. * Good tradeoff for quality/perf cross devices
  97902. *
  97903. * Execute PCF on a 3*3 kernel.
  97904. *
  97905. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97906. */
  97907. static readonly QUALITY_MEDIUM: number;
  97908. /**
  97909. * Reserved for PCF and PCSS
  97910. * The lowest quality but the fastest.
  97911. *
  97912. * Execute PCF on a 1*1 kernel.
  97913. *
  97914. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97915. */
  97916. static readonly QUALITY_LOW: number;
  97917. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97918. id: string;
  97919. /** Gets or sets the custom shader name to use */
  97920. customShaderOptions: ICustomShaderOptions;
  97921. /**
  97922. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97923. */
  97924. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97925. /**
  97926. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97927. */
  97928. onAfterShadowMapRenderObservable: Observable<Effect>;
  97929. /**
  97930. * Observable triggered before a mesh is rendered in the shadow map.
  97931. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97932. */
  97933. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97934. /**
  97935. * Observable triggered after a mesh is rendered in the shadow map.
  97936. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97937. */
  97938. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97939. protected _bias: number;
  97940. /**
  97941. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97942. */
  97943. get bias(): number;
  97944. /**
  97945. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97946. */
  97947. set bias(bias: number);
  97948. protected _normalBias: number;
  97949. /**
  97950. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97951. */
  97952. get normalBias(): number;
  97953. /**
  97954. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97955. */
  97956. set normalBias(normalBias: number);
  97957. protected _blurBoxOffset: number;
  97958. /**
  97959. * Gets the blur box offset: offset applied during the blur pass.
  97960. * Only useful if useKernelBlur = false
  97961. */
  97962. get blurBoxOffset(): number;
  97963. /**
  97964. * Sets the blur box offset: offset applied during the blur pass.
  97965. * Only useful if useKernelBlur = false
  97966. */
  97967. set blurBoxOffset(value: number);
  97968. protected _blurScale: number;
  97969. /**
  97970. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97971. * 2 means half of the size.
  97972. */
  97973. get blurScale(): number;
  97974. /**
  97975. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97976. * 2 means half of the size.
  97977. */
  97978. set blurScale(value: number);
  97979. protected _blurKernel: number;
  97980. /**
  97981. * Gets the blur kernel: kernel size of the blur pass.
  97982. * Only useful if useKernelBlur = true
  97983. */
  97984. get blurKernel(): number;
  97985. /**
  97986. * Sets the blur kernel: kernel size of the blur pass.
  97987. * Only useful if useKernelBlur = true
  97988. */
  97989. set blurKernel(value: number);
  97990. protected _useKernelBlur: boolean;
  97991. /**
  97992. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97993. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97994. */
  97995. get useKernelBlur(): boolean;
  97996. /**
  97997. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97998. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97999. */
  98000. set useKernelBlur(value: boolean);
  98001. protected _depthScale: number;
  98002. /**
  98003. * Gets the depth scale used in ESM mode.
  98004. */
  98005. get depthScale(): number;
  98006. /**
  98007. * Sets the depth scale used in ESM mode.
  98008. * This can override the scale stored on the light.
  98009. */
  98010. set depthScale(value: number);
  98011. protected _validateFilter(filter: number): number;
  98012. protected _filter: number;
  98013. /**
  98014. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98015. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98016. */
  98017. get filter(): number;
  98018. /**
  98019. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98020. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98021. */
  98022. set filter(value: number);
  98023. /**
  98024. * Gets if the current filter is set to Poisson Sampling.
  98025. */
  98026. get usePoissonSampling(): boolean;
  98027. /**
  98028. * Sets the current filter to Poisson Sampling.
  98029. */
  98030. set usePoissonSampling(value: boolean);
  98031. /**
  98032. * Gets if the current filter is set to ESM.
  98033. */
  98034. get useExponentialShadowMap(): boolean;
  98035. /**
  98036. * Sets the current filter is to ESM.
  98037. */
  98038. set useExponentialShadowMap(value: boolean);
  98039. /**
  98040. * Gets if the current filter is set to filtered ESM.
  98041. */
  98042. get useBlurExponentialShadowMap(): boolean;
  98043. /**
  98044. * Gets if the current filter is set to filtered ESM.
  98045. */
  98046. set useBlurExponentialShadowMap(value: boolean);
  98047. /**
  98048. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98049. * exponential to prevent steep falloff artifacts).
  98050. */
  98051. get useCloseExponentialShadowMap(): boolean;
  98052. /**
  98053. * Sets the current filter to "close ESM" (using the inverse of the
  98054. * exponential to prevent steep falloff artifacts).
  98055. */
  98056. set useCloseExponentialShadowMap(value: boolean);
  98057. /**
  98058. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98059. * exponential to prevent steep falloff artifacts).
  98060. */
  98061. get useBlurCloseExponentialShadowMap(): boolean;
  98062. /**
  98063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98064. * exponential to prevent steep falloff artifacts).
  98065. */
  98066. set useBlurCloseExponentialShadowMap(value: boolean);
  98067. /**
  98068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98069. */
  98070. get usePercentageCloserFiltering(): boolean;
  98071. /**
  98072. * Sets the current filter to "PCF" (percentage closer filtering).
  98073. */
  98074. set usePercentageCloserFiltering(value: boolean);
  98075. protected _filteringQuality: number;
  98076. /**
  98077. * Gets the PCF or PCSS Quality.
  98078. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98079. */
  98080. get filteringQuality(): number;
  98081. /**
  98082. * Sets the PCF or PCSS Quality.
  98083. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98084. */
  98085. set filteringQuality(filteringQuality: number);
  98086. /**
  98087. * Gets if the current filter is set to "PCSS" (contact hardening).
  98088. */
  98089. get useContactHardeningShadow(): boolean;
  98090. /**
  98091. * Sets the current filter to "PCSS" (contact hardening).
  98092. */
  98093. set useContactHardeningShadow(value: boolean);
  98094. protected _contactHardeningLightSizeUVRatio: number;
  98095. /**
  98096. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98097. * Using a ratio helps keeping shape stability independently of the map size.
  98098. *
  98099. * It does not account for the light projection as it was having too much
  98100. * instability during the light setup or during light position changes.
  98101. *
  98102. * Only valid if useContactHardeningShadow is true.
  98103. */
  98104. get contactHardeningLightSizeUVRatio(): number;
  98105. /**
  98106. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98107. * Using a ratio helps keeping shape stability independently of the map size.
  98108. *
  98109. * It does not account for the light projection as it was having too much
  98110. * instability during the light setup or during light position changes.
  98111. *
  98112. * Only valid if useContactHardeningShadow is true.
  98113. */
  98114. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98115. protected _darkness: number;
  98116. /** Gets or sets the actual darkness of a shadow */
  98117. get darkness(): number;
  98118. set darkness(value: number);
  98119. /**
  98120. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98121. * 0 means strongest and 1 would means no shadow.
  98122. * @returns the darkness.
  98123. */
  98124. getDarkness(): number;
  98125. /**
  98126. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98127. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98128. * @returns the shadow generator allowing fluent coding.
  98129. */
  98130. setDarkness(darkness: number): ShadowGenerator;
  98131. protected _transparencyShadow: boolean;
  98132. /** Gets or sets the ability to have transparent shadow */
  98133. get transparencyShadow(): boolean;
  98134. set transparencyShadow(value: boolean);
  98135. /**
  98136. * Sets the ability to have transparent shadow (boolean).
  98137. * @param transparent True if transparent else False
  98138. * @returns the shadow generator allowing fluent coding
  98139. */
  98140. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98141. /**
  98142. * Enables or disables shadows with varying strength based on the transparency
  98143. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98144. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98145. * mesh.visibility * alphaTexture.a
  98146. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98147. */
  98148. enableSoftTransparentShadow: boolean;
  98149. protected _shadowMap: Nullable<RenderTargetTexture>;
  98150. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98151. /**
  98152. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98153. * @returns The render target texture if present otherwise, null
  98154. */
  98155. getShadowMap(): Nullable<RenderTargetTexture>;
  98156. /**
  98157. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98158. * @returns The render target texture if the shadow map is present otherwise, null
  98159. */
  98160. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98161. /**
  98162. * Gets the class name of that object
  98163. * @returns "ShadowGenerator"
  98164. */
  98165. getClassName(): string;
  98166. /**
  98167. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98168. * @param mesh Mesh to add
  98169. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98170. * @returns the Shadow Generator itself
  98171. */
  98172. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98173. /**
  98174. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98175. * @param mesh Mesh to remove
  98176. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98177. * @returns the Shadow Generator itself
  98178. */
  98179. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98180. /**
  98181. * Controls the extent to which the shadows fade out at the edge of the frustum
  98182. */
  98183. frustumEdgeFalloff: number;
  98184. protected _light: IShadowLight;
  98185. /**
  98186. * Returns the associated light object.
  98187. * @returns the light generating the shadow
  98188. */
  98189. getLight(): IShadowLight;
  98190. /**
  98191. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98192. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98193. * It might on the other hand introduce peter panning.
  98194. */
  98195. forceBackFacesOnly: boolean;
  98196. protected _scene: Scene;
  98197. protected _lightDirection: Vector3;
  98198. protected _effect: Effect;
  98199. protected _viewMatrix: Matrix;
  98200. protected _projectionMatrix: Matrix;
  98201. protected _transformMatrix: Matrix;
  98202. protected _cachedPosition: Vector3;
  98203. protected _cachedDirection: Vector3;
  98204. protected _cachedDefines: string;
  98205. protected _currentRenderID: number;
  98206. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98207. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98208. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98209. protected _blurPostProcesses: PostProcess[];
  98210. protected _mapSize: number;
  98211. protected _currentFaceIndex: number;
  98212. protected _currentFaceIndexCache: number;
  98213. protected _textureType: number;
  98214. protected _defaultTextureMatrix: Matrix;
  98215. protected _storedUniqueId: Nullable<number>;
  98216. /** @hidden */
  98217. static _SceneComponentInitialization: (scene: Scene) => void;
  98218. /**
  98219. * Creates a ShadowGenerator object.
  98220. * A ShadowGenerator is the required tool to use the shadows.
  98221. * Each light casting shadows needs to use its own ShadowGenerator.
  98222. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98223. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98224. * @param light The light object generating the shadows.
  98225. * @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.
  98226. */
  98227. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98228. protected _initializeGenerator(): void;
  98229. protected _createTargetRenderTexture(): void;
  98230. protected _initializeShadowMap(): void;
  98231. protected _initializeBlurRTTAndPostProcesses(): void;
  98232. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98233. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98234. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98235. protected _applyFilterValues(): void;
  98236. /**
  98237. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98238. * @param onCompiled Callback triggered at the and of the effects compilation
  98239. * @param options Sets of optional options forcing the compilation with different modes
  98240. */
  98241. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98242. useInstances: boolean;
  98243. }>): void;
  98244. /**
  98245. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98246. * @param options Sets of optional options forcing the compilation with different modes
  98247. * @returns A promise that resolves when the compilation completes
  98248. */
  98249. forceCompilationAsync(options?: Partial<{
  98250. useInstances: boolean;
  98251. }>): Promise<void>;
  98252. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98253. private _prepareShadowDefines;
  98254. /**
  98255. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98256. * @param subMesh The submesh we want to render in the shadow map
  98257. * @param useInstances Defines wether will draw in the map using instances
  98258. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98259. * @returns true if ready otherwise, false
  98260. */
  98261. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98262. /**
  98263. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98264. * @param defines Defines of the material we want to update
  98265. * @param lightIndex Index of the light in the enabled light list of the material
  98266. */
  98267. prepareDefines(defines: any, lightIndex: number): void;
  98268. /**
  98269. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98270. * defined in the generator but impacting the effect).
  98271. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98272. * @param effect The effect we are binfing the information for
  98273. */
  98274. bindShadowLight(lightIndex: string, effect: Effect): void;
  98275. /**
  98276. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98277. * (eq to shadow prjection matrix * light transform matrix)
  98278. * @returns The transform matrix used to create the shadow map
  98279. */
  98280. getTransformMatrix(): Matrix;
  98281. /**
  98282. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98283. * Cube and 2D textures for instance.
  98284. */
  98285. recreateShadowMap(): void;
  98286. protected _disposeBlurPostProcesses(): void;
  98287. protected _disposeRTTandPostProcesses(): void;
  98288. /**
  98289. * Disposes the ShadowGenerator.
  98290. * Returns nothing.
  98291. */
  98292. dispose(): void;
  98293. /**
  98294. * Serializes the shadow generator setup to a json object.
  98295. * @returns The serialized JSON object
  98296. */
  98297. serialize(): any;
  98298. /**
  98299. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98300. * @param parsedShadowGenerator The JSON object to parse
  98301. * @param scene The scene to create the shadow map for
  98302. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98303. * @returns The parsed shadow generator
  98304. */
  98305. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98306. }
  98307. }
  98308. declare module BABYLON {
  98309. /**
  98310. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98311. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98312. * 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.
  98313. */
  98314. export abstract class Light extends Node {
  98315. /**
  98316. * Falloff Default: light is falling off following the material specification:
  98317. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98318. */
  98319. static readonly FALLOFF_DEFAULT: number;
  98320. /**
  98321. * Falloff Physical: light is falling off following the inverse squared distance law.
  98322. */
  98323. static readonly FALLOFF_PHYSICAL: number;
  98324. /**
  98325. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98326. * to enhance interoperability with other engines.
  98327. */
  98328. static readonly FALLOFF_GLTF: number;
  98329. /**
  98330. * Falloff Standard: light is falling off like in the standard material
  98331. * to enhance interoperability with other materials.
  98332. */
  98333. static readonly FALLOFF_STANDARD: number;
  98334. /**
  98335. * If every light affecting the material is in this lightmapMode,
  98336. * material.lightmapTexture adds or multiplies
  98337. * (depends on material.useLightmapAsShadowmap)
  98338. * after every other light calculations.
  98339. */
  98340. static readonly LIGHTMAP_DEFAULT: number;
  98341. /**
  98342. * material.lightmapTexture as only diffuse lighting from this light
  98343. * adds only specular lighting from this light
  98344. * adds dynamic shadows
  98345. */
  98346. static readonly LIGHTMAP_SPECULAR: number;
  98347. /**
  98348. * material.lightmapTexture as only lighting
  98349. * no light calculation from this light
  98350. * only adds dynamic shadows from this light
  98351. */
  98352. static readonly LIGHTMAP_SHADOWSONLY: number;
  98353. /**
  98354. * Each light type uses the default quantity according to its type:
  98355. * point/spot lights use luminous intensity
  98356. * directional lights use illuminance
  98357. */
  98358. static readonly INTENSITYMODE_AUTOMATIC: number;
  98359. /**
  98360. * lumen (lm)
  98361. */
  98362. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98363. /**
  98364. * candela (lm/sr)
  98365. */
  98366. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98367. /**
  98368. * lux (lm/m^2)
  98369. */
  98370. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98371. /**
  98372. * nit (cd/m^2)
  98373. */
  98374. static readonly INTENSITYMODE_LUMINANCE: number;
  98375. /**
  98376. * Light type const id of the point light.
  98377. */
  98378. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98379. /**
  98380. * Light type const id of the directional light.
  98381. */
  98382. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98383. /**
  98384. * Light type const id of the spot light.
  98385. */
  98386. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98387. /**
  98388. * Light type const id of the hemispheric light.
  98389. */
  98390. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98391. /**
  98392. * Diffuse gives the basic color to an object.
  98393. */
  98394. diffuse: Color3;
  98395. /**
  98396. * Specular produces a highlight color on an object.
  98397. * Note: This is note affecting PBR materials.
  98398. */
  98399. specular: Color3;
  98400. /**
  98401. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98402. * falling off base on range or angle.
  98403. * This can be set to any values in Light.FALLOFF_x.
  98404. *
  98405. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98406. * other types of materials.
  98407. */
  98408. falloffType: number;
  98409. /**
  98410. * Strength of the light.
  98411. * Note: By default it is define in the framework own unit.
  98412. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98413. */
  98414. intensity: number;
  98415. private _range;
  98416. protected _inverseSquaredRange: number;
  98417. /**
  98418. * Defines how far from the source the light is impacting in scene units.
  98419. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98420. */
  98421. get range(): number;
  98422. /**
  98423. * Defines how far from the source the light is impacting in scene units.
  98424. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98425. */
  98426. set range(value: number);
  98427. /**
  98428. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98429. * of light.
  98430. */
  98431. private _photometricScale;
  98432. private _intensityMode;
  98433. /**
  98434. * Gets the photometric scale used to interpret the intensity.
  98435. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98436. */
  98437. get intensityMode(): number;
  98438. /**
  98439. * Sets the photometric scale used to interpret the intensity.
  98440. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98441. */
  98442. set intensityMode(value: number);
  98443. private _radius;
  98444. /**
  98445. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98446. */
  98447. get radius(): number;
  98448. /**
  98449. * sets the light radius used by PBR Materials to simulate soft area lights.
  98450. */
  98451. set radius(value: number);
  98452. private _renderPriority;
  98453. /**
  98454. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98455. * exceeding the number allowed of the materials.
  98456. */
  98457. renderPriority: number;
  98458. private _shadowEnabled;
  98459. /**
  98460. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98461. * the current shadow generator.
  98462. */
  98463. get shadowEnabled(): boolean;
  98464. /**
  98465. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98466. * the current shadow generator.
  98467. */
  98468. set shadowEnabled(value: boolean);
  98469. private _includedOnlyMeshes;
  98470. /**
  98471. * Gets the only meshes impacted by this light.
  98472. */
  98473. get includedOnlyMeshes(): AbstractMesh[];
  98474. /**
  98475. * Sets the only meshes impacted by this light.
  98476. */
  98477. set includedOnlyMeshes(value: AbstractMesh[]);
  98478. private _excludedMeshes;
  98479. /**
  98480. * Gets the meshes not impacted by this light.
  98481. */
  98482. get excludedMeshes(): AbstractMesh[];
  98483. /**
  98484. * Sets the meshes not impacted by this light.
  98485. */
  98486. set excludedMeshes(value: AbstractMesh[]);
  98487. private _excludeWithLayerMask;
  98488. /**
  98489. * Gets the layer id use to find what meshes are not impacted by the light.
  98490. * Inactive if 0
  98491. */
  98492. get excludeWithLayerMask(): number;
  98493. /**
  98494. * Sets the layer id use to find what meshes are not impacted by the light.
  98495. * Inactive if 0
  98496. */
  98497. set excludeWithLayerMask(value: number);
  98498. private _includeOnlyWithLayerMask;
  98499. /**
  98500. * Gets the layer id use to find what meshes are impacted by the light.
  98501. * Inactive if 0
  98502. */
  98503. get includeOnlyWithLayerMask(): number;
  98504. /**
  98505. * Sets the layer id use to find what meshes are impacted by the light.
  98506. * Inactive if 0
  98507. */
  98508. set includeOnlyWithLayerMask(value: number);
  98509. private _lightmapMode;
  98510. /**
  98511. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98512. */
  98513. get lightmapMode(): number;
  98514. /**
  98515. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98516. */
  98517. set lightmapMode(value: number);
  98518. /**
  98519. * Shadow generator associted to the light.
  98520. * @hidden Internal use only.
  98521. */
  98522. _shadowGenerator: Nullable<IShadowGenerator>;
  98523. /**
  98524. * @hidden Internal use only.
  98525. */
  98526. _excludedMeshesIds: string[];
  98527. /**
  98528. * @hidden Internal use only.
  98529. */
  98530. _includedOnlyMeshesIds: string[];
  98531. /**
  98532. * The current light unifom buffer.
  98533. * @hidden Internal use only.
  98534. */
  98535. _uniformBuffer: UniformBuffer;
  98536. /** @hidden */
  98537. _renderId: number;
  98538. /**
  98539. * Creates a Light object in the scene.
  98540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98541. * @param name The firendly name of the light
  98542. * @param scene The scene the light belongs too
  98543. */
  98544. constructor(name: string, scene: Scene);
  98545. protected abstract _buildUniformLayout(): void;
  98546. /**
  98547. * Sets the passed Effect "effect" with the Light information.
  98548. * @param effect The effect to update
  98549. * @param lightIndex The index of the light in the effect to update
  98550. * @returns The light
  98551. */
  98552. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98553. /**
  98554. * Sets the passed Effect "effect" with the Light textures.
  98555. * @param effect The effect to update
  98556. * @param lightIndex The index of the light in the effect to update
  98557. * @returns The light
  98558. */
  98559. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98560. /**
  98561. * Binds the lights information from the scene to the effect for the given mesh.
  98562. * @param lightIndex Light index
  98563. * @param scene The scene where the light belongs to
  98564. * @param effect The effect we are binding the data to
  98565. * @param useSpecular Defines if specular is supported
  98566. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98567. */
  98568. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98569. /**
  98570. * Sets the passed Effect "effect" with the Light information.
  98571. * @param effect The effect to update
  98572. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98573. * @returns The light
  98574. */
  98575. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98576. /**
  98577. * Returns the string "Light".
  98578. * @returns the class name
  98579. */
  98580. getClassName(): string;
  98581. /** @hidden */
  98582. readonly _isLight: boolean;
  98583. /**
  98584. * Converts the light information to a readable string for debug purpose.
  98585. * @param fullDetails Supports for multiple levels of logging within scene loading
  98586. * @returns the human readable light info
  98587. */
  98588. toString(fullDetails?: boolean): string;
  98589. /** @hidden */
  98590. protected _syncParentEnabledState(): void;
  98591. /**
  98592. * Set the enabled state of this node.
  98593. * @param value - the new enabled state
  98594. */
  98595. setEnabled(value: boolean): void;
  98596. /**
  98597. * Returns the Light associated shadow generator if any.
  98598. * @return the associated shadow generator.
  98599. */
  98600. getShadowGenerator(): Nullable<IShadowGenerator>;
  98601. /**
  98602. * Returns a Vector3, the absolute light position in the World.
  98603. * @returns the world space position of the light
  98604. */
  98605. getAbsolutePosition(): Vector3;
  98606. /**
  98607. * Specifies if the light will affect the passed mesh.
  98608. * @param mesh The mesh to test against the light
  98609. * @return true the mesh is affected otherwise, false.
  98610. */
  98611. canAffectMesh(mesh: AbstractMesh): boolean;
  98612. /**
  98613. * Sort function to order lights for rendering.
  98614. * @param a First Light object to compare to second.
  98615. * @param b Second Light object to compare first.
  98616. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98617. */
  98618. static CompareLightsPriority(a: Light, b: Light): number;
  98619. /**
  98620. * Releases resources associated with this node.
  98621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98623. */
  98624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98625. /**
  98626. * Returns the light type ID (integer).
  98627. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98628. */
  98629. getTypeID(): number;
  98630. /**
  98631. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98632. * @returns the scaled intensity in intensity mode unit
  98633. */
  98634. getScaledIntensity(): number;
  98635. /**
  98636. * Returns a new Light object, named "name", from the current one.
  98637. * @param name The name of the cloned light
  98638. * @param newParent The parent of this light, if it has one
  98639. * @returns the new created light
  98640. */
  98641. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98642. /**
  98643. * Serializes the current light into a Serialization object.
  98644. * @returns the serialized object.
  98645. */
  98646. serialize(): any;
  98647. /**
  98648. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98649. * This new light is named "name" and added to the passed scene.
  98650. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98651. * @param name The friendly name of the light
  98652. * @param scene The scene the new light will belong to
  98653. * @returns the constructor function
  98654. */
  98655. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98656. /**
  98657. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98658. * @param parsedLight The JSON representation of the light
  98659. * @param scene The scene to create the parsed light in
  98660. * @returns the created light after parsing
  98661. */
  98662. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98663. private _hookArrayForExcluded;
  98664. private _hookArrayForIncludedOnly;
  98665. private _resyncMeshes;
  98666. /**
  98667. * Forces the meshes to update their light related information in their rendering used effects
  98668. * @hidden Internal Use Only
  98669. */
  98670. _markMeshesAsLightDirty(): void;
  98671. /**
  98672. * Recomputes the cached photometric scale if needed.
  98673. */
  98674. private _computePhotometricScale;
  98675. /**
  98676. * Returns the Photometric Scale according to the light type and intensity mode.
  98677. */
  98678. private _getPhotometricScale;
  98679. /**
  98680. * Reorder the light in the scene according to their defined priority.
  98681. * @hidden Internal Use Only
  98682. */
  98683. _reorderLightsInScene(): void;
  98684. /**
  98685. * Prepares the list of defines specific to the light type.
  98686. * @param defines the list of defines
  98687. * @param lightIndex defines the index of the light for the effect
  98688. */
  98689. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98690. }
  98691. }
  98692. declare module BABYLON {
  98693. /**
  98694. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98695. * This is the base of the follow, arc rotate cameras and Free camera
  98696. * @see https://doc.babylonjs.com/features/cameras
  98697. */
  98698. export class TargetCamera extends Camera {
  98699. private static _RigCamTransformMatrix;
  98700. private static _TargetTransformMatrix;
  98701. private static _TargetFocalPoint;
  98702. private _tmpUpVector;
  98703. private _tmpTargetVector;
  98704. /**
  98705. * Define the current direction the camera is moving to
  98706. */
  98707. cameraDirection: Vector3;
  98708. /**
  98709. * Define the current rotation the camera is rotating to
  98710. */
  98711. cameraRotation: Vector2;
  98712. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98713. ignoreParentScaling: boolean;
  98714. /**
  98715. * When set, the up vector of the camera will be updated by the rotation of the camera
  98716. */
  98717. updateUpVectorFromRotation: boolean;
  98718. private _tmpQuaternion;
  98719. /**
  98720. * Define the current rotation of the camera
  98721. */
  98722. rotation: Vector3;
  98723. /**
  98724. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98725. */
  98726. rotationQuaternion: Quaternion;
  98727. /**
  98728. * Define the current speed of the camera
  98729. */
  98730. speed: number;
  98731. /**
  98732. * Add constraint to the camera to prevent it to move freely in all directions and
  98733. * around all axis.
  98734. */
  98735. noRotationConstraint: boolean;
  98736. /**
  98737. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98738. * panning
  98739. */
  98740. invertRotation: boolean;
  98741. /**
  98742. * Speed multiplier for inverse camera panning
  98743. */
  98744. inverseRotationSpeed: number;
  98745. /**
  98746. * Define the current target of the camera as an object or a position.
  98747. */
  98748. lockedTarget: any;
  98749. /** @hidden */
  98750. _currentTarget: Vector3;
  98751. /** @hidden */
  98752. _initialFocalDistance: number;
  98753. /** @hidden */
  98754. _viewMatrix: Matrix;
  98755. /** @hidden */
  98756. _camMatrix: Matrix;
  98757. /** @hidden */
  98758. _cameraTransformMatrix: Matrix;
  98759. /** @hidden */
  98760. _cameraRotationMatrix: Matrix;
  98761. /** @hidden */
  98762. _referencePoint: Vector3;
  98763. /** @hidden */
  98764. _transformedReferencePoint: Vector3;
  98765. /** @hidden */
  98766. _reset: () => void;
  98767. private _defaultUp;
  98768. /**
  98769. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98770. * This is the base of the follow, arc rotate cameras and Free camera
  98771. * @see https://doc.babylonjs.com/features/cameras
  98772. * @param name Defines the name of the camera in the scene
  98773. * @param position Defines the start position of the camera in the scene
  98774. * @param scene Defines the scene the camera belongs to
  98775. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98776. */
  98777. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98778. /**
  98779. * Gets the position in front of the camera at a given distance.
  98780. * @param distance The distance from the camera we want the position to be
  98781. * @returns the position
  98782. */
  98783. getFrontPosition(distance: number): Vector3;
  98784. /** @hidden */
  98785. _getLockedTargetPosition(): Nullable<Vector3>;
  98786. private _storedPosition;
  98787. private _storedRotation;
  98788. private _storedRotationQuaternion;
  98789. /**
  98790. * Store current camera state of the camera (fov, position, rotation, etc..)
  98791. * @returns the camera
  98792. */
  98793. storeState(): Camera;
  98794. /**
  98795. * Restored camera state. You must call storeState() first
  98796. * @returns whether it was successful or not
  98797. * @hidden
  98798. */
  98799. _restoreStateValues(): boolean;
  98800. /** @hidden */
  98801. _initCache(): void;
  98802. /** @hidden */
  98803. _updateCache(ignoreParentClass?: boolean): void;
  98804. /** @hidden */
  98805. _isSynchronizedViewMatrix(): boolean;
  98806. /** @hidden */
  98807. _computeLocalCameraSpeed(): number;
  98808. /**
  98809. * Defines the target the camera should look at.
  98810. * @param target Defines the new target as a Vector or a mesh
  98811. */
  98812. setTarget(target: Vector3): void;
  98813. /**
  98814. * Defines the target point of the camera.
  98815. * The camera looks towards it form the radius distance.
  98816. */
  98817. get target(): Vector3;
  98818. set target(value: Vector3);
  98819. /**
  98820. * Return the current target position of the camera. This value is expressed in local space.
  98821. * @returns the target position
  98822. */
  98823. getTarget(): Vector3;
  98824. /** @hidden */
  98825. _decideIfNeedsToMove(): boolean;
  98826. /** @hidden */
  98827. _updatePosition(): void;
  98828. /** @hidden */
  98829. _checkInputs(): void;
  98830. protected _updateCameraRotationMatrix(): void;
  98831. /**
  98832. * 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)
  98833. * @returns the current camera
  98834. */
  98835. private _rotateUpVectorWithCameraRotationMatrix;
  98836. private _cachedRotationZ;
  98837. private _cachedQuaternionRotationZ;
  98838. /** @hidden */
  98839. _getViewMatrix(): Matrix;
  98840. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98841. /**
  98842. * @hidden
  98843. */
  98844. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98845. /**
  98846. * @hidden
  98847. */
  98848. _updateRigCameras(): void;
  98849. private _getRigCamPositionAndTarget;
  98850. /**
  98851. * Gets the current object class name.
  98852. * @return the class name
  98853. */
  98854. getClassName(): string;
  98855. }
  98856. }
  98857. declare module BABYLON {
  98858. /**
  98859. * Gather the list of keyboard event types as constants.
  98860. */
  98861. export class KeyboardEventTypes {
  98862. /**
  98863. * The keydown event is fired when a key becomes active (pressed).
  98864. */
  98865. static readonly KEYDOWN: number;
  98866. /**
  98867. * The keyup event is fired when a key has been released.
  98868. */
  98869. static readonly KEYUP: number;
  98870. }
  98871. /**
  98872. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98873. */
  98874. export class KeyboardInfo {
  98875. /**
  98876. * Defines the type of event (KeyboardEventTypes)
  98877. */
  98878. type: number;
  98879. /**
  98880. * Defines the related dom event
  98881. */
  98882. event: KeyboardEvent;
  98883. /**
  98884. * Instantiates a new keyboard info.
  98885. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98886. * @param type Defines the type of event (KeyboardEventTypes)
  98887. * @param event Defines the related dom event
  98888. */
  98889. constructor(
  98890. /**
  98891. * Defines the type of event (KeyboardEventTypes)
  98892. */
  98893. type: number,
  98894. /**
  98895. * Defines the related dom event
  98896. */
  98897. event: KeyboardEvent);
  98898. }
  98899. /**
  98900. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98901. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98902. */
  98903. export class KeyboardInfoPre extends KeyboardInfo {
  98904. /**
  98905. * Defines the type of event (KeyboardEventTypes)
  98906. */
  98907. type: number;
  98908. /**
  98909. * Defines the related dom event
  98910. */
  98911. event: KeyboardEvent;
  98912. /**
  98913. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98914. */
  98915. skipOnPointerObservable: boolean;
  98916. /**
  98917. * Instantiates a new keyboard pre info.
  98918. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98919. * @param type Defines the type of event (KeyboardEventTypes)
  98920. * @param event Defines the related dom event
  98921. */
  98922. constructor(
  98923. /**
  98924. * Defines the type of event (KeyboardEventTypes)
  98925. */
  98926. type: number,
  98927. /**
  98928. * Defines the related dom event
  98929. */
  98930. event: KeyboardEvent);
  98931. }
  98932. }
  98933. declare module BABYLON {
  98934. /**
  98935. * Manage the keyboard inputs to control the movement of a free camera.
  98936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98937. */
  98938. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98939. /**
  98940. * Defines the camera the input is attached to.
  98941. */
  98942. camera: FreeCamera;
  98943. /**
  98944. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98945. */
  98946. keysUp: number[];
  98947. /**
  98948. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98949. */
  98950. keysUpward: number[];
  98951. /**
  98952. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98953. */
  98954. keysDown: number[];
  98955. /**
  98956. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98957. */
  98958. keysDownward: number[];
  98959. /**
  98960. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98961. */
  98962. keysLeft: number[];
  98963. /**
  98964. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98965. */
  98966. keysRight: number[];
  98967. private _keys;
  98968. private _onCanvasBlurObserver;
  98969. private _onKeyboardObserver;
  98970. private _engine;
  98971. private _scene;
  98972. /**
  98973. * Attach the input controls to a specific dom element to get the input from.
  98974. * @param element Defines the element the controls should be listened from
  98975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98976. */
  98977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98978. /**
  98979. * Detach the current controls from the specified dom element.
  98980. * @param element Defines the element to stop listening the inputs from
  98981. */
  98982. detachControl(element: Nullable<HTMLElement>): void;
  98983. /**
  98984. * Update the current camera state depending on the inputs that have been used this frame.
  98985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98986. */
  98987. checkInputs(): void;
  98988. /**
  98989. * Gets the class name of the current intput.
  98990. * @returns the class name
  98991. */
  98992. getClassName(): string;
  98993. /** @hidden */
  98994. _onLostFocus(): void;
  98995. /**
  98996. * Get the friendly name associated with the input class.
  98997. * @returns the input friendly name
  98998. */
  98999. getSimpleName(): string;
  99000. }
  99001. }
  99002. declare module BABYLON {
  99003. /**
  99004. * Gather the list of pointer event types as constants.
  99005. */
  99006. export class PointerEventTypes {
  99007. /**
  99008. * 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.
  99009. */
  99010. static readonly POINTERDOWN: number;
  99011. /**
  99012. * The pointerup event is fired when a pointer is no longer active.
  99013. */
  99014. static readonly POINTERUP: number;
  99015. /**
  99016. * The pointermove event is fired when a pointer changes coordinates.
  99017. */
  99018. static readonly POINTERMOVE: number;
  99019. /**
  99020. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99021. */
  99022. static readonly POINTERWHEEL: number;
  99023. /**
  99024. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99025. */
  99026. static readonly POINTERPICK: number;
  99027. /**
  99028. * The pointertap event is fired when a the object has been touched and released without drag.
  99029. */
  99030. static readonly POINTERTAP: number;
  99031. /**
  99032. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99033. */
  99034. static readonly POINTERDOUBLETAP: number;
  99035. }
  99036. /**
  99037. * Base class of pointer info types.
  99038. */
  99039. export class PointerInfoBase {
  99040. /**
  99041. * Defines the type of event (PointerEventTypes)
  99042. */
  99043. type: number;
  99044. /**
  99045. * Defines the related dom event
  99046. */
  99047. event: PointerEvent | MouseWheelEvent;
  99048. /**
  99049. * Instantiates the base class of pointers info.
  99050. * @param type Defines the type of event (PointerEventTypes)
  99051. * @param event Defines the related dom event
  99052. */
  99053. constructor(
  99054. /**
  99055. * Defines the type of event (PointerEventTypes)
  99056. */
  99057. type: number,
  99058. /**
  99059. * Defines the related dom event
  99060. */
  99061. event: PointerEvent | MouseWheelEvent);
  99062. }
  99063. /**
  99064. * This class is used to store pointer related info for the onPrePointerObservable event.
  99065. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99066. */
  99067. export class PointerInfoPre extends PointerInfoBase {
  99068. /**
  99069. * Ray from a pointer if availible (eg. 6dof controller)
  99070. */
  99071. ray: Nullable<Ray>;
  99072. /**
  99073. * Defines the local position of the pointer on the canvas.
  99074. */
  99075. localPosition: Vector2;
  99076. /**
  99077. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99078. */
  99079. skipOnPointerObservable: boolean;
  99080. /**
  99081. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99082. * @param type Defines the type of event (PointerEventTypes)
  99083. * @param event Defines the related dom event
  99084. * @param localX Defines the local x coordinates of the pointer when the event occured
  99085. * @param localY Defines the local y coordinates of the pointer when the event occured
  99086. */
  99087. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99088. }
  99089. /**
  99090. * This type contains all the data related to a pointer event in Babylon.js.
  99091. * 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.
  99092. */
  99093. export class PointerInfo extends PointerInfoBase {
  99094. /**
  99095. * Defines the picking info associated to the info (if any)\
  99096. */
  99097. pickInfo: Nullable<PickingInfo>;
  99098. /**
  99099. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99100. * @param type Defines the type of event (PointerEventTypes)
  99101. * @param event Defines the related dom event
  99102. * @param pickInfo Defines the picking info associated to the info (if any)\
  99103. */
  99104. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99105. /**
  99106. * Defines the picking info associated to the info (if any)\
  99107. */
  99108. pickInfo: Nullable<PickingInfo>);
  99109. }
  99110. /**
  99111. * Data relating to a touch event on the screen.
  99112. */
  99113. export interface PointerTouch {
  99114. /**
  99115. * X coordinate of touch.
  99116. */
  99117. x: number;
  99118. /**
  99119. * Y coordinate of touch.
  99120. */
  99121. y: number;
  99122. /**
  99123. * Id of touch. Unique for each finger.
  99124. */
  99125. pointerId: number;
  99126. /**
  99127. * Event type passed from DOM.
  99128. */
  99129. type: any;
  99130. }
  99131. }
  99132. declare module BABYLON {
  99133. /**
  99134. * Manage the mouse inputs to control the movement of a free camera.
  99135. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99136. */
  99137. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99138. /**
  99139. * Define if touch is enabled in the mouse input
  99140. */
  99141. touchEnabled: boolean;
  99142. /**
  99143. * Defines the camera the input is attached to.
  99144. */
  99145. camera: FreeCamera;
  99146. /**
  99147. * Defines the buttons associated with the input to handle camera move.
  99148. */
  99149. buttons: number[];
  99150. /**
  99151. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99152. */
  99153. angularSensibility: number;
  99154. private _pointerInput;
  99155. private _onMouseMove;
  99156. private _observer;
  99157. private previousPosition;
  99158. /**
  99159. * Observable for when a pointer move event occurs containing the move offset
  99160. */
  99161. onPointerMovedObservable: Observable<{
  99162. offsetX: number;
  99163. offsetY: number;
  99164. }>;
  99165. /**
  99166. * @hidden
  99167. * If the camera should be rotated automatically based on pointer movement
  99168. */
  99169. _allowCameraRotation: boolean;
  99170. /**
  99171. * Manage the mouse inputs to control the movement of a free camera.
  99172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99173. * @param touchEnabled Defines if touch is enabled or not
  99174. */
  99175. constructor(
  99176. /**
  99177. * Define if touch is enabled in the mouse input
  99178. */
  99179. touchEnabled?: boolean);
  99180. /**
  99181. * Attach the input controls to a specific dom element to get the input from.
  99182. * @param element Defines the element the controls should be listened from
  99183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99184. */
  99185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99186. /**
  99187. * Called on JS contextmenu event.
  99188. * Override this method to provide functionality.
  99189. */
  99190. protected onContextMenu(evt: PointerEvent): void;
  99191. /**
  99192. * Detach the current controls from the specified dom element.
  99193. * @param element Defines the element to stop listening the inputs from
  99194. */
  99195. detachControl(element: Nullable<HTMLElement>): void;
  99196. /**
  99197. * Gets the class name of the current intput.
  99198. * @returns the class name
  99199. */
  99200. getClassName(): string;
  99201. /**
  99202. * Get the friendly name associated with the input class.
  99203. * @returns the input friendly name
  99204. */
  99205. getSimpleName(): string;
  99206. }
  99207. }
  99208. declare module BABYLON {
  99209. /**
  99210. * Manage the touch inputs to control the movement of a free camera.
  99211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99212. */
  99213. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99214. /**
  99215. * Define if mouse events can be treated as touch events
  99216. */
  99217. allowMouse: boolean;
  99218. /**
  99219. * Defines the camera the input is attached to.
  99220. */
  99221. camera: FreeCamera;
  99222. /**
  99223. * Defines the touch sensibility for rotation.
  99224. * The higher the faster.
  99225. */
  99226. touchAngularSensibility: number;
  99227. /**
  99228. * Defines the touch sensibility for move.
  99229. * The higher the faster.
  99230. */
  99231. touchMoveSensibility: number;
  99232. private _offsetX;
  99233. private _offsetY;
  99234. private _pointerPressed;
  99235. private _pointerInput;
  99236. private _observer;
  99237. private _onLostFocus;
  99238. /**
  99239. * Manage the touch inputs to control the movement of a free camera.
  99240. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99241. * @param allowMouse Defines if mouse events can be treated as touch events
  99242. */
  99243. constructor(
  99244. /**
  99245. * Define if mouse events can be treated as touch events
  99246. */
  99247. allowMouse?: boolean);
  99248. /**
  99249. * Attach the input controls to a specific dom element to get the input from.
  99250. * @param element Defines the element the controls should be listened from
  99251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99252. */
  99253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99254. /**
  99255. * Detach the current controls from the specified dom element.
  99256. * @param element Defines the element to stop listening the inputs from
  99257. */
  99258. detachControl(element: Nullable<HTMLElement>): void;
  99259. /**
  99260. * Update the current camera state depending on the inputs that have been used this frame.
  99261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99262. */
  99263. checkInputs(): void;
  99264. /**
  99265. * Gets the class name of the current intput.
  99266. * @returns the class name
  99267. */
  99268. getClassName(): string;
  99269. /**
  99270. * Get the friendly name associated with the input class.
  99271. * @returns the input friendly name
  99272. */
  99273. getSimpleName(): string;
  99274. }
  99275. }
  99276. declare module BABYLON {
  99277. /**
  99278. * Default Inputs manager for the FreeCamera.
  99279. * It groups all the default supported inputs for ease of use.
  99280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99281. */
  99282. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99283. /**
  99284. * @hidden
  99285. */
  99286. _mouseInput: Nullable<FreeCameraMouseInput>;
  99287. /**
  99288. * Instantiates a new FreeCameraInputsManager.
  99289. * @param camera Defines the camera the inputs belong to
  99290. */
  99291. constructor(camera: FreeCamera);
  99292. /**
  99293. * Add keyboard input support to the input manager.
  99294. * @returns the current input manager
  99295. */
  99296. addKeyboard(): FreeCameraInputsManager;
  99297. /**
  99298. * Add mouse input support to the input manager.
  99299. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99300. * @returns the current input manager
  99301. */
  99302. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99303. /**
  99304. * Removes the mouse input support from the manager
  99305. * @returns the current input manager
  99306. */
  99307. removeMouse(): FreeCameraInputsManager;
  99308. /**
  99309. * Add touch input support to the input manager.
  99310. * @returns the current input manager
  99311. */
  99312. addTouch(): FreeCameraInputsManager;
  99313. /**
  99314. * Remove all attached input methods from a camera
  99315. */
  99316. clear(): void;
  99317. }
  99318. }
  99319. declare module BABYLON {
  99320. /**
  99321. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99322. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99323. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99324. */
  99325. export class FreeCamera extends TargetCamera {
  99326. /**
  99327. * Define the collision ellipsoid of the camera.
  99328. * This is helpful to simulate a camera body like the player body around the camera
  99329. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99330. */
  99331. ellipsoid: Vector3;
  99332. /**
  99333. * Define an offset for the position of the ellipsoid around the camera.
  99334. * This can be helpful to determine the center of the body near the gravity center of the body
  99335. * instead of its head.
  99336. */
  99337. ellipsoidOffset: Vector3;
  99338. /**
  99339. * Enable or disable collisions of the camera with the rest of the scene objects.
  99340. */
  99341. checkCollisions: boolean;
  99342. /**
  99343. * Enable or disable gravity on the camera.
  99344. */
  99345. applyGravity: boolean;
  99346. /**
  99347. * Define the input manager associated to the camera.
  99348. */
  99349. inputs: FreeCameraInputsManager;
  99350. /**
  99351. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99352. * Higher values reduce sensitivity.
  99353. */
  99354. get angularSensibility(): number;
  99355. /**
  99356. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99357. * Higher values reduce sensitivity.
  99358. */
  99359. set angularSensibility(value: number);
  99360. /**
  99361. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99362. */
  99363. get keysUp(): number[];
  99364. set keysUp(value: number[]);
  99365. /**
  99366. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99367. */
  99368. get keysUpward(): number[];
  99369. set keysUpward(value: number[]);
  99370. /**
  99371. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99372. */
  99373. get keysDown(): number[];
  99374. set keysDown(value: number[]);
  99375. /**
  99376. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99377. */
  99378. get keysDownward(): number[];
  99379. set keysDownward(value: number[]);
  99380. /**
  99381. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99382. */
  99383. get keysLeft(): number[];
  99384. set keysLeft(value: number[]);
  99385. /**
  99386. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99387. */
  99388. get keysRight(): number[];
  99389. set keysRight(value: number[]);
  99390. /**
  99391. * Event raised when the camera collide with a mesh in the scene.
  99392. */
  99393. onCollide: (collidedMesh: AbstractMesh) => void;
  99394. private _collider;
  99395. private _needMoveForGravity;
  99396. private _oldPosition;
  99397. private _diffPosition;
  99398. private _newPosition;
  99399. /** @hidden */
  99400. _localDirection: Vector3;
  99401. /** @hidden */
  99402. _transformedDirection: Vector3;
  99403. /**
  99404. * Instantiates a Free Camera.
  99405. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99406. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99407. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99408. * @param name Define the name of the camera in the scene
  99409. * @param position Define the start position of the camera in the scene
  99410. * @param scene Define the scene the camera belongs to
  99411. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99412. */
  99413. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99414. /**
  99415. * Attached controls to the current camera.
  99416. * @param element Defines the element the controls should be listened from
  99417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99418. */
  99419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99420. /**
  99421. * Detach the current controls from the camera.
  99422. * The camera will stop reacting to inputs.
  99423. * @param element Defines the element to stop listening the inputs from
  99424. */
  99425. detachControl(element: HTMLElement): void;
  99426. private _collisionMask;
  99427. /**
  99428. * Define a collision mask to limit the list of object the camera can collide with
  99429. */
  99430. get collisionMask(): number;
  99431. set collisionMask(mask: number);
  99432. /** @hidden */
  99433. _collideWithWorld(displacement: Vector3): void;
  99434. private _onCollisionPositionChange;
  99435. /** @hidden */
  99436. _checkInputs(): void;
  99437. /** @hidden */
  99438. _decideIfNeedsToMove(): boolean;
  99439. /** @hidden */
  99440. _updatePosition(): void;
  99441. /**
  99442. * Destroy the camera and release the current resources hold by it.
  99443. */
  99444. dispose(): void;
  99445. /**
  99446. * Gets the current object class name.
  99447. * @return the class name
  99448. */
  99449. getClassName(): string;
  99450. }
  99451. }
  99452. declare module BABYLON {
  99453. /**
  99454. * Represents a gamepad control stick position
  99455. */
  99456. export class StickValues {
  99457. /**
  99458. * The x component of the control stick
  99459. */
  99460. x: number;
  99461. /**
  99462. * The y component of the control stick
  99463. */
  99464. y: number;
  99465. /**
  99466. * Initializes the gamepad x and y control stick values
  99467. * @param x The x component of the gamepad control stick value
  99468. * @param y The y component of the gamepad control stick value
  99469. */
  99470. constructor(
  99471. /**
  99472. * The x component of the control stick
  99473. */
  99474. x: number,
  99475. /**
  99476. * The y component of the control stick
  99477. */
  99478. y: number);
  99479. }
  99480. /**
  99481. * An interface which manages callbacks for gamepad button changes
  99482. */
  99483. export interface GamepadButtonChanges {
  99484. /**
  99485. * Called when a gamepad has been changed
  99486. */
  99487. changed: boolean;
  99488. /**
  99489. * Called when a gamepad press event has been triggered
  99490. */
  99491. pressChanged: boolean;
  99492. /**
  99493. * Called when a touch event has been triggered
  99494. */
  99495. touchChanged: boolean;
  99496. /**
  99497. * Called when a value has changed
  99498. */
  99499. valueChanged: boolean;
  99500. }
  99501. /**
  99502. * Represents a gamepad
  99503. */
  99504. export class Gamepad {
  99505. /**
  99506. * The id of the gamepad
  99507. */
  99508. id: string;
  99509. /**
  99510. * The index of the gamepad
  99511. */
  99512. index: number;
  99513. /**
  99514. * The browser gamepad
  99515. */
  99516. browserGamepad: any;
  99517. /**
  99518. * Specifies what type of gamepad this represents
  99519. */
  99520. type: number;
  99521. private _leftStick;
  99522. private _rightStick;
  99523. /** @hidden */
  99524. _isConnected: boolean;
  99525. private _leftStickAxisX;
  99526. private _leftStickAxisY;
  99527. private _rightStickAxisX;
  99528. private _rightStickAxisY;
  99529. /**
  99530. * Triggered when the left control stick has been changed
  99531. */
  99532. private _onleftstickchanged;
  99533. /**
  99534. * Triggered when the right control stick has been changed
  99535. */
  99536. private _onrightstickchanged;
  99537. /**
  99538. * Represents a gamepad controller
  99539. */
  99540. static GAMEPAD: number;
  99541. /**
  99542. * Represents a generic controller
  99543. */
  99544. static GENERIC: number;
  99545. /**
  99546. * Represents an XBox controller
  99547. */
  99548. static XBOX: number;
  99549. /**
  99550. * Represents a pose-enabled controller
  99551. */
  99552. static POSE_ENABLED: number;
  99553. /**
  99554. * Represents an Dual Shock controller
  99555. */
  99556. static DUALSHOCK: number;
  99557. /**
  99558. * Specifies whether the left control stick should be Y-inverted
  99559. */
  99560. protected _invertLeftStickY: boolean;
  99561. /**
  99562. * Specifies if the gamepad has been connected
  99563. */
  99564. get isConnected(): boolean;
  99565. /**
  99566. * Initializes the gamepad
  99567. * @param id The id of the gamepad
  99568. * @param index The index of the gamepad
  99569. * @param browserGamepad The browser gamepad
  99570. * @param leftStickX The x component of the left joystick
  99571. * @param leftStickY The y component of the left joystick
  99572. * @param rightStickX The x component of the right joystick
  99573. * @param rightStickY The y component of the right joystick
  99574. */
  99575. constructor(
  99576. /**
  99577. * The id of the gamepad
  99578. */
  99579. id: string,
  99580. /**
  99581. * The index of the gamepad
  99582. */
  99583. index: number,
  99584. /**
  99585. * The browser gamepad
  99586. */
  99587. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99588. /**
  99589. * Callback triggered when the left joystick has changed
  99590. * @param callback
  99591. */
  99592. onleftstickchanged(callback: (values: StickValues) => void): void;
  99593. /**
  99594. * Callback triggered when the right joystick has changed
  99595. * @param callback
  99596. */
  99597. onrightstickchanged(callback: (values: StickValues) => void): void;
  99598. /**
  99599. * Gets the left joystick
  99600. */
  99601. get leftStick(): StickValues;
  99602. /**
  99603. * Sets the left joystick values
  99604. */
  99605. set leftStick(newValues: StickValues);
  99606. /**
  99607. * Gets the right joystick
  99608. */
  99609. get rightStick(): StickValues;
  99610. /**
  99611. * Sets the right joystick value
  99612. */
  99613. set rightStick(newValues: StickValues);
  99614. /**
  99615. * Updates the gamepad joystick positions
  99616. */
  99617. update(): void;
  99618. /**
  99619. * Disposes the gamepad
  99620. */
  99621. dispose(): void;
  99622. }
  99623. /**
  99624. * Represents a generic gamepad
  99625. */
  99626. export class GenericPad extends Gamepad {
  99627. private _buttons;
  99628. private _onbuttondown;
  99629. private _onbuttonup;
  99630. /**
  99631. * Observable triggered when a button has been pressed
  99632. */
  99633. onButtonDownObservable: Observable<number>;
  99634. /**
  99635. * Observable triggered when a button has been released
  99636. */
  99637. onButtonUpObservable: Observable<number>;
  99638. /**
  99639. * Callback triggered when a button has been pressed
  99640. * @param callback Called when a button has been pressed
  99641. */
  99642. onbuttondown(callback: (buttonPressed: number) => void): void;
  99643. /**
  99644. * Callback triggered when a button has been released
  99645. * @param callback Called when a button has been released
  99646. */
  99647. onbuttonup(callback: (buttonReleased: number) => void): void;
  99648. /**
  99649. * Initializes the generic gamepad
  99650. * @param id The id of the generic gamepad
  99651. * @param index The index of the generic gamepad
  99652. * @param browserGamepad The browser gamepad
  99653. */
  99654. constructor(id: string, index: number, browserGamepad: any);
  99655. private _setButtonValue;
  99656. /**
  99657. * Updates the generic gamepad
  99658. */
  99659. update(): void;
  99660. /**
  99661. * Disposes the generic gamepad
  99662. */
  99663. dispose(): void;
  99664. }
  99665. }
  99666. declare module BABYLON {
  99667. /**
  99668. * Defines the types of pose enabled controllers that are supported
  99669. */
  99670. export enum PoseEnabledControllerType {
  99671. /**
  99672. * HTC Vive
  99673. */
  99674. VIVE = 0,
  99675. /**
  99676. * Oculus Rift
  99677. */
  99678. OCULUS = 1,
  99679. /**
  99680. * Windows mixed reality
  99681. */
  99682. WINDOWS = 2,
  99683. /**
  99684. * Samsung gear VR
  99685. */
  99686. GEAR_VR = 3,
  99687. /**
  99688. * Google Daydream
  99689. */
  99690. DAYDREAM = 4,
  99691. /**
  99692. * Generic
  99693. */
  99694. GENERIC = 5
  99695. }
  99696. /**
  99697. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99698. */
  99699. export interface MutableGamepadButton {
  99700. /**
  99701. * Value of the button/trigger
  99702. */
  99703. value: number;
  99704. /**
  99705. * If the button/trigger is currently touched
  99706. */
  99707. touched: boolean;
  99708. /**
  99709. * If the button/trigger is currently pressed
  99710. */
  99711. pressed: boolean;
  99712. }
  99713. /**
  99714. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99715. * @hidden
  99716. */
  99717. export interface ExtendedGamepadButton extends GamepadButton {
  99718. /**
  99719. * If the button/trigger is currently pressed
  99720. */
  99721. readonly pressed: boolean;
  99722. /**
  99723. * If the button/trigger is currently touched
  99724. */
  99725. readonly touched: boolean;
  99726. /**
  99727. * Value of the button/trigger
  99728. */
  99729. readonly value: number;
  99730. }
  99731. /** @hidden */
  99732. export interface _GamePadFactory {
  99733. /**
  99734. * Returns whether or not the current gamepad can be created for this type of controller.
  99735. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99736. * @returns true if it can be created, otherwise false
  99737. */
  99738. canCreate(gamepadInfo: any): boolean;
  99739. /**
  99740. * Creates a new instance of the Gamepad.
  99741. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99742. * @returns the new gamepad instance
  99743. */
  99744. create(gamepadInfo: any): Gamepad;
  99745. }
  99746. /**
  99747. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99748. */
  99749. export class PoseEnabledControllerHelper {
  99750. /** @hidden */
  99751. static _ControllerFactories: _GamePadFactory[];
  99752. /** @hidden */
  99753. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99754. /**
  99755. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99756. * @param vrGamepad the gamepad to initialized
  99757. * @returns a vr controller of the type the gamepad identified as
  99758. */
  99759. static InitiateController(vrGamepad: any): Gamepad;
  99760. }
  99761. /**
  99762. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99763. */
  99764. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99765. /**
  99766. * If the controller is used in a webXR session
  99767. */
  99768. isXR: boolean;
  99769. private _deviceRoomPosition;
  99770. private _deviceRoomRotationQuaternion;
  99771. /**
  99772. * The device position in babylon space
  99773. */
  99774. devicePosition: Vector3;
  99775. /**
  99776. * The device rotation in babylon space
  99777. */
  99778. deviceRotationQuaternion: Quaternion;
  99779. /**
  99780. * The scale factor of the device in babylon space
  99781. */
  99782. deviceScaleFactor: number;
  99783. /**
  99784. * (Likely devicePosition should be used instead) The device position in its room space
  99785. */
  99786. position: Vector3;
  99787. /**
  99788. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99789. */
  99790. rotationQuaternion: Quaternion;
  99791. /**
  99792. * The type of controller (Eg. Windows mixed reality)
  99793. */
  99794. controllerType: PoseEnabledControllerType;
  99795. protected _calculatedPosition: Vector3;
  99796. private _calculatedRotation;
  99797. /**
  99798. * The raw pose from the device
  99799. */
  99800. rawPose: DevicePose;
  99801. private _trackPosition;
  99802. private _maxRotationDistFromHeadset;
  99803. private _draggedRoomRotation;
  99804. /**
  99805. * @hidden
  99806. */
  99807. _disableTrackPosition(fixedPosition: Vector3): void;
  99808. /**
  99809. * Internal, the mesh attached to the controller
  99810. * @hidden
  99811. */
  99812. _mesh: Nullable<AbstractMesh>;
  99813. private _poseControlledCamera;
  99814. private _leftHandSystemQuaternion;
  99815. /**
  99816. * Internal, matrix used to convert room space to babylon space
  99817. * @hidden
  99818. */
  99819. _deviceToWorld: Matrix;
  99820. /**
  99821. * Node to be used when casting a ray from the controller
  99822. * @hidden
  99823. */
  99824. _pointingPoseNode: Nullable<TransformNode>;
  99825. /**
  99826. * Name of the child mesh that can be used to cast a ray from the controller
  99827. */
  99828. static readonly POINTING_POSE: string;
  99829. /**
  99830. * Creates a new PoseEnabledController from a gamepad
  99831. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99832. */
  99833. constructor(browserGamepad: any);
  99834. private _workingMatrix;
  99835. /**
  99836. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99837. */
  99838. update(): void;
  99839. /**
  99840. * Updates only the pose device and mesh without doing any button event checking
  99841. */
  99842. protected _updatePoseAndMesh(): void;
  99843. /**
  99844. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99845. * @param poseData raw pose fromthe device
  99846. */
  99847. updateFromDevice(poseData: DevicePose): void;
  99848. /**
  99849. * @hidden
  99850. */
  99851. _meshAttachedObservable: Observable<AbstractMesh>;
  99852. /**
  99853. * Attaches a mesh to the controller
  99854. * @param mesh the mesh to be attached
  99855. */
  99856. attachToMesh(mesh: AbstractMesh): void;
  99857. /**
  99858. * Attaches the controllers mesh to a camera
  99859. * @param camera the camera the mesh should be attached to
  99860. */
  99861. attachToPoseControlledCamera(camera: TargetCamera): void;
  99862. /**
  99863. * Disposes of the controller
  99864. */
  99865. dispose(): void;
  99866. /**
  99867. * The mesh that is attached to the controller
  99868. */
  99869. get mesh(): Nullable<AbstractMesh>;
  99870. /**
  99871. * Gets the ray of the controller in the direction the controller is pointing
  99872. * @param length the length the resulting ray should be
  99873. * @returns a ray in the direction the controller is pointing
  99874. */
  99875. getForwardRay(length?: number): Ray;
  99876. }
  99877. }
  99878. declare module BABYLON {
  99879. /**
  99880. * Defines the WebVRController object that represents controllers tracked in 3D space
  99881. */
  99882. export abstract class WebVRController extends PoseEnabledController {
  99883. /**
  99884. * Internal, the default controller model for the controller
  99885. */
  99886. protected _defaultModel: Nullable<AbstractMesh>;
  99887. /**
  99888. * Fired when the trigger state has changed
  99889. */
  99890. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99891. /**
  99892. * Fired when the main button state has changed
  99893. */
  99894. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99895. /**
  99896. * Fired when the secondary button state has changed
  99897. */
  99898. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99899. /**
  99900. * Fired when the pad state has changed
  99901. */
  99902. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99903. /**
  99904. * Fired when controllers stick values have changed
  99905. */
  99906. onPadValuesChangedObservable: Observable<StickValues>;
  99907. /**
  99908. * Array of button availible on the controller
  99909. */
  99910. protected _buttons: Array<MutableGamepadButton>;
  99911. private _onButtonStateChange;
  99912. /**
  99913. * Fired when a controller button's state has changed
  99914. * @param callback the callback containing the button that was modified
  99915. */
  99916. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99917. /**
  99918. * X and Y axis corresponding to the controllers joystick
  99919. */
  99920. pad: StickValues;
  99921. /**
  99922. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99923. */
  99924. hand: string;
  99925. /**
  99926. * The default controller model for the controller
  99927. */
  99928. get defaultModel(): Nullable<AbstractMesh>;
  99929. /**
  99930. * Creates a new WebVRController from a gamepad
  99931. * @param vrGamepad the gamepad that the WebVRController should be created from
  99932. */
  99933. constructor(vrGamepad: any);
  99934. /**
  99935. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99936. */
  99937. update(): void;
  99938. /**
  99939. * Function to be called when a button is modified
  99940. */
  99941. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99942. /**
  99943. * Loads a mesh and attaches it to the controller
  99944. * @param scene the scene the mesh should be added to
  99945. * @param meshLoaded callback for when the mesh has been loaded
  99946. */
  99947. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99948. private _setButtonValue;
  99949. private _changes;
  99950. private _checkChanges;
  99951. /**
  99952. * Disposes of th webVRCOntroller
  99953. */
  99954. dispose(): void;
  99955. }
  99956. }
  99957. declare module BABYLON {
  99958. /**
  99959. * The HemisphericLight simulates the ambient environment light,
  99960. * so the passed direction is the light reflection direction, not the incoming direction.
  99961. */
  99962. export class HemisphericLight extends Light {
  99963. /**
  99964. * The groundColor is the light in the opposite direction to the one specified during creation.
  99965. * 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.
  99966. */
  99967. groundColor: Color3;
  99968. /**
  99969. * The light reflection direction, not the incoming direction.
  99970. */
  99971. direction: Vector3;
  99972. /**
  99973. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99974. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99975. * The HemisphericLight can't cast shadows.
  99976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99977. * @param name The friendly name of the light
  99978. * @param direction The direction of the light reflection
  99979. * @param scene The scene the light belongs to
  99980. */
  99981. constructor(name: string, direction: Vector3, scene: Scene);
  99982. protected _buildUniformLayout(): void;
  99983. /**
  99984. * Returns the string "HemisphericLight".
  99985. * @return The class name
  99986. */
  99987. getClassName(): string;
  99988. /**
  99989. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99990. * Returns the updated direction.
  99991. * @param target The target the direction should point to
  99992. * @return The computed direction
  99993. */
  99994. setDirectionToTarget(target: Vector3): Vector3;
  99995. /**
  99996. * Returns the shadow generator associated to the light.
  99997. * @returns Always null for hemispheric lights because it does not support shadows.
  99998. */
  99999. getShadowGenerator(): Nullable<IShadowGenerator>;
  100000. /**
  100001. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100002. * @param effect The effect to update
  100003. * @param lightIndex The index of the light in the effect to update
  100004. * @returns The hemispheric light
  100005. */
  100006. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100007. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100008. /**
  100009. * Computes the world matrix of the node
  100010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100011. * @param useWasUpdatedFlag defines a reserved property
  100012. * @returns the world matrix
  100013. */
  100014. computeWorldMatrix(): Matrix;
  100015. /**
  100016. * Returns the integer 3.
  100017. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100018. */
  100019. getTypeID(): number;
  100020. /**
  100021. * Prepares the list of defines specific to the light type.
  100022. * @param defines the list of defines
  100023. * @param lightIndex defines the index of the light for the effect
  100024. */
  100025. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100026. }
  100027. }
  100028. declare module BABYLON {
  100029. /** @hidden */
  100030. export var vrMultiviewToSingleviewPixelShader: {
  100031. name: string;
  100032. shader: string;
  100033. };
  100034. }
  100035. declare module BABYLON {
  100036. /**
  100037. * Renders to multiple views with a single draw call
  100038. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100039. */
  100040. export class MultiviewRenderTarget extends RenderTargetTexture {
  100041. /**
  100042. * Creates a multiview render target
  100043. * @param scene scene used with the render target
  100044. * @param size the size of the render target (used for each view)
  100045. */
  100046. constructor(scene: Scene, size?: number | {
  100047. width: number;
  100048. height: number;
  100049. } | {
  100050. ratio: number;
  100051. });
  100052. /**
  100053. * @hidden
  100054. * @param faceIndex the face index, if its a cube texture
  100055. */
  100056. _bindFrameBuffer(faceIndex?: number): void;
  100057. /**
  100058. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100059. * @returns the view count
  100060. */
  100061. getViewCount(): number;
  100062. }
  100063. }
  100064. declare module BABYLON {
  100065. interface Engine {
  100066. /**
  100067. * Creates a new multiview render target
  100068. * @param width defines the width of the texture
  100069. * @param height defines the height of the texture
  100070. * @returns the created multiview texture
  100071. */
  100072. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100073. /**
  100074. * Binds a multiview framebuffer to be drawn to
  100075. * @param multiviewTexture texture to bind
  100076. */
  100077. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100078. }
  100079. interface Camera {
  100080. /**
  100081. * @hidden
  100082. * 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)
  100083. */
  100084. _useMultiviewToSingleView: boolean;
  100085. /**
  100086. * @hidden
  100087. * 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)
  100088. */
  100089. _multiviewTexture: Nullable<RenderTargetTexture>;
  100090. /**
  100091. * @hidden
  100092. * ensures the multiview texture of the camera exists and has the specified width/height
  100093. * @param width height to set on the multiview texture
  100094. * @param height width to set on the multiview texture
  100095. */
  100096. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100097. }
  100098. interface Scene {
  100099. /** @hidden */
  100100. _transformMatrixR: Matrix;
  100101. /** @hidden */
  100102. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100103. /** @hidden */
  100104. _createMultiviewUbo(): void;
  100105. /** @hidden */
  100106. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100107. /** @hidden */
  100108. _renderMultiviewToSingleView(camera: Camera): void;
  100109. }
  100110. }
  100111. declare module BABYLON {
  100112. /**
  100113. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100114. * This will not be used for webXR as it supports displaying texture arrays directly
  100115. */
  100116. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100117. /**
  100118. * Gets a string identifying the name of the class
  100119. * @returns "VRMultiviewToSingleviewPostProcess" string
  100120. */
  100121. getClassName(): string;
  100122. /**
  100123. * Initializes a VRMultiviewToSingleview
  100124. * @param name name of the post process
  100125. * @param camera camera to be applied to
  100126. * @param scaleFactor scaling factor to the size of the output texture
  100127. */
  100128. constructor(name: string, camera: Camera, scaleFactor: number);
  100129. }
  100130. }
  100131. declare module BABYLON {
  100132. /**
  100133. * Interface used to define additional presentation attributes
  100134. */
  100135. export interface IVRPresentationAttributes {
  100136. /**
  100137. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100138. */
  100139. highRefreshRate: boolean;
  100140. /**
  100141. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100142. */
  100143. foveationLevel: number;
  100144. }
  100145. interface Engine {
  100146. /** @hidden */
  100147. _vrDisplay: any;
  100148. /** @hidden */
  100149. _vrSupported: boolean;
  100150. /** @hidden */
  100151. _oldSize: Size;
  100152. /** @hidden */
  100153. _oldHardwareScaleFactor: number;
  100154. /** @hidden */
  100155. _vrExclusivePointerMode: boolean;
  100156. /** @hidden */
  100157. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100158. /** @hidden */
  100159. _onVRDisplayPointerRestricted: () => void;
  100160. /** @hidden */
  100161. _onVRDisplayPointerUnrestricted: () => void;
  100162. /** @hidden */
  100163. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100164. /** @hidden */
  100165. _onVrDisplayDisconnect: Nullable<() => void>;
  100166. /** @hidden */
  100167. _onVrDisplayPresentChange: Nullable<() => void>;
  100168. /**
  100169. * Observable signaled when VR display mode changes
  100170. */
  100171. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100172. /**
  100173. * Observable signaled when VR request present is complete
  100174. */
  100175. onVRRequestPresentComplete: Observable<boolean>;
  100176. /**
  100177. * Observable signaled when VR request present starts
  100178. */
  100179. onVRRequestPresentStart: Observable<Engine>;
  100180. /**
  100181. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100182. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100183. */
  100184. isInVRExclusivePointerMode: boolean;
  100185. /**
  100186. * Gets a boolean indicating if a webVR device was detected
  100187. * @returns true if a webVR device was detected
  100188. */
  100189. isVRDevicePresent(): boolean;
  100190. /**
  100191. * Gets the current webVR device
  100192. * @returns the current webVR device (or null)
  100193. */
  100194. getVRDevice(): any;
  100195. /**
  100196. * Initializes a webVR display and starts listening to display change events
  100197. * The onVRDisplayChangedObservable will be notified upon these changes
  100198. * @returns A promise containing a VRDisplay and if vr is supported
  100199. */
  100200. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100201. /** @hidden */
  100202. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100203. /**
  100204. * Gets or sets the presentation attributes used to configure VR rendering
  100205. */
  100206. vrPresentationAttributes?: IVRPresentationAttributes;
  100207. /**
  100208. * Call this function to switch to webVR mode
  100209. * Will do nothing if webVR is not supported or if there is no webVR device
  100210. * @param options the webvr options provided to the camera. mainly used for multiview
  100211. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100212. */
  100213. enableVR(options: WebVROptions): void;
  100214. /** @hidden */
  100215. _onVRFullScreenTriggered(): void;
  100216. }
  100217. }
  100218. declare module BABYLON {
  100219. /**
  100220. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100221. * IMPORTANT!! The data is right-hand data.
  100222. * @export
  100223. * @interface DevicePose
  100224. */
  100225. export interface DevicePose {
  100226. /**
  100227. * The position of the device, values in array are [x,y,z].
  100228. */
  100229. readonly position: Nullable<Float32Array>;
  100230. /**
  100231. * The linearVelocity of the device, values in array are [x,y,z].
  100232. */
  100233. readonly linearVelocity: Nullable<Float32Array>;
  100234. /**
  100235. * The linearAcceleration of the device, values in array are [x,y,z].
  100236. */
  100237. readonly linearAcceleration: Nullable<Float32Array>;
  100238. /**
  100239. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100240. */
  100241. readonly orientation: Nullable<Float32Array>;
  100242. /**
  100243. * The angularVelocity of the device, values in array are [x,y,z].
  100244. */
  100245. readonly angularVelocity: Nullable<Float32Array>;
  100246. /**
  100247. * The angularAcceleration of the device, values in array are [x,y,z].
  100248. */
  100249. readonly angularAcceleration: Nullable<Float32Array>;
  100250. }
  100251. /**
  100252. * Interface representing a pose controlled object in Babylon.
  100253. * A pose controlled object has both regular pose values as well as pose values
  100254. * from an external device such as a VR head mounted display
  100255. */
  100256. export interface PoseControlled {
  100257. /**
  100258. * The position of the object in babylon space.
  100259. */
  100260. position: Vector3;
  100261. /**
  100262. * The rotation quaternion of the object in babylon space.
  100263. */
  100264. rotationQuaternion: Quaternion;
  100265. /**
  100266. * The position of the device in babylon space.
  100267. */
  100268. devicePosition?: Vector3;
  100269. /**
  100270. * The rotation quaternion of the device in babylon space.
  100271. */
  100272. deviceRotationQuaternion: Quaternion;
  100273. /**
  100274. * The raw pose coming from the device.
  100275. */
  100276. rawPose: Nullable<DevicePose>;
  100277. /**
  100278. * The scale of the device to be used when translating from device space to babylon space.
  100279. */
  100280. deviceScaleFactor: number;
  100281. /**
  100282. * Updates the poseControlled values based on the input device pose.
  100283. * @param poseData the pose data to update the object with
  100284. */
  100285. updateFromDevice(poseData: DevicePose): void;
  100286. }
  100287. /**
  100288. * Set of options to customize the webVRCamera
  100289. */
  100290. export interface WebVROptions {
  100291. /**
  100292. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100293. */
  100294. trackPosition?: boolean;
  100295. /**
  100296. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100297. */
  100298. positionScale?: number;
  100299. /**
  100300. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100301. */
  100302. displayName?: string;
  100303. /**
  100304. * Should the native controller meshes be initialized. (default: true)
  100305. */
  100306. controllerMeshes?: boolean;
  100307. /**
  100308. * Creating a default HemiLight only on controllers. (default: true)
  100309. */
  100310. defaultLightingOnControllers?: boolean;
  100311. /**
  100312. * If you don't want to use the default VR button of the helper. (default: false)
  100313. */
  100314. useCustomVRButton?: boolean;
  100315. /**
  100316. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100317. */
  100318. customVRButton?: HTMLButtonElement;
  100319. /**
  100320. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100321. */
  100322. rayLength?: number;
  100323. /**
  100324. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100325. */
  100326. defaultHeight?: number;
  100327. /**
  100328. * If multiview should be used if availible (default: false)
  100329. */
  100330. useMultiview?: boolean;
  100331. }
  100332. /**
  100333. * This represents a WebVR camera.
  100334. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100335. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100336. */
  100337. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100338. private webVROptions;
  100339. /**
  100340. * @hidden
  100341. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100342. */
  100343. _vrDevice: any;
  100344. /**
  100345. * The rawPose of the vrDevice.
  100346. */
  100347. rawPose: Nullable<DevicePose>;
  100348. private _onVREnabled;
  100349. private _specsVersion;
  100350. private _attached;
  100351. private _frameData;
  100352. protected _descendants: Array<Node>;
  100353. private _deviceRoomPosition;
  100354. /** @hidden */
  100355. _deviceRoomRotationQuaternion: Quaternion;
  100356. private _standingMatrix;
  100357. /**
  100358. * Represents device position in babylon space.
  100359. */
  100360. devicePosition: Vector3;
  100361. /**
  100362. * Represents device rotation in babylon space.
  100363. */
  100364. deviceRotationQuaternion: Quaternion;
  100365. /**
  100366. * The scale of the device to be used when translating from device space to babylon space.
  100367. */
  100368. deviceScaleFactor: number;
  100369. private _deviceToWorld;
  100370. private _worldToDevice;
  100371. /**
  100372. * References to the webVR controllers for the vrDevice.
  100373. */
  100374. controllers: Array<WebVRController>;
  100375. /**
  100376. * Emits an event when a controller is attached.
  100377. */
  100378. onControllersAttachedObservable: Observable<WebVRController[]>;
  100379. /**
  100380. * Emits an event when a controller's mesh has been loaded;
  100381. */
  100382. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100383. /**
  100384. * Emits an event when the HMD's pose has been updated.
  100385. */
  100386. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100387. private _poseSet;
  100388. /**
  100389. * If the rig cameras be used as parent instead of this camera.
  100390. */
  100391. rigParenting: boolean;
  100392. private _lightOnControllers;
  100393. private _defaultHeight?;
  100394. /**
  100395. * Instantiates a WebVRFreeCamera.
  100396. * @param name The name of the WebVRFreeCamera
  100397. * @param position The starting anchor position for the camera
  100398. * @param scene The scene the camera belongs to
  100399. * @param webVROptions a set of customizable options for the webVRCamera
  100400. */
  100401. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100402. /**
  100403. * Gets the device distance from the ground in meters.
  100404. * @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.
  100405. */
  100406. deviceDistanceToRoomGround(): number;
  100407. /**
  100408. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100409. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100410. */
  100411. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100412. /**
  100413. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100414. * @returns A promise with a boolean set to if the standing matrix is supported.
  100415. */
  100416. useStandingMatrixAsync(): Promise<boolean>;
  100417. /**
  100418. * Disposes the camera
  100419. */
  100420. dispose(): void;
  100421. /**
  100422. * Gets a vrController by name.
  100423. * @param name The name of the controller to retreive
  100424. * @returns the controller matching the name specified or null if not found
  100425. */
  100426. getControllerByName(name: string): Nullable<WebVRController>;
  100427. private _leftController;
  100428. /**
  100429. * The controller corresponding to the users left hand.
  100430. */
  100431. get leftController(): Nullable<WebVRController>;
  100432. private _rightController;
  100433. /**
  100434. * The controller corresponding to the users right hand.
  100435. */
  100436. get rightController(): Nullable<WebVRController>;
  100437. /**
  100438. * Casts a ray forward from the vrCamera's gaze.
  100439. * @param length Length of the ray (default: 100)
  100440. * @returns the ray corresponding to the gaze
  100441. */
  100442. getForwardRay(length?: number): Ray;
  100443. /**
  100444. * @hidden
  100445. * Updates the camera based on device's frame data
  100446. */
  100447. _checkInputs(): void;
  100448. /**
  100449. * Updates the poseControlled values based on the input device pose.
  100450. * @param poseData Pose coming from the device
  100451. */
  100452. updateFromDevice(poseData: DevicePose): void;
  100453. private _htmlElementAttached;
  100454. private _detachIfAttached;
  100455. /**
  100456. * WebVR's attach control will start broadcasting frames to the device.
  100457. * Note that in certain browsers (chrome for example) this function must be called
  100458. * within a user-interaction callback. Example:
  100459. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100460. *
  100461. * @param element html element to attach the vrDevice to
  100462. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100463. */
  100464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100465. /**
  100466. * Detaches the camera from the html element and disables VR
  100467. *
  100468. * @param element html element to detach from
  100469. */
  100470. detachControl(element: HTMLElement): void;
  100471. /**
  100472. * @returns the name of this class
  100473. */
  100474. getClassName(): string;
  100475. /**
  100476. * Calls resetPose on the vrDisplay
  100477. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100478. */
  100479. resetToCurrentRotation(): void;
  100480. /**
  100481. * @hidden
  100482. * Updates the rig cameras (left and right eye)
  100483. */
  100484. _updateRigCameras(): void;
  100485. private _workingVector;
  100486. private _oneVector;
  100487. private _workingMatrix;
  100488. private updateCacheCalled;
  100489. private _correctPositionIfNotTrackPosition;
  100490. /**
  100491. * @hidden
  100492. * Updates the cached values of the camera
  100493. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100494. */
  100495. _updateCache(ignoreParentClass?: boolean): void;
  100496. /**
  100497. * @hidden
  100498. * Get current device position in babylon world
  100499. */
  100500. _computeDevicePosition(): void;
  100501. /**
  100502. * Updates the current device position and rotation in the babylon world
  100503. */
  100504. update(): void;
  100505. /**
  100506. * @hidden
  100507. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100508. * @returns an identity matrix
  100509. */
  100510. _getViewMatrix(): Matrix;
  100511. private _tmpMatrix;
  100512. /**
  100513. * This function is called by the two RIG cameras.
  100514. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100515. * @hidden
  100516. */
  100517. _getWebVRViewMatrix(): Matrix;
  100518. /** @hidden */
  100519. _getWebVRProjectionMatrix(): Matrix;
  100520. private _onGamepadConnectedObserver;
  100521. private _onGamepadDisconnectedObserver;
  100522. private _updateCacheWhenTrackingDisabledObserver;
  100523. /**
  100524. * Initializes the controllers and their meshes
  100525. */
  100526. initControllers(): void;
  100527. }
  100528. }
  100529. declare module BABYLON {
  100530. /**
  100531. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100532. *
  100533. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100534. *
  100535. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100536. */
  100537. export class MaterialHelper {
  100538. /**
  100539. * Bind the current view position to an effect.
  100540. * @param effect The effect to be bound
  100541. * @param scene The scene the eyes position is used from
  100542. * @param variableName name of the shader variable that will hold the eye position
  100543. */
  100544. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100545. /**
  100546. * Helps preparing the defines values about the UVs in used in the effect.
  100547. * UVs are shared as much as we can accross channels in the shaders.
  100548. * @param texture The texture we are preparing the UVs for
  100549. * @param defines The defines to update
  100550. * @param key The channel key "diffuse", "specular"... used in the shader
  100551. */
  100552. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100553. /**
  100554. * Binds a texture matrix value to its corrsponding uniform
  100555. * @param texture The texture to bind the matrix for
  100556. * @param uniformBuffer The uniform buffer receivin the data
  100557. * @param key The channel key "diffuse", "specular"... used in the shader
  100558. */
  100559. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100560. /**
  100561. * Gets the current status of the fog (should it be enabled?)
  100562. * @param mesh defines the mesh to evaluate for fog support
  100563. * @param scene defines the hosting scene
  100564. * @returns true if fog must be enabled
  100565. */
  100566. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100567. /**
  100568. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100569. * @param mesh defines the current mesh
  100570. * @param scene defines the current scene
  100571. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100572. * @param pointsCloud defines if point cloud rendering has to be turned on
  100573. * @param fogEnabled defines if fog has to be turned on
  100574. * @param alphaTest defines if alpha testing has to be turned on
  100575. * @param defines defines the current list of defines
  100576. */
  100577. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100578. /**
  100579. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100580. * @param scene defines the current scene
  100581. * @param engine defines the current engine
  100582. * @param defines specifies the list of active defines
  100583. * @param useInstances defines if instances have to be turned on
  100584. * @param useClipPlane defines if clip plane have to be turned on
  100585. * @param useInstances defines if instances have to be turned on
  100586. * @param useThinInstances defines if thin instances have to be turned on
  100587. */
  100588. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100589. /**
  100590. * Prepares the defines for bones
  100591. * @param mesh The mesh containing the geometry data we will draw
  100592. * @param defines The defines to update
  100593. */
  100594. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100595. /**
  100596. * Prepares the defines for morph targets
  100597. * @param mesh The mesh containing the geometry data we will draw
  100598. * @param defines The defines to update
  100599. */
  100600. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100601. /**
  100602. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100603. * @param mesh The mesh containing the geometry data we will draw
  100604. * @param defines The defines to update
  100605. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100606. * @param useBones Precise whether bones should be used or not (override mesh info)
  100607. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100608. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100609. * @returns false if defines are considered not dirty and have not been checked
  100610. */
  100611. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100612. /**
  100613. * Prepares the defines related to multiview
  100614. * @param scene The scene we are intending to draw
  100615. * @param defines The defines to update
  100616. */
  100617. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100618. /**
  100619. * Prepares the defines related to the prepass
  100620. * @param scene The scene we are intending to draw
  100621. * @param defines The defines to update
  100622. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100623. */
  100624. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100625. /**
  100626. * Prepares the defines related to the light information passed in parameter
  100627. * @param scene The scene we are intending to draw
  100628. * @param mesh The mesh the effect is compiling for
  100629. * @param light The light the effect is compiling for
  100630. * @param lightIndex The index of the light
  100631. * @param defines The defines to update
  100632. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100633. * @param state Defines the current state regarding what is needed (normals, etc...)
  100634. */
  100635. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100636. needNormals: boolean;
  100637. needRebuild: boolean;
  100638. shadowEnabled: boolean;
  100639. specularEnabled: boolean;
  100640. lightmapMode: boolean;
  100641. }): void;
  100642. /**
  100643. * Prepares the defines related to the light information passed in parameter
  100644. * @param scene The scene we are intending to draw
  100645. * @param mesh The mesh the effect is compiling for
  100646. * @param defines The defines to update
  100647. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100648. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100649. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100650. * @returns true if normals will be required for the rest of the effect
  100651. */
  100652. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100653. /**
  100654. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100655. * @param lightIndex defines the light index
  100656. * @param uniformsList The uniform list
  100657. * @param samplersList The sampler list
  100658. * @param projectedLightTexture defines if projected texture must be used
  100659. * @param uniformBuffersList defines an optional list of uniform buffers
  100660. */
  100661. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100662. /**
  100663. * Prepares the uniforms and samplers list to be used in the effect
  100664. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100665. * @param samplersList The sampler list
  100666. * @param defines The defines helping in the list generation
  100667. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100668. */
  100669. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100670. /**
  100671. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100672. * @param defines The defines to update while falling back
  100673. * @param fallbacks The authorized effect fallbacks
  100674. * @param maxSimultaneousLights The maximum number of lights allowed
  100675. * @param rank the current rank of the Effect
  100676. * @returns The newly affected rank
  100677. */
  100678. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100679. private static _TmpMorphInfluencers;
  100680. /**
  100681. * Prepares the list of attributes required for morph targets according to the effect defines.
  100682. * @param attribs The current list of supported attribs
  100683. * @param mesh The mesh to prepare the morph targets attributes for
  100684. * @param influencers The number of influencers
  100685. */
  100686. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100687. /**
  100688. * Prepares the list of attributes required for morph targets according to the effect defines.
  100689. * @param attribs The current list of supported attribs
  100690. * @param mesh The mesh to prepare the morph targets attributes for
  100691. * @param defines The current Defines of the effect
  100692. */
  100693. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100694. /**
  100695. * Prepares the list of attributes required for bones according to the effect defines.
  100696. * @param attribs The current list of supported attribs
  100697. * @param mesh The mesh to prepare the bones attributes for
  100698. * @param defines The current Defines of the effect
  100699. * @param fallbacks The current efffect fallback strategy
  100700. */
  100701. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100702. /**
  100703. * Check and prepare the list of attributes required for instances according to the effect defines.
  100704. * @param attribs The current list of supported attribs
  100705. * @param defines The current MaterialDefines of the effect
  100706. */
  100707. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100708. /**
  100709. * Add the list of attributes required for instances to the attribs array.
  100710. * @param attribs The current list of supported attribs
  100711. */
  100712. static PushAttributesForInstances(attribs: string[]): void;
  100713. /**
  100714. * Binds the light information to the effect.
  100715. * @param light The light containing the generator
  100716. * @param effect The effect we are binding the data to
  100717. * @param lightIndex The light index in the effect used to render
  100718. */
  100719. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100720. /**
  100721. * Binds the lights information from the scene to the effect for the given mesh.
  100722. * @param light Light to bind
  100723. * @param lightIndex Light index
  100724. * @param scene The scene where the light belongs to
  100725. * @param effect The effect we are binding the data to
  100726. * @param useSpecular Defines if specular is supported
  100727. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100728. */
  100729. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100730. /**
  100731. * Binds the lights information from the scene to the effect for the given mesh.
  100732. * @param scene The scene the lights belongs to
  100733. * @param mesh The mesh we are binding the information to render
  100734. * @param effect The effect we are binding the data to
  100735. * @param defines The generated defines for the effect
  100736. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100737. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100738. */
  100739. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100740. private static _tempFogColor;
  100741. /**
  100742. * Binds the fog information from the scene to the effect for the given mesh.
  100743. * @param scene The scene the lights belongs to
  100744. * @param mesh The mesh we are binding the information to render
  100745. * @param effect The effect we are binding the data to
  100746. * @param linearSpace Defines if the fog effect is applied in linear space
  100747. */
  100748. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100749. /**
  100750. * Binds the bones information from the mesh to the effect.
  100751. * @param mesh The mesh we are binding the information to render
  100752. * @param effect The effect we are binding the data to
  100753. */
  100754. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100755. /**
  100756. * Binds the morph targets information from the mesh to the effect.
  100757. * @param abstractMesh The mesh we are binding the information to render
  100758. * @param effect The effect we are binding the data to
  100759. */
  100760. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100761. /**
  100762. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100763. * @param defines The generated defines used in the effect
  100764. * @param effect The effect we are binding the data to
  100765. * @param scene The scene we are willing to render with logarithmic scale for
  100766. */
  100767. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100768. /**
  100769. * Binds the clip plane information from the scene to the effect.
  100770. * @param scene The scene the clip plane information are extracted from
  100771. * @param effect The effect we are binding the data to
  100772. */
  100773. static BindClipPlane(effect: Effect, scene: Scene): void;
  100774. }
  100775. }
  100776. declare module BABYLON {
  100777. /**
  100778. * Block used to expose an input value
  100779. */
  100780. export class InputBlock extends NodeMaterialBlock {
  100781. private _mode;
  100782. private _associatedVariableName;
  100783. private _storedValue;
  100784. private _valueCallback;
  100785. private _type;
  100786. private _animationType;
  100787. /** Gets or set a value used to limit the range of float values */
  100788. min: number;
  100789. /** Gets or set a value used to limit the range of float values */
  100790. max: number;
  100791. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100792. isBoolean: boolean;
  100793. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100794. matrixMode: number;
  100795. /** @hidden */
  100796. _systemValue: Nullable<NodeMaterialSystemValues>;
  100797. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100798. isConstant: boolean;
  100799. /** Gets or sets the group to use to display this block in the Inspector */
  100800. groupInInspector: string;
  100801. /** Gets an observable raised when the value is changed */
  100802. onValueChangedObservable: Observable<InputBlock>;
  100803. /**
  100804. * Gets or sets the connection point type (default is float)
  100805. */
  100806. get type(): NodeMaterialBlockConnectionPointTypes;
  100807. /**
  100808. * Creates a new InputBlock
  100809. * @param name defines the block name
  100810. * @param target defines the target of that block (Vertex by default)
  100811. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100812. */
  100813. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100814. /**
  100815. * Validates if a name is a reserve word.
  100816. * @param newName the new name to be given to the node.
  100817. * @returns false if the name is a reserve word, else true.
  100818. */
  100819. validateBlockName(newName: string): boolean;
  100820. /**
  100821. * Gets the output component
  100822. */
  100823. get output(): NodeMaterialConnectionPoint;
  100824. /**
  100825. * Set the source of this connection point to a vertex attribute
  100826. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100827. * @returns the current connection point
  100828. */
  100829. setAsAttribute(attributeName?: string): InputBlock;
  100830. /**
  100831. * Set the source of this connection point to a system value
  100832. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100833. * @returns the current connection point
  100834. */
  100835. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100836. /**
  100837. * Gets or sets the value of that point.
  100838. * Please note that this value will be ignored if valueCallback is defined
  100839. */
  100840. get value(): any;
  100841. set value(value: any);
  100842. /**
  100843. * Gets or sets a callback used to get the value of that point.
  100844. * Please note that setting this value will force the connection point to ignore the value property
  100845. */
  100846. get valueCallback(): () => any;
  100847. set valueCallback(value: () => any);
  100848. /**
  100849. * Gets or sets the associated variable name in the shader
  100850. */
  100851. get associatedVariableName(): string;
  100852. set associatedVariableName(value: string);
  100853. /** Gets or sets the type of animation applied to the input */
  100854. get animationType(): AnimatedInputBlockTypes;
  100855. set animationType(value: AnimatedInputBlockTypes);
  100856. /**
  100857. * Gets a boolean indicating that this connection point not defined yet
  100858. */
  100859. get isUndefined(): boolean;
  100860. /**
  100861. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100862. * In this case the connection point name must be the name of the uniform to use.
  100863. * Can only be set on inputs
  100864. */
  100865. get isUniform(): boolean;
  100866. set isUniform(value: boolean);
  100867. /**
  100868. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100869. * In this case the connection point name must be the name of the attribute to use
  100870. * Can only be set on inputs
  100871. */
  100872. get isAttribute(): boolean;
  100873. set isAttribute(value: boolean);
  100874. /**
  100875. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100876. * Can only be set on exit points
  100877. */
  100878. get isVarying(): boolean;
  100879. set isVarying(value: boolean);
  100880. /**
  100881. * Gets a boolean indicating that the current connection point is a system value
  100882. */
  100883. get isSystemValue(): boolean;
  100884. /**
  100885. * Gets or sets the current well known value or null if not defined as a system value
  100886. */
  100887. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100888. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100889. /**
  100890. * Gets the current class name
  100891. * @returns the class name
  100892. */
  100893. getClassName(): string;
  100894. /**
  100895. * Animate the input if animationType !== None
  100896. * @param scene defines the rendering scene
  100897. */
  100898. animate(scene: Scene): void;
  100899. private _emitDefine;
  100900. initialize(state: NodeMaterialBuildState): void;
  100901. /**
  100902. * Set the input block to its default value (based on its type)
  100903. */
  100904. setDefaultValue(): void;
  100905. private _emitConstant;
  100906. /** @hidden */
  100907. get _noContextSwitch(): boolean;
  100908. private _emit;
  100909. /** @hidden */
  100910. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100911. /** @hidden */
  100912. _transmit(effect: Effect, scene: Scene): void;
  100913. protected _buildBlock(state: NodeMaterialBuildState): void;
  100914. protected _dumpPropertiesCode(): string;
  100915. dispose(): void;
  100916. serialize(): any;
  100917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * Enum used to define the compatibility state between two connection points
  100923. */
  100924. export enum NodeMaterialConnectionPointCompatibilityStates {
  100925. /** Points are compatibles */
  100926. Compatible = 0,
  100927. /** Points are incompatible because of their types */
  100928. TypeIncompatible = 1,
  100929. /** Points are incompatible because of their targets (vertex vs fragment) */
  100930. TargetIncompatible = 2
  100931. }
  100932. /**
  100933. * Defines the direction of a connection point
  100934. */
  100935. export enum NodeMaterialConnectionPointDirection {
  100936. /** Input */
  100937. Input = 0,
  100938. /** Output */
  100939. Output = 1
  100940. }
  100941. /**
  100942. * Defines a connection point for a block
  100943. */
  100944. export class NodeMaterialConnectionPoint {
  100945. /** @hidden */
  100946. _ownerBlock: NodeMaterialBlock;
  100947. /** @hidden */
  100948. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100949. private _endpoints;
  100950. private _associatedVariableName;
  100951. private _direction;
  100952. /** @hidden */
  100953. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100954. /** @hidden */
  100955. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100956. private _type;
  100957. /** @hidden */
  100958. _enforceAssociatedVariableName: boolean;
  100959. /** Gets the direction of the point */
  100960. get direction(): NodeMaterialConnectionPointDirection;
  100961. /** Indicates that this connection point needs dual validation before being connected to another point */
  100962. needDualDirectionValidation: boolean;
  100963. /**
  100964. * Gets or sets the additional types supported by this connection point
  100965. */
  100966. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100967. /**
  100968. * Gets or sets the additional types excluded by this connection point
  100969. */
  100970. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100971. /**
  100972. * Observable triggered when this point is connected
  100973. */
  100974. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100975. /**
  100976. * Gets or sets the associated variable name in the shader
  100977. */
  100978. get associatedVariableName(): string;
  100979. set associatedVariableName(value: string);
  100980. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100981. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100982. /**
  100983. * Gets or sets the connection point type (default is float)
  100984. */
  100985. get type(): NodeMaterialBlockConnectionPointTypes;
  100986. set type(value: NodeMaterialBlockConnectionPointTypes);
  100987. /**
  100988. * Gets or sets the connection point name
  100989. */
  100990. name: string;
  100991. /**
  100992. * Gets or sets the connection point name
  100993. */
  100994. displayName: string;
  100995. /**
  100996. * Gets or sets a boolean indicating that this connection point can be omitted
  100997. */
  100998. isOptional: boolean;
  100999. /**
  101000. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101001. */
  101002. isExposedOnFrame: boolean;
  101003. /**
  101004. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101005. */
  101006. define: string;
  101007. /** @hidden */
  101008. _prioritizeVertex: boolean;
  101009. private _target;
  101010. /** Gets or sets the target of that connection point */
  101011. get target(): NodeMaterialBlockTargets;
  101012. set target(value: NodeMaterialBlockTargets);
  101013. /**
  101014. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101015. */
  101016. get isConnected(): boolean;
  101017. /**
  101018. * Gets a boolean indicating that the current point is connected to an input block
  101019. */
  101020. get isConnectedToInputBlock(): boolean;
  101021. /**
  101022. * Gets a the connected input block (if any)
  101023. */
  101024. get connectInputBlock(): Nullable<InputBlock>;
  101025. /** Get the other side of the connection (if any) */
  101026. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101027. /** Get the block that owns this connection point */
  101028. get ownerBlock(): NodeMaterialBlock;
  101029. /** Get the block connected on the other side of this connection (if any) */
  101030. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101031. /** Get the block connected on the endpoints of this connection (if any) */
  101032. get connectedBlocks(): Array<NodeMaterialBlock>;
  101033. /** Gets the list of connected endpoints */
  101034. get endpoints(): NodeMaterialConnectionPoint[];
  101035. /** Gets a boolean indicating if that output point is connected to at least one input */
  101036. get hasEndpoints(): boolean;
  101037. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101038. get isConnectedInVertexShader(): boolean;
  101039. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101040. get isConnectedInFragmentShader(): boolean;
  101041. /**
  101042. * Creates a block suitable to be used as an input for this input point.
  101043. * If null is returned, a block based on the point type will be created.
  101044. * @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
  101045. */
  101046. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101047. /**
  101048. * Creates a new connection point
  101049. * @param name defines the connection point name
  101050. * @param ownerBlock defines the block hosting this connection point
  101051. * @param direction defines the direction of the connection point
  101052. */
  101053. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101054. /**
  101055. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101056. * @returns the class name
  101057. */
  101058. getClassName(): string;
  101059. /**
  101060. * Gets a boolean indicating if the current point can be connected to another point
  101061. * @param connectionPoint defines the other connection point
  101062. * @returns a boolean
  101063. */
  101064. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101065. /**
  101066. * Gets a number indicating if the current point can be connected to another point
  101067. * @param connectionPoint defines the other connection point
  101068. * @returns a number defining the compatibility state
  101069. */
  101070. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101071. /**
  101072. * Connect this point to another connection point
  101073. * @param connectionPoint defines the other connection point
  101074. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101075. * @returns the current connection point
  101076. */
  101077. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101078. /**
  101079. * Disconnect this point from one of his endpoint
  101080. * @param endpoint defines the other connection point
  101081. * @returns the current connection point
  101082. */
  101083. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101084. /**
  101085. * Serializes this point in a JSON representation
  101086. * @param isInput defines if the connection point is an input (default is true)
  101087. * @returns the serialized point object
  101088. */
  101089. serialize(isInput?: boolean): any;
  101090. /**
  101091. * Release resources
  101092. */
  101093. dispose(): void;
  101094. }
  101095. }
  101096. declare module BABYLON {
  101097. /**
  101098. * Enum used to define the material modes
  101099. */
  101100. export enum NodeMaterialModes {
  101101. /** Regular material */
  101102. Material = 0,
  101103. /** For post process */
  101104. PostProcess = 1,
  101105. /** For particle system */
  101106. Particle = 2,
  101107. /** For procedural texture */
  101108. ProceduralTexture = 3
  101109. }
  101110. }
  101111. declare module BABYLON {
  101112. /**
  101113. * Block used to read a texture from a sampler
  101114. */
  101115. export class TextureBlock extends NodeMaterialBlock {
  101116. private _defineName;
  101117. private _linearDefineName;
  101118. private _gammaDefineName;
  101119. private _tempTextureRead;
  101120. private _samplerName;
  101121. private _transformedUVName;
  101122. private _textureTransformName;
  101123. private _textureInfoName;
  101124. private _mainUVName;
  101125. private _mainUVDefineName;
  101126. private _fragmentOnly;
  101127. /**
  101128. * Gets or sets the texture associated with the node
  101129. */
  101130. texture: Nullable<Texture>;
  101131. /**
  101132. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101133. */
  101134. convertToGammaSpace: boolean;
  101135. /**
  101136. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101137. */
  101138. convertToLinearSpace: boolean;
  101139. /**
  101140. * Create a new TextureBlock
  101141. * @param name defines the block name
  101142. */
  101143. constructor(name: string, fragmentOnly?: boolean);
  101144. /**
  101145. * Gets the current class name
  101146. * @returns the class name
  101147. */
  101148. getClassName(): string;
  101149. /**
  101150. * Gets the uv input component
  101151. */
  101152. get uv(): NodeMaterialConnectionPoint;
  101153. /**
  101154. * Gets the rgba output component
  101155. */
  101156. get rgba(): NodeMaterialConnectionPoint;
  101157. /**
  101158. * Gets the rgb output component
  101159. */
  101160. get rgb(): NodeMaterialConnectionPoint;
  101161. /**
  101162. * Gets the r output component
  101163. */
  101164. get r(): NodeMaterialConnectionPoint;
  101165. /**
  101166. * Gets the g output component
  101167. */
  101168. get g(): NodeMaterialConnectionPoint;
  101169. /**
  101170. * Gets the b output component
  101171. */
  101172. get b(): NodeMaterialConnectionPoint;
  101173. /**
  101174. * Gets the a output component
  101175. */
  101176. get a(): NodeMaterialConnectionPoint;
  101177. get target(): NodeMaterialBlockTargets;
  101178. autoConfigure(material: NodeMaterial): void;
  101179. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101181. isReady(): boolean;
  101182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101183. private get _isMixed();
  101184. private _injectVertexCode;
  101185. private _writeTextureRead;
  101186. private _writeOutput;
  101187. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101188. protected _dumpPropertiesCode(): string;
  101189. serialize(): any;
  101190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101191. }
  101192. }
  101193. declare module BABYLON {
  101194. /** @hidden */
  101195. export var reflectionFunction: {
  101196. name: string;
  101197. shader: string;
  101198. };
  101199. }
  101200. declare module BABYLON {
  101201. /**
  101202. * Base block used to read a reflection texture from a sampler
  101203. */
  101204. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101205. /** @hidden */
  101206. _define3DName: string;
  101207. /** @hidden */
  101208. _defineCubicName: string;
  101209. /** @hidden */
  101210. _defineExplicitName: string;
  101211. /** @hidden */
  101212. _defineProjectionName: string;
  101213. /** @hidden */
  101214. _defineLocalCubicName: string;
  101215. /** @hidden */
  101216. _defineSphericalName: string;
  101217. /** @hidden */
  101218. _definePlanarName: string;
  101219. /** @hidden */
  101220. _defineEquirectangularName: string;
  101221. /** @hidden */
  101222. _defineMirroredEquirectangularFixedName: string;
  101223. /** @hidden */
  101224. _defineEquirectangularFixedName: string;
  101225. /** @hidden */
  101226. _defineSkyboxName: string;
  101227. /** @hidden */
  101228. _defineOppositeZ: string;
  101229. /** @hidden */
  101230. _cubeSamplerName: string;
  101231. /** @hidden */
  101232. _2DSamplerName: string;
  101233. protected _positionUVWName: string;
  101234. protected _directionWName: string;
  101235. protected _reflectionVectorName: string;
  101236. /** @hidden */
  101237. _reflectionCoordsName: string;
  101238. /** @hidden */
  101239. _reflectionMatrixName: string;
  101240. protected _reflectionColorName: string;
  101241. /**
  101242. * Gets or sets the texture associated with the node
  101243. */
  101244. texture: Nullable<BaseTexture>;
  101245. /**
  101246. * Create a new ReflectionTextureBaseBlock
  101247. * @param name defines the block name
  101248. */
  101249. constructor(name: string);
  101250. /**
  101251. * Gets the current class name
  101252. * @returns the class name
  101253. */
  101254. getClassName(): string;
  101255. /**
  101256. * Gets the world position input component
  101257. */
  101258. abstract get position(): NodeMaterialConnectionPoint;
  101259. /**
  101260. * Gets the world position input component
  101261. */
  101262. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101263. /**
  101264. * Gets the world normal input component
  101265. */
  101266. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101267. /**
  101268. * Gets the world input component
  101269. */
  101270. abstract get world(): NodeMaterialConnectionPoint;
  101271. /**
  101272. * Gets the camera (or eye) position component
  101273. */
  101274. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101275. /**
  101276. * Gets the view input component
  101277. */
  101278. abstract get view(): NodeMaterialConnectionPoint;
  101279. protected _getTexture(): Nullable<BaseTexture>;
  101280. autoConfigure(material: NodeMaterial): void;
  101281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101282. isReady(): boolean;
  101283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101284. /**
  101285. * Gets the code to inject in the vertex shader
  101286. * @param state current state of the node material building
  101287. * @returns the shader code
  101288. */
  101289. handleVertexSide(state: NodeMaterialBuildState): string;
  101290. /**
  101291. * Handles the inits for the fragment code path
  101292. * @param state node material build state
  101293. */
  101294. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101295. /**
  101296. * Generates the reflection coords code for the fragment code path
  101297. * @param worldNormalVarName name of the world normal variable
  101298. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101299. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101300. * @returns the shader code
  101301. */
  101302. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101303. /**
  101304. * Generates the reflection color code for the fragment code path
  101305. * @param lodVarName name of the lod variable
  101306. * @param swizzleLookupTexture swizzle to use for the final color variable
  101307. * @returns the shader code
  101308. */
  101309. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101310. /**
  101311. * Generates the code corresponding to the connected output points
  101312. * @param state node material build state
  101313. * @param varName name of the variable to output
  101314. * @returns the shader code
  101315. */
  101316. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101317. protected _buildBlock(state: NodeMaterialBuildState): this;
  101318. protected _dumpPropertiesCode(): string;
  101319. serialize(): any;
  101320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101321. }
  101322. }
  101323. declare module BABYLON {
  101324. /**
  101325. * Defines a connection point to be used for points with a custom object type
  101326. */
  101327. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101328. private _blockType;
  101329. private _blockName;
  101330. private _nameForCheking?;
  101331. /**
  101332. * Creates a new connection point
  101333. * @param name defines the connection point name
  101334. * @param ownerBlock defines the block hosting this connection point
  101335. * @param direction defines the direction of the connection point
  101336. */
  101337. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101338. /**
  101339. * Gets a number indicating if the current point can be connected to another point
  101340. * @param connectionPoint defines the other connection point
  101341. * @returns a number defining the compatibility state
  101342. */
  101343. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101344. /**
  101345. * Creates a block suitable to be used as an input for this input point.
  101346. * If null is returned, a block based on the point type will be created.
  101347. * @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
  101348. */
  101349. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101350. }
  101351. }
  101352. declare module BABYLON {
  101353. /**
  101354. * Enum defining the type of properties that can be edited in the property pages in the NME
  101355. */
  101356. export enum PropertyTypeForEdition {
  101357. /** property is a boolean */
  101358. Boolean = 0,
  101359. /** property is a float */
  101360. Float = 1,
  101361. /** property is a Vector2 */
  101362. Vector2 = 2,
  101363. /** property is a list of values */
  101364. List = 3
  101365. }
  101366. /**
  101367. * Interface that defines an option in a variable of type list
  101368. */
  101369. export interface IEditablePropertyListOption {
  101370. /** label of the option */
  101371. "label": string;
  101372. /** value of the option */
  101373. "value": number;
  101374. }
  101375. /**
  101376. * Interface that defines the options available for an editable property
  101377. */
  101378. export interface IEditablePropertyOption {
  101379. /** min value */
  101380. "min"?: number;
  101381. /** max value */
  101382. "max"?: number;
  101383. /** notifiers: indicates which actions to take when the property is changed */
  101384. "notifiers"?: {
  101385. /** the material should be rebuilt */
  101386. "rebuild"?: boolean;
  101387. /** the preview should be updated */
  101388. "update"?: boolean;
  101389. };
  101390. /** list of the options for a variable of type list */
  101391. "options"?: IEditablePropertyListOption[];
  101392. }
  101393. /**
  101394. * Interface that describes an editable property
  101395. */
  101396. export interface IPropertyDescriptionForEdition {
  101397. /** name of the property */
  101398. "propertyName": string;
  101399. /** display name of the property */
  101400. "displayName": string;
  101401. /** type of the property */
  101402. "type": PropertyTypeForEdition;
  101403. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101404. "groupName": string;
  101405. /** options for the property */
  101406. "options": IEditablePropertyOption;
  101407. }
  101408. /**
  101409. * Decorator that flags a property in a node material block as being editable
  101410. */
  101411. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101412. }
  101413. declare module BABYLON {
  101414. /**
  101415. * Block used to implement the refraction part of the sub surface module of the PBR material
  101416. */
  101417. export class RefractionBlock extends NodeMaterialBlock {
  101418. /** @hidden */
  101419. _define3DName: string;
  101420. /** @hidden */
  101421. _refractionMatrixName: string;
  101422. /** @hidden */
  101423. _defineLODRefractionAlpha: string;
  101424. /** @hidden */
  101425. _defineLinearSpecularRefraction: string;
  101426. /** @hidden */
  101427. _defineOppositeZ: string;
  101428. /** @hidden */
  101429. _cubeSamplerName: string;
  101430. /** @hidden */
  101431. _2DSamplerName: string;
  101432. /** @hidden */
  101433. _vRefractionMicrosurfaceInfosName: string;
  101434. /** @hidden */
  101435. _vRefractionInfosName: string;
  101436. private _scene;
  101437. /**
  101438. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101439. * Materials half opaque for instance using refraction could benefit from this control.
  101440. */
  101441. linkRefractionWithTransparency: boolean;
  101442. /**
  101443. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101444. */
  101445. invertRefractionY: boolean;
  101446. /**
  101447. * Gets or sets the texture associated with the node
  101448. */
  101449. texture: Nullable<BaseTexture>;
  101450. /**
  101451. * Create a new RefractionBlock
  101452. * @param name defines the block name
  101453. */
  101454. constructor(name: string);
  101455. /**
  101456. * Gets the current class name
  101457. * @returns the class name
  101458. */
  101459. getClassName(): string;
  101460. /**
  101461. * Gets the intensity input component
  101462. */
  101463. get intensity(): NodeMaterialConnectionPoint;
  101464. /**
  101465. * Gets the index of refraction input component
  101466. */
  101467. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101468. /**
  101469. * Gets the tint at distance input component
  101470. */
  101471. get tintAtDistance(): NodeMaterialConnectionPoint;
  101472. /**
  101473. * Gets the view input component
  101474. */
  101475. get view(): NodeMaterialConnectionPoint;
  101476. /**
  101477. * Gets the refraction object output component
  101478. */
  101479. get refraction(): NodeMaterialConnectionPoint;
  101480. /**
  101481. * Returns true if the block has a texture
  101482. */
  101483. get hasTexture(): boolean;
  101484. protected _getTexture(): Nullable<BaseTexture>;
  101485. autoConfigure(material: NodeMaterial): void;
  101486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101487. isReady(): boolean;
  101488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101489. /**
  101490. * Gets the main code of the block (fragment side)
  101491. * @param state current state of the node material building
  101492. * @returns the shader code
  101493. */
  101494. getCode(state: NodeMaterialBuildState): string;
  101495. protected _buildBlock(state: NodeMaterialBuildState): this;
  101496. protected _dumpPropertiesCode(): string;
  101497. serialize(): any;
  101498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101499. }
  101500. }
  101501. declare module BABYLON {
  101502. /**
  101503. * Base block used as input for post process
  101504. */
  101505. export class CurrentScreenBlock extends NodeMaterialBlock {
  101506. private _samplerName;
  101507. private _linearDefineName;
  101508. private _gammaDefineName;
  101509. private _mainUVName;
  101510. private _tempTextureRead;
  101511. /**
  101512. * Gets or sets the texture associated with the node
  101513. */
  101514. texture: Nullable<BaseTexture>;
  101515. /**
  101516. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101517. */
  101518. convertToGammaSpace: boolean;
  101519. /**
  101520. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101521. */
  101522. convertToLinearSpace: boolean;
  101523. /**
  101524. * Create a new CurrentScreenBlock
  101525. * @param name defines the block name
  101526. */
  101527. constructor(name: string);
  101528. /**
  101529. * Gets the current class name
  101530. * @returns the class name
  101531. */
  101532. getClassName(): string;
  101533. /**
  101534. * Gets the uv input component
  101535. */
  101536. get uv(): NodeMaterialConnectionPoint;
  101537. /**
  101538. * Gets the rgba output component
  101539. */
  101540. get rgba(): NodeMaterialConnectionPoint;
  101541. /**
  101542. * Gets the rgb output component
  101543. */
  101544. get rgb(): NodeMaterialConnectionPoint;
  101545. /**
  101546. * Gets the r output component
  101547. */
  101548. get r(): NodeMaterialConnectionPoint;
  101549. /**
  101550. * Gets the g output component
  101551. */
  101552. get g(): NodeMaterialConnectionPoint;
  101553. /**
  101554. * Gets the b output component
  101555. */
  101556. get b(): NodeMaterialConnectionPoint;
  101557. /**
  101558. * Gets the a output component
  101559. */
  101560. get a(): NodeMaterialConnectionPoint;
  101561. /**
  101562. * Initialize the block and prepare the context for build
  101563. * @param state defines the state that will be used for the build
  101564. */
  101565. initialize(state: NodeMaterialBuildState): void;
  101566. get target(): NodeMaterialBlockTargets;
  101567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101568. isReady(): boolean;
  101569. private _injectVertexCode;
  101570. private _writeTextureRead;
  101571. private _writeOutput;
  101572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101573. serialize(): any;
  101574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101575. }
  101576. }
  101577. declare module BABYLON {
  101578. /**
  101579. * Base block used for the particle texture
  101580. */
  101581. export class ParticleTextureBlock extends NodeMaterialBlock {
  101582. private _samplerName;
  101583. private _linearDefineName;
  101584. private _gammaDefineName;
  101585. private _tempTextureRead;
  101586. /**
  101587. * Gets or sets the texture associated with the node
  101588. */
  101589. texture: Nullable<BaseTexture>;
  101590. /**
  101591. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101592. */
  101593. convertToGammaSpace: boolean;
  101594. /**
  101595. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101596. */
  101597. convertToLinearSpace: boolean;
  101598. /**
  101599. * Create a new ParticleTextureBlock
  101600. * @param name defines the block name
  101601. */
  101602. constructor(name: string);
  101603. /**
  101604. * Gets the current class name
  101605. * @returns the class name
  101606. */
  101607. getClassName(): string;
  101608. /**
  101609. * Gets the uv input component
  101610. */
  101611. get uv(): NodeMaterialConnectionPoint;
  101612. /**
  101613. * Gets the rgba output component
  101614. */
  101615. get rgba(): NodeMaterialConnectionPoint;
  101616. /**
  101617. * Gets the rgb output component
  101618. */
  101619. get rgb(): NodeMaterialConnectionPoint;
  101620. /**
  101621. * Gets the r output component
  101622. */
  101623. get r(): NodeMaterialConnectionPoint;
  101624. /**
  101625. * Gets the g output component
  101626. */
  101627. get g(): NodeMaterialConnectionPoint;
  101628. /**
  101629. * Gets the b output component
  101630. */
  101631. get b(): NodeMaterialConnectionPoint;
  101632. /**
  101633. * Gets the a output component
  101634. */
  101635. get a(): NodeMaterialConnectionPoint;
  101636. /**
  101637. * Initialize the block and prepare the context for build
  101638. * @param state defines the state that will be used for the build
  101639. */
  101640. initialize(state: NodeMaterialBuildState): void;
  101641. autoConfigure(material: NodeMaterial): void;
  101642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101643. isReady(): boolean;
  101644. private _writeOutput;
  101645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101646. serialize(): any;
  101647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101648. }
  101649. }
  101650. declare module BABYLON {
  101651. /**
  101652. * Class used to store shared data between 2 NodeMaterialBuildState
  101653. */
  101654. export class NodeMaterialBuildStateSharedData {
  101655. /**
  101656. * Gets the list of emitted varyings
  101657. */
  101658. temps: string[];
  101659. /**
  101660. * Gets the list of emitted varyings
  101661. */
  101662. varyings: string[];
  101663. /**
  101664. * Gets the varying declaration string
  101665. */
  101666. varyingDeclaration: string;
  101667. /**
  101668. * Input blocks
  101669. */
  101670. inputBlocks: InputBlock[];
  101671. /**
  101672. * Input blocks
  101673. */
  101674. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101675. /**
  101676. * Bindable blocks (Blocks that need to set data to the effect)
  101677. */
  101678. bindableBlocks: NodeMaterialBlock[];
  101679. /**
  101680. * List of blocks that can provide a compilation fallback
  101681. */
  101682. blocksWithFallbacks: NodeMaterialBlock[];
  101683. /**
  101684. * List of blocks that can provide a define update
  101685. */
  101686. blocksWithDefines: NodeMaterialBlock[];
  101687. /**
  101688. * List of blocks that can provide a repeatable content
  101689. */
  101690. repeatableContentBlocks: NodeMaterialBlock[];
  101691. /**
  101692. * List of blocks that can provide a dynamic list of uniforms
  101693. */
  101694. dynamicUniformBlocks: NodeMaterialBlock[];
  101695. /**
  101696. * List of blocks that can block the isReady function for the material
  101697. */
  101698. blockingBlocks: NodeMaterialBlock[];
  101699. /**
  101700. * Gets the list of animated inputs
  101701. */
  101702. animatedInputs: InputBlock[];
  101703. /**
  101704. * Build Id used to avoid multiple recompilations
  101705. */
  101706. buildId: number;
  101707. /** List of emitted variables */
  101708. variableNames: {
  101709. [key: string]: number;
  101710. };
  101711. /** List of emitted defines */
  101712. defineNames: {
  101713. [key: string]: number;
  101714. };
  101715. /** Should emit comments? */
  101716. emitComments: boolean;
  101717. /** Emit build activity */
  101718. verbose: boolean;
  101719. /** Gets or sets the hosting scene */
  101720. scene: Scene;
  101721. /**
  101722. * Gets the compilation hints emitted at compilation time
  101723. */
  101724. hints: {
  101725. needWorldViewMatrix: boolean;
  101726. needWorldViewProjectionMatrix: boolean;
  101727. needAlphaBlending: boolean;
  101728. needAlphaTesting: boolean;
  101729. };
  101730. /**
  101731. * List of compilation checks
  101732. */
  101733. checks: {
  101734. emitVertex: boolean;
  101735. emitFragment: boolean;
  101736. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101737. };
  101738. /**
  101739. * Is vertex program allowed to be empty?
  101740. */
  101741. allowEmptyVertexProgram: boolean;
  101742. /** Creates a new shared data */
  101743. constructor();
  101744. /**
  101745. * Emits console errors and exceptions if there is a failing check
  101746. */
  101747. emitErrors(): void;
  101748. }
  101749. }
  101750. declare module BABYLON {
  101751. /**
  101752. * Class used to store node based material build state
  101753. */
  101754. export class NodeMaterialBuildState {
  101755. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101756. supportUniformBuffers: boolean;
  101757. /**
  101758. * Gets the list of emitted attributes
  101759. */
  101760. attributes: string[];
  101761. /**
  101762. * Gets the list of emitted uniforms
  101763. */
  101764. uniforms: string[];
  101765. /**
  101766. * Gets the list of emitted constants
  101767. */
  101768. constants: string[];
  101769. /**
  101770. * Gets the list of emitted samplers
  101771. */
  101772. samplers: string[];
  101773. /**
  101774. * Gets the list of emitted functions
  101775. */
  101776. functions: {
  101777. [key: string]: string;
  101778. };
  101779. /**
  101780. * Gets the list of emitted extensions
  101781. */
  101782. extensions: {
  101783. [key: string]: string;
  101784. };
  101785. /**
  101786. * Gets the target of the compilation state
  101787. */
  101788. target: NodeMaterialBlockTargets;
  101789. /**
  101790. * Gets the list of emitted counters
  101791. */
  101792. counters: {
  101793. [key: string]: number;
  101794. };
  101795. /**
  101796. * Shared data between multiple NodeMaterialBuildState instances
  101797. */
  101798. sharedData: NodeMaterialBuildStateSharedData;
  101799. /** @hidden */
  101800. _vertexState: NodeMaterialBuildState;
  101801. /** @hidden */
  101802. _attributeDeclaration: string;
  101803. /** @hidden */
  101804. _uniformDeclaration: string;
  101805. /** @hidden */
  101806. _constantDeclaration: string;
  101807. /** @hidden */
  101808. _samplerDeclaration: string;
  101809. /** @hidden */
  101810. _varyingTransfer: string;
  101811. /** @hidden */
  101812. _injectAtEnd: string;
  101813. private _repeatableContentAnchorIndex;
  101814. /** @hidden */
  101815. _builtCompilationString: string;
  101816. /**
  101817. * Gets the emitted compilation strings
  101818. */
  101819. compilationString: string;
  101820. /**
  101821. * Finalize the compilation strings
  101822. * @param state defines the current compilation state
  101823. */
  101824. finalize(state: NodeMaterialBuildState): void;
  101825. /** @hidden */
  101826. get _repeatableContentAnchor(): string;
  101827. /** @hidden */
  101828. _getFreeVariableName(prefix: string): string;
  101829. /** @hidden */
  101830. _getFreeDefineName(prefix: string): string;
  101831. /** @hidden */
  101832. _excludeVariableName(name: string): void;
  101833. /** @hidden */
  101834. _emit2DSampler(name: string): void;
  101835. /** @hidden */
  101836. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101837. /** @hidden */
  101838. _emitExtension(name: string, extension: string, define?: string): void;
  101839. /** @hidden */
  101840. _emitFunction(name: string, code: string, comments: string): void;
  101841. /** @hidden */
  101842. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101843. replaceStrings?: {
  101844. search: RegExp;
  101845. replace: string;
  101846. }[];
  101847. repeatKey?: string;
  101848. }): string;
  101849. /** @hidden */
  101850. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101851. repeatKey?: string;
  101852. removeAttributes?: boolean;
  101853. removeUniforms?: boolean;
  101854. removeVaryings?: boolean;
  101855. removeIfDef?: boolean;
  101856. replaceStrings?: {
  101857. search: RegExp;
  101858. replace: string;
  101859. }[];
  101860. }, storeKey?: string): void;
  101861. /** @hidden */
  101862. _registerTempVariable(name: string): boolean;
  101863. /** @hidden */
  101864. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101865. /** @hidden */
  101866. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101867. /** @hidden */
  101868. _emitFloat(value: number): string;
  101869. }
  101870. }
  101871. declare module BABYLON {
  101872. /**
  101873. * Helper class used to generate session unique ID
  101874. */
  101875. export class UniqueIdGenerator {
  101876. private static _UniqueIdCounter;
  101877. /**
  101878. * Gets an unique (relatively to the current scene) Id
  101879. */
  101880. static get UniqueId(): number;
  101881. }
  101882. }
  101883. declare module BABYLON {
  101884. /**
  101885. * Defines a block that can be used inside a node based material
  101886. */
  101887. export class NodeMaterialBlock {
  101888. private _buildId;
  101889. private _buildTarget;
  101890. private _target;
  101891. private _isFinalMerger;
  101892. private _isInput;
  101893. private _name;
  101894. protected _isUnique: boolean;
  101895. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101896. inputsAreExclusive: boolean;
  101897. /** @hidden */
  101898. _codeVariableName: string;
  101899. /** @hidden */
  101900. _inputs: NodeMaterialConnectionPoint[];
  101901. /** @hidden */
  101902. _outputs: NodeMaterialConnectionPoint[];
  101903. /** @hidden */
  101904. _preparationId: number;
  101905. /**
  101906. * Gets the name of the block
  101907. */
  101908. get name(): string;
  101909. /**
  101910. * Sets the name of the block. Will check if the name is valid.
  101911. */
  101912. set name(newName: string);
  101913. /**
  101914. * Gets or sets the unique id of the node
  101915. */
  101916. uniqueId: number;
  101917. /**
  101918. * Gets or sets the comments associated with this block
  101919. */
  101920. comments: string;
  101921. /**
  101922. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101923. */
  101924. get isUnique(): boolean;
  101925. /**
  101926. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101927. */
  101928. get isFinalMerger(): boolean;
  101929. /**
  101930. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101931. */
  101932. get isInput(): boolean;
  101933. /**
  101934. * Gets or sets the build Id
  101935. */
  101936. get buildId(): number;
  101937. set buildId(value: number);
  101938. /**
  101939. * Gets or sets the target of the block
  101940. */
  101941. get target(): NodeMaterialBlockTargets;
  101942. set target(value: NodeMaterialBlockTargets);
  101943. /**
  101944. * Gets the list of input points
  101945. */
  101946. get inputs(): NodeMaterialConnectionPoint[];
  101947. /** Gets the list of output points */
  101948. get outputs(): NodeMaterialConnectionPoint[];
  101949. /**
  101950. * Find an input by its name
  101951. * @param name defines the name of the input to look for
  101952. * @returns the input or null if not found
  101953. */
  101954. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101955. /**
  101956. * Find an output by its name
  101957. * @param name defines the name of the outputto look for
  101958. * @returns the output or null if not found
  101959. */
  101960. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101961. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101962. visibleInInspector: boolean;
  101963. /**
  101964. * Creates a new NodeMaterialBlock
  101965. * @param name defines the block name
  101966. * @param target defines the target of that block (Vertex by default)
  101967. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101968. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101969. */
  101970. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101971. /**
  101972. * Initialize the block and prepare the context for build
  101973. * @param state defines the state that will be used for the build
  101974. */
  101975. initialize(state: NodeMaterialBuildState): void;
  101976. /**
  101977. * Bind data to effect. Will only be called for blocks with isBindable === true
  101978. * @param effect defines the effect to bind data to
  101979. * @param nodeMaterial defines the hosting NodeMaterial
  101980. * @param mesh defines the mesh that will be rendered
  101981. * @param subMesh defines the submesh that will be rendered
  101982. */
  101983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101984. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101985. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101986. protected _writeFloat(value: number): string;
  101987. /**
  101988. * Gets the current class name e.g. "NodeMaterialBlock"
  101989. * @returns the class name
  101990. */
  101991. getClassName(): string;
  101992. /**
  101993. * Register a new input. Must be called inside a block constructor
  101994. * @param name defines the connection point name
  101995. * @param type defines the connection point type
  101996. * @param isOptional defines a boolean indicating that this input can be omitted
  101997. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101998. * @param point an already created connection point. If not provided, create a new one
  101999. * @returns the current block
  102000. */
  102001. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102002. /**
  102003. * Register a new output. Must be called inside a block constructor
  102004. * @param name defines the connection point name
  102005. * @param type defines the connection point type
  102006. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102007. * @param point an already created connection point. If not provided, create a new one
  102008. * @returns the current block
  102009. */
  102010. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102011. /**
  102012. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102013. * @param forOutput defines an optional connection point to check compatibility with
  102014. * @returns the first available input or null
  102015. */
  102016. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102017. /**
  102018. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102019. * @param forBlock defines an optional block to check compatibility with
  102020. * @returns the first available input or null
  102021. */
  102022. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102023. /**
  102024. * Gets the sibling of the given output
  102025. * @param current defines the current output
  102026. * @returns the next output in the list or null
  102027. */
  102028. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102029. /**
  102030. * Connect current block with another block
  102031. * @param other defines the block to connect with
  102032. * @param options define the various options to help pick the right connections
  102033. * @returns the current block
  102034. */
  102035. connectTo(other: NodeMaterialBlock, options?: {
  102036. input?: string;
  102037. output?: string;
  102038. outputSwizzle?: string;
  102039. }): this | undefined;
  102040. protected _buildBlock(state: NodeMaterialBuildState): void;
  102041. /**
  102042. * Add uniforms, samplers and uniform buffers at compilation time
  102043. * @param state defines the state to update
  102044. * @param nodeMaterial defines the node material requesting the update
  102045. * @param defines defines the material defines to update
  102046. * @param uniformBuffers defines the list of uniform buffer names
  102047. */
  102048. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102049. /**
  102050. * Add potential fallbacks if shader compilation fails
  102051. * @param mesh defines the mesh to be rendered
  102052. * @param fallbacks defines the current prioritized list of fallbacks
  102053. */
  102054. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102055. /**
  102056. * Initialize defines for shader compilation
  102057. * @param mesh defines the mesh to be rendered
  102058. * @param nodeMaterial defines the node material requesting the update
  102059. * @param defines defines the material defines to update
  102060. * @param useInstances specifies that instances should be used
  102061. */
  102062. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102063. /**
  102064. * Update defines for shader compilation
  102065. * @param mesh defines the mesh to be rendered
  102066. * @param nodeMaterial defines the node material requesting the update
  102067. * @param defines defines the material defines to update
  102068. * @param useInstances specifies that instances should be used
  102069. * @param subMesh defines which submesh to render
  102070. */
  102071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102072. /**
  102073. * Lets the block try to connect some inputs automatically
  102074. * @param material defines the hosting NodeMaterial
  102075. */
  102076. autoConfigure(material: NodeMaterial): void;
  102077. /**
  102078. * Function called when a block is declared as repeatable content generator
  102079. * @param vertexShaderState defines the current compilation state for the vertex shader
  102080. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102081. * @param mesh defines the mesh to be rendered
  102082. * @param defines defines the material defines to update
  102083. */
  102084. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102085. /**
  102086. * Checks if the block is ready
  102087. * @param mesh defines the mesh to be rendered
  102088. * @param nodeMaterial defines the node material requesting the update
  102089. * @param defines defines the material defines to update
  102090. * @param useInstances specifies that instances should be used
  102091. * @returns true if the block is ready
  102092. */
  102093. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102094. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102095. private _processBuild;
  102096. /**
  102097. * Validates the new name for the block node.
  102098. * @param newName the new name to be given to the node.
  102099. * @returns false if the name is a reserve word, else true.
  102100. */
  102101. validateBlockName(newName: string): boolean;
  102102. /**
  102103. * Compile the current node and generate the shader code
  102104. * @param state defines the current compilation state (uniforms, samplers, current string)
  102105. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102106. * @returns true if already built
  102107. */
  102108. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102109. protected _inputRename(name: string): string;
  102110. protected _outputRename(name: string): string;
  102111. protected _dumpPropertiesCode(): string;
  102112. /** @hidden */
  102113. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102114. /** @hidden */
  102115. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102116. /**
  102117. * Clone the current block to a new identical block
  102118. * @param scene defines the hosting scene
  102119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102120. * @returns a copy of the current block
  102121. */
  102122. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102123. /**
  102124. * Serializes this block in a JSON representation
  102125. * @returns the serialized block object
  102126. */
  102127. serialize(): any;
  102128. /** @hidden */
  102129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102130. private _deserializePortDisplayNamesAndExposedOnFrame;
  102131. /**
  102132. * Release resources
  102133. */
  102134. dispose(): void;
  102135. }
  102136. }
  102137. declare module BABYLON {
  102138. /**
  102139. * Base class of materials working in push mode in babylon JS
  102140. * @hidden
  102141. */
  102142. export class PushMaterial extends Material {
  102143. protected _activeEffect: Effect;
  102144. protected _normalMatrix: Matrix;
  102145. constructor(name: string, scene: Scene);
  102146. getEffect(): Effect;
  102147. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102148. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102149. /**
  102150. * Binds the given world matrix to the active effect
  102151. *
  102152. * @param world the matrix to bind
  102153. */
  102154. bindOnlyWorldMatrix(world: Matrix): void;
  102155. /**
  102156. * Binds the given normal matrix to the active effect
  102157. *
  102158. * @param normalMatrix the matrix to bind
  102159. */
  102160. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102161. bind(world: Matrix, mesh?: Mesh): void;
  102162. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102163. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102164. }
  102165. }
  102166. declare module BABYLON {
  102167. /**
  102168. * Root class for all node material optimizers
  102169. */
  102170. export class NodeMaterialOptimizer {
  102171. /**
  102172. * Function used to optimize a NodeMaterial graph
  102173. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102174. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102175. */
  102176. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102177. }
  102178. }
  102179. declare module BABYLON {
  102180. /**
  102181. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102182. */
  102183. export class TransformBlock extends NodeMaterialBlock {
  102184. /**
  102185. * Defines the value to use to complement W value to transform it to a Vector4
  102186. */
  102187. complementW: number;
  102188. /**
  102189. * Defines the value to use to complement z value to transform it to a Vector4
  102190. */
  102191. complementZ: number;
  102192. /**
  102193. * Creates a new TransformBlock
  102194. * @param name defines the block name
  102195. */
  102196. constructor(name: string);
  102197. /**
  102198. * Gets the current class name
  102199. * @returns the class name
  102200. */
  102201. getClassName(): string;
  102202. /**
  102203. * Gets the vector input
  102204. */
  102205. get vector(): NodeMaterialConnectionPoint;
  102206. /**
  102207. * Gets the output component
  102208. */
  102209. get output(): NodeMaterialConnectionPoint;
  102210. /**
  102211. * Gets the xyz output component
  102212. */
  102213. get xyz(): NodeMaterialConnectionPoint;
  102214. /**
  102215. * Gets the matrix transform input
  102216. */
  102217. get transform(): NodeMaterialConnectionPoint;
  102218. protected _buildBlock(state: NodeMaterialBuildState): this;
  102219. /**
  102220. * Update defines for shader compilation
  102221. * @param mesh defines the mesh to be rendered
  102222. * @param nodeMaterial defines the node material requesting the update
  102223. * @param defines defines the material defines to update
  102224. * @param useInstances specifies that instances should be used
  102225. * @param subMesh defines which submesh to render
  102226. */
  102227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102228. serialize(): any;
  102229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102230. protected _dumpPropertiesCode(): string;
  102231. }
  102232. }
  102233. declare module BABYLON {
  102234. /**
  102235. * Block used to output the vertex position
  102236. */
  102237. export class VertexOutputBlock extends NodeMaterialBlock {
  102238. /**
  102239. * Creates a new VertexOutputBlock
  102240. * @param name defines the block name
  102241. */
  102242. constructor(name: string);
  102243. /**
  102244. * Gets the current class name
  102245. * @returns the class name
  102246. */
  102247. getClassName(): string;
  102248. /**
  102249. * Gets the vector input component
  102250. */
  102251. get vector(): NodeMaterialConnectionPoint;
  102252. protected _buildBlock(state: NodeMaterialBuildState): this;
  102253. }
  102254. }
  102255. declare module BABYLON {
  102256. /**
  102257. * Block used to output the final color
  102258. */
  102259. export class FragmentOutputBlock extends NodeMaterialBlock {
  102260. /**
  102261. * Create a new FragmentOutputBlock
  102262. * @param name defines the block name
  102263. */
  102264. constructor(name: string);
  102265. /**
  102266. * Gets the current class name
  102267. * @returns the class name
  102268. */
  102269. getClassName(): string;
  102270. /**
  102271. * Gets the rgba input component
  102272. */
  102273. get rgba(): NodeMaterialConnectionPoint;
  102274. /**
  102275. * Gets the rgb input component
  102276. */
  102277. get rgb(): NodeMaterialConnectionPoint;
  102278. /**
  102279. * Gets the a input component
  102280. */
  102281. get a(): NodeMaterialConnectionPoint;
  102282. protected _buildBlock(state: NodeMaterialBuildState): this;
  102283. }
  102284. }
  102285. declare module BABYLON {
  102286. /**
  102287. * Block used for the particle ramp gradient section
  102288. */
  102289. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102290. /**
  102291. * Create a new ParticleRampGradientBlock
  102292. * @param name defines the block name
  102293. */
  102294. constructor(name: string);
  102295. /**
  102296. * Gets the current class name
  102297. * @returns the class name
  102298. */
  102299. getClassName(): string;
  102300. /**
  102301. * Gets the color input component
  102302. */
  102303. get color(): NodeMaterialConnectionPoint;
  102304. /**
  102305. * Gets the rampColor output component
  102306. */
  102307. get rampColor(): NodeMaterialConnectionPoint;
  102308. /**
  102309. * Initialize the block and prepare the context for build
  102310. * @param state defines the state that will be used for the build
  102311. */
  102312. initialize(state: NodeMaterialBuildState): void;
  102313. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102314. }
  102315. }
  102316. declare module BABYLON {
  102317. /**
  102318. * Block used for the particle blend multiply section
  102319. */
  102320. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102321. /**
  102322. * Create a new ParticleBlendMultiplyBlock
  102323. * @param name defines the block name
  102324. */
  102325. constructor(name: string);
  102326. /**
  102327. * Gets the current class name
  102328. * @returns the class name
  102329. */
  102330. getClassName(): string;
  102331. /**
  102332. * Gets the color input component
  102333. */
  102334. get color(): NodeMaterialConnectionPoint;
  102335. /**
  102336. * Gets the alphaTexture input component
  102337. */
  102338. get alphaTexture(): NodeMaterialConnectionPoint;
  102339. /**
  102340. * Gets the alphaColor input component
  102341. */
  102342. get alphaColor(): NodeMaterialConnectionPoint;
  102343. /**
  102344. * Gets the blendColor output component
  102345. */
  102346. get blendColor(): NodeMaterialConnectionPoint;
  102347. /**
  102348. * Initialize the block and prepare the context for build
  102349. * @param state defines the state that will be used for the build
  102350. */
  102351. initialize(state: NodeMaterialBuildState): void;
  102352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /**
  102357. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102358. */
  102359. export class VectorMergerBlock extends NodeMaterialBlock {
  102360. /**
  102361. * Create a new VectorMergerBlock
  102362. * @param name defines the block name
  102363. */
  102364. constructor(name: string);
  102365. /**
  102366. * Gets the current class name
  102367. * @returns the class name
  102368. */
  102369. getClassName(): string;
  102370. /**
  102371. * Gets the xyz component (input)
  102372. */
  102373. get xyzIn(): NodeMaterialConnectionPoint;
  102374. /**
  102375. * Gets the xy component (input)
  102376. */
  102377. get xyIn(): NodeMaterialConnectionPoint;
  102378. /**
  102379. * Gets the x component (input)
  102380. */
  102381. get x(): NodeMaterialConnectionPoint;
  102382. /**
  102383. * Gets the y component (input)
  102384. */
  102385. get y(): NodeMaterialConnectionPoint;
  102386. /**
  102387. * Gets the z component (input)
  102388. */
  102389. get z(): NodeMaterialConnectionPoint;
  102390. /**
  102391. * Gets the w component (input)
  102392. */
  102393. get w(): NodeMaterialConnectionPoint;
  102394. /**
  102395. * Gets the xyzw component (output)
  102396. */
  102397. get xyzw(): NodeMaterialConnectionPoint;
  102398. /**
  102399. * Gets the xyz component (output)
  102400. */
  102401. get xyzOut(): NodeMaterialConnectionPoint;
  102402. /**
  102403. * Gets the xy component (output)
  102404. */
  102405. get xyOut(): NodeMaterialConnectionPoint;
  102406. /**
  102407. * Gets the xy component (output)
  102408. * @deprecated Please use xyOut instead.
  102409. */
  102410. get xy(): NodeMaterialConnectionPoint;
  102411. /**
  102412. * Gets the xyz component (output)
  102413. * @deprecated Please use xyzOut instead.
  102414. */
  102415. get xyz(): NodeMaterialConnectionPoint;
  102416. protected _buildBlock(state: NodeMaterialBuildState): this;
  102417. }
  102418. }
  102419. declare module BABYLON {
  102420. /**
  102421. * Block used to remap a float from a range to a new one
  102422. */
  102423. export class RemapBlock extends NodeMaterialBlock {
  102424. /**
  102425. * Gets or sets the source range
  102426. */
  102427. sourceRange: Vector2;
  102428. /**
  102429. * Gets or sets the target range
  102430. */
  102431. targetRange: Vector2;
  102432. /**
  102433. * Creates a new RemapBlock
  102434. * @param name defines the block name
  102435. */
  102436. constructor(name: string);
  102437. /**
  102438. * Gets the current class name
  102439. * @returns the class name
  102440. */
  102441. getClassName(): string;
  102442. /**
  102443. * Gets the input component
  102444. */
  102445. get input(): NodeMaterialConnectionPoint;
  102446. /**
  102447. * Gets the source min input component
  102448. */
  102449. get sourceMin(): NodeMaterialConnectionPoint;
  102450. /**
  102451. * Gets the source max input component
  102452. */
  102453. get sourceMax(): NodeMaterialConnectionPoint;
  102454. /**
  102455. * Gets the target min input component
  102456. */
  102457. get targetMin(): NodeMaterialConnectionPoint;
  102458. /**
  102459. * Gets the target max input component
  102460. */
  102461. get targetMax(): NodeMaterialConnectionPoint;
  102462. /**
  102463. * Gets the output component
  102464. */
  102465. get output(): NodeMaterialConnectionPoint;
  102466. protected _buildBlock(state: NodeMaterialBuildState): this;
  102467. protected _dumpPropertiesCode(): string;
  102468. serialize(): any;
  102469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102470. }
  102471. }
  102472. declare module BABYLON {
  102473. /**
  102474. * Block used to multiply 2 values
  102475. */
  102476. export class MultiplyBlock extends NodeMaterialBlock {
  102477. /**
  102478. * Creates a new MultiplyBlock
  102479. * @param name defines the block name
  102480. */
  102481. constructor(name: string);
  102482. /**
  102483. * Gets the current class name
  102484. * @returns the class name
  102485. */
  102486. getClassName(): string;
  102487. /**
  102488. * Gets the left operand input component
  102489. */
  102490. get left(): NodeMaterialConnectionPoint;
  102491. /**
  102492. * Gets the right operand input component
  102493. */
  102494. get right(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the output component
  102497. */
  102498. get output(): NodeMaterialConnectionPoint;
  102499. protected _buildBlock(state: NodeMaterialBuildState): this;
  102500. }
  102501. }
  102502. declare module BABYLON {
  102503. /**
  102504. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102505. */
  102506. export class ColorSplitterBlock extends NodeMaterialBlock {
  102507. /**
  102508. * Create a new ColorSplitterBlock
  102509. * @param name defines the block name
  102510. */
  102511. constructor(name: string);
  102512. /**
  102513. * Gets the current class name
  102514. * @returns the class name
  102515. */
  102516. getClassName(): string;
  102517. /**
  102518. * Gets the rgba component (input)
  102519. */
  102520. get rgba(): NodeMaterialConnectionPoint;
  102521. /**
  102522. * Gets the rgb component (input)
  102523. */
  102524. get rgbIn(): NodeMaterialConnectionPoint;
  102525. /**
  102526. * Gets the rgb component (output)
  102527. */
  102528. get rgbOut(): NodeMaterialConnectionPoint;
  102529. /**
  102530. * Gets the r component (output)
  102531. */
  102532. get r(): NodeMaterialConnectionPoint;
  102533. /**
  102534. * Gets the g component (output)
  102535. */
  102536. get g(): NodeMaterialConnectionPoint;
  102537. /**
  102538. * Gets the b component (output)
  102539. */
  102540. get b(): NodeMaterialConnectionPoint;
  102541. /**
  102542. * Gets the a component (output)
  102543. */
  102544. get a(): NodeMaterialConnectionPoint;
  102545. protected _inputRename(name: string): string;
  102546. protected _outputRename(name: string): string;
  102547. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102548. }
  102549. }
  102550. declare module BABYLON {
  102551. /**
  102552. * Operations supported by the Trigonometry block
  102553. */
  102554. export enum TrigonometryBlockOperations {
  102555. /** Cos */
  102556. Cos = 0,
  102557. /** Sin */
  102558. Sin = 1,
  102559. /** Abs */
  102560. Abs = 2,
  102561. /** Exp */
  102562. Exp = 3,
  102563. /** Exp2 */
  102564. Exp2 = 4,
  102565. /** Round */
  102566. Round = 5,
  102567. /** Floor */
  102568. Floor = 6,
  102569. /** Ceiling */
  102570. Ceiling = 7,
  102571. /** Square root */
  102572. Sqrt = 8,
  102573. /** Log */
  102574. Log = 9,
  102575. /** Tangent */
  102576. Tan = 10,
  102577. /** Arc tangent */
  102578. ArcTan = 11,
  102579. /** Arc cosinus */
  102580. ArcCos = 12,
  102581. /** Arc sinus */
  102582. ArcSin = 13,
  102583. /** Fraction */
  102584. Fract = 14,
  102585. /** Sign */
  102586. Sign = 15,
  102587. /** To radians (from degrees) */
  102588. Radians = 16,
  102589. /** To degrees (from radians) */
  102590. Degrees = 17
  102591. }
  102592. /**
  102593. * Block used to apply trigonometry operation to floats
  102594. */
  102595. export class TrigonometryBlock extends NodeMaterialBlock {
  102596. /**
  102597. * Gets or sets the operation applied by the block
  102598. */
  102599. operation: TrigonometryBlockOperations;
  102600. /**
  102601. * Creates a new TrigonometryBlock
  102602. * @param name defines the block name
  102603. */
  102604. constructor(name: string);
  102605. /**
  102606. * Gets the current class name
  102607. * @returns the class name
  102608. */
  102609. getClassName(): string;
  102610. /**
  102611. * Gets the input component
  102612. */
  102613. get input(): NodeMaterialConnectionPoint;
  102614. /**
  102615. * Gets the output component
  102616. */
  102617. get output(): NodeMaterialConnectionPoint;
  102618. protected _buildBlock(state: NodeMaterialBuildState): this;
  102619. serialize(): any;
  102620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102621. protected _dumpPropertiesCode(): string;
  102622. }
  102623. }
  102624. declare module BABYLON {
  102625. /**
  102626. * Interface used to configure the node material editor
  102627. */
  102628. export interface INodeMaterialEditorOptions {
  102629. /** Define the URl to load node editor script */
  102630. editorURL?: string;
  102631. }
  102632. /** @hidden */
  102633. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102634. NORMAL: boolean;
  102635. TANGENT: boolean;
  102636. UV1: boolean;
  102637. /** BONES */
  102638. NUM_BONE_INFLUENCERS: number;
  102639. BonesPerMesh: number;
  102640. BONETEXTURE: boolean;
  102641. /** MORPH TARGETS */
  102642. MORPHTARGETS: boolean;
  102643. MORPHTARGETS_NORMAL: boolean;
  102644. MORPHTARGETS_TANGENT: boolean;
  102645. MORPHTARGETS_UV: boolean;
  102646. NUM_MORPH_INFLUENCERS: number;
  102647. /** IMAGE PROCESSING */
  102648. IMAGEPROCESSING: boolean;
  102649. VIGNETTE: boolean;
  102650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102651. VIGNETTEBLENDMODEOPAQUE: boolean;
  102652. TONEMAPPING: boolean;
  102653. TONEMAPPING_ACES: boolean;
  102654. CONTRAST: boolean;
  102655. EXPOSURE: boolean;
  102656. COLORCURVES: boolean;
  102657. COLORGRADING: boolean;
  102658. COLORGRADING3D: boolean;
  102659. SAMPLER3DGREENDEPTH: boolean;
  102660. SAMPLER3DBGRMAP: boolean;
  102661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102662. /** MISC. */
  102663. BUMPDIRECTUV: number;
  102664. constructor();
  102665. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102666. }
  102667. /**
  102668. * Class used to configure NodeMaterial
  102669. */
  102670. export interface INodeMaterialOptions {
  102671. /**
  102672. * Defines if blocks should emit comments
  102673. */
  102674. emitComments: boolean;
  102675. }
  102676. /**
  102677. * Class used to create a node based material built by assembling shader blocks
  102678. */
  102679. export class NodeMaterial extends PushMaterial {
  102680. private static _BuildIdGenerator;
  102681. private _options;
  102682. private _vertexCompilationState;
  102683. private _fragmentCompilationState;
  102684. private _sharedData;
  102685. private _buildId;
  102686. private _buildWasSuccessful;
  102687. private _cachedWorldViewMatrix;
  102688. private _cachedWorldViewProjectionMatrix;
  102689. private _optimizers;
  102690. private _animationFrame;
  102691. /** Define the Url to load node editor script */
  102692. static EditorURL: string;
  102693. /** Define the Url to load snippets */
  102694. static SnippetUrl: string;
  102695. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102696. static IgnoreTexturesAtLoadTime: boolean;
  102697. private BJSNODEMATERIALEDITOR;
  102698. /** Get the inspector from bundle or global */
  102699. private _getGlobalNodeMaterialEditor;
  102700. /**
  102701. * Snippet ID if the material was created from the snippet server
  102702. */
  102703. snippetId: string;
  102704. /**
  102705. * Gets or sets data used by visual editor
  102706. * @see https://nme.babylonjs.com
  102707. */
  102708. editorData: any;
  102709. /**
  102710. * 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)
  102711. */
  102712. ignoreAlpha: boolean;
  102713. /**
  102714. * Defines the maximum number of lights that can be used in the material
  102715. */
  102716. maxSimultaneousLights: number;
  102717. /**
  102718. * Observable raised when the material is built
  102719. */
  102720. onBuildObservable: Observable<NodeMaterial>;
  102721. /**
  102722. * Gets or sets the root nodes of the material vertex shader
  102723. */
  102724. _vertexOutputNodes: NodeMaterialBlock[];
  102725. /**
  102726. * Gets or sets the root nodes of the material fragment (pixel) shader
  102727. */
  102728. _fragmentOutputNodes: NodeMaterialBlock[];
  102729. /** Gets or sets options to control the node material overall behavior */
  102730. get options(): INodeMaterialOptions;
  102731. set options(options: INodeMaterialOptions);
  102732. /**
  102733. * Default configuration related to image processing available in the standard Material.
  102734. */
  102735. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102736. /**
  102737. * Gets the image processing configuration used either in this material.
  102738. */
  102739. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102740. /**
  102741. * Sets the Default image processing configuration used either in the this material.
  102742. *
  102743. * If sets to null, the scene one is in use.
  102744. */
  102745. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102746. /**
  102747. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102748. */
  102749. attachedBlocks: NodeMaterialBlock[];
  102750. /**
  102751. * Specifies the mode of the node material
  102752. * @hidden
  102753. */
  102754. _mode: NodeMaterialModes;
  102755. /**
  102756. * Gets the mode property
  102757. */
  102758. get mode(): NodeMaterialModes;
  102759. /**
  102760. * Create a new node based material
  102761. * @param name defines the material name
  102762. * @param scene defines the hosting scene
  102763. * @param options defines creation option
  102764. */
  102765. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102766. /**
  102767. * Gets the current class name of the material e.g. "NodeMaterial"
  102768. * @returns the class name
  102769. */
  102770. getClassName(): string;
  102771. /**
  102772. * Keep track of the image processing observer to allow dispose and replace.
  102773. */
  102774. private _imageProcessingObserver;
  102775. /**
  102776. * Attaches a new image processing configuration to the Standard Material.
  102777. * @param configuration
  102778. */
  102779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102780. /**
  102781. * Get a block by its name
  102782. * @param name defines the name of the block to retrieve
  102783. * @returns the required block or null if not found
  102784. */
  102785. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102786. /**
  102787. * Get a block by its name
  102788. * @param predicate defines the predicate used to find the good candidate
  102789. * @returns the required block or null if not found
  102790. */
  102791. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102792. /**
  102793. * Get an input block by its name
  102794. * @param predicate defines the predicate used to find the good candidate
  102795. * @returns the required input block or null if not found
  102796. */
  102797. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102798. /**
  102799. * Gets the list of input blocks attached to this material
  102800. * @returns an array of InputBlocks
  102801. */
  102802. getInputBlocks(): InputBlock[];
  102803. /**
  102804. * Adds a new optimizer to the list of optimizers
  102805. * @param optimizer defines the optimizers to add
  102806. * @returns the current material
  102807. */
  102808. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102809. /**
  102810. * Remove an optimizer from the list of optimizers
  102811. * @param optimizer defines the optimizers to remove
  102812. * @returns the current material
  102813. */
  102814. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102815. /**
  102816. * Add a new block to the list of output nodes
  102817. * @param node defines the node to add
  102818. * @returns the current material
  102819. */
  102820. addOutputNode(node: NodeMaterialBlock): this;
  102821. /**
  102822. * Remove a block from the list of root nodes
  102823. * @param node defines the node to remove
  102824. * @returns the current material
  102825. */
  102826. removeOutputNode(node: NodeMaterialBlock): this;
  102827. private _addVertexOutputNode;
  102828. private _removeVertexOutputNode;
  102829. private _addFragmentOutputNode;
  102830. private _removeFragmentOutputNode;
  102831. /**
  102832. * Specifies if the material will require alpha blending
  102833. * @returns a boolean specifying if alpha blending is needed
  102834. */
  102835. needAlphaBlending(): boolean;
  102836. /**
  102837. * Specifies if this material should be rendered in alpha test mode
  102838. * @returns a boolean specifying if an alpha test is needed.
  102839. */
  102840. needAlphaTesting(): boolean;
  102841. private _initializeBlock;
  102842. private _resetDualBlocks;
  102843. /**
  102844. * Remove a block from the current node material
  102845. * @param block defines the block to remove
  102846. */
  102847. removeBlock(block: NodeMaterialBlock): void;
  102848. /**
  102849. * Build the material and generates the inner effect
  102850. * @param verbose defines if the build should log activity
  102851. */
  102852. build(verbose?: boolean): void;
  102853. /**
  102854. * Runs an otpimization phase to try to improve the shader code
  102855. */
  102856. optimize(): void;
  102857. private _prepareDefinesForAttributes;
  102858. /**
  102859. * Create a post process from the material
  102860. * @param camera The camera to apply the render pass to.
  102861. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102863. * @param engine The engine which the post process will be applied. (default: current engine)
  102864. * @param reusable If the post process can be reused on the same frame. (default: false)
  102865. * @param textureType Type of textures used when performing the post process. (default: 0)
  102866. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102867. * @returns the post process created
  102868. */
  102869. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102870. /**
  102871. * Create the post process effect from the material
  102872. * @param postProcess The post process to create the effect for
  102873. */
  102874. createEffectForPostProcess(postProcess: PostProcess): void;
  102875. private _createEffectForPostProcess;
  102876. /**
  102877. * Create a new procedural texture based on this node material
  102878. * @param size defines the size of the texture
  102879. * @param scene defines the hosting scene
  102880. * @returns the new procedural texture attached to this node material
  102881. */
  102882. createProceduralTexture(size: number | {
  102883. width: number;
  102884. height: number;
  102885. layers?: number;
  102886. }, scene: Scene): Nullable<ProceduralTexture>;
  102887. private _createEffectForParticles;
  102888. private _checkInternals;
  102889. /**
  102890. * Create the effect to be used as the custom effect for a particle system
  102891. * @param particleSystem Particle system to create the effect for
  102892. * @param onCompiled defines a function to call when the effect creation is successful
  102893. * @param onError defines a function to call when the effect creation has failed
  102894. */
  102895. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102896. private _processDefines;
  102897. /**
  102898. * Get if the submesh is ready to be used and all its information available.
  102899. * Child classes can use it to update shaders
  102900. * @param mesh defines the mesh to check
  102901. * @param subMesh defines which submesh to check
  102902. * @param useInstances specifies that instances should be used
  102903. * @returns a boolean indicating that the submesh is ready or not
  102904. */
  102905. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102906. /**
  102907. * Get a string representing the shaders built by the current node graph
  102908. */
  102909. get compiledShaders(): string;
  102910. /**
  102911. * Binds the world matrix to the material
  102912. * @param world defines the world transformation matrix
  102913. */
  102914. bindOnlyWorldMatrix(world: Matrix): void;
  102915. /**
  102916. * Binds the submesh to this material by preparing the effect and shader to draw
  102917. * @param world defines the world transformation matrix
  102918. * @param mesh defines the mesh containing the submesh
  102919. * @param subMesh defines the submesh to bind the material to
  102920. */
  102921. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102922. /**
  102923. * Gets the active textures from the material
  102924. * @returns an array of textures
  102925. */
  102926. getActiveTextures(): BaseTexture[];
  102927. /**
  102928. * Gets the list of texture blocks
  102929. * @returns an array of texture blocks
  102930. */
  102931. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102932. /**
  102933. * Specifies if the material uses a texture
  102934. * @param texture defines the texture to check against the material
  102935. * @returns a boolean specifying if the material uses the texture
  102936. */
  102937. hasTexture(texture: BaseTexture): boolean;
  102938. /**
  102939. * Disposes the material
  102940. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102941. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102942. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102943. */
  102944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102945. /** Creates the node editor window. */
  102946. private _createNodeEditor;
  102947. /**
  102948. * Launch the node material editor
  102949. * @param config Define the configuration of the editor
  102950. * @return a promise fulfilled when the node editor is visible
  102951. */
  102952. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102953. /**
  102954. * Clear the current material
  102955. */
  102956. clear(): void;
  102957. /**
  102958. * Clear the current material and set it to a default state
  102959. */
  102960. setToDefault(): void;
  102961. /**
  102962. * Clear the current material and set it to a default state for post process
  102963. */
  102964. setToDefaultPostProcess(): void;
  102965. /**
  102966. * Clear the current material and set it to a default state for procedural texture
  102967. */
  102968. setToDefaultProceduralTexture(): void;
  102969. /**
  102970. * Clear the current material and set it to a default state for particle
  102971. */
  102972. setToDefaultParticle(): void;
  102973. /**
  102974. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102975. * @param url defines the url to load from
  102976. * @returns a promise that will fullfil when the material is fully loaded
  102977. */
  102978. loadAsync(url: string): Promise<void>;
  102979. private _gatherBlocks;
  102980. /**
  102981. * Generate a string containing the code declaration required to create an equivalent of this material
  102982. * @returns a string
  102983. */
  102984. generateCode(): string;
  102985. /**
  102986. * Serializes this material in a JSON representation
  102987. * @returns the serialized material object
  102988. */
  102989. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102990. private _restoreConnections;
  102991. /**
  102992. * Clear the current graph and load a new one from a serialization object
  102993. * @param source defines the JSON representation of the material
  102994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102995. * @param merge defines whether or not the source must be merged or replace the current content
  102996. */
  102997. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102998. /**
  102999. * Makes a duplicate of the current material.
  103000. * @param name - name to use for the new material.
  103001. */
  103002. clone(name: string): NodeMaterial;
  103003. /**
  103004. * Creates a node material from parsed material data
  103005. * @param source defines the JSON representation of the material
  103006. * @param scene defines the hosting scene
  103007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103008. * @returns a new node material
  103009. */
  103010. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103011. /**
  103012. * Creates a node material from a snippet saved in a remote file
  103013. * @param name defines the name of the material to create
  103014. * @param url defines the url to load from
  103015. * @param scene defines the hosting scene
  103016. * @returns a promise that will resolve to the new node material
  103017. */
  103018. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103019. /**
  103020. * Creates a node material from a snippet saved by the node material editor
  103021. * @param snippetId defines the snippet to load
  103022. * @param scene defines the hosting scene
  103023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103024. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103025. * @returns a promise that will resolve to the new node material
  103026. */
  103027. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103028. /**
  103029. * Creates a new node material set to default basic configuration
  103030. * @param name defines the name of the material
  103031. * @param scene defines the hosting scene
  103032. * @returns a new NodeMaterial
  103033. */
  103034. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103035. }
  103036. }
  103037. declare module BABYLON {
  103038. /**
  103039. * Size options for a post process
  103040. */
  103041. export type PostProcessOptions = {
  103042. width: number;
  103043. height: number;
  103044. };
  103045. /**
  103046. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103047. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103048. */
  103049. export class PostProcess {
  103050. /**
  103051. * Gets or sets the unique id of the post process
  103052. */
  103053. uniqueId: number;
  103054. /** Name of the PostProcess. */
  103055. name: string;
  103056. /**
  103057. * Width of the texture to apply the post process on
  103058. */
  103059. width: number;
  103060. /**
  103061. * Height of the texture to apply the post process on
  103062. */
  103063. height: number;
  103064. /**
  103065. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103066. */
  103067. nodeMaterialSource: Nullable<NodeMaterial>;
  103068. /**
  103069. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103070. * @hidden
  103071. */
  103072. _outputTexture: Nullable<InternalTexture>;
  103073. /**
  103074. * Sampling mode used by the shader
  103075. * See https://doc.babylonjs.com/classes/3.1/texture
  103076. */
  103077. renderTargetSamplingMode: number;
  103078. /**
  103079. * Clear color to use when screen clearing
  103080. */
  103081. clearColor: Color4;
  103082. /**
  103083. * If the buffer needs to be cleared before applying the post process. (default: true)
  103084. * Should be set to false if shader will overwrite all previous pixels.
  103085. */
  103086. autoClear: boolean;
  103087. /**
  103088. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103089. */
  103090. alphaMode: number;
  103091. /**
  103092. * Sets the setAlphaBlendConstants of the babylon engine
  103093. */
  103094. alphaConstants: Color4;
  103095. /**
  103096. * Animations to be used for the post processing
  103097. */
  103098. animations: Animation[];
  103099. /**
  103100. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103101. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103102. */
  103103. enablePixelPerfectMode: boolean;
  103104. /**
  103105. * Force the postprocess to be applied without taking in account viewport
  103106. */
  103107. forceFullscreenViewport: boolean;
  103108. /**
  103109. * List of inspectable custom properties (used by the Inspector)
  103110. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103111. */
  103112. inspectableCustomProperties: IInspectable[];
  103113. /**
  103114. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103115. *
  103116. * | Value | Type | Description |
  103117. * | ----- | ----------------------------------- | ----------- |
  103118. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103119. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103120. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103121. *
  103122. */
  103123. scaleMode: number;
  103124. /**
  103125. * Force textures to be a power of two (default: false)
  103126. */
  103127. alwaysForcePOT: boolean;
  103128. private _samples;
  103129. /**
  103130. * Number of sample textures (default: 1)
  103131. */
  103132. get samples(): number;
  103133. set samples(n: number);
  103134. /**
  103135. * Modify the scale of the post process to be the same as the viewport (default: false)
  103136. */
  103137. adaptScaleToCurrentViewport: boolean;
  103138. private _camera;
  103139. protected _scene: Scene;
  103140. private _engine;
  103141. private _options;
  103142. private _reusable;
  103143. private _textureType;
  103144. private _textureFormat;
  103145. /**
  103146. * Smart array of input and output textures for the post process.
  103147. * @hidden
  103148. */
  103149. _textures: SmartArray<InternalTexture>;
  103150. /**
  103151. * The index in _textures that corresponds to the output texture.
  103152. * @hidden
  103153. */
  103154. _currentRenderTextureInd: number;
  103155. private _effect;
  103156. private _samplers;
  103157. private _fragmentUrl;
  103158. private _vertexUrl;
  103159. private _parameters;
  103160. private _scaleRatio;
  103161. protected _indexParameters: any;
  103162. private _shareOutputWithPostProcess;
  103163. private _texelSize;
  103164. private _forcedOutputTexture;
  103165. /**
  103166. * Returns the fragment url or shader name used in the post process.
  103167. * @returns the fragment url or name in the shader store.
  103168. */
  103169. getEffectName(): string;
  103170. /**
  103171. * An event triggered when the postprocess is activated.
  103172. */
  103173. onActivateObservable: Observable<Camera>;
  103174. private _onActivateObserver;
  103175. /**
  103176. * A function that is added to the onActivateObservable
  103177. */
  103178. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103179. /**
  103180. * An event triggered when the postprocess changes its size.
  103181. */
  103182. onSizeChangedObservable: Observable<PostProcess>;
  103183. private _onSizeChangedObserver;
  103184. /**
  103185. * A function that is added to the onSizeChangedObservable
  103186. */
  103187. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103188. /**
  103189. * An event triggered when the postprocess applies its effect.
  103190. */
  103191. onApplyObservable: Observable<Effect>;
  103192. private _onApplyObserver;
  103193. /**
  103194. * A function that is added to the onApplyObservable
  103195. */
  103196. set onApply(callback: (effect: Effect) => void);
  103197. /**
  103198. * An event triggered before rendering the postprocess
  103199. */
  103200. onBeforeRenderObservable: Observable<Effect>;
  103201. private _onBeforeRenderObserver;
  103202. /**
  103203. * A function that is added to the onBeforeRenderObservable
  103204. */
  103205. set onBeforeRender(callback: (effect: Effect) => void);
  103206. /**
  103207. * An event triggered after rendering the postprocess
  103208. */
  103209. onAfterRenderObservable: Observable<Effect>;
  103210. private _onAfterRenderObserver;
  103211. /**
  103212. * A function that is added to the onAfterRenderObservable
  103213. */
  103214. set onAfterRender(callback: (efect: Effect) => void);
  103215. /**
  103216. * 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
  103217. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103218. */
  103219. get inputTexture(): InternalTexture;
  103220. set inputTexture(value: InternalTexture);
  103221. /**
  103222. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103223. * the only way to unset it is to use this function to restore its internal state
  103224. */
  103225. restoreDefaultInputTexture(): void;
  103226. /**
  103227. * Gets the camera which post process is applied to.
  103228. * @returns The camera the post process is applied to.
  103229. */
  103230. getCamera(): Camera;
  103231. /**
  103232. * Gets the texel size of the postprocess.
  103233. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103234. */
  103235. get texelSize(): Vector2;
  103236. /**
  103237. * Creates a new instance PostProcess
  103238. * @param name The name of the PostProcess.
  103239. * @param fragmentUrl The url of the fragment shader to be used.
  103240. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103241. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103242. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103243. * @param camera The camera to apply the render pass to.
  103244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103245. * @param engine The engine which the post process will be applied. (default: current engine)
  103246. * @param reusable If the post process can be reused on the same frame. (default: false)
  103247. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103248. * @param textureType Type of textures used when performing the post process. (default: 0)
  103249. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103250. * @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
  103251. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103252. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103253. */
  103254. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  103255. /**
  103256. * Gets a string identifying the name of the class
  103257. * @returns "PostProcess" string
  103258. */
  103259. getClassName(): string;
  103260. /**
  103261. * Gets the engine which this post process belongs to.
  103262. * @returns The engine the post process was enabled with.
  103263. */
  103264. getEngine(): Engine;
  103265. /**
  103266. * The effect that is created when initializing the post process.
  103267. * @returns The created effect corresponding the the postprocess.
  103268. */
  103269. getEffect(): Effect;
  103270. /**
  103271. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103272. * @param postProcess The post process to share the output with.
  103273. * @returns This post process.
  103274. */
  103275. shareOutputWith(postProcess: PostProcess): PostProcess;
  103276. /**
  103277. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103278. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103279. */
  103280. useOwnOutput(): void;
  103281. /**
  103282. * Updates the effect with the current post process compile time values and recompiles the shader.
  103283. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103284. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103285. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103286. * @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
  103287. * @param onCompiled Called when the shader has been compiled.
  103288. * @param onError Called if there is an error when compiling a shader.
  103289. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103290. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103291. */
  103292. 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;
  103293. /**
  103294. * The post process is reusable if it can be used multiple times within one frame.
  103295. * @returns If the post process is reusable
  103296. */
  103297. isReusable(): boolean;
  103298. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103299. markTextureDirty(): void;
  103300. /**
  103301. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103302. * 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.
  103303. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103304. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103305. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103306. * @returns The target texture that was bound to be written to.
  103307. */
  103308. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103309. /**
  103310. * If the post process is supported.
  103311. */
  103312. get isSupported(): boolean;
  103313. /**
  103314. * The aspect ratio of the output texture.
  103315. */
  103316. get aspectRatio(): number;
  103317. /**
  103318. * Get a value indicating if the post-process is ready to be used
  103319. * @returns true if the post-process is ready (shader is compiled)
  103320. */
  103321. isReady(): boolean;
  103322. /**
  103323. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103324. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103325. */
  103326. apply(): Nullable<Effect>;
  103327. private _disposeTextures;
  103328. /**
  103329. * Disposes the post process.
  103330. * @param camera The camera to dispose the post process on.
  103331. */
  103332. dispose(camera?: Camera): void;
  103333. /**
  103334. * Serializes the particle system to a JSON object
  103335. * @returns the JSON object
  103336. */
  103337. serialize(): any;
  103338. /**
  103339. * Creates a material from parsed material data
  103340. * @param parsedPostProcess defines parsed post process data
  103341. * @param scene defines the hosting scene
  103342. * @param rootUrl defines the root URL to use to load textures
  103343. * @returns a new post process
  103344. */
  103345. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /** @hidden */
  103350. export var kernelBlurVaryingDeclaration: {
  103351. name: string;
  103352. shader: string;
  103353. };
  103354. }
  103355. declare module BABYLON {
  103356. /** @hidden */
  103357. export var kernelBlurFragment: {
  103358. name: string;
  103359. shader: string;
  103360. };
  103361. }
  103362. declare module BABYLON {
  103363. /** @hidden */
  103364. export var kernelBlurFragment2: {
  103365. name: string;
  103366. shader: string;
  103367. };
  103368. }
  103369. declare module BABYLON {
  103370. /** @hidden */
  103371. export var kernelBlurPixelShader: {
  103372. name: string;
  103373. shader: string;
  103374. };
  103375. }
  103376. declare module BABYLON {
  103377. /** @hidden */
  103378. export var kernelBlurVertex: {
  103379. name: string;
  103380. shader: string;
  103381. };
  103382. }
  103383. declare module BABYLON {
  103384. /** @hidden */
  103385. export var kernelBlurVertexShader: {
  103386. name: string;
  103387. shader: string;
  103388. };
  103389. }
  103390. declare module BABYLON {
  103391. /**
  103392. * The Blur Post Process which blurs an image based on a kernel and direction.
  103393. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103394. */
  103395. export class BlurPostProcess extends PostProcess {
  103396. private blockCompilation;
  103397. protected _kernel: number;
  103398. protected _idealKernel: number;
  103399. protected _packedFloat: boolean;
  103400. private _staticDefines;
  103401. /** The direction in which to blur the image. */
  103402. direction: Vector2;
  103403. /**
  103404. * Sets the length in pixels of the blur sample region
  103405. */
  103406. set kernel(v: number);
  103407. /**
  103408. * Gets the length in pixels of the blur sample region
  103409. */
  103410. get kernel(): number;
  103411. /**
  103412. * Sets wether or not the blur needs to unpack/repack floats
  103413. */
  103414. set packedFloat(v: boolean);
  103415. /**
  103416. * Gets wether or not the blur is unpacking/repacking floats
  103417. */
  103418. get packedFloat(): boolean;
  103419. /**
  103420. * Gets a string identifying the name of the class
  103421. * @returns "BlurPostProcess" string
  103422. */
  103423. getClassName(): string;
  103424. /**
  103425. * Creates a new instance BlurPostProcess
  103426. * @param name The name of the effect.
  103427. * @param direction The direction in which to blur the image.
  103428. * @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.
  103429. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103430. * @param camera The camera to apply the render pass to.
  103431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103432. * @param engine The engine which the post process will be applied. (default: current engine)
  103433. * @param reusable If the post process can be reused on the same frame. (default: false)
  103434. * @param textureType Type of textures used when performing the post process. (default: 0)
  103435. * @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)
  103436. */
  103437. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  103438. /**
  103439. * Updates the effect with the current post process compile time values and recompiles the shader.
  103440. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103441. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103442. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103443. * @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
  103444. * @param onCompiled Called when the shader has been compiled.
  103445. * @param onError Called if there is an error when compiling a shader.
  103446. */
  103447. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103448. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103449. /**
  103450. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103451. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103452. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103453. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103454. * The gaps between physical kernels are compensated for in the weighting of the samples
  103455. * @param idealKernel Ideal blur kernel.
  103456. * @return Nearest best kernel.
  103457. */
  103458. protected _nearestBestKernel(idealKernel: number): number;
  103459. /**
  103460. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103461. * @param x The point on the Gaussian distribution to sample.
  103462. * @return the value of the Gaussian function at x.
  103463. */
  103464. protected _gaussianWeight(x: number): number;
  103465. /**
  103466. * Generates a string that can be used as a floating point number in GLSL.
  103467. * @param x Value to print.
  103468. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103469. * @return GLSL float string.
  103470. */
  103471. protected _glslFloat(x: number, decimalFigures?: number): string;
  103472. /** @hidden */
  103473. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103474. }
  103475. }
  103476. declare module BABYLON {
  103477. /**
  103478. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103479. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103480. * You can then easily use it as a reflectionTexture on a flat surface.
  103481. * In case the surface is not a plane, please consider relying on reflection probes.
  103482. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103483. */
  103484. export class MirrorTexture extends RenderTargetTexture {
  103485. private scene;
  103486. /**
  103487. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103488. * 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.
  103489. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103490. */
  103491. mirrorPlane: Plane;
  103492. /**
  103493. * Define the blur ratio used to blur the reflection if needed.
  103494. */
  103495. set blurRatio(value: number);
  103496. get blurRatio(): number;
  103497. /**
  103498. * Define the adaptive blur kernel used to blur the reflection if needed.
  103499. * This will autocompute the closest best match for the `blurKernel`
  103500. */
  103501. set adaptiveBlurKernel(value: number);
  103502. /**
  103503. * Define the blur kernel used to blur the reflection if needed.
  103504. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103505. */
  103506. set blurKernel(value: number);
  103507. /**
  103508. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103509. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103510. */
  103511. set blurKernelX(value: number);
  103512. get blurKernelX(): number;
  103513. /**
  103514. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103515. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103516. */
  103517. set blurKernelY(value: number);
  103518. get blurKernelY(): number;
  103519. private _autoComputeBlurKernel;
  103520. protected _onRatioRescale(): void;
  103521. private _updateGammaSpace;
  103522. private _imageProcessingConfigChangeObserver;
  103523. private _transformMatrix;
  103524. private _mirrorMatrix;
  103525. private _savedViewMatrix;
  103526. private _blurX;
  103527. private _blurY;
  103528. private _adaptiveBlurKernel;
  103529. private _blurKernelX;
  103530. private _blurKernelY;
  103531. private _blurRatio;
  103532. /**
  103533. * Instantiates a Mirror Texture.
  103534. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103535. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103536. * You can then easily use it as a reflectionTexture on a flat surface.
  103537. * In case the surface is not a plane, please consider relying on reflection probes.
  103538. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103539. * @param name
  103540. * @param size
  103541. * @param scene
  103542. * @param generateMipMaps
  103543. * @param type
  103544. * @param samplingMode
  103545. * @param generateDepthBuffer
  103546. */
  103547. constructor(name: string, size: number | {
  103548. width: number;
  103549. height: number;
  103550. } | {
  103551. ratio: number;
  103552. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103553. private _preparePostProcesses;
  103554. /**
  103555. * Clone the mirror texture.
  103556. * @returns the cloned texture
  103557. */
  103558. clone(): MirrorTexture;
  103559. /**
  103560. * Serialize the texture to a JSON representation you could use in Parse later on
  103561. * @returns the serialized JSON representation
  103562. */
  103563. serialize(): any;
  103564. /**
  103565. * Dispose the texture and release its associated resources.
  103566. */
  103567. dispose(): void;
  103568. }
  103569. }
  103570. declare module BABYLON {
  103571. /**
  103572. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103573. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103574. */
  103575. export class Texture extends BaseTexture {
  103576. /**
  103577. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103578. */
  103579. static SerializeBuffers: boolean;
  103580. /** @hidden */
  103581. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103582. /** @hidden */
  103583. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103584. /** @hidden */
  103585. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103586. /** nearest is mag = nearest and min = nearest and mip = linear */
  103587. static readonly NEAREST_SAMPLINGMODE: number;
  103588. /** nearest is mag = nearest and min = nearest and mip = linear */
  103589. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103590. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103591. static readonly BILINEAR_SAMPLINGMODE: number;
  103592. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103593. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103594. /** Trilinear is mag = linear and min = linear and mip = linear */
  103595. static readonly TRILINEAR_SAMPLINGMODE: number;
  103596. /** Trilinear is mag = linear and min = linear and mip = linear */
  103597. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103598. /** mag = nearest and min = nearest and mip = nearest */
  103599. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103600. /** mag = nearest and min = linear and mip = nearest */
  103601. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103602. /** mag = nearest and min = linear and mip = linear */
  103603. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103604. /** mag = nearest and min = linear and mip = none */
  103605. static readonly NEAREST_LINEAR: number;
  103606. /** mag = nearest and min = nearest and mip = none */
  103607. static readonly NEAREST_NEAREST: number;
  103608. /** mag = linear and min = nearest and mip = nearest */
  103609. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103610. /** mag = linear and min = nearest and mip = linear */
  103611. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103612. /** mag = linear and min = linear and mip = none */
  103613. static readonly LINEAR_LINEAR: number;
  103614. /** mag = linear and min = nearest and mip = none */
  103615. static readonly LINEAR_NEAREST: number;
  103616. /** Explicit coordinates mode */
  103617. static readonly EXPLICIT_MODE: number;
  103618. /** Spherical coordinates mode */
  103619. static readonly SPHERICAL_MODE: number;
  103620. /** Planar coordinates mode */
  103621. static readonly PLANAR_MODE: number;
  103622. /** Cubic coordinates mode */
  103623. static readonly CUBIC_MODE: number;
  103624. /** Projection coordinates mode */
  103625. static readonly PROJECTION_MODE: number;
  103626. /** Inverse Cubic coordinates mode */
  103627. static readonly SKYBOX_MODE: number;
  103628. /** Inverse Cubic coordinates mode */
  103629. static readonly INVCUBIC_MODE: number;
  103630. /** Equirectangular coordinates mode */
  103631. static readonly EQUIRECTANGULAR_MODE: number;
  103632. /** Equirectangular Fixed coordinates mode */
  103633. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103634. /** Equirectangular Fixed Mirrored coordinates mode */
  103635. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103636. /** Texture is not repeating outside of 0..1 UVs */
  103637. static readonly CLAMP_ADDRESSMODE: number;
  103638. /** Texture is repeating outside of 0..1 UVs */
  103639. static readonly WRAP_ADDRESSMODE: number;
  103640. /** Texture is repeating and mirrored */
  103641. static readonly MIRROR_ADDRESSMODE: number;
  103642. /**
  103643. * 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
  103644. */
  103645. static UseSerializedUrlIfAny: boolean;
  103646. /**
  103647. * Define the url of the texture.
  103648. */
  103649. url: Nullable<string>;
  103650. /**
  103651. * Define an offset on the texture to offset the u coordinates of the UVs
  103652. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103653. */
  103654. uOffset: number;
  103655. /**
  103656. * Define an offset on the texture to offset the v coordinates of the UVs
  103657. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103658. */
  103659. vOffset: number;
  103660. /**
  103661. * Define an offset on the texture to scale the u coordinates of the UVs
  103662. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103663. */
  103664. uScale: number;
  103665. /**
  103666. * Define an offset on the texture to scale the v coordinates of the UVs
  103667. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103668. */
  103669. vScale: number;
  103670. /**
  103671. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103672. * @see https://doc.babylonjs.com/how_to/more_materials
  103673. */
  103674. uAng: number;
  103675. /**
  103676. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103677. * @see https://doc.babylonjs.com/how_to/more_materials
  103678. */
  103679. vAng: number;
  103680. /**
  103681. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103682. * @see https://doc.babylonjs.com/how_to/more_materials
  103683. */
  103684. wAng: number;
  103685. /**
  103686. * Defines the center of rotation (U)
  103687. */
  103688. uRotationCenter: number;
  103689. /**
  103690. * Defines the center of rotation (V)
  103691. */
  103692. vRotationCenter: number;
  103693. /**
  103694. * Defines the center of rotation (W)
  103695. */
  103696. wRotationCenter: number;
  103697. /**
  103698. * Are mip maps generated for this texture or not.
  103699. */
  103700. get noMipmap(): boolean;
  103701. /**
  103702. * List of inspectable custom properties (used by the Inspector)
  103703. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103704. */
  103705. inspectableCustomProperties: Nullable<IInspectable[]>;
  103706. private _noMipmap;
  103707. /** @hidden */
  103708. _invertY: boolean;
  103709. private _rowGenerationMatrix;
  103710. private _cachedTextureMatrix;
  103711. private _projectionModeMatrix;
  103712. private _t0;
  103713. private _t1;
  103714. private _t2;
  103715. private _cachedUOffset;
  103716. private _cachedVOffset;
  103717. private _cachedUScale;
  103718. private _cachedVScale;
  103719. private _cachedUAng;
  103720. private _cachedVAng;
  103721. private _cachedWAng;
  103722. private _cachedProjectionMatrixId;
  103723. private _cachedCoordinatesMode;
  103724. /** @hidden */
  103725. protected _initialSamplingMode: number;
  103726. /** @hidden */
  103727. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103728. private _deleteBuffer;
  103729. protected _format: Nullable<number>;
  103730. private _delayedOnLoad;
  103731. private _delayedOnError;
  103732. private _mimeType?;
  103733. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103734. get mimeType(): string | undefined;
  103735. /**
  103736. * Observable triggered once the texture has been loaded.
  103737. */
  103738. onLoadObservable: Observable<Texture>;
  103739. protected _isBlocking: boolean;
  103740. /**
  103741. * Is the texture preventing material to render while loading.
  103742. * If false, a default texture will be used instead of the loading one during the preparation step.
  103743. */
  103744. set isBlocking(value: boolean);
  103745. get isBlocking(): boolean;
  103746. /**
  103747. * Get the current sampling mode associated with the texture.
  103748. */
  103749. get samplingMode(): number;
  103750. /**
  103751. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103752. */
  103753. get invertY(): boolean;
  103754. /**
  103755. * Instantiates a new texture.
  103756. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103757. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103758. * @param url defines the url of the picture to load as a texture
  103759. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103760. * @param noMipmap defines if the texture will require mip maps or not
  103761. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103762. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103763. * @param onLoad defines a callback triggered when the texture has been loaded
  103764. * @param onError defines a callback triggered when an error occurred during the loading session
  103765. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103766. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103767. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103768. * @param mimeType defines an optional mime type information
  103769. */
  103770. 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);
  103771. /**
  103772. * Update the url (and optional buffer) of this texture if url was null during construction.
  103773. * @param url the url of the texture
  103774. * @param buffer the buffer of the texture (defaults to null)
  103775. * @param onLoad callback called when the texture is loaded (defaults to null)
  103776. */
  103777. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103778. /**
  103779. * Finish the loading sequence of a texture flagged as delayed load.
  103780. * @hidden
  103781. */
  103782. delayLoad(): void;
  103783. private _prepareRowForTextureGeneration;
  103784. /**
  103785. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103786. * @returns the transform matrix of the texture.
  103787. */
  103788. getTextureMatrix(uBase?: number): Matrix;
  103789. /**
  103790. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103791. * @returns The reflection texture transform
  103792. */
  103793. getReflectionTextureMatrix(): Matrix;
  103794. /**
  103795. * Clones the texture.
  103796. * @returns the cloned texture
  103797. */
  103798. clone(): Texture;
  103799. /**
  103800. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103801. * @returns The JSON representation of the texture
  103802. */
  103803. serialize(): any;
  103804. /**
  103805. * Get the current class name of the texture useful for serialization or dynamic coding.
  103806. * @returns "Texture"
  103807. */
  103808. getClassName(): string;
  103809. /**
  103810. * Dispose the texture and release its associated resources.
  103811. */
  103812. dispose(): void;
  103813. /**
  103814. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103815. * @param parsedTexture Define the JSON representation of the texture
  103816. * @param scene Define the scene the parsed texture should be instantiated in
  103817. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103818. * @returns The parsed texture if successful
  103819. */
  103820. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103821. /**
  103822. * Creates a texture from its base 64 representation.
  103823. * @param data Define the base64 payload without the data: prefix
  103824. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103825. * @param scene Define the scene the texture should belong to
  103826. * @param noMipmap Forces the texture to not create mip map information if true
  103827. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103828. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103829. * @param onLoad define a callback triggered when the texture has been loaded
  103830. * @param onError define a callback triggered when an error occurred during the loading session
  103831. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103832. * @returns the created texture
  103833. */
  103834. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103835. /**
  103836. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103837. * @param data Define the base64 payload without the data: prefix
  103838. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103839. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103840. * @param scene Define the scene the texture should belong to
  103841. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103842. * @param noMipmap Forces the texture to not create mip map information if true
  103843. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103844. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103845. * @param onLoad define a callback triggered when the texture has been loaded
  103846. * @param onError define a callback triggered when an error occurred during the loading session
  103847. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103848. * @returns the created texture
  103849. */
  103850. 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;
  103851. }
  103852. }
  103853. declare module BABYLON {
  103854. /**
  103855. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103856. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103857. */
  103858. export class PostProcessManager {
  103859. private _scene;
  103860. private _indexBuffer;
  103861. private _vertexBuffers;
  103862. /**
  103863. * Creates a new instance PostProcess
  103864. * @param scene The scene that the post process is associated with.
  103865. */
  103866. constructor(scene: Scene);
  103867. private _prepareBuffers;
  103868. private _buildIndexBuffer;
  103869. /**
  103870. * Rebuilds the vertex buffers of the manager.
  103871. * @hidden
  103872. */
  103873. _rebuild(): void;
  103874. /**
  103875. * Prepares a frame to be run through a post process.
  103876. * @param sourceTexture The input texture to the post procesess. (default: null)
  103877. * @param postProcesses An array of post processes to be run. (default: null)
  103878. * @returns True if the post processes were able to be run.
  103879. * @hidden
  103880. */
  103881. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103882. /**
  103883. * Manually render a set of post processes to a texture.
  103884. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103885. * @param postProcesses An array of post processes to be run.
  103886. * @param targetTexture The target texture to render to.
  103887. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103888. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103889. * @param lodLevel defines which lod of the texture to render to
  103890. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103891. */
  103892. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103893. /**
  103894. * Finalize the result of the output of the postprocesses.
  103895. * @param doNotPresent If true the result will not be displayed to the screen.
  103896. * @param targetTexture The target texture to render to.
  103897. * @param faceIndex The index of the face to bind the target texture to.
  103898. * @param postProcesses The array of post processes to render.
  103899. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103900. * @hidden
  103901. */
  103902. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103903. /**
  103904. * Disposes of the post process manager.
  103905. */
  103906. dispose(): void;
  103907. }
  103908. }
  103909. declare module BABYLON {
  103910. /**
  103911. * This Helps creating a texture that will be created from a camera in your scene.
  103912. * It is basically a dynamic texture that could be used to create special effects for instance.
  103913. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103914. */
  103915. export class RenderTargetTexture extends Texture {
  103916. /**
  103917. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103918. */
  103919. static readonly REFRESHRATE_RENDER_ONCE: number;
  103920. /**
  103921. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103922. */
  103923. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103924. /**
  103925. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103926. * the central point of your effect and can save a lot of performances.
  103927. */
  103928. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103929. /**
  103930. * Use this predicate to dynamically define the list of mesh you want to render.
  103931. * If set, the renderList property will be overwritten.
  103932. */
  103933. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103934. private _renderList;
  103935. /**
  103936. * Use this list to define the list of mesh you want to render.
  103937. */
  103938. get renderList(): Nullable<Array<AbstractMesh>>;
  103939. set renderList(value: Nullable<Array<AbstractMesh>>);
  103940. /**
  103941. * Use this function to overload the renderList array at rendering time.
  103942. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103943. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103944. * the cube (if the RTT is a cube, else layerOrFace=0).
  103945. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103946. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103947. * hold dummy elements!
  103948. */
  103949. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103950. private _hookArray;
  103951. /**
  103952. * Define if particles should be rendered in your texture.
  103953. */
  103954. renderParticles: boolean;
  103955. /**
  103956. * Define if sprites should be rendered in your texture.
  103957. */
  103958. renderSprites: boolean;
  103959. /**
  103960. * Define the camera used to render the texture.
  103961. */
  103962. activeCamera: Nullable<Camera>;
  103963. /**
  103964. * Override the mesh isReady function with your own one.
  103965. */
  103966. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103967. /**
  103968. * Override the render function of the texture with your own one.
  103969. */
  103970. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103971. /**
  103972. * Define if camera post processes should be use while rendering the texture.
  103973. */
  103974. useCameraPostProcesses: boolean;
  103975. /**
  103976. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103977. */
  103978. ignoreCameraViewport: boolean;
  103979. private _postProcessManager;
  103980. private _postProcesses;
  103981. private _resizeObserver;
  103982. /**
  103983. * An event triggered when the texture is unbind.
  103984. */
  103985. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103986. /**
  103987. * An event triggered when the texture is unbind.
  103988. */
  103989. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103990. private _onAfterUnbindObserver;
  103991. /**
  103992. * Set a after unbind callback in the texture.
  103993. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103994. */
  103995. set onAfterUnbind(callback: () => void);
  103996. /**
  103997. * An event triggered before rendering the texture
  103998. */
  103999. onBeforeRenderObservable: Observable<number>;
  104000. private _onBeforeRenderObserver;
  104001. /**
  104002. * Set a before render callback in the texture.
  104003. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104004. */
  104005. set onBeforeRender(callback: (faceIndex: number) => void);
  104006. /**
  104007. * An event triggered after rendering the texture
  104008. */
  104009. onAfterRenderObservable: Observable<number>;
  104010. private _onAfterRenderObserver;
  104011. /**
  104012. * Set a after render callback in the texture.
  104013. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104014. */
  104015. set onAfterRender(callback: (faceIndex: number) => void);
  104016. /**
  104017. * An event triggered after the texture clear
  104018. */
  104019. onClearObservable: Observable<Engine>;
  104020. private _onClearObserver;
  104021. /**
  104022. * Set a clear callback in the texture.
  104023. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104024. */
  104025. set onClear(callback: (Engine: Engine) => void);
  104026. /**
  104027. * An event triggered when the texture is resized.
  104028. */
  104029. onResizeObservable: Observable<RenderTargetTexture>;
  104030. /**
  104031. * Define the clear color of the Render Target if it should be different from the scene.
  104032. */
  104033. clearColor: Color4;
  104034. protected _size: number | {
  104035. width: number;
  104036. height: number;
  104037. layers?: number;
  104038. };
  104039. protected _initialSizeParameter: number | {
  104040. width: number;
  104041. height: number;
  104042. } | {
  104043. ratio: number;
  104044. };
  104045. protected _sizeRatio: Nullable<number>;
  104046. /** @hidden */
  104047. _generateMipMaps: boolean;
  104048. protected _renderingManager: RenderingManager;
  104049. /** @hidden */
  104050. _waitingRenderList?: string[];
  104051. protected _doNotChangeAspectRatio: boolean;
  104052. protected _currentRefreshId: number;
  104053. protected _refreshRate: number;
  104054. protected _textureMatrix: Matrix;
  104055. protected _samples: number;
  104056. protected _renderTargetOptions: RenderTargetCreationOptions;
  104057. /**
  104058. * Gets render target creation options that were used.
  104059. */
  104060. get renderTargetOptions(): RenderTargetCreationOptions;
  104061. protected _onRatioRescale(): void;
  104062. /**
  104063. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104064. * It must define where the camera used to render the texture is set
  104065. */
  104066. boundingBoxPosition: Vector3;
  104067. private _boundingBoxSize;
  104068. /**
  104069. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104070. * When defined, the cubemap will switch to local mode
  104071. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104072. * @example https://www.babylonjs-playground.com/#RNASML
  104073. */
  104074. set boundingBoxSize(value: Vector3);
  104075. get boundingBoxSize(): Vector3;
  104076. /**
  104077. * In case the RTT has been created with a depth texture, get the associated
  104078. * depth texture.
  104079. * Otherwise, return null.
  104080. */
  104081. get depthStencilTexture(): Nullable<InternalTexture>;
  104082. /**
  104083. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104084. * or used a shadow, depth texture...
  104085. * @param name The friendly name of the texture
  104086. * @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)
  104087. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104088. * @param generateMipMaps True if mip maps need to be generated after render.
  104089. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104090. * @param type The type of the buffer in the RTT (int, half float, float...)
  104091. * @param isCube True if a cube texture needs to be created
  104092. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104093. * @param generateDepthBuffer True to generate a depth buffer
  104094. * @param generateStencilBuffer True to generate a stencil buffer
  104095. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104096. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104097. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104098. */
  104099. constructor(name: string, size: number | {
  104100. width: number;
  104101. height: number;
  104102. layers?: number;
  104103. } | {
  104104. ratio: number;
  104105. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104106. /**
  104107. * Creates a depth stencil texture.
  104108. * This is only available in WebGL 2 or with the depth texture extension available.
  104109. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104110. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104111. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104112. */
  104113. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104114. private _processSizeParameter;
  104115. /**
  104116. * Define the number of samples to use in case of MSAA.
  104117. * It defaults to one meaning no MSAA has been enabled.
  104118. */
  104119. get samples(): number;
  104120. set samples(value: number);
  104121. /**
  104122. * Resets the refresh counter of the texture and start bak from scratch.
  104123. * Could be useful to regenerate the texture if it is setup to render only once.
  104124. */
  104125. resetRefreshCounter(): void;
  104126. /**
  104127. * Define the refresh rate of the texture or the rendering frequency.
  104128. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104129. */
  104130. get refreshRate(): number;
  104131. set refreshRate(value: number);
  104132. /**
  104133. * Adds a post process to the render target rendering passes.
  104134. * @param postProcess define the post process to add
  104135. */
  104136. addPostProcess(postProcess: PostProcess): void;
  104137. /**
  104138. * Clear all the post processes attached to the render target
  104139. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104140. */
  104141. clearPostProcesses(dispose?: boolean): void;
  104142. /**
  104143. * Remove one of the post process from the list of attached post processes to the texture
  104144. * @param postProcess define the post process to remove from the list
  104145. */
  104146. removePostProcess(postProcess: PostProcess): void;
  104147. /** @hidden */
  104148. _shouldRender(): boolean;
  104149. /**
  104150. * Gets the actual render size of the texture.
  104151. * @returns the width of the render size
  104152. */
  104153. getRenderSize(): number;
  104154. /**
  104155. * Gets the actual render width of the texture.
  104156. * @returns the width of the render size
  104157. */
  104158. getRenderWidth(): number;
  104159. /**
  104160. * Gets the actual render height of the texture.
  104161. * @returns the height of the render size
  104162. */
  104163. getRenderHeight(): number;
  104164. /**
  104165. * Gets the actual number of layers of the texture.
  104166. * @returns the number of layers
  104167. */
  104168. getRenderLayers(): number;
  104169. /**
  104170. * Get if the texture can be rescaled or not.
  104171. */
  104172. get canRescale(): boolean;
  104173. /**
  104174. * Resize the texture using a ratio.
  104175. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104176. */
  104177. scale(ratio: number): void;
  104178. /**
  104179. * Get the texture reflection matrix used to rotate/transform the reflection.
  104180. * @returns the reflection matrix
  104181. */
  104182. getReflectionTextureMatrix(): Matrix;
  104183. /**
  104184. * Resize the texture to a new desired size.
  104185. * Be carrefull as it will recreate all the data in the new texture.
  104186. * @param size Define the new size. It can be:
  104187. * - a number for squared texture,
  104188. * - an object containing { width: number, height: number }
  104189. * - or an object containing a ratio { ratio: number }
  104190. */
  104191. resize(size: number | {
  104192. width: number;
  104193. height: number;
  104194. } | {
  104195. ratio: number;
  104196. }): void;
  104197. private _defaultRenderListPrepared;
  104198. /**
  104199. * Renders all the objects from the render list into the texture.
  104200. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104201. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104202. */
  104203. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104204. private _bestReflectionRenderTargetDimension;
  104205. private _prepareRenderingManager;
  104206. /**
  104207. * @hidden
  104208. * @param faceIndex face index to bind to if this is a cubetexture
  104209. * @param layer defines the index of the texture to bind in the array
  104210. */
  104211. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104212. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104213. private renderToTarget;
  104214. /**
  104215. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104216. * This allowed control for front to back rendering or reversly depending of the special needs.
  104217. *
  104218. * @param renderingGroupId The rendering group id corresponding to its index
  104219. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104220. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104221. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104222. */
  104223. 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;
  104224. /**
  104225. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104226. *
  104227. * @param renderingGroupId The rendering group id corresponding to its index
  104228. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104229. */
  104230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104231. /**
  104232. * Clones the texture.
  104233. * @returns the cloned texture
  104234. */
  104235. clone(): RenderTargetTexture;
  104236. /**
  104237. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104238. * @returns The JSON representation of the texture
  104239. */
  104240. serialize(): any;
  104241. /**
  104242. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104243. */
  104244. disposeFramebufferObjects(): void;
  104245. /**
  104246. * Dispose the texture and release its associated resources.
  104247. */
  104248. dispose(): void;
  104249. /** @hidden */
  104250. _rebuild(): void;
  104251. /**
  104252. * Clear the info related to rendering groups preventing retention point in material dispose.
  104253. */
  104254. freeRenderingGroups(): void;
  104255. /**
  104256. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104257. * @returns the view count
  104258. */
  104259. getViewCount(): number;
  104260. }
  104261. }
  104262. declare module BABYLON {
  104263. /**
  104264. * Class used to manipulate GUIDs
  104265. */
  104266. export class GUID {
  104267. /**
  104268. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104269. * Be aware Math.random() could cause collisions, but:
  104270. * "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"
  104271. * @returns a pseudo random id
  104272. */
  104273. static RandomId(): string;
  104274. }
  104275. }
  104276. declare module BABYLON {
  104277. /**
  104278. * Options to be used when creating a shadow depth material
  104279. */
  104280. export interface IIOptionShadowDepthMaterial {
  104281. /** Variables in the vertex shader code that need to have their names remapped.
  104282. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104283. * "var_name" should be either: worldPos or vNormalW
  104284. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104285. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104286. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104287. */
  104288. remappedVariables?: string[];
  104289. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104290. standalone?: boolean;
  104291. }
  104292. /**
  104293. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104294. */
  104295. export class ShadowDepthWrapper {
  104296. private _scene;
  104297. private _options?;
  104298. private _baseMaterial;
  104299. private _onEffectCreatedObserver;
  104300. private _subMeshToEffect;
  104301. private _subMeshToDepthEffect;
  104302. private _meshes;
  104303. /** @hidden */
  104304. _matriceNames: any;
  104305. /** Gets the standalone status of the wrapper */
  104306. get standalone(): boolean;
  104307. /** Gets the base material the wrapper is built upon */
  104308. get baseMaterial(): Material;
  104309. /**
  104310. * Instantiate a new shadow depth wrapper.
  104311. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104312. * generate the shadow depth map. For more information, please refer to the documentation:
  104313. * https://doc.babylonjs.com/babylon101/shadows
  104314. * @param baseMaterial Material to wrap
  104315. * @param scene Define the scene the material belongs to
  104316. * @param options Options used to create the wrapper
  104317. */
  104318. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104319. /**
  104320. * Gets the effect to use to generate the depth map
  104321. * @param subMesh subMesh to get the effect for
  104322. * @param shadowGenerator shadow generator to get the effect for
  104323. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104324. */
  104325. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104326. /**
  104327. * Specifies that the submesh is ready to be used for depth rendering
  104328. * @param subMesh submesh to check
  104329. * @param defines the list of defines to take into account when checking the effect
  104330. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104331. * @param useInstances specifies that instances should be used
  104332. * @returns a boolean indicating that the submesh is ready or not
  104333. */
  104334. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104335. /**
  104336. * Disposes the resources
  104337. */
  104338. dispose(): void;
  104339. private _makeEffect;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. interface ThinEngine {
  104344. /**
  104345. * Unbind a list of render target textures from the webGL context
  104346. * This is used only when drawBuffer extension or webGL2 are active
  104347. * @param textures defines the render target textures to unbind
  104348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104350. */
  104351. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104352. /**
  104353. * Create a multi render target texture
  104354. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104355. * @param size defines the size of the texture
  104356. * @param options defines the creation options
  104357. * @returns the cube texture as an InternalTexture
  104358. */
  104359. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104360. /**
  104361. * Update the sample count for a given multiple render target texture
  104362. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104363. * @param textures defines the textures to update
  104364. * @param samples defines the sample count to set
  104365. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104366. */
  104367. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104368. /**
  104369. * Select a subsets of attachments to draw to.
  104370. * @param attachments gl attachments
  104371. */
  104372. bindAttachments(attachments: number[]): void;
  104373. }
  104374. }
  104375. declare module BABYLON {
  104376. /**
  104377. * Creation options of the multi render target texture.
  104378. */
  104379. export interface IMultiRenderTargetOptions {
  104380. /**
  104381. * Define if the texture needs to create mip maps after render.
  104382. */
  104383. generateMipMaps?: boolean;
  104384. /**
  104385. * Define the types of all the draw buffers we want to create
  104386. */
  104387. types?: number[];
  104388. /**
  104389. * Define the sampling modes of all the draw buffers we want to create
  104390. */
  104391. samplingModes?: number[];
  104392. /**
  104393. * Define if a depth buffer is required
  104394. */
  104395. generateDepthBuffer?: boolean;
  104396. /**
  104397. * Define if a stencil buffer is required
  104398. */
  104399. generateStencilBuffer?: boolean;
  104400. /**
  104401. * Define if a depth texture is required instead of a depth buffer
  104402. */
  104403. generateDepthTexture?: boolean;
  104404. /**
  104405. * Define the number of desired draw buffers
  104406. */
  104407. textureCount?: number;
  104408. /**
  104409. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104410. */
  104411. doNotChangeAspectRatio?: boolean;
  104412. /**
  104413. * Define the default type of the buffers we are creating
  104414. */
  104415. defaultType?: number;
  104416. }
  104417. /**
  104418. * A multi render target, like a render target provides the ability to render to a texture.
  104419. * Unlike the render target, it can render to several draw buffers in one draw.
  104420. * This is specially interesting in deferred rendering or for any effects requiring more than
  104421. * just one color from a single pass.
  104422. */
  104423. export class MultiRenderTarget extends RenderTargetTexture {
  104424. private _internalTextures;
  104425. private _textures;
  104426. private _multiRenderTargetOptions;
  104427. private _count;
  104428. /**
  104429. * Get if draw buffers are currently supported by the used hardware and browser.
  104430. */
  104431. get isSupported(): boolean;
  104432. /**
  104433. * Get the list of textures generated by the multi render target.
  104434. */
  104435. get textures(): Texture[];
  104436. /**
  104437. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104438. */
  104439. get count(): number;
  104440. /**
  104441. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104442. */
  104443. get depthTexture(): Texture;
  104444. /**
  104445. * Set the wrapping mode on U of all the textures we are rendering to.
  104446. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104447. */
  104448. set wrapU(wrap: number);
  104449. /**
  104450. * Set the wrapping mode on V of all the textures we are rendering to.
  104451. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104452. */
  104453. set wrapV(wrap: number);
  104454. /**
  104455. * Instantiate a new multi render target texture.
  104456. * A multi render target, like a render target provides the ability to render to a texture.
  104457. * Unlike the render target, it can render to several draw buffers in one draw.
  104458. * This is specially interesting in deferred rendering or for any effects requiring more than
  104459. * just one color from a single pass.
  104460. * @param name Define the name of the texture
  104461. * @param size Define the size of the buffers to render to
  104462. * @param count Define the number of target we are rendering into
  104463. * @param scene Define the scene the texture belongs to
  104464. * @param options Define the options used to create the multi render target
  104465. */
  104466. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104467. private _initTypes;
  104468. /** @hidden */
  104469. _rebuild(forceFullRebuild?: boolean): void;
  104470. private _createInternalTextures;
  104471. private _createTextures;
  104472. /**
  104473. * Define the number of samples used if MSAA is enabled.
  104474. */
  104475. get samples(): number;
  104476. set samples(value: number);
  104477. /**
  104478. * Resize all the textures in the multi render target.
  104479. * Be careful as it will recreate all the data in the new texture.
  104480. * @param size Define the new size
  104481. */
  104482. resize(size: any): void;
  104483. /**
  104484. * Changes the number of render targets in this MRT
  104485. * Be careful as it will recreate all the data in the new texture.
  104486. * @param count new texture count
  104487. * @param options Specifies texture types and sampling modes for new textures
  104488. */
  104489. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104490. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104491. /**
  104492. * Dispose the render targets and their associated resources
  104493. */
  104494. dispose(): void;
  104495. /**
  104496. * Release all the underlying texture used as draw buffers.
  104497. */
  104498. releaseInternalTextures(): void;
  104499. }
  104500. }
  104501. declare module BABYLON {
  104502. /** @hidden */
  104503. export var imageProcessingPixelShader: {
  104504. name: string;
  104505. shader: string;
  104506. };
  104507. }
  104508. declare module BABYLON {
  104509. /**
  104510. * ImageProcessingPostProcess
  104511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104512. */
  104513. export class ImageProcessingPostProcess extends PostProcess {
  104514. /**
  104515. * Default configuration related to image processing available in the PBR Material.
  104516. */
  104517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104518. /**
  104519. * Gets the image processing configuration used either in this material.
  104520. */
  104521. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104522. /**
  104523. * Sets the Default image processing configuration used either in the this material.
  104524. *
  104525. * If sets to null, the scene one is in use.
  104526. */
  104527. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104528. /**
  104529. * Keep track of the image processing observer to allow dispose and replace.
  104530. */
  104531. private _imageProcessingObserver;
  104532. /**
  104533. * Attaches a new image processing configuration to the PBR Material.
  104534. * @param configuration
  104535. */
  104536. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104537. /**
  104538. * If the post process is supported.
  104539. */
  104540. get isSupported(): boolean;
  104541. /**
  104542. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104543. */
  104544. get colorCurves(): Nullable<ColorCurves>;
  104545. /**
  104546. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104547. */
  104548. set colorCurves(value: Nullable<ColorCurves>);
  104549. /**
  104550. * Gets wether the color curves effect is enabled.
  104551. */
  104552. get colorCurvesEnabled(): boolean;
  104553. /**
  104554. * Sets wether the color curves effect is enabled.
  104555. */
  104556. set colorCurvesEnabled(value: boolean);
  104557. /**
  104558. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104559. */
  104560. get colorGradingTexture(): Nullable<BaseTexture>;
  104561. /**
  104562. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104563. */
  104564. set colorGradingTexture(value: Nullable<BaseTexture>);
  104565. /**
  104566. * Gets wether the color grading effect is enabled.
  104567. */
  104568. get colorGradingEnabled(): boolean;
  104569. /**
  104570. * Gets wether the color grading effect is enabled.
  104571. */
  104572. set colorGradingEnabled(value: boolean);
  104573. /**
  104574. * Gets exposure used in the effect.
  104575. */
  104576. get exposure(): number;
  104577. /**
  104578. * Sets exposure used in the effect.
  104579. */
  104580. set exposure(value: number);
  104581. /**
  104582. * Gets wether tonemapping is enabled or not.
  104583. */
  104584. get toneMappingEnabled(): boolean;
  104585. /**
  104586. * Sets wether tonemapping is enabled or not
  104587. */
  104588. set toneMappingEnabled(value: boolean);
  104589. /**
  104590. * Gets the type of tone mapping effect.
  104591. */
  104592. get toneMappingType(): number;
  104593. /**
  104594. * Sets the type of tone mapping effect.
  104595. */
  104596. set toneMappingType(value: number);
  104597. /**
  104598. * Gets contrast used in the effect.
  104599. */
  104600. get contrast(): number;
  104601. /**
  104602. * Sets contrast used in the effect.
  104603. */
  104604. set contrast(value: number);
  104605. /**
  104606. * Gets Vignette stretch size.
  104607. */
  104608. get vignetteStretch(): number;
  104609. /**
  104610. * Sets Vignette stretch size.
  104611. */
  104612. set vignetteStretch(value: number);
  104613. /**
  104614. * Gets Vignette centre X Offset.
  104615. */
  104616. get vignetteCentreX(): number;
  104617. /**
  104618. * Sets Vignette centre X Offset.
  104619. */
  104620. set vignetteCentreX(value: number);
  104621. /**
  104622. * Gets Vignette centre Y Offset.
  104623. */
  104624. get vignetteCentreY(): number;
  104625. /**
  104626. * Sets Vignette centre Y Offset.
  104627. */
  104628. set vignetteCentreY(value: number);
  104629. /**
  104630. * Gets Vignette weight or intensity of the vignette effect.
  104631. */
  104632. get vignetteWeight(): number;
  104633. /**
  104634. * Sets Vignette weight or intensity of the vignette effect.
  104635. */
  104636. set vignetteWeight(value: number);
  104637. /**
  104638. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104639. * if vignetteEnabled is set to true.
  104640. */
  104641. get vignetteColor(): Color4;
  104642. /**
  104643. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104644. * if vignetteEnabled is set to true.
  104645. */
  104646. set vignetteColor(value: Color4);
  104647. /**
  104648. * Gets Camera field of view used by the Vignette effect.
  104649. */
  104650. get vignetteCameraFov(): number;
  104651. /**
  104652. * Sets Camera field of view used by the Vignette effect.
  104653. */
  104654. set vignetteCameraFov(value: number);
  104655. /**
  104656. * Gets the vignette blend mode allowing different kind of effect.
  104657. */
  104658. get vignetteBlendMode(): number;
  104659. /**
  104660. * Sets the vignette blend mode allowing different kind of effect.
  104661. */
  104662. set vignetteBlendMode(value: number);
  104663. /**
  104664. * Gets wether the vignette effect is enabled.
  104665. */
  104666. get vignetteEnabled(): boolean;
  104667. /**
  104668. * Sets wether the vignette effect is enabled.
  104669. */
  104670. set vignetteEnabled(value: boolean);
  104671. private _fromLinearSpace;
  104672. /**
  104673. * Gets wether the input of the processing is in Gamma or Linear Space.
  104674. */
  104675. get fromLinearSpace(): boolean;
  104676. /**
  104677. * Sets wether the input of the processing is in Gamma or Linear Space.
  104678. */
  104679. set fromLinearSpace(value: boolean);
  104680. /**
  104681. * Defines cache preventing GC.
  104682. */
  104683. private _defines;
  104684. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104685. /**
  104686. * "ImageProcessingPostProcess"
  104687. * @returns "ImageProcessingPostProcess"
  104688. */
  104689. getClassName(): string;
  104690. /**
  104691. * @hidden
  104692. */
  104693. _updateParameters(): void;
  104694. dispose(camera?: Camera): void;
  104695. }
  104696. }
  104697. declare module BABYLON {
  104698. /**
  104699. * Interface for defining prepass effects in the prepass post-process pipeline
  104700. */
  104701. export interface PrePassEffectConfiguration {
  104702. /**
  104703. * Name of the effect
  104704. */
  104705. name: string;
  104706. /**
  104707. * Post process to attach for this effect
  104708. */
  104709. postProcess?: PostProcess;
  104710. /**
  104711. * Textures required in the MRT
  104712. */
  104713. texturesRequired: number[];
  104714. /**
  104715. * Is the effect enabled
  104716. */
  104717. enabled: boolean;
  104718. /**
  104719. * Disposes the effect configuration
  104720. */
  104721. dispose(): void;
  104722. /**
  104723. * Creates the associated post process
  104724. */
  104725. createPostProcess?: () => PostProcess;
  104726. }
  104727. }
  104728. declare module BABYLON {
  104729. /**
  104730. * Renders a pre pass of the scene
  104731. * This means every mesh in the scene will be rendered to a render target texture
  104732. * And then this texture will be composited to the rendering canvas with post processes
  104733. * It is necessary for effects like subsurface scattering or deferred shading
  104734. */
  104735. export class PrePassRenderer {
  104736. /** @hidden */
  104737. static _SceneComponentInitialization: (scene: Scene) => void;
  104738. private _textureFormats;
  104739. private _textureIndices;
  104740. private _scene;
  104741. private _engine;
  104742. private _isDirty;
  104743. /**
  104744. * Number of textures in the multi render target texture where the scene is directly rendered
  104745. */
  104746. mrtCount: number;
  104747. /**
  104748. * The render target where the scene is directly rendered
  104749. */
  104750. prePassRT: MultiRenderTarget;
  104751. private _multiRenderAttachments;
  104752. private _defaultAttachments;
  104753. private _clearAttachments;
  104754. private _postProcesses;
  104755. private readonly _clearColor;
  104756. /**
  104757. * Image processing post process for composition
  104758. */
  104759. imageProcessingPostProcess: ImageProcessingPostProcess;
  104760. /**
  104761. * Configuration for prepass effects
  104762. */
  104763. private _effectConfigurations;
  104764. /**
  104765. * Should materials render their geometry on the MRT
  104766. */
  104767. materialsShouldRenderGeometry: boolean;
  104768. /**
  104769. * Should materials render the irradiance information on the MRT
  104770. */
  104771. materialsShouldRenderIrradiance: boolean;
  104772. private _mrtFormats;
  104773. private _mrtLayout;
  104774. private _enabled;
  104775. /**
  104776. * Indicates if the prepass is enabled
  104777. */
  104778. get enabled(): boolean;
  104779. /**
  104780. * How many samples are used for MSAA of the scene render target
  104781. */
  104782. get samples(): number;
  104783. set samples(n: number);
  104784. /**
  104785. * Instanciates a prepass renderer
  104786. * @param scene The scene
  104787. */
  104788. constructor(scene: Scene);
  104789. private _initializeAttachments;
  104790. private _createCompositionEffect;
  104791. /**
  104792. * Indicates if rendering a prepass is supported
  104793. */
  104794. get isSupported(): boolean;
  104795. /**
  104796. * Sets the proper output textures to draw in the engine.
  104797. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104798. */
  104799. bindAttachmentsForEffect(effect: Effect): void;
  104800. /**
  104801. * @hidden
  104802. */
  104803. _beforeCameraDraw(): void;
  104804. /**
  104805. * @hidden
  104806. */
  104807. _afterCameraDraw(): void;
  104808. private _checkRTSize;
  104809. private _bindFrameBuffer;
  104810. /**
  104811. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104812. */
  104813. clear(): void;
  104814. private _setState;
  104815. private _checkTextureType;
  104816. /**
  104817. * Adds an effect configuration to the prepass.
  104818. * If an effect has already been added, it won't add it twice and will return the configuration
  104819. * already present.
  104820. * @param cfg the effect configuration
  104821. * @return the effect configuration now used by the prepass
  104822. */
  104823. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104824. /**
  104825. * Returns the index of a texture in the multi render target texture array.
  104826. * @param type Texture type
  104827. * @return The index
  104828. */
  104829. getIndex(type: number): number;
  104830. private _enable;
  104831. private _disable;
  104832. private _resetLayout;
  104833. private _resetPostProcessChain;
  104834. private _bindPostProcessChain;
  104835. /**
  104836. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104837. */
  104838. markAsDirty(): void;
  104839. /**
  104840. * Enables a texture on the MultiRenderTarget for prepass
  104841. */
  104842. private _enableTextures;
  104843. private _update;
  104844. /**
  104845. * Disposes the prepass renderer.
  104846. */
  104847. dispose(): void;
  104848. }
  104849. }
  104850. declare module BABYLON {
  104851. /**
  104852. * Options for compiling materials.
  104853. */
  104854. export interface IMaterialCompilationOptions {
  104855. /**
  104856. * Defines whether clip planes are enabled.
  104857. */
  104858. clipPlane: boolean;
  104859. /**
  104860. * Defines whether instances are enabled.
  104861. */
  104862. useInstances: boolean;
  104863. }
  104864. /**
  104865. * Options passed when calling customShaderNameResolve
  104866. */
  104867. export interface ICustomShaderNameResolveOptions {
  104868. /**
  104869. * 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
  104870. */
  104871. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104872. }
  104873. /**
  104874. * Base class for the main features of a material in Babylon.js
  104875. */
  104876. export class Material implements IAnimatable {
  104877. /**
  104878. * Returns the triangle fill mode
  104879. */
  104880. static readonly TriangleFillMode: number;
  104881. /**
  104882. * Returns the wireframe mode
  104883. */
  104884. static readonly WireFrameFillMode: number;
  104885. /**
  104886. * Returns the point fill mode
  104887. */
  104888. static readonly PointFillMode: number;
  104889. /**
  104890. * Returns the point list draw mode
  104891. */
  104892. static readonly PointListDrawMode: number;
  104893. /**
  104894. * Returns the line list draw mode
  104895. */
  104896. static readonly LineListDrawMode: number;
  104897. /**
  104898. * Returns the line loop draw mode
  104899. */
  104900. static readonly LineLoopDrawMode: number;
  104901. /**
  104902. * Returns the line strip draw mode
  104903. */
  104904. static readonly LineStripDrawMode: number;
  104905. /**
  104906. * Returns the triangle strip draw mode
  104907. */
  104908. static readonly TriangleStripDrawMode: number;
  104909. /**
  104910. * Returns the triangle fan draw mode
  104911. */
  104912. static readonly TriangleFanDrawMode: number;
  104913. /**
  104914. * Stores the clock-wise side orientation
  104915. */
  104916. static readonly ClockWiseSideOrientation: number;
  104917. /**
  104918. * Stores the counter clock-wise side orientation
  104919. */
  104920. static readonly CounterClockWiseSideOrientation: number;
  104921. /**
  104922. * The dirty texture flag value
  104923. */
  104924. static readonly TextureDirtyFlag: number;
  104925. /**
  104926. * The dirty light flag value
  104927. */
  104928. static readonly LightDirtyFlag: number;
  104929. /**
  104930. * The dirty fresnel flag value
  104931. */
  104932. static readonly FresnelDirtyFlag: number;
  104933. /**
  104934. * The dirty attribute flag value
  104935. */
  104936. static readonly AttributesDirtyFlag: number;
  104937. /**
  104938. * The dirty misc flag value
  104939. */
  104940. static readonly MiscDirtyFlag: number;
  104941. /**
  104942. * The all dirty flag value
  104943. */
  104944. static readonly AllDirtyFlag: number;
  104945. /**
  104946. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104947. */
  104948. static readonly MATERIAL_OPAQUE: number;
  104949. /**
  104950. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104951. */
  104952. static readonly MATERIAL_ALPHATEST: number;
  104953. /**
  104954. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104955. */
  104956. static readonly MATERIAL_ALPHABLEND: number;
  104957. /**
  104958. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104959. * They are also discarded below the alpha cutoff threshold to improve performances.
  104960. */
  104961. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104962. /**
  104963. * The Whiteout method is used to blend normals.
  104964. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104965. */
  104966. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104967. /**
  104968. * The Reoriented Normal Mapping method is used to blend normals.
  104969. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104970. */
  104971. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104972. /**
  104973. * Custom callback helping to override the default shader used in the material.
  104974. */
  104975. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104976. /**
  104977. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104978. */
  104979. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104980. /**
  104981. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104982. * This means that the material can keep using a previous shader while a new one is being compiled.
  104983. * This is mostly used when shader parallel compilation is supported (true by default)
  104984. */
  104985. allowShaderHotSwapping: boolean;
  104986. /**
  104987. * The ID of the material
  104988. */
  104989. id: string;
  104990. /**
  104991. * Gets or sets the unique id of the material
  104992. */
  104993. uniqueId: number;
  104994. /**
  104995. * The name of the material
  104996. */
  104997. name: string;
  104998. /**
  104999. * Gets or sets user defined metadata
  105000. */
  105001. metadata: any;
  105002. /**
  105003. * For internal use only. Please do not use.
  105004. */
  105005. reservedDataStore: any;
  105006. /**
  105007. * Specifies if the ready state should be checked on each call
  105008. */
  105009. checkReadyOnEveryCall: boolean;
  105010. /**
  105011. * Specifies if the ready state should be checked once
  105012. */
  105013. checkReadyOnlyOnce: boolean;
  105014. /**
  105015. * The state of the material
  105016. */
  105017. state: string;
  105018. /**
  105019. * If the material can be rendered to several textures with MRT extension
  105020. */
  105021. get canRenderToMRT(): boolean;
  105022. /**
  105023. * The alpha value of the material
  105024. */
  105025. protected _alpha: number;
  105026. /**
  105027. * List of inspectable custom properties (used by the Inspector)
  105028. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105029. */
  105030. inspectableCustomProperties: IInspectable[];
  105031. /**
  105032. * Sets the alpha value of the material
  105033. */
  105034. set alpha(value: number);
  105035. /**
  105036. * Gets the alpha value of the material
  105037. */
  105038. get alpha(): number;
  105039. /**
  105040. * Specifies if back face culling is enabled
  105041. */
  105042. protected _backFaceCulling: boolean;
  105043. /**
  105044. * Sets the back-face culling state
  105045. */
  105046. set backFaceCulling(value: boolean);
  105047. /**
  105048. * Gets the back-face culling state
  105049. */
  105050. get backFaceCulling(): boolean;
  105051. /**
  105052. * Stores the value for side orientation
  105053. */
  105054. sideOrientation: number;
  105055. /**
  105056. * Callback triggered when the material is compiled
  105057. */
  105058. onCompiled: Nullable<(effect: Effect) => void>;
  105059. /**
  105060. * Callback triggered when an error occurs
  105061. */
  105062. onError: Nullable<(effect: Effect, errors: string) => void>;
  105063. /**
  105064. * Callback triggered to get the render target textures
  105065. */
  105066. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105067. /**
  105068. * Gets a boolean indicating that current material needs to register RTT
  105069. */
  105070. get hasRenderTargetTextures(): boolean;
  105071. /**
  105072. * Specifies if the material should be serialized
  105073. */
  105074. doNotSerialize: boolean;
  105075. /**
  105076. * @hidden
  105077. */
  105078. _storeEffectOnSubMeshes: boolean;
  105079. /**
  105080. * Stores the animations for the material
  105081. */
  105082. animations: Nullable<Array<Animation>>;
  105083. /**
  105084. * An event triggered when the material is disposed
  105085. */
  105086. onDisposeObservable: Observable<Material>;
  105087. /**
  105088. * An observer which watches for dispose events
  105089. */
  105090. private _onDisposeObserver;
  105091. private _onUnBindObservable;
  105092. /**
  105093. * Called during a dispose event
  105094. */
  105095. set onDispose(callback: () => void);
  105096. private _onBindObservable;
  105097. /**
  105098. * An event triggered when the material is bound
  105099. */
  105100. get onBindObservable(): Observable<AbstractMesh>;
  105101. /**
  105102. * An observer which watches for bind events
  105103. */
  105104. private _onBindObserver;
  105105. /**
  105106. * Called during a bind event
  105107. */
  105108. set onBind(callback: (Mesh: AbstractMesh) => void);
  105109. /**
  105110. * An event triggered when the material is unbound
  105111. */
  105112. get onUnBindObservable(): Observable<Material>;
  105113. protected _onEffectCreatedObservable: Nullable<Observable<{
  105114. effect: Effect;
  105115. subMesh: Nullable<SubMesh>;
  105116. }>>;
  105117. /**
  105118. * An event triggered when the effect is (re)created
  105119. */
  105120. get onEffectCreatedObservable(): Observable<{
  105121. effect: Effect;
  105122. subMesh: Nullable<SubMesh>;
  105123. }>;
  105124. /**
  105125. * Stores the value of the alpha mode
  105126. */
  105127. private _alphaMode;
  105128. /**
  105129. * Sets the value of the alpha mode.
  105130. *
  105131. * | Value | Type | Description |
  105132. * | --- | --- | --- |
  105133. * | 0 | ALPHA_DISABLE | |
  105134. * | 1 | ALPHA_ADD | |
  105135. * | 2 | ALPHA_COMBINE | |
  105136. * | 3 | ALPHA_SUBTRACT | |
  105137. * | 4 | ALPHA_MULTIPLY | |
  105138. * | 5 | ALPHA_MAXIMIZED | |
  105139. * | 6 | ALPHA_ONEONE | |
  105140. * | 7 | ALPHA_PREMULTIPLIED | |
  105141. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105142. * | 9 | ALPHA_INTERPOLATE | |
  105143. * | 10 | ALPHA_SCREENMODE | |
  105144. *
  105145. */
  105146. set alphaMode(value: number);
  105147. /**
  105148. * Gets the value of the alpha mode
  105149. */
  105150. get alphaMode(): number;
  105151. /**
  105152. * Stores the state of the need depth pre-pass value
  105153. */
  105154. private _needDepthPrePass;
  105155. /**
  105156. * Sets the need depth pre-pass value
  105157. */
  105158. set needDepthPrePass(value: boolean);
  105159. /**
  105160. * Gets the depth pre-pass value
  105161. */
  105162. get needDepthPrePass(): boolean;
  105163. /**
  105164. * Specifies if depth writing should be disabled
  105165. */
  105166. disableDepthWrite: boolean;
  105167. /**
  105168. * Specifies if color writing should be disabled
  105169. */
  105170. disableColorWrite: boolean;
  105171. /**
  105172. * Specifies if depth writing should be forced
  105173. */
  105174. forceDepthWrite: boolean;
  105175. /**
  105176. * Specifies the depth function that should be used. 0 means the default engine function
  105177. */
  105178. depthFunction: number;
  105179. /**
  105180. * Specifies if there should be a separate pass for culling
  105181. */
  105182. separateCullingPass: boolean;
  105183. /**
  105184. * Stores the state specifing if fog should be enabled
  105185. */
  105186. private _fogEnabled;
  105187. /**
  105188. * Sets the state for enabling fog
  105189. */
  105190. set fogEnabled(value: boolean);
  105191. /**
  105192. * Gets the value of the fog enabled state
  105193. */
  105194. get fogEnabled(): boolean;
  105195. /**
  105196. * Stores the size of points
  105197. */
  105198. pointSize: number;
  105199. /**
  105200. * Stores the z offset value
  105201. */
  105202. zOffset: number;
  105203. get wireframe(): boolean;
  105204. /**
  105205. * Sets the state of wireframe mode
  105206. */
  105207. set wireframe(value: boolean);
  105208. /**
  105209. * Gets the value specifying if point clouds are enabled
  105210. */
  105211. get pointsCloud(): boolean;
  105212. /**
  105213. * Sets the state of point cloud mode
  105214. */
  105215. set pointsCloud(value: boolean);
  105216. /**
  105217. * Gets the material fill mode
  105218. */
  105219. get fillMode(): number;
  105220. /**
  105221. * Sets the material fill mode
  105222. */
  105223. set fillMode(value: number);
  105224. /**
  105225. * @hidden
  105226. * Stores the effects for the material
  105227. */
  105228. _effect: Nullable<Effect>;
  105229. /**
  105230. * Specifies if uniform buffers should be used
  105231. */
  105232. private _useUBO;
  105233. /**
  105234. * Stores a reference to the scene
  105235. */
  105236. private _scene;
  105237. /**
  105238. * Stores the fill mode state
  105239. */
  105240. private _fillMode;
  105241. /**
  105242. * Specifies if the depth write state should be cached
  105243. */
  105244. private _cachedDepthWriteState;
  105245. /**
  105246. * Specifies if the color write state should be cached
  105247. */
  105248. private _cachedColorWriteState;
  105249. /**
  105250. * Specifies if the depth function state should be cached
  105251. */
  105252. private _cachedDepthFunctionState;
  105253. /**
  105254. * Stores the uniform buffer
  105255. */
  105256. protected _uniformBuffer: UniformBuffer;
  105257. /** @hidden */
  105258. _indexInSceneMaterialArray: number;
  105259. /** @hidden */
  105260. meshMap: Nullable<{
  105261. [id: string]: AbstractMesh | undefined;
  105262. }>;
  105263. /**
  105264. * Creates a material instance
  105265. * @param name defines the name of the material
  105266. * @param scene defines the scene to reference
  105267. * @param doNotAdd specifies if the material should be added to the scene
  105268. */
  105269. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105270. /**
  105271. * Returns a string representation of the current material
  105272. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105273. * @returns a string with material information
  105274. */
  105275. toString(fullDetails?: boolean): string;
  105276. /**
  105277. * Gets the class name of the material
  105278. * @returns a string with the class name of the material
  105279. */
  105280. getClassName(): string;
  105281. /**
  105282. * Specifies if updates for the material been locked
  105283. */
  105284. get isFrozen(): boolean;
  105285. /**
  105286. * Locks updates for the material
  105287. */
  105288. freeze(): void;
  105289. /**
  105290. * Unlocks updates for the material
  105291. */
  105292. unfreeze(): void;
  105293. /**
  105294. * Specifies if the material is ready to be used
  105295. * @param mesh defines the mesh to check
  105296. * @param useInstances specifies if instances should be used
  105297. * @returns a boolean indicating if the material is ready to be used
  105298. */
  105299. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105300. /**
  105301. * Specifies that the submesh is ready to be used
  105302. * @param mesh defines the mesh to check
  105303. * @param subMesh defines which submesh to check
  105304. * @param useInstances specifies that instances should be used
  105305. * @returns a boolean indicating that the submesh is ready or not
  105306. */
  105307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105308. /**
  105309. * Returns the material effect
  105310. * @returns the effect associated with the material
  105311. */
  105312. getEffect(): Nullable<Effect>;
  105313. /**
  105314. * Returns the current scene
  105315. * @returns a Scene
  105316. */
  105317. getScene(): Scene;
  105318. /**
  105319. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105320. */
  105321. protected _forceAlphaTest: boolean;
  105322. /**
  105323. * The transparency mode of the material.
  105324. */
  105325. protected _transparencyMode: Nullable<number>;
  105326. /**
  105327. * Gets the current transparency mode.
  105328. */
  105329. get transparencyMode(): Nullable<number>;
  105330. /**
  105331. * Sets the transparency mode of the material.
  105332. *
  105333. * | Value | Type | Description |
  105334. * | ----- | ----------------------------------- | ----------- |
  105335. * | 0 | OPAQUE | |
  105336. * | 1 | ALPHATEST | |
  105337. * | 2 | ALPHABLEND | |
  105338. * | 3 | ALPHATESTANDBLEND | |
  105339. *
  105340. */
  105341. set transparencyMode(value: Nullable<number>);
  105342. /**
  105343. * Returns true if alpha blending should be disabled.
  105344. */
  105345. protected get _disableAlphaBlending(): boolean;
  105346. /**
  105347. * Specifies whether or not this material should be rendered in alpha blend mode.
  105348. * @returns a boolean specifying if alpha blending is needed
  105349. */
  105350. needAlphaBlending(): boolean;
  105351. /**
  105352. * Specifies if the mesh will require alpha blending
  105353. * @param mesh defines the mesh to check
  105354. * @returns a boolean specifying if alpha blending is needed for the mesh
  105355. */
  105356. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105357. /**
  105358. * Specifies whether or not this material should be rendered in alpha test mode.
  105359. * @returns a boolean specifying if an alpha test is needed.
  105360. */
  105361. needAlphaTesting(): boolean;
  105362. /**
  105363. * Specifies if material alpha testing should be turned on for the mesh
  105364. * @param mesh defines the mesh to check
  105365. */
  105366. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105367. /**
  105368. * Gets the texture used for the alpha test
  105369. * @returns the texture to use for alpha testing
  105370. */
  105371. getAlphaTestTexture(): Nullable<BaseTexture>;
  105372. /**
  105373. * Marks the material to indicate that it needs to be re-calculated
  105374. */
  105375. markDirty(): void;
  105376. /** @hidden */
  105377. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105378. /**
  105379. * Binds the material to the mesh
  105380. * @param world defines the world transformation matrix
  105381. * @param mesh defines the mesh to bind the material to
  105382. */
  105383. bind(world: Matrix, mesh?: Mesh): void;
  105384. /**
  105385. * Binds the submesh to the material
  105386. * @param world defines the world transformation matrix
  105387. * @param mesh defines the mesh containing the submesh
  105388. * @param subMesh defines the submesh to bind the material to
  105389. */
  105390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105391. /**
  105392. * Binds the world matrix to the material
  105393. * @param world defines the world transformation matrix
  105394. */
  105395. bindOnlyWorldMatrix(world: Matrix): void;
  105396. /**
  105397. * Binds the scene's uniform buffer to the effect.
  105398. * @param effect defines the effect to bind to the scene uniform buffer
  105399. * @param sceneUbo defines the uniform buffer storing scene data
  105400. */
  105401. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105402. /**
  105403. * Binds the view matrix to the effect
  105404. * @param effect defines the effect to bind the view matrix to
  105405. */
  105406. bindView(effect: Effect): void;
  105407. /**
  105408. * Binds the view projection matrix to the effect
  105409. * @param effect defines the effect to bind the view projection matrix to
  105410. */
  105411. bindViewProjection(effect: Effect): void;
  105412. /**
  105413. * Processes to execute after binding the material to a mesh
  105414. * @param mesh defines the rendered mesh
  105415. */
  105416. protected _afterBind(mesh?: Mesh): void;
  105417. /**
  105418. * Unbinds the material from the mesh
  105419. */
  105420. unbind(): void;
  105421. /**
  105422. * Gets the active textures from the material
  105423. * @returns an array of textures
  105424. */
  105425. getActiveTextures(): BaseTexture[];
  105426. /**
  105427. * Specifies if the material uses a texture
  105428. * @param texture defines the texture to check against the material
  105429. * @returns a boolean specifying if the material uses the texture
  105430. */
  105431. hasTexture(texture: BaseTexture): boolean;
  105432. /**
  105433. * Makes a duplicate of the material, and gives it a new name
  105434. * @param name defines the new name for the duplicated material
  105435. * @returns the cloned material
  105436. */
  105437. clone(name: string): Nullable<Material>;
  105438. /**
  105439. * Gets the meshes bound to the material
  105440. * @returns an array of meshes bound to the material
  105441. */
  105442. getBindedMeshes(): AbstractMesh[];
  105443. /**
  105444. * Force shader compilation
  105445. * @param mesh defines the mesh associated with this material
  105446. * @param onCompiled defines a function to execute once the material is compiled
  105447. * @param options defines the options to configure the compilation
  105448. * @param onError defines a function to execute if the material fails compiling
  105449. */
  105450. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105451. /**
  105452. * Force shader compilation
  105453. * @param mesh defines the mesh that will use this material
  105454. * @param options defines additional options for compiling the shaders
  105455. * @returns a promise that resolves when the compilation completes
  105456. */
  105457. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105458. private static readonly _AllDirtyCallBack;
  105459. private static readonly _ImageProcessingDirtyCallBack;
  105460. private static readonly _TextureDirtyCallBack;
  105461. private static readonly _FresnelDirtyCallBack;
  105462. private static readonly _MiscDirtyCallBack;
  105463. private static readonly _LightsDirtyCallBack;
  105464. private static readonly _AttributeDirtyCallBack;
  105465. private static _FresnelAndMiscDirtyCallBack;
  105466. private static _TextureAndMiscDirtyCallBack;
  105467. private static readonly _DirtyCallbackArray;
  105468. private static readonly _RunDirtyCallBacks;
  105469. /**
  105470. * Marks a define in the material to indicate that it needs to be re-computed
  105471. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105472. */
  105473. markAsDirty(flag: number): void;
  105474. /**
  105475. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105476. * @param func defines a function which checks material defines against the submeshes
  105477. */
  105478. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105479. /**
  105480. * Indicates that the scene should check if the rendering now needs a prepass
  105481. */
  105482. protected _markScenePrePassDirty(): void;
  105483. /**
  105484. * Indicates that we need to re-calculated for all submeshes
  105485. */
  105486. protected _markAllSubMeshesAsAllDirty(): void;
  105487. /**
  105488. * Indicates that image processing needs to be re-calculated for all submeshes
  105489. */
  105490. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105491. /**
  105492. * Indicates that textures need to be re-calculated for all submeshes
  105493. */
  105494. protected _markAllSubMeshesAsTexturesDirty(): void;
  105495. /**
  105496. * Indicates that fresnel needs to be re-calculated for all submeshes
  105497. */
  105498. protected _markAllSubMeshesAsFresnelDirty(): void;
  105499. /**
  105500. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105501. */
  105502. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105503. /**
  105504. * Indicates that lights need to be re-calculated for all submeshes
  105505. */
  105506. protected _markAllSubMeshesAsLightsDirty(): void;
  105507. /**
  105508. * Indicates that attributes need to be re-calculated for all submeshes
  105509. */
  105510. protected _markAllSubMeshesAsAttributesDirty(): void;
  105511. /**
  105512. * Indicates that misc needs to be re-calculated for all submeshes
  105513. */
  105514. protected _markAllSubMeshesAsMiscDirty(): void;
  105515. /**
  105516. * Indicates that textures and misc need to be re-calculated for all submeshes
  105517. */
  105518. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105519. /**
  105520. * Sets the required values to the prepass renderer.
  105521. * @param prePassRenderer defines the prepass renderer to setup.
  105522. * @returns true if the pre pass is needed.
  105523. */
  105524. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105525. /**
  105526. * Disposes the material
  105527. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105528. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105529. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105530. */
  105531. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105532. /** @hidden */
  105533. private releaseVertexArrayObject;
  105534. /**
  105535. * Serializes this material
  105536. * @returns the serialized material object
  105537. */
  105538. serialize(): any;
  105539. /**
  105540. * Creates a material from parsed material data
  105541. * @param parsedMaterial defines parsed material data
  105542. * @param scene defines the hosting scene
  105543. * @param rootUrl defines the root URL to use to load textures
  105544. * @returns a new material
  105545. */
  105546. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105547. }
  105548. }
  105549. declare module BABYLON {
  105550. /**
  105551. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105552. * separate meshes. This can be use to improve performances.
  105553. * @see https://doc.babylonjs.com/how_to/multi_materials
  105554. */
  105555. export class MultiMaterial extends Material {
  105556. private _subMaterials;
  105557. /**
  105558. * Gets or Sets the list of Materials used within the multi material.
  105559. * They need to be ordered according to the submeshes order in the associated mesh
  105560. */
  105561. get subMaterials(): Nullable<Material>[];
  105562. set subMaterials(value: Nullable<Material>[]);
  105563. /**
  105564. * Function used to align with Node.getChildren()
  105565. * @returns the list of Materials used within the multi material
  105566. */
  105567. getChildren(): Nullable<Material>[];
  105568. /**
  105569. * Instantiates a new Multi Material
  105570. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105571. * separate meshes. This can be use to improve performances.
  105572. * @see https://doc.babylonjs.com/how_to/multi_materials
  105573. * @param name Define the name in the scene
  105574. * @param scene Define the scene the material belongs to
  105575. */
  105576. constructor(name: string, scene: Scene);
  105577. private _hookArray;
  105578. /**
  105579. * Get one of the submaterial by its index in the submaterials array
  105580. * @param index The index to look the sub material at
  105581. * @returns The Material if the index has been defined
  105582. */
  105583. getSubMaterial(index: number): Nullable<Material>;
  105584. /**
  105585. * Get the list of active textures for the whole sub materials list.
  105586. * @returns All the textures that will be used during the rendering
  105587. */
  105588. getActiveTextures(): BaseTexture[];
  105589. /**
  105590. * Gets the current class name of the material e.g. "MultiMaterial"
  105591. * Mainly use in serialization.
  105592. * @returns the class name
  105593. */
  105594. getClassName(): string;
  105595. /**
  105596. * Checks if the material is ready to render the requested sub mesh
  105597. * @param mesh Define the mesh the submesh belongs to
  105598. * @param subMesh Define the sub mesh to look readyness for
  105599. * @param useInstances Define whether or not the material is used with instances
  105600. * @returns true if ready, otherwise false
  105601. */
  105602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105603. /**
  105604. * Clones the current material and its related sub materials
  105605. * @param name Define the name of the newly cloned material
  105606. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105607. * @returns the cloned material
  105608. */
  105609. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105610. /**
  105611. * Serializes the materials into a JSON representation.
  105612. * @returns the JSON representation
  105613. */
  105614. serialize(): any;
  105615. /**
  105616. * Dispose the material and release its associated resources
  105617. * @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)
  105618. * @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)
  105619. * @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)
  105620. */
  105621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105622. /**
  105623. * Creates a MultiMaterial from parsed MultiMaterial data.
  105624. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105625. * @param scene defines the hosting scene
  105626. * @returns a new MultiMaterial
  105627. */
  105628. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105629. }
  105630. }
  105631. declare module BABYLON {
  105632. /**
  105633. * Defines a subdivision inside a mesh
  105634. */
  105635. export class SubMesh implements ICullable {
  105636. /** the material index to use */
  105637. materialIndex: number;
  105638. /** vertex index start */
  105639. verticesStart: number;
  105640. /** vertices count */
  105641. verticesCount: number;
  105642. /** index start */
  105643. indexStart: number;
  105644. /** indices count */
  105645. indexCount: number;
  105646. /** @hidden */
  105647. _materialDefines: Nullable<MaterialDefines>;
  105648. /** @hidden */
  105649. _materialEffect: Nullable<Effect>;
  105650. /** @hidden */
  105651. _effectOverride: Nullable<Effect>;
  105652. /**
  105653. * Gets material defines used by the effect associated to the sub mesh
  105654. */
  105655. get materialDefines(): Nullable<MaterialDefines>;
  105656. /**
  105657. * Sets material defines used by the effect associated to the sub mesh
  105658. */
  105659. set materialDefines(defines: Nullable<MaterialDefines>);
  105660. /**
  105661. * Gets associated effect
  105662. */
  105663. get effect(): Nullable<Effect>;
  105664. /**
  105665. * Sets associated effect (effect used to render this submesh)
  105666. * @param effect defines the effect to associate with
  105667. * @param defines defines the set of defines used to compile this effect
  105668. */
  105669. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105670. /** @hidden */
  105671. _linesIndexCount: number;
  105672. private _mesh;
  105673. private _renderingMesh;
  105674. private _boundingInfo;
  105675. private _linesIndexBuffer;
  105676. /** @hidden */
  105677. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105678. /** @hidden */
  105679. _trianglePlanes: Plane[];
  105680. /** @hidden */
  105681. _lastColliderTransformMatrix: Nullable<Matrix>;
  105682. /** @hidden */
  105683. _renderId: number;
  105684. /** @hidden */
  105685. _alphaIndex: number;
  105686. /** @hidden */
  105687. _distanceToCamera: number;
  105688. /** @hidden */
  105689. _id: number;
  105690. private _currentMaterial;
  105691. /**
  105692. * Add a new submesh to a mesh
  105693. * @param materialIndex defines the material index to use
  105694. * @param verticesStart defines vertex index start
  105695. * @param verticesCount defines vertices count
  105696. * @param indexStart defines index start
  105697. * @param indexCount defines indices count
  105698. * @param mesh defines the parent mesh
  105699. * @param renderingMesh defines an optional rendering mesh
  105700. * @param createBoundingBox defines if bounding box should be created for this submesh
  105701. * @returns the new submesh
  105702. */
  105703. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105704. /**
  105705. * Creates a new submesh
  105706. * @param materialIndex defines the material index to use
  105707. * @param verticesStart defines vertex index start
  105708. * @param verticesCount defines vertices count
  105709. * @param indexStart defines index start
  105710. * @param indexCount defines indices count
  105711. * @param mesh defines the parent mesh
  105712. * @param renderingMesh defines an optional rendering mesh
  105713. * @param createBoundingBox defines if bounding box should be created for this submesh
  105714. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105715. */
  105716. constructor(
  105717. /** the material index to use */
  105718. materialIndex: number,
  105719. /** vertex index start */
  105720. verticesStart: number,
  105721. /** vertices count */
  105722. verticesCount: number,
  105723. /** index start */
  105724. indexStart: number,
  105725. /** indices count */
  105726. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105727. /**
  105728. * Returns true if this submesh covers the entire parent mesh
  105729. * @ignorenaming
  105730. */
  105731. get IsGlobal(): boolean;
  105732. /**
  105733. * Returns the submesh BoudingInfo object
  105734. * @returns current bounding info (or mesh's one if the submesh is global)
  105735. */
  105736. getBoundingInfo(): BoundingInfo;
  105737. /**
  105738. * Sets the submesh BoundingInfo
  105739. * @param boundingInfo defines the new bounding info to use
  105740. * @returns the SubMesh
  105741. */
  105742. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105743. /**
  105744. * Returns the mesh of the current submesh
  105745. * @return the parent mesh
  105746. */
  105747. getMesh(): AbstractMesh;
  105748. /**
  105749. * Returns the rendering mesh of the submesh
  105750. * @returns the rendering mesh (could be different from parent mesh)
  105751. */
  105752. getRenderingMesh(): Mesh;
  105753. /**
  105754. * Returns the replacement mesh of the submesh
  105755. * @returns the replacement mesh (could be different from parent mesh)
  105756. */
  105757. getReplacementMesh(): Nullable<AbstractMesh>;
  105758. /**
  105759. * Returns the effective mesh of the submesh
  105760. * @returns the effective mesh (could be different from parent mesh)
  105761. */
  105762. getEffectiveMesh(): AbstractMesh;
  105763. /**
  105764. * Returns the submesh material
  105765. * @returns null or the current material
  105766. */
  105767. getMaterial(): Nullable<Material>;
  105768. private _IsMultiMaterial;
  105769. /**
  105770. * Sets a new updated BoundingInfo object to the submesh
  105771. * @param data defines an optional position array to use to determine the bounding info
  105772. * @returns the SubMesh
  105773. */
  105774. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105775. /** @hidden */
  105776. _checkCollision(collider: Collider): boolean;
  105777. /**
  105778. * Updates the submesh BoundingInfo
  105779. * @param world defines the world matrix to use to update the bounding info
  105780. * @returns the submesh
  105781. */
  105782. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105783. /**
  105784. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105785. * @param frustumPlanes defines the frustum planes
  105786. * @returns true if the submesh is intersecting with the frustum
  105787. */
  105788. isInFrustum(frustumPlanes: Plane[]): boolean;
  105789. /**
  105790. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105791. * @param frustumPlanes defines the frustum planes
  105792. * @returns true if the submesh is inside the frustum
  105793. */
  105794. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105795. /**
  105796. * Renders the submesh
  105797. * @param enableAlphaMode defines if alpha needs to be used
  105798. * @returns the submesh
  105799. */
  105800. render(enableAlphaMode: boolean): SubMesh;
  105801. /**
  105802. * @hidden
  105803. */
  105804. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105805. /**
  105806. * Checks if the submesh intersects with a ray
  105807. * @param ray defines the ray to test
  105808. * @returns true is the passed ray intersects the submesh bounding box
  105809. */
  105810. canIntersects(ray: Ray): boolean;
  105811. /**
  105812. * Intersects current submesh with a ray
  105813. * @param ray defines the ray to test
  105814. * @param positions defines mesh's positions array
  105815. * @param indices defines mesh's indices array
  105816. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105817. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105818. * @returns intersection info or null if no intersection
  105819. */
  105820. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105821. /** @hidden */
  105822. private _intersectLines;
  105823. /** @hidden */
  105824. private _intersectUnIndexedLines;
  105825. /** @hidden */
  105826. private _intersectTriangles;
  105827. /** @hidden */
  105828. private _intersectUnIndexedTriangles;
  105829. /** @hidden */
  105830. _rebuild(): void;
  105831. /**
  105832. * Creates a new submesh from the passed mesh
  105833. * @param newMesh defines the new hosting mesh
  105834. * @param newRenderingMesh defines an optional rendering mesh
  105835. * @returns the new submesh
  105836. */
  105837. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105838. /**
  105839. * Release associated resources
  105840. */
  105841. dispose(): void;
  105842. /**
  105843. * Gets the class name
  105844. * @returns the string "SubMesh".
  105845. */
  105846. getClassName(): string;
  105847. /**
  105848. * Creates a new submesh from indices data
  105849. * @param materialIndex the index of the main mesh material
  105850. * @param startIndex the index where to start the copy in the mesh indices array
  105851. * @param indexCount the number of indices to copy then from the startIndex
  105852. * @param mesh the main mesh to create the submesh from
  105853. * @param renderingMesh the optional rendering mesh
  105854. * @returns a new submesh
  105855. */
  105856. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105857. }
  105858. }
  105859. declare module BABYLON {
  105860. /**
  105861. * Class used to represent data loading progression
  105862. */
  105863. export class SceneLoaderFlags {
  105864. private static _ForceFullSceneLoadingForIncremental;
  105865. private static _ShowLoadingScreen;
  105866. private static _CleanBoneMatrixWeights;
  105867. private static _loggingLevel;
  105868. /**
  105869. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105870. */
  105871. static get ForceFullSceneLoadingForIncremental(): boolean;
  105872. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105873. /**
  105874. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105875. */
  105876. static get ShowLoadingScreen(): boolean;
  105877. static set ShowLoadingScreen(value: boolean);
  105878. /**
  105879. * Defines the current logging level (while loading the scene)
  105880. * @ignorenaming
  105881. */
  105882. static get loggingLevel(): number;
  105883. static set loggingLevel(value: number);
  105884. /**
  105885. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105886. */
  105887. static get CleanBoneMatrixWeights(): boolean;
  105888. static set CleanBoneMatrixWeights(value: boolean);
  105889. }
  105890. }
  105891. declare module BABYLON {
  105892. /**
  105893. * Class used to store geometry data (vertex buffers + index buffer)
  105894. */
  105895. export class Geometry implements IGetSetVerticesData {
  105896. /**
  105897. * Gets or sets the ID of the geometry
  105898. */
  105899. id: string;
  105900. /**
  105901. * Gets or sets the unique ID of the geometry
  105902. */
  105903. uniqueId: number;
  105904. /**
  105905. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105906. */
  105907. delayLoadState: number;
  105908. /**
  105909. * Gets the file containing the data to load when running in delay load state
  105910. */
  105911. delayLoadingFile: Nullable<string>;
  105912. /**
  105913. * Callback called when the geometry is updated
  105914. */
  105915. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105916. private _scene;
  105917. private _engine;
  105918. private _meshes;
  105919. private _totalVertices;
  105920. /** @hidden */
  105921. _indices: IndicesArray;
  105922. /** @hidden */
  105923. _vertexBuffers: {
  105924. [key: string]: VertexBuffer;
  105925. };
  105926. private _isDisposed;
  105927. private _extend;
  105928. private _boundingBias;
  105929. /** @hidden */
  105930. _delayInfo: Array<string>;
  105931. private _indexBuffer;
  105932. private _indexBufferIsUpdatable;
  105933. /** @hidden */
  105934. _boundingInfo: Nullable<BoundingInfo>;
  105935. /** @hidden */
  105936. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105937. /** @hidden */
  105938. _softwareSkinningFrameId: number;
  105939. private _vertexArrayObjects;
  105940. private _updatable;
  105941. /** @hidden */
  105942. _positions: Nullable<Vector3[]>;
  105943. /**
  105944. * 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
  105945. */
  105946. get boundingBias(): Vector2;
  105947. /**
  105948. * 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
  105949. */
  105950. set boundingBias(value: Vector2);
  105951. /**
  105952. * Static function used to attach a new empty geometry to a mesh
  105953. * @param mesh defines the mesh to attach the geometry to
  105954. * @returns the new Geometry
  105955. */
  105956. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105957. /** Get the list of meshes using this geometry */
  105958. get meshes(): Mesh[];
  105959. /**
  105960. * 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
  105961. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105962. */
  105963. useBoundingInfoFromGeometry: boolean;
  105964. /**
  105965. * Creates a new geometry
  105966. * @param id defines the unique ID
  105967. * @param scene defines the hosting scene
  105968. * @param vertexData defines the VertexData used to get geometry data
  105969. * @param updatable defines if geometry must be updatable (false by default)
  105970. * @param mesh defines the mesh that will be associated with the geometry
  105971. */
  105972. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105973. /**
  105974. * Gets the current extend of the geometry
  105975. */
  105976. get extend(): {
  105977. minimum: Vector3;
  105978. maximum: Vector3;
  105979. };
  105980. /**
  105981. * Gets the hosting scene
  105982. * @returns the hosting Scene
  105983. */
  105984. getScene(): Scene;
  105985. /**
  105986. * Gets the hosting engine
  105987. * @returns the hosting Engine
  105988. */
  105989. getEngine(): Engine;
  105990. /**
  105991. * Defines if the geometry is ready to use
  105992. * @returns true if the geometry is ready to be used
  105993. */
  105994. isReady(): boolean;
  105995. /**
  105996. * Gets a value indicating that the geometry should not be serialized
  105997. */
  105998. get doNotSerialize(): boolean;
  105999. /** @hidden */
  106000. _rebuild(): void;
  106001. /**
  106002. * Affects all geometry data in one call
  106003. * @param vertexData defines the geometry data
  106004. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106005. */
  106006. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106007. /**
  106008. * Set specific vertex data
  106009. * @param kind defines the data kind (Position, normal, etc...)
  106010. * @param data defines the vertex data to use
  106011. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106012. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106013. */
  106014. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106015. /**
  106016. * Removes a specific vertex data
  106017. * @param kind defines the data kind (Position, normal, etc...)
  106018. */
  106019. removeVerticesData(kind: string): void;
  106020. /**
  106021. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106022. * @param buffer defines the vertex buffer to use
  106023. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106024. */
  106025. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106026. /**
  106027. * Update a specific vertex buffer
  106028. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106029. * It will do nothing if the buffer is not updatable
  106030. * @param kind defines the data kind (Position, normal, etc...)
  106031. * @param data defines the data to use
  106032. * @param offset defines the offset in the target buffer where to store the data
  106033. * @param useBytes set to true if the offset is in bytes
  106034. */
  106035. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106036. /**
  106037. * Update a specific vertex buffer
  106038. * This function will create a new buffer if the current one is not updatable
  106039. * @param kind defines the data kind (Position, normal, etc...)
  106040. * @param data defines the data to use
  106041. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106042. */
  106043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106044. private _updateBoundingInfo;
  106045. /** @hidden */
  106046. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106047. /**
  106048. * Gets total number of vertices
  106049. * @returns the total number of vertices
  106050. */
  106051. getTotalVertices(): number;
  106052. /**
  106053. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106054. * @param kind defines the data kind (Position, normal, etc...)
  106055. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106056. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106057. * @returns a float array containing vertex data
  106058. */
  106059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106060. /**
  106061. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106062. * @param kind defines the data kind (Position, normal, etc...)
  106063. * @returns true if the vertex buffer with the specified kind is updatable
  106064. */
  106065. isVertexBufferUpdatable(kind: string): boolean;
  106066. /**
  106067. * Gets a specific vertex buffer
  106068. * @param kind defines the data kind (Position, normal, etc...)
  106069. * @returns a VertexBuffer
  106070. */
  106071. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106072. /**
  106073. * Returns all vertex buffers
  106074. * @return an object holding all vertex buffers indexed by kind
  106075. */
  106076. getVertexBuffers(): Nullable<{
  106077. [key: string]: VertexBuffer;
  106078. }>;
  106079. /**
  106080. * Gets a boolean indicating if specific vertex buffer is present
  106081. * @param kind defines the data kind (Position, normal, etc...)
  106082. * @returns true if data is present
  106083. */
  106084. isVerticesDataPresent(kind: string): boolean;
  106085. /**
  106086. * Gets a list of all attached data kinds (Position, normal, etc...)
  106087. * @returns a list of string containing all kinds
  106088. */
  106089. getVerticesDataKinds(): string[];
  106090. /**
  106091. * Update index buffer
  106092. * @param indices defines the indices to store in the index buffer
  106093. * @param offset defines the offset in the target buffer where to store the data
  106094. * @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)
  106095. */
  106096. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106097. /**
  106098. * Creates a new index buffer
  106099. * @param indices defines the indices to store in the index buffer
  106100. * @param totalVertices defines the total number of vertices (could be null)
  106101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106102. */
  106103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106104. /**
  106105. * Return the total number of indices
  106106. * @returns the total number of indices
  106107. */
  106108. getTotalIndices(): number;
  106109. /**
  106110. * Gets the index buffer array
  106111. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106113. * @returns the index buffer array
  106114. */
  106115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106116. /**
  106117. * Gets the index buffer
  106118. * @return the index buffer
  106119. */
  106120. getIndexBuffer(): Nullable<DataBuffer>;
  106121. /** @hidden */
  106122. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106123. /**
  106124. * Release the associated resources for a specific mesh
  106125. * @param mesh defines the source mesh
  106126. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106127. */
  106128. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106129. /**
  106130. * Apply current geometry to a given mesh
  106131. * @param mesh defines the mesh to apply geometry to
  106132. */
  106133. applyToMesh(mesh: Mesh): void;
  106134. private _updateExtend;
  106135. private _applyToMesh;
  106136. private notifyUpdate;
  106137. /**
  106138. * Load the geometry if it was flagged as delay loaded
  106139. * @param scene defines the hosting scene
  106140. * @param onLoaded defines a callback called when the geometry is loaded
  106141. */
  106142. load(scene: Scene, onLoaded?: () => void): void;
  106143. private _queueLoad;
  106144. /**
  106145. * Invert the geometry to move from a right handed system to a left handed one.
  106146. */
  106147. toLeftHanded(): void;
  106148. /** @hidden */
  106149. _resetPointsArrayCache(): void;
  106150. /** @hidden */
  106151. _generatePointsArray(): boolean;
  106152. /**
  106153. * Gets a value indicating if the geometry is disposed
  106154. * @returns true if the geometry was disposed
  106155. */
  106156. isDisposed(): boolean;
  106157. private _disposeVertexArrayObjects;
  106158. /**
  106159. * Free all associated resources
  106160. */
  106161. dispose(): void;
  106162. /**
  106163. * Clone the current geometry into a new geometry
  106164. * @param id defines the unique ID of the new geometry
  106165. * @returns a new geometry object
  106166. */
  106167. copy(id: string): Geometry;
  106168. /**
  106169. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106170. * @return a JSON representation of the current geometry data (without the vertices data)
  106171. */
  106172. serialize(): any;
  106173. private toNumberArray;
  106174. /**
  106175. * Serialize all vertices data into a JSON oject
  106176. * @returns a JSON representation of the current geometry data
  106177. */
  106178. serializeVerticeData(): any;
  106179. /**
  106180. * Extracts a clone of a mesh geometry
  106181. * @param mesh defines the source mesh
  106182. * @param id defines the unique ID of the new geometry object
  106183. * @returns the new geometry object
  106184. */
  106185. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106186. /**
  106187. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106188. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106189. * Be aware Math.random() could cause collisions, but:
  106190. * "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"
  106191. * @returns a string containing a new GUID
  106192. */
  106193. static RandomId(): string;
  106194. /** @hidden */
  106195. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106196. private static _CleanMatricesWeights;
  106197. /**
  106198. * Create a new geometry from persisted data (Using .babylon file format)
  106199. * @param parsedVertexData defines the persisted data
  106200. * @param scene defines the hosting scene
  106201. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106202. * @returns the new geometry object
  106203. */
  106204. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106205. }
  106206. }
  106207. declare module BABYLON {
  106208. /**
  106209. * Define an interface for all classes that will get and set the data on vertices
  106210. */
  106211. export interface IGetSetVerticesData {
  106212. /**
  106213. * Gets a boolean indicating if specific vertex data is present
  106214. * @param kind defines the vertex data kind to use
  106215. * @returns true is data kind is present
  106216. */
  106217. isVerticesDataPresent(kind: string): boolean;
  106218. /**
  106219. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106220. * @param kind defines the data kind (Position, normal, etc...)
  106221. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106222. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106223. * @returns a float array containing vertex data
  106224. */
  106225. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106226. /**
  106227. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106228. * @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.
  106229. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106230. * @returns the indices array or an empty array if the mesh has no geometry
  106231. */
  106232. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106233. /**
  106234. * Set specific vertex data
  106235. * @param kind defines the data kind (Position, normal, etc...)
  106236. * @param data defines the vertex data to use
  106237. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106238. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106239. */
  106240. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106241. /**
  106242. * Update a specific associated vertex buffer
  106243. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106244. * - VertexBuffer.PositionKind
  106245. * - VertexBuffer.UVKind
  106246. * - VertexBuffer.UV2Kind
  106247. * - VertexBuffer.UV3Kind
  106248. * - VertexBuffer.UV4Kind
  106249. * - VertexBuffer.UV5Kind
  106250. * - VertexBuffer.UV6Kind
  106251. * - VertexBuffer.ColorKind
  106252. * - VertexBuffer.MatricesIndicesKind
  106253. * - VertexBuffer.MatricesIndicesExtraKind
  106254. * - VertexBuffer.MatricesWeightsKind
  106255. * - VertexBuffer.MatricesWeightsExtraKind
  106256. * @param data defines the data source
  106257. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106258. * @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)
  106259. */
  106260. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106261. /**
  106262. * Creates a new index buffer
  106263. * @param indices defines the indices to store in the index buffer
  106264. * @param totalVertices defines the total number of vertices (could be null)
  106265. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106266. */
  106267. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106268. }
  106269. /**
  106270. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106271. */
  106272. export class VertexData {
  106273. /**
  106274. * Mesh side orientation : usually the external or front surface
  106275. */
  106276. static readonly FRONTSIDE: number;
  106277. /**
  106278. * Mesh side orientation : usually the internal or back surface
  106279. */
  106280. static readonly BACKSIDE: number;
  106281. /**
  106282. * Mesh side orientation : both internal and external or front and back surfaces
  106283. */
  106284. static readonly DOUBLESIDE: number;
  106285. /**
  106286. * Mesh side orientation : by default, `FRONTSIDE`
  106287. */
  106288. static readonly DEFAULTSIDE: number;
  106289. /**
  106290. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106291. */
  106292. positions: Nullable<FloatArray>;
  106293. /**
  106294. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106295. */
  106296. normals: Nullable<FloatArray>;
  106297. /**
  106298. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106299. */
  106300. tangents: Nullable<FloatArray>;
  106301. /**
  106302. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106303. */
  106304. uvs: Nullable<FloatArray>;
  106305. /**
  106306. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106307. */
  106308. uvs2: Nullable<FloatArray>;
  106309. /**
  106310. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106311. */
  106312. uvs3: Nullable<FloatArray>;
  106313. /**
  106314. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106315. */
  106316. uvs4: Nullable<FloatArray>;
  106317. /**
  106318. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106319. */
  106320. uvs5: Nullable<FloatArray>;
  106321. /**
  106322. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106323. */
  106324. uvs6: Nullable<FloatArray>;
  106325. /**
  106326. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106327. */
  106328. colors: Nullable<FloatArray>;
  106329. /**
  106330. * 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).
  106331. */
  106332. matricesIndices: Nullable<FloatArray>;
  106333. /**
  106334. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106335. */
  106336. matricesWeights: Nullable<FloatArray>;
  106337. /**
  106338. * An array extending the number of possible indices
  106339. */
  106340. matricesIndicesExtra: Nullable<FloatArray>;
  106341. /**
  106342. * An array extending the number of possible weights when the number of indices is extended
  106343. */
  106344. matricesWeightsExtra: Nullable<FloatArray>;
  106345. /**
  106346. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106347. */
  106348. indices: Nullable<IndicesArray>;
  106349. /**
  106350. * Uses the passed data array to set the set the values for the specified kind of data
  106351. * @param data a linear array of floating numbers
  106352. * @param kind the type of data that is being set, eg positions, colors etc
  106353. */
  106354. set(data: FloatArray, kind: string): void;
  106355. /**
  106356. * Associates the vertexData to the passed Mesh.
  106357. * Sets it as updatable or not (default `false`)
  106358. * @param mesh the mesh the vertexData is applied to
  106359. * @param updatable when used and having the value true allows new data to update the vertexData
  106360. * @returns the VertexData
  106361. */
  106362. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106363. /**
  106364. * Associates the vertexData to the passed Geometry.
  106365. * Sets it as updatable or not (default `false`)
  106366. * @param geometry the geometry the vertexData is applied to
  106367. * @param updatable when used and having the value true allows new data to update the vertexData
  106368. * @returns VertexData
  106369. */
  106370. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106371. /**
  106372. * Updates the associated mesh
  106373. * @param mesh the mesh to be updated
  106374. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106375. * @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
  106376. * @returns VertexData
  106377. */
  106378. updateMesh(mesh: Mesh): VertexData;
  106379. /**
  106380. * Updates the associated geometry
  106381. * @param geometry the geometry to be updated
  106382. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106383. * @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
  106384. * @returns VertexData.
  106385. */
  106386. updateGeometry(geometry: Geometry): VertexData;
  106387. private _applyTo;
  106388. private _update;
  106389. /**
  106390. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106391. * @param matrix the transforming matrix
  106392. * @returns the VertexData
  106393. */
  106394. transform(matrix: Matrix): VertexData;
  106395. /**
  106396. * Merges the passed VertexData into the current one
  106397. * @param other the VertexData to be merged into the current one
  106398. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106399. * @returns the modified VertexData
  106400. */
  106401. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106402. private _mergeElement;
  106403. private _validate;
  106404. /**
  106405. * Serializes the VertexData
  106406. * @returns a serialized object
  106407. */
  106408. serialize(): any;
  106409. /**
  106410. * Extracts the vertexData from a mesh
  106411. * @param mesh the mesh from which to extract the VertexData
  106412. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106413. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106414. * @returns the object VertexData associated to the passed mesh
  106415. */
  106416. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106417. /**
  106418. * Extracts the vertexData from the geometry
  106419. * @param geometry the geometry from which to extract the VertexData
  106420. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106422. * @returns the object VertexData associated to the passed mesh
  106423. */
  106424. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106425. private static _ExtractFrom;
  106426. /**
  106427. * Creates the VertexData for a Ribbon
  106428. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106429. * * pathArray array of paths, each of which an array of successive Vector3
  106430. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106431. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106432. * * 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
  106433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106434. * * 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)
  106435. * * 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)
  106436. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106437. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106438. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106439. * @returns the VertexData of the ribbon
  106440. */
  106441. static CreateRibbon(options: {
  106442. pathArray: Vector3[][];
  106443. closeArray?: boolean;
  106444. closePath?: boolean;
  106445. offset?: number;
  106446. sideOrientation?: number;
  106447. frontUVs?: Vector4;
  106448. backUVs?: Vector4;
  106449. invertUV?: boolean;
  106450. uvs?: Vector2[];
  106451. colors?: Color4[];
  106452. }): VertexData;
  106453. /**
  106454. * Creates the VertexData for a box
  106455. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106456. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106457. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106458. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106459. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106460. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106461. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106463. * * 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)
  106464. * * 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)
  106465. * @returns the VertexData of the box
  106466. */
  106467. static CreateBox(options: {
  106468. size?: number;
  106469. width?: number;
  106470. height?: number;
  106471. depth?: number;
  106472. faceUV?: Vector4[];
  106473. faceColors?: Color4[];
  106474. sideOrientation?: number;
  106475. frontUVs?: Vector4;
  106476. backUVs?: Vector4;
  106477. }): VertexData;
  106478. /**
  106479. * Creates the VertexData for a tiled box
  106480. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106481. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106482. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106483. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106485. * @returns the VertexData of the box
  106486. */
  106487. static CreateTiledBox(options: {
  106488. pattern?: number;
  106489. width?: number;
  106490. height?: number;
  106491. depth?: number;
  106492. tileSize?: number;
  106493. tileWidth?: number;
  106494. tileHeight?: number;
  106495. alignHorizontal?: number;
  106496. alignVertical?: number;
  106497. faceUV?: Vector4[];
  106498. faceColors?: Color4[];
  106499. sideOrientation?: number;
  106500. }): VertexData;
  106501. /**
  106502. * Creates the VertexData for a tiled plane
  106503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106504. * * pattern a limited pattern arrangement depending on the number
  106505. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106506. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106507. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106509. * * 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)
  106510. * * 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)
  106511. * @returns the VertexData of the tiled plane
  106512. */
  106513. static CreateTiledPlane(options: {
  106514. pattern?: number;
  106515. tileSize?: number;
  106516. tileWidth?: number;
  106517. tileHeight?: number;
  106518. size?: number;
  106519. width?: number;
  106520. height?: number;
  106521. alignHorizontal?: number;
  106522. alignVertical?: number;
  106523. sideOrientation?: number;
  106524. frontUVs?: Vector4;
  106525. backUVs?: Vector4;
  106526. }): VertexData;
  106527. /**
  106528. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106530. * * segments sets the number of horizontal strips optional, default 32
  106531. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106532. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106533. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106534. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106535. * * 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
  106536. * * 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
  106537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106538. * * 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)
  106539. * * 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)
  106540. * @returns the VertexData of the ellipsoid
  106541. */
  106542. static CreateSphere(options: {
  106543. segments?: number;
  106544. diameter?: number;
  106545. diameterX?: number;
  106546. diameterY?: number;
  106547. diameterZ?: number;
  106548. arc?: number;
  106549. slice?: number;
  106550. sideOrientation?: number;
  106551. frontUVs?: Vector4;
  106552. backUVs?: Vector4;
  106553. }): VertexData;
  106554. /**
  106555. * Creates the VertexData for a cylinder, cone or prism
  106556. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106557. * * height sets the height (y direction) of the cylinder, optional, default 2
  106558. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106559. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106560. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106561. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106562. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106563. * * 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
  106564. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106565. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106566. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106567. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106569. * * 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)
  106570. * * 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)
  106571. * @returns the VertexData of the cylinder, cone or prism
  106572. */
  106573. static CreateCylinder(options: {
  106574. height?: number;
  106575. diameterTop?: number;
  106576. diameterBottom?: number;
  106577. diameter?: number;
  106578. tessellation?: number;
  106579. subdivisions?: number;
  106580. arc?: number;
  106581. faceColors?: Color4[];
  106582. faceUV?: Vector4[];
  106583. hasRings?: boolean;
  106584. enclose?: boolean;
  106585. sideOrientation?: number;
  106586. frontUVs?: Vector4;
  106587. backUVs?: Vector4;
  106588. }): VertexData;
  106589. /**
  106590. * Creates the VertexData for a torus
  106591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106592. * * diameter the diameter of the torus, optional default 1
  106593. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106594. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106596. * * 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)
  106597. * * 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)
  106598. * @returns the VertexData of the torus
  106599. */
  106600. static CreateTorus(options: {
  106601. diameter?: number;
  106602. thickness?: number;
  106603. tessellation?: number;
  106604. sideOrientation?: number;
  106605. frontUVs?: Vector4;
  106606. backUVs?: Vector4;
  106607. }): VertexData;
  106608. /**
  106609. * Creates the VertexData of the LineSystem
  106610. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106611. * - lines an array of lines, each line being an array of successive Vector3
  106612. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106613. * @returns the VertexData of the LineSystem
  106614. */
  106615. static CreateLineSystem(options: {
  106616. lines: Vector3[][];
  106617. colors?: Nullable<Color4[][]>;
  106618. }): VertexData;
  106619. /**
  106620. * Create the VertexData for a DashedLines
  106621. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106622. * - points an array successive Vector3
  106623. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106624. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106625. * - dashNb the intended total number of dashes, optional, default 200
  106626. * @returns the VertexData for the DashedLines
  106627. */
  106628. static CreateDashedLines(options: {
  106629. points: Vector3[];
  106630. dashSize?: number;
  106631. gapSize?: number;
  106632. dashNb?: number;
  106633. }): VertexData;
  106634. /**
  106635. * Creates the VertexData for a Ground
  106636. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106637. * - width the width (x direction) of the ground, optional, default 1
  106638. * - height the height (z direction) of the ground, optional, default 1
  106639. * - subdivisions the number of subdivisions per side, optional, default 1
  106640. * @returns the VertexData of the Ground
  106641. */
  106642. static CreateGround(options: {
  106643. width?: number;
  106644. height?: number;
  106645. subdivisions?: number;
  106646. subdivisionsX?: number;
  106647. subdivisionsY?: number;
  106648. }): VertexData;
  106649. /**
  106650. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106651. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106652. * * xmin the ground minimum X coordinate, optional, default -1
  106653. * * zmin the ground minimum Z coordinate, optional, default -1
  106654. * * xmax the ground maximum X coordinate, optional, default 1
  106655. * * zmax the ground maximum Z coordinate, optional, default 1
  106656. * * 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}
  106657. * * 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}
  106658. * @returns the VertexData of the TiledGround
  106659. */
  106660. static CreateTiledGround(options: {
  106661. xmin: number;
  106662. zmin: number;
  106663. xmax: number;
  106664. zmax: number;
  106665. subdivisions?: {
  106666. w: number;
  106667. h: number;
  106668. };
  106669. precision?: {
  106670. w: number;
  106671. h: number;
  106672. };
  106673. }): VertexData;
  106674. /**
  106675. * Creates the VertexData of the Ground designed from a heightmap
  106676. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106677. * * width the width (x direction) of the ground
  106678. * * height the height (z direction) of the ground
  106679. * * subdivisions the number of subdivisions per side
  106680. * * minHeight the minimum altitude on the ground, optional, default 0
  106681. * * maxHeight the maximum altitude on the ground, optional default 1
  106682. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106683. * * buffer the array holding the image color data
  106684. * * bufferWidth the width of image
  106685. * * bufferHeight the height of image
  106686. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106687. * @returns the VertexData of the Ground designed from a heightmap
  106688. */
  106689. static CreateGroundFromHeightMap(options: {
  106690. width: number;
  106691. height: number;
  106692. subdivisions: number;
  106693. minHeight: number;
  106694. maxHeight: number;
  106695. colorFilter: Color3;
  106696. buffer: Uint8Array;
  106697. bufferWidth: number;
  106698. bufferHeight: number;
  106699. alphaFilter: number;
  106700. }): VertexData;
  106701. /**
  106702. * Creates the VertexData for a Plane
  106703. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106704. * * size sets the width and height of the plane to the value of size, optional default 1
  106705. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106706. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106708. * * 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)
  106709. * * 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)
  106710. * @returns the VertexData of the box
  106711. */
  106712. static CreatePlane(options: {
  106713. size?: number;
  106714. width?: number;
  106715. height?: number;
  106716. sideOrientation?: number;
  106717. frontUVs?: Vector4;
  106718. backUVs?: Vector4;
  106719. }): VertexData;
  106720. /**
  106721. * Creates the VertexData of the Disc or regular Polygon
  106722. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106723. * * radius the radius of the disc, optional default 0.5
  106724. * * tessellation the number of polygon sides, optional, default 64
  106725. * * 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
  106726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106727. * * 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)
  106728. * * 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)
  106729. * @returns the VertexData of the box
  106730. */
  106731. static CreateDisc(options: {
  106732. radius?: number;
  106733. tessellation?: number;
  106734. arc?: number;
  106735. sideOrientation?: number;
  106736. frontUVs?: Vector4;
  106737. backUVs?: Vector4;
  106738. }): VertexData;
  106739. /**
  106740. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106741. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106742. * @param polygon a mesh built from polygonTriangulation.build()
  106743. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106744. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106745. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106746. * @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)
  106747. * @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)
  106748. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106749. * @returns the VertexData of the Polygon
  106750. */
  106751. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106752. /**
  106753. * Creates the VertexData of the IcoSphere
  106754. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106755. * * radius the radius of the IcoSphere, optional default 1
  106756. * * radiusX allows stretching in the x direction, optional, default radius
  106757. * * radiusY allows stretching in the y direction, optional, default radius
  106758. * * radiusZ allows stretching in the z direction, optional, default radius
  106759. * * flat when true creates a flat shaded mesh, optional, default true
  106760. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106762. * * 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)
  106763. * * 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)
  106764. * @returns the VertexData of the IcoSphere
  106765. */
  106766. static CreateIcoSphere(options: {
  106767. radius?: number;
  106768. radiusX?: number;
  106769. radiusY?: number;
  106770. radiusZ?: number;
  106771. flat?: boolean;
  106772. subdivisions?: number;
  106773. sideOrientation?: number;
  106774. frontUVs?: Vector4;
  106775. backUVs?: Vector4;
  106776. }): VertexData;
  106777. /**
  106778. * Creates the VertexData for a Polyhedron
  106779. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106780. * * type provided types are:
  106781. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106782. * * 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)
  106783. * * size the size of the IcoSphere, optional default 1
  106784. * * sizeX allows stretching in the x direction, optional, default size
  106785. * * sizeY allows stretching in the y direction, optional, default size
  106786. * * sizeZ allows stretching in the z direction, optional, default size
  106787. * * 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
  106788. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106789. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106790. * * flat when true creates a flat shaded mesh, optional, default true
  106791. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106793. * * 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)
  106794. * * 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)
  106795. * @returns the VertexData of the Polyhedron
  106796. */
  106797. static CreatePolyhedron(options: {
  106798. type?: number;
  106799. size?: number;
  106800. sizeX?: number;
  106801. sizeY?: number;
  106802. sizeZ?: number;
  106803. custom?: any;
  106804. faceUV?: Vector4[];
  106805. faceColors?: Color4[];
  106806. flat?: boolean;
  106807. sideOrientation?: number;
  106808. frontUVs?: Vector4;
  106809. backUVs?: Vector4;
  106810. }): VertexData;
  106811. /**
  106812. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106813. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106814. * @returns the VertexData of the Capsule
  106815. */
  106816. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106817. /**
  106818. * Creates the VertexData for a TorusKnot
  106819. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106820. * * radius the radius of the torus knot, optional, default 2
  106821. * * tube the thickness of the tube, optional, default 0.5
  106822. * * radialSegments the number of sides on each tube segments, optional, default 32
  106823. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106824. * * p the number of windings around the z axis, optional, default 2
  106825. * * q the number of windings around the x axis, optional, default 3
  106826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106827. * * 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)
  106828. * * 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)
  106829. * @returns the VertexData of the Torus Knot
  106830. */
  106831. static CreateTorusKnot(options: {
  106832. radius?: number;
  106833. tube?: number;
  106834. radialSegments?: number;
  106835. tubularSegments?: number;
  106836. p?: number;
  106837. q?: number;
  106838. sideOrientation?: number;
  106839. frontUVs?: Vector4;
  106840. backUVs?: Vector4;
  106841. }): VertexData;
  106842. /**
  106843. * Compute normals for given positions and indices
  106844. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106845. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106846. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106847. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106848. * * facetNormals : optional array of facet normals (vector3)
  106849. * * facetPositions : optional array of facet positions (vector3)
  106850. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106851. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106852. * * bInfo : optional bounding info, required for facetPartitioning computation
  106853. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106854. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106855. * * useRightHandedSystem: optional boolean to for right handed system computation
  106856. * * depthSort : optional boolean to enable the facet depth sort computation
  106857. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106858. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106859. */
  106860. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106861. facetNormals?: any;
  106862. facetPositions?: any;
  106863. facetPartitioning?: any;
  106864. ratio?: number;
  106865. bInfo?: any;
  106866. bbSize?: Vector3;
  106867. subDiv?: any;
  106868. useRightHandedSystem?: boolean;
  106869. depthSort?: boolean;
  106870. distanceTo?: Vector3;
  106871. depthSortedFacets?: any;
  106872. }): void;
  106873. /** @hidden */
  106874. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106875. /**
  106876. * Applies VertexData created from the imported parameters to the geometry
  106877. * @param parsedVertexData the parsed data from an imported file
  106878. * @param geometry the geometry to apply the VertexData to
  106879. */
  106880. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106881. }
  106882. }
  106883. declare module BABYLON {
  106884. /**
  106885. * Defines a target to use with MorphTargetManager
  106886. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106887. */
  106888. export class MorphTarget implements IAnimatable {
  106889. /** defines the name of the target */
  106890. name: string;
  106891. /**
  106892. * Gets or sets the list of animations
  106893. */
  106894. animations: Animation[];
  106895. private _scene;
  106896. private _positions;
  106897. private _normals;
  106898. private _tangents;
  106899. private _uvs;
  106900. private _influence;
  106901. private _uniqueId;
  106902. /**
  106903. * Observable raised when the influence changes
  106904. */
  106905. onInfluenceChanged: Observable<boolean>;
  106906. /** @hidden */
  106907. _onDataLayoutChanged: Observable<void>;
  106908. /**
  106909. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106910. */
  106911. get influence(): number;
  106912. set influence(influence: number);
  106913. /**
  106914. * Gets or sets the id of the morph Target
  106915. */
  106916. id: string;
  106917. private _animationPropertiesOverride;
  106918. /**
  106919. * Gets or sets the animation properties override
  106920. */
  106921. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106922. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106923. /**
  106924. * Creates a new MorphTarget
  106925. * @param name defines the name of the target
  106926. * @param influence defines the influence to use
  106927. * @param scene defines the scene the morphtarget belongs to
  106928. */
  106929. constructor(
  106930. /** defines the name of the target */
  106931. name: string, influence?: number, scene?: Nullable<Scene>);
  106932. /**
  106933. * Gets the unique ID of this manager
  106934. */
  106935. get uniqueId(): number;
  106936. /**
  106937. * Gets a boolean defining if the target contains position data
  106938. */
  106939. get hasPositions(): boolean;
  106940. /**
  106941. * Gets a boolean defining if the target contains normal data
  106942. */
  106943. get hasNormals(): boolean;
  106944. /**
  106945. * Gets a boolean defining if the target contains tangent data
  106946. */
  106947. get hasTangents(): boolean;
  106948. /**
  106949. * Gets a boolean defining if the target contains texture coordinates data
  106950. */
  106951. get hasUVs(): boolean;
  106952. /**
  106953. * Affects position data to this target
  106954. * @param data defines the position data to use
  106955. */
  106956. setPositions(data: Nullable<FloatArray>): void;
  106957. /**
  106958. * Gets the position data stored in this target
  106959. * @returns a FloatArray containing the position data (or null if not present)
  106960. */
  106961. getPositions(): Nullable<FloatArray>;
  106962. /**
  106963. * Affects normal data to this target
  106964. * @param data defines the normal data to use
  106965. */
  106966. setNormals(data: Nullable<FloatArray>): void;
  106967. /**
  106968. * Gets the normal data stored in this target
  106969. * @returns a FloatArray containing the normal data (or null if not present)
  106970. */
  106971. getNormals(): Nullable<FloatArray>;
  106972. /**
  106973. * Affects tangent data to this target
  106974. * @param data defines the tangent data to use
  106975. */
  106976. setTangents(data: Nullable<FloatArray>): void;
  106977. /**
  106978. * Gets the tangent data stored in this target
  106979. * @returns a FloatArray containing the tangent data (or null if not present)
  106980. */
  106981. getTangents(): Nullable<FloatArray>;
  106982. /**
  106983. * Affects texture coordinates data to this target
  106984. * @param data defines the texture coordinates data to use
  106985. */
  106986. setUVs(data: Nullable<FloatArray>): void;
  106987. /**
  106988. * Gets the texture coordinates data stored in this target
  106989. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106990. */
  106991. getUVs(): Nullable<FloatArray>;
  106992. /**
  106993. * Clone the current target
  106994. * @returns a new MorphTarget
  106995. */
  106996. clone(): MorphTarget;
  106997. /**
  106998. * Serializes the current target into a Serialization object
  106999. * @returns the serialized object
  107000. */
  107001. serialize(): any;
  107002. /**
  107003. * Returns the string "MorphTarget"
  107004. * @returns "MorphTarget"
  107005. */
  107006. getClassName(): string;
  107007. /**
  107008. * Creates a new target from serialized data
  107009. * @param serializationObject defines the serialized data to use
  107010. * @returns a new MorphTarget
  107011. */
  107012. static Parse(serializationObject: any): MorphTarget;
  107013. /**
  107014. * Creates a MorphTarget from mesh data
  107015. * @param mesh defines the source mesh
  107016. * @param name defines the name to use for the new target
  107017. * @param influence defines the influence to attach to the target
  107018. * @returns a new MorphTarget
  107019. */
  107020. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107021. }
  107022. }
  107023. declare module BABYLON {
  107024. /**
  107025. * This class is used to deform meshes using morphing between different targets
  107026. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107027. */
  107028. export class MorphTargetManager {
  107029. private _targets;
  107030. private _targetInfluenceChangedObservers;
  107031. private _targetDataLayoutChangedObservers;
  107032. private _activeTargets;
  107033. private _scene;
  107034. private _influences;
  107035. private _supportsNormals;
  107036. private _supportsTangents;
  107037. private _supportsUVs;
  107038. private _vertexCount;
  107039. private _uniqueId;
  107040. private _tempInfluences;
  107041. /**
  107042. * Gets or sets a boolean indicating if normals must be morphed
  107043. */
  107044. enableNormalMorphing: boolean;
  107045. /**
  107046. * Gets or sets a boolean indicating if tangents must be morphed
  107047. */
  107048. enableTangentMorphing: boolean;
  107049. /**
  107050. * Gets or sets a boolean indicating if UV must be morphed
  107051. */
  107052. enableUVMorphing: boolean;
  107053. /**
  107054. * Creates a new MorphTargetManager
  107055. * @param scene defines the current scene
  107056. */
  107057. constructor(scene?: Nullable<Scene>);
  107058. /**
  107059. * Gets the unique ID of this manager
  107060. */
  107061. get uniqueId(): number;
  107062. /**
  107063. * Gets the number of vertices handled by this manager
  107064. */
  107065. get vertexCount(): number;
  107066. /**
  107067. * Gets a boolean indicating if this manager supports morphing of normals
  107068. */
  107069. get supportsNormals(): boolean;
  107070. /**
  107071. * Gets a boolean indicating if this manager supports morphing of tangents
  107072. */
  107073. get supportsTangents(): boolean;
  107074. /**
  107075. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107076. */
  107077. get supportsUVs(): boolean;
  107078. /**
  107079. * Gets the number of targets stored in this manager
  107080. */
  107081. get numTargets(): number;
  107082. /**
  107083. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107084. */
  107085. get numInfluencers(): number;
  107086. /**
  107087. * Gets the list of influences (one per target)
  107088. */
  107089. get influences(): Float32Array;
  107090. /**
  107091. * Gets the active target at specified index. An active target is a target with an influence > 0
  107092. * @param index defines the index to check
  107093. * @returns the requested target
  107094. */
  107095. getActiveTarget(index: number): MorphTarget;
  107096. /**
  107097. * Gets the target at specified index
  107098. * @param index defines the index to check
  107099. * @returns the requested target
  107100. */
  107101. getTarget(index: number): MorphTarget;
  107102. /**
  107103. * Add a new target to this manager
  107104. * @param target defines the target to add
  107105. */
  107106. addTarget(target: MorphTarget): void;
  107107. /**
  107108. * Removes a target from the manager
  107109. * @param target defines the target to remove
  107110. */
  107111. removeTarget(target: MorphTarget): void;
  107112. /**
  107113. * Clone the current manager
  107114. * @returns a new MorphTargetManager
  107115. */
  107116. clone(): MorphTargetManager;
  107117. /**
  107118. * Serializes the current manager into a Serialization object
  107119. * @returns the serialized object
  107120. */
  107121. serialize(): any;
  107122. private _syncActiveTargets;
  107123. /**
  107124. * Syncrhonize the targets with all the meshes using this morph target manager
  107125. */
  107126. synchronize(): void;
  107127. /**
  107128. * Creates a new MorphTargetManager from serialized data
  107129. * @param serializationObject defines the serialized data
  107130. * @param scene defines the hosting scene
  107131. * @returns the new MorphTargetManager
  107132. */
  107133. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107134. }
  107135. }
  107136. declare module BABYLON {
  107137. /**
  107138. * Class used to represent a specific level of detail of a mesh
  107139. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107140. */
  107141. export class MeshLODLevel {
  107142. /** Defines the distance where this level should start being displayed */
  107143. distance: number;
  107144. /** Defines the mesh to use to render this level */
  107145. mesh: Nullable<Mesh>;
  107146. /**
  107147. * Creates a new LOD level
  107148. * @param distance defines the distance where this level should star being displayed
  107149. * @param mesh defines the mesh to use to render this level
  107150. */
  107151. constructor(
  107152. /** Defines the distance where this level should start being displayed */
  107153. distance: number,
  107154. /** Defines the mesh to use to render this level */
  107155. mesh: Nullable<Mesh>);
  107156. }
  107157. }
  107158. declare module BABYLON {
  107159. /**
  107160. * Helper class used to generate a canvas to manipulate images
  107161. */
  107162. export class CanvasGenerator {
  107163. /**
  107164. * Create a new canvas (or offscreen canvas depending on the context)
  107165. * @param width defines the expected width
  107166. * @param height defines the expected height
  107167. * @return a new canvas or offscreen canvas
  107168. */
  107169. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107170. }
  107171. }
  107172. declare module BABYLON {
  107173. /**
  107174. * Mesh representing the gorund
  107175. */
  107176. export class GroundMesh extends Mesh {
  107177. /** If octree should be generated */
  107178. generateOctree: boolean;
  107179. private _heightQuads;
  107180. /** @hidden */
  107181. _subdivisionsX: number;
  107182. /** @hidden */
  107183. _subdivisionsY: number;
  107184. /** @hidden */
  107185. _width: number;
  107186. /** @hidden */
  107187. _height: number;
  107188. /** @hidden */
  107189. _minX: number;
  107190. /** @hidden */
  107191. _maxX: number;
  107192. /** @hidden */
  107193. _minZ: number;
  107194. /** @hidden */
  107195. _maxZ: number;
  107196. constructor(name: string, scene: Scene);
  107197. /**
  107198. * "GroundMesh"
  107199. * @returns "GroundMesh"
  107200. */
  107201. getClassName(): string;
  107202. /**
  107203. * The minimum of x and y subdivisions
  107204. */
  107205. get subdivisions(): number;
  107206. /**
  107207. * X subdivisions
  107208. */
  107209. get subdivisionsX(): number;
  107210. /**
  107211. * Y subdivisions
  107212. */
  107213. get subdivisionsY(): number;
  107214. /**
  107215. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107216. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107217. * @param chunksCount the number of subdivisions for x and y
  107218. * @param octreeBlocksSize (Default: 32)
  107219. */
  107220. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107221. /**
  107222. * Returns a height (y) value in the Worl system :
  107223. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107224. * @param x x coordinate
  107225. * @param z z coordinate
  107226. * @returns the ground y position if (x, z) are outside the ground surface.
  107227. */
  107228. getHeightAtCoordinates(x: number, z: number): number;
  107229. /**
  107230. * Returns a normalized vector (Vector3) orthogonal to the ground
  107231. * at the ground coordinates (x, z) expressed in the World system.
  107232. * @param x x coordinate
  107233. * @param z z coordinate
  107234. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107235. */
  107236. getNormalAtCoordinates(x: number, z: number): Vector3;
  107237. /**
  107238. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107239. * at the ground coordinates (x, z) expressed in the World system.
  107240. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107241. * @param x x coordinate
  107242. * @param z z coordinate
  107243. * @param ref vector to store the result
  107244. * @returns the GroundMesh.
  107245. */
  107246. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107247. /**
  107248. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107249. * if the ground has been updated.
  107250. * This can be used in the render loop.
  107251. * @returns the GroundMesh.
  107252. */
  107253. updateCoordinateHeights(): GroundMesh;
  107254. private _getFacetAt;
  107255. private _initHeightQuads;
  107256. private _computeHeightQuads;
  107257. /**
  107258. * Serializes this ground mesh
  107259. * @param serializationObject object to write serialization to
  107260. */
  107261. serialize(serializationObject: any): void;
  107262. /**
  107263. * Parses a serialized ground mesh
  107264. * @param parsedMesh the serialized mesh
  107265. * @param scene the scene to create the ground mesh in
  107266. * @returns the created ground mesh
  107267. */
  107268. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107269. }
  107270. }
  107271. declare module BABYLON {
  107272. /**
  107273. * Interface for Physics-Joint data
  107274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107275. */
  107276. export interface PhysicsJointData {
  107277. /**
  107278. * The main pivot of the joint
  107279. */
  107280. mainPivot?: Vector3;
  107281. /**
  107282. * The connected pivot of the joint
  107283. */
  107284. connectedPivot?: Vector3;
  107285. /**
  107286. * The main axis of the joint
  107287. */
  107288. mainAxis?: Vector3;
  107289. /**
  107290. * The connected axis of the joint
  107291. */
  107292. connectedAxis?: Vector3;
  107293. /**
  107294. * The collision of the joint
  107295. */
  107296. collision?: boolean;
  107297. /**
  107298. * Native Oimo/Cannon/Energy data
  107299. */
  107300. nativeParams?: any;
  107301. }
  107302. /**
  107303. * This is a holder class for the physics joint created by the physics plugin
  107304. * It holds a set of functions to control the underlying joint
  107305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107306. */
  107307. export class PhysicsJoint {
  107308. /**
  107309. * The type of the physics joint
  107310. */
  107311. type: number;
  107312. /**
  107313. * The data for the physics joint
  107314. */
  107315. jointData: PhysicsJointData;
  107316. private _physicsJoint;
  107317. protected _physicsPlugin: IPhysicsEnginePlugin;
  107318. /**
  107319. * Initializes the physics joint
  107320. * @param type The type of the physics joint
  107321. * @param jointData The data for the physics joint
  107322. */
  107323. constructor(
  107324. /**
  107325. * The type of the physics joint
  107326. */
  107327. type: number,
  107328. /**
  107329. * The data for the physics joint
  107330. */
  107331. jointData: PhysicsJointData);
  107332. /**
  107333. * Gets the physics joint
  107334. */
  107335. get physicsJoint(): any;
  107336. /**
  107337. * Sets the physics joint
  107338. */
  107339. set physicsJoint(newJoint: any);
  107340. /**
  107341. * Sets the physics plugin
  107342. */
  107343. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107344. /**
  107345. * Execute a function that is physics-plugin specific.
  107346. * @param {Function} func the function that will be executed.
  107347. * It accepts two parameters: the physics world and the physics joint
  107348. */
  107349. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107350. /**
  107351. * Distance-Joint type
  107352. */
  107353. static DistanceJoint: number;
  107354. /**
  107355. * Hinge-Joint type
  107356. */
  107357. static HingeJoint: number;
  107358. /**
  107359. * Ball-and-Socket joint type
  107360. */
  107361. static BallAndSocketJoint: number;
  107362. /**
  107363. * Wheel-Joint type
  107364. */
  107365. static WheelJoint: number;
  107366. /**
  107367. * Slider-Joint type
  107368. */
  107369. static SliderJoint: number;
  107370. /**
  107371. * Prismatic-Joint type
  107372. */
  107373. static PrismaticJoint: number;
  107374. /**
  107375. * Universal-Joint type
  107376. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107377. */
  107378. static UniversalJoint: number;
  107379. /**
  107380. * Hinge-Joint 2 type
  107381. */
  107382. static Hinge2Joint: number;
  107383. /**
  107384. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107385. */
  107386. static PointToPointJoint: number;
  107387. /**
  107388. * Spring-Joint type
  107389. */
  107390. static SpringJoint: number;
  107391. /**
  107392. * Lock-Joint type
  107393. */
  107394. static LockJoint: number;
  107395. }
  107396. /**
  107397. * A class representing a physics distance joint
  107398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107399. */
  107400. export class DistanceJoint extends PhysicsJoint {
  107401. /**
  107402. *
  107403. * @param jointData The data for the Distance-Joint
  107404. */
  107405. constructor(jointData: DistanceJointData);
  107406. /**
  107407. * Update the predefined distance.
  107408. * @param maxDistance The maximum preferred distance
  107409. * @param minDistance The minimum preferred distance
  107410. */
  107411. updateDistance(maxDistance: number, minDistance?: number): void;
  107412. }
  107413. /**
  107414. * Represents a Motor-Enabled Joint
  107415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107416. */
  107417. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107418. /**
  107419. * Initializes the Motor-Enabled Joint
  107420. * @param type The type of the joint
  107421. * @param jointData The physica joint data for the joint
  107422. */
  107423. constructor(type: number, jointData: PhysicsJointData);
  107424. /**
  107425. * Set the motor values.
  107426. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107427. * @param force the force to apply
  107428. * @param maxForce max force for this motor.
  107429. */
  107430. setMotor(force?: number, maxForce?: number): void;
  107431. /**
  107432. * Set the motor's limits.
  107433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107434. * @param upperLimit The upper limit of the motor
  107435. * @param lowerLimit The lower limit of the motor
  107436. */
  107437. setLimit(upperLimit: number, lowerLimit?: number): void;
  107438. }
  107439. /**
  107440. * This class represents a single physics Hinge-Joint
  107441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107442. */
  107443. export class HingeJoint extends MotorEnabledJoint {
  107444. /**
  107445. * Initializes the Hinge-Joint
  107446. * @param jointData The joint data for the Hinge-Joint
  107447. */
  107448. constructor(jointData: PhysicsJointData);
  107449. /**
  107450. * Set the motor values.
  107451. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107452. * @param {number} force the force to apply
  107453. * @param {number} maxForce max force for this motor.
  107454. */
  107455. setMotor(force?: number, maxForce?: number): void;
  107456. /**
  107457. * Set the motor's limits.
  107458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107459. * @param upperLimit The upper limit of the motor
  107460. * @param lowerLimit The lower limit of the motor
  107461. */
  107462. setLimit(upperLimit: number, lowerLimit?: number): void;
  107463. }
  107464. /**
  107465. * This class represents a dual hinge physics joint (same as wheel joint)
  107466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107467. */
  107468. export class Hinge2Joint extends MotorEnabledJoint {
  107469. /**
  107470. * Initializes the Hinge2-Joint
  107471. * @param jointData The joint data for the Hinge2-Joint
  107472. */
  107473. constructor(jointData: PhysicsJointData);
  107474. /**
  107475. * Set the motor values.
  107476. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107477. * @param {number} targetSpeed the speed the motor is to reach
  107478. * @param {number} maxForce max force for this motor.
  107479. * @param {motorIndex} the motor's index, 0 or 1.
  107480. */
  107481. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107482. /**
  107483. * Set the motor limits.
  107484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107485. * @param {number} upperLimit the upper limit
  107486. * @param {number} lowerLimit lower limit
  107487. * @param {motorIndex} the motor's index, 0 or 1.
  107488. */
  107489. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107490. }
  107491. /**
  107492. * Interface for a motor enabled joint
  107493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107494. */
  107495. export interface IMotorEnabledJoint {
  107496. /**
  107497. * Physics joint
  107498. */
  107499. physicsJoint: any;
  107500. /**
  107501. * Sets the motor of the motor-enabled joint
  107502. * @param force The force of the motor
  107503. * @param maxForce The maximum force of the motor
  107504. * @param motorIndex The index of the motor
  107505. */
  107506. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107507. /**
  107508. * Sets the limit of the motor
  107509. * @param upperLimit The upper limit of the motor
  107510. * @param lowerLimit The lower limit of the motor
  107511. * @param motorIndex The index of the motor
  107512. */
  107513. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107514. }
  107515. /**
  107516. * Joint data for a Distance-Joint
  107517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107518. */
  107519. export interface DistanceJointData extends PhysicsJointData {
  107520. /**
  107521. * Max distance the 2 joint objects can be apart
  107522. */
  107523. maxDistance: number;
  107524. }
  107525. /**
  107526. * Joint data from a spring joint
  107527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107528. */
  107529. export interface SpringJointData extends PhysicsJointData {
  107530. /**
  107531. * Length of the spring
  107532. */
  107533. length: number;
  107534. /**
  107535. * Stiffness of the spring
  107536. */
  107537. stiffness: number;
  107538. /**
  107539. * Damping of the spring
  107540. */
  107541. damping: number;
  107542. /** this callback will be called when applying the force to the impostors. */
  107543. forceApplicationCallback: () => void;
  107544. }
  107545. }
  107546. declare module BABYLON {
  107547. /**
  107548. * Holds the data for the raycast result
  107549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107550. */
  107551. export class PhysicsRaycastResult {
  107552. private _hasHit;
  107553. private _hitDistance;
  107554. private _hitNormalWorld;
  107555. private _hitPointWorld;
  107556. private _rayFromWorld;
  107557. private _rayToWorld;
  107558. /**
  107559. * Gets if there was a hit
  107560. */
  107561. get hasHit(): boolean;
  107562. /**
  107563. * Gets the distance from the hit
  107564. */
  107565. get hitDistance(): number;
  107566. /**
  107567. * Gets the hit normal/direction in the world
  107568. */
  107569. get hitNormalWorld(): Vector3;
  107570. /**
  107571. * Gets the hit point in the world
  107572. */
  107573. get hitPointWorld(): Vector3;
  107574. /**
  107575. * Gets the ray "start point" of the ray in the world
  107576. */
  107577. get rayFromWorld(): Vector3;
  107578. /**
  107579. * Gets the ray "end point" of the ray in the world
  107580. */
  107581. get rayToWorld(): Vector3;
  107582. /**
  107583. * Sets the hit data (normal & point in world space)
  107584. * @param hitNormalWorld defines the normal in world space
  107585. * @param hitPointWorld defines the point in world space
  107586. */
  107587. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107588. /**
  107589. * Sets the distance from the start point to the hit point
  107590. * @param distance
  107591. */
  107592. setHitDistance(distance: number): void;
  107593. /**
  107594. * Calculates the distance manually
  107595. */
  107596. calculateHitDistance(): void;
  107597. /**
  107598. * Resets all the values to default
  107599. * @param from The from point on world space
  107600. * @param to The to point on world space
  107601. */
  107602. reset(from?: Vector3, to?: Vector3): void;
  107603. }
  107604. /**
  107605. * Interface for the size containing width and height
  107606. */
  107607. interface IXYZ {
  107608. /**
  107609. * X
  107610. */
  107611. x: number;
  107612. /**
  107613. * Y
  107614. */
  107615. y: number;
  107616. /**
  107617. * Z
  107618. */
  107619. z: number;
  107620. }
  107621. }
  107622. declare module BABYLON {
  107623. /**
  107624. * Interface used to describe a physics joint
  107625. */
  107626. export interface PhysicsImpostorJoint {
  107627. /** Defines the main impostor to which the joint is linked */
  107628. mainImpostor: PhysicsImpostor;
  107629. /** Defines the impostor that is connected to the main impostor using this joint */
  107630. connectedImpostor: PhysicsImpostor;
  107631. /** Defines the joint itself */
  107632. joint: PhysicsJoint;
  107633. }
  107634. /** @hidden */
  107635. export interface IPhysicsEnginePlugin {
  107636. world: any;
  107637. name: string;
  107638. setGravity(gravity: Vector3): void;
  107639. setTimeStep(timeStep: number): void;
  107640. getTimeStep(): number;
  107641. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107645. removePhysicsBody(impostor: PhysicsImpostor): void;
  107646. generateJoint(joint: PhysicsImpostorJoint): void;
  107647. removeJoint(joint: PhysicsImpostorJoint): void;
  107648. isSupported(): boolean;
  107649. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107650. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107653. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107655. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107656. getBodyMass(impostor: PhysicsImpostor): number;
  107657. getBodyFriction(impostor: PhysicsImpostor): number;
  107658. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107659. getBodyRestitution(impostor: PhysicsImpostor): number;
  107660. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107661. getBodyPressure?(impostor: PhysicsImpostor): number;
  107662. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107663. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107664. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107665. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107666. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107667. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107668. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107669. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107670. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107671. sleepBody(impostor: PhysicsImpostor): void;
  107672. wakeUpBody(impostor: PhysicsImpostor): void;
  107673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107675. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107677. getRadius(impostor: PhysicsImpostor): number;
  107678. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107679. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107680. dispose(): void;
  107681. }
  107682. /**
  107683. * Interface used to define a physics engine
  107684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107685. */
  107686. export interface IPhysicsEngine {
  107687. /**
  107688. * Gets the gravity vector used by the simulation
  107689. */
  107690. gravity: Vector3;
  107691. /**
  107692. * Sets the gravity vector used by the simulation
  107693. * @param gravity defines the gravity vector to use
  107694. */
  107695. setGravity(gravity: Vector3): void;
  107696. /**
  107697. * Set the time step of the physics engine.
  107698. * Default is 1/60.
  107699. * To slow it down, enter 1/600 for example.
  107700. * To speed it up, 1/30
  107701. * @param newTimeStep the new timestep to apply to this world.
  107702. */
  107703. setTimeStep(newTimeStep: number): void;
  107704. /**
  107705. * Get the time step of the physics engine.
  107706. * @returns the current time step
  107707. */
  107708. getTimeStep(): number;
  107709. /**
  107710. * Set the sub time step of the physics engine.
  107711. * Default is 0 meaning there is no sub steps
  107712. * To increase physics resolution precision, set a small value (like 1 ms)
  107713. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107714. */
  107715. setSubTimeStep(subTimeStep: number): void;
  107716. /**
  107717. * Get the sub time step of the physics engine.
  107718. * @returns the current sub time step
  107719. */
  107720. getSubTimeStep(): number;
  107721. /**
  107722. * Release all resources
  107723. */
  107724. dispose(): void;
  107725. /**
  107726. * Gets the name of the current physics plugin
  107727. * @returns the name of the plugin
  107728. */
  107729. getPhysicsPluginName(): string;
  107730. /**
  107731. * Adding a new impostor for the impostor tracking.
  107732. * This will be done by the impostor itself.
  107733. * @param impostor the impostor to add
  107734. */
  107735. addImpostor(impostor: PhysicsImpostor): void;
  107736. /**
  107737. * Remove an impostor from the engine.
  107738. * This impostor and its mesh will not longer be updated by the physics engine.
  107739. * @param impostor the impostor to remove
  107740. */
  107741. removeImpostor(impostor: PhysicsImpostor): void;
  107742. /**
  107743. * Add a joint to the physics engine
  107744. * @param mainImpostor defines the main impostor to which the joint is added.
  107745. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107746. * @param joint defines the joint that will connect both impostors.
  107747. */
  107748. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107749. /**
  107750. * Removes a joint from the simulation
  107751. * @param mainImpostor defines the impostor used with the joint
  107752. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107753. * @param joint defines the joint to remove
  107754. */
  107755. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107756. /**
  107757. * Gets the current plugin used to run the simulation
  107758. * @returns current plugin
  107759. */
  107760. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107761. /**
  107762. * Gets the list of physic impostors
  107763. * @returns an array of PhysicsImpostor
  107764. */
  107765. getImpostors(): Array<PhysicsImpostor>;
  107766. /**
  107767. * Gets the impostor for a physics enabled object
  107768. * @param object defines the object impersonated by the impostor
  107769. * @returns the PhysicsImpostor or null if not found
  107770. */
  107771. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107772. /**
  107773. * Gets the impostor for a physics body object
  107774. * @param body defines physics body used by the impostor
  107775. * @returns the PhysicsImpostor or null if not found
  107776. */
  107777. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107778. /**
  107779. * Does a raycast in the physics world
  107780. * @param from when should the ray start?
  107781. * @param to when should the ray end?
  107782. * @returns PhysicsRaycastResult
  107783. */
  107784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107785. /**
  107786. * Called by the scene. No need to call it.
  107787. * @param delta defines the timespam between frames
  107788. */
  107789. _step(delta: number): void;
  107790. }
  107791. }
  107792. declare module BABYLON {
  107793. /**
  107794. * The interface for the physics imposter parameters
  107795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107796. */
  107797. export interface PhysicsImpostorParameters {
  107798. /**
  107799. * The mass of the physics imposter
  107800. */
  107801. mass: number;
  107802. /**
  107803. * The friction of the physics imposter
  107804. */
  107805. friction?: number;
  107806. /**
  107807. * The coefficient of restitution of the physics imposter
  107808. */
  107809. restitution?: number;
  107810. /**
  107811. * The native options of the physics imposter
  107812. */
  107813. nativeOptions?: any;
  107814. /**
  107815. * Specifies if the parent should be ignored
  107816. */
  107817. ignoreParent?: boolean;
  107818. /**
  107819. * Specifies if bi-directional transformations should be disabled
  107820. */
  107821. disableBidirectionalTransformation?: boolean;
  107822. /**
  107823. * The pressure inside the physics imposter, soft object only
  107824. */
  107825. pressure?: number;
  107826. /**
  107827. * The stiffness the physics imposter, soft object only
  107828. */
  107829. stiffness?: number;
  107830. /**
  107831. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107832. */
  107833. velocityIterations?: number;
  107834. /**
  107835. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107836. */
  107837. positionIterations?: number;
  107838. /**
  107839. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107840. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107841. * Add to fix multiple points
  107842. */
  107843. fixedPoints?: number;
  107844. /**
  107845. * The collision margin around a soft object
  107846. */
  107847. margin?: number;
  107848. /**
  107849. * The collision margin around a soft object
  107850. */
  107851. damping?: number;
  107852. /**
  107853. * The path for a rope based on an extrusion
  107854. */
  107855. path?: any;
  107856. /**
  107857. * The shape of an extrusion used for a rope based on an extrusion
  107858. */
  107859. shape?: any;
  107860. }
  107861. /**
  107862. * Interface for a physics-enabled object
  107863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107864. */
  107865. export interface IPhysicsEnabledObject {
  107866. /**
  107867. * The position of the physics-enabled object
  107868. */
  107869. position: Vector3;
  107870. /**
  107871. * The rotation of the physics-enabled object
  107872. */
  107873. rotationQuaternion: Nullable<Quaternion>;
  107874. /**
  107875. * The scale of the physics-enabled object
  107876. */
  107877. scaling: Vector3;
  107878. /**
  107879. * The rotation of the physics-enabled object
  107880. */
  107881. rotation?: Vector3;
  107882. /**
  107883. * The parent of the physics-enabled object
  107884. */
  107885. parent?: any;
  107886. /**
  107887. * The bounding info of the physics-enabled object
  107888. * @returns The bounding info of the physics-enabled object
  107889. */
  107890. getBoundingInfo(): BoundingInfo;
  107891. /**
  107892. * Computes the world matrix
  107893. * @param force Specifies if the world matrix should be computed by force
  107894. * @returns A world matrix
  107895. */
  107896. computeWorldMatrix(force: boolean): Matrix;
  107897. /**
  107898. * Gets the world matrix
  107899. * @returns A world matrix
  107900. */
  107901. getWorldMatrix?(): Matrix;
  107902. /**
  107903. * Gets the child meshes
  107904. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107905. * @returns An array of abstract meshes
  107906. */
  107907. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107908. /**
  107909. * Gets the vertex data
  107910. * @param kind The type of vertex data
  107911. * @returns A nullable array of numbers, or a float32 array
  107912. */
  107913. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107914. /**
  107915. * Gets the indices from the mesh
  107916. * @returns A nullable array of index arrays
  107917. */
  107918. getIndices?(): Nullable<IndicesArray>;
  107919. /**
  107920. * Gets the scene from the mesh
  107921. * @returns the indices array or null
  107922. */
  107923. getScene?(): Scene;
  107924. /**
  107925. * Gets the absolute position from the mesh
  107926. * @returns the absolute position
  107927. */
  107928. getAbsolutePosition(): Vector3;
  107929. /**
  107930. * Gets the absolute pivot point from the mesh
  107931. * @returns the absolute pivot point
  107932. */
  107933. getAbsolutePivotPoint(): Vector3;
  107934. /**
  107935. * Rotates the mesh
  107936. * @param axis The axis of rotation
  107937. * @param amount The amount of rotation
  107938. * @param space The space of the rotation
  107939. * @returns The rotation transform node
  107940. */
  107941. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107942. /**
  107943. * Translates the mesh
  107944. * @param axis The axis of translation
  107945. * @param distance The distance of translation
  107946. * @param space The space of the translation
  107947. * @returns The transform node
  107948. */
  107949. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107950. /**
  107951. * Sets the absolute position of the mesh
  107952. * @param absolutePosition The absolute position of the mesh
  107953. * @returns The transform node
  107954. */
  107955. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107956. /**
  107957. * Gets the class name of the mesh
  107958. * @returns The class name
  107959. */
  107960. getClassName(): string;
  107961. }
  107962. /**
  107963. * Represents a physics imposter
  107964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107965. */
  107966. export class PhysicsImpostor {
  107967. /**
  107968. * The physics-enabled object used as the physics imposter
  107969. */
  107970. object: IPhysicsEnabledObject;
  107971. /**
  107972. * The type of the physics imposter
  107973. */
  107974. type: number;
  107975. private _options;
  107976. private _scene?;
  107977. /**
  107978. * The default object size of the imposter
  107979. */
  107980. static DEFAULT_OBJECT_SIZE: Vector3;
  107981. /**
  107982. * The identity quaternion of the imposter
  107983. */
  107984. static IDENTITY_QUATERNION: Quaternion;
  107985. /** @hidden */
  107986. _pluginData: any;
  107987. private _physicsEngine;
  107988. private _physicsBody;
  107989. private _bodyUpdateRequired;
  107990. private _onBeforePhysicsStepCallbacks;
  107991. private _onAfterPhysicsStepCallbacks;
  107992. /** @hidden */
  107993. _onPhysicsCollideCallbacks: Array<{
  107994. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107995. otherImpostors: Array<PhysicsImpostor>;
  107996. }>;
  107997. private _deltaPosition;
  107998. private _deltaRotation;
  107999. private _deltaRotationConjugated;
  108000. /** @hidden */
  108001. _isFromLine: boolean;
  108002. private _parent;
  108003. private _isDisposed;
  108004. private static _tmpVecs;
  108005. private static _tmpQuat;
  108006. /**
  108007. * Specifies if the physics imposter is disposed
  108008. */
  108009. get isDisposed(): boolean;
  108010. /**
  108011. * Gets the mass of the physics imposter
  108012. */
  108013. get mass(): number;
  108014. set mass(value: number);
  108015. /**
  108016. * Gets the coefficient of friction
  108017. */
  108018. get friction(): number;
  108019. /**
  108020. * Sets the coefficient of friction
  108021. */
  108022. set friction(value: number);
  108023. /**
  108024. * Gets the coefficient of restitution
  108025. */
  108026. get restitution(): number;
  108027. /**
  108028. * Sets the coefficient of restitution
  108029. */
  108030. set restitution(value: number);
  108031. /**
  108032. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108033. */
  108034. get pressure(): number;
  108035. /**
  108036. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108037. */
  108038. set pressure(value: number);
  108039. /**
  108040. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108041. */
  108042. get stiffness(): number;
  108043. /**
  108044. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108045. */
  108046. set stiffness(value: number);
  108047. /**
  108048. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108049. */
  108050. get velocityIterations(): number;
  108051. /**
  108052. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108053. */
  108054. set velocityIterations(value: number);
  108055. /**
  108056. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108057. */
  108058. get positionIterations(): number;
  108059. /**
  108060. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108061. */
  108062. set positionIterations(value: number);
  108063. /**
  108064. * The unique id of the physics imposter
  108065. * set by the physics engine when adding this impostor to the array
  108066. */
  108067. uniqueId: number;
  108068. /**
  108069. * @hidden
  108070. */
  108071. soft: boolean;
  108072. /**
  108073. * @hidden
  108074. */
  108075. segments: number;
  108076. private _joints;
  108077. /**
  108078. * Initializes the physics imposter
  108079. * @param object The physics-enabled object used as the physics imposter
  108080. * @param type The type of the physics imposter
  108081. * @param _options The options for the physics imposter
  108082. * @param _scene The Babylon scene
  108083. */
  108084. constructor(
  108085. /**
  108086. * The physics-enabled object used as the physics imposter
  108087. */
  108088. object: IPhysicsEnabledObject,
  108089. /**
  108090. * The type of the physics imposter
  108091. */
  108092. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108093. /**
  108094. * This function will completly initialize this impostor.
  108095. * It will create a new body - but only if this mesh has no parent.
  108096. * If it has, this impostor will not be used other than to define the impostor
  108097. * of the child mesh.
  108098. * @hidden
  108099. */
  108100. _init(): void;
  108101. private _getPhysicsParent;
  108102. /**
  108103. * Should a new body be generated.
  108104. * @returns boolean specifying if body initialization is required
  108105. */
  108106. isBodyInitRequired(): boolean;
  108107. /**
  108108. * Sets the updated scaling
  108109. * @param updated Specifies if the scaling is updated
  108110. */
  108111. setScalingUpdated(): void;
  108112. /**
  108113. * Force a regeneration of this or the parent's impostor's body.
  108114. * Use under cautious - This will remove all joints already implemented.
  108115. */
  108116. forceUpdate(): void;
  108117. /**
  108118. * Gets the body that holds this impostor. Either its own, or its parent.
  108119. */
  108120. get physicsBody(): any;
  108121. /**
  108122. * Get the parent of the physics imposter
  108123. * @returns Physics imposter or null
  108124. */
  108125. get parent(): Nullable<PhysicsImpostor>;
  108126. /**
  108127. * Sets the parent of the physics imposter
  108128. */
  108129. set parent(value: Nullable<PhysicsImpostor>);
  108130. /**
  108131. * Set the physics body. Used mainly by the physics engine/plugin
  108132. */
  108133. set physicsBody(physicsBody: any);
  108134. /**
  108135. * Resets the update flags
  108136. */
  108137. resetUpdateFlags(): void;
  108138. /**
  108139. * Gets the object extend size
  108140. * @returns the object extend size
  108141. */
  108142. getObjectExtendSize(): Vector3;
  108143. /**
  108144. * Gets the object center
  108145. * @returns The object center
  108146. */
  108147. getObjectCenter(): Vector3;
  108148. /**
  108149. * Get a specific parameter from the options parameters
  108150. * @param paramName The object parameter name
  108151. * @returns The object parameter
  108152. */
  108153. getParam(paramName: string): any;
  108154. /**
  108155. * Sets a specific parameter in the options given to the physics plugin
  108156. * @param paramName The parameter name
  108157. * @param value The value of the parameter
  108158. */
  108159. setParam(paramName: string, value: number): void;
  108160. /**
  108161. * Specifically change the body's mass option. Won't recreate the physics body object
  108162. * @param mass The mass of the physics imposter
  108163. */
  108164. setMass(mass: number): void;
  108165. /**
  108166. * Gets the linear velocity
  108167. * @returns linear velocity or null
  108168. */
  108169. getLinearVelocity(): Nullable<Vector3>;
  108170. /**
  108171. * Sets the linear velocity
  108172. * @param velocity linear velocity or null
  108173. */
  108174. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108175. /**
  108176. * Gets the angular velocity
  108177. * @returns angular velocity or null
  108178. */
  108179. getAngularVelocity(): Nullable<Vector3>;
  108180. /**
  108181. * Sets the angular velocity
  108182. * @param velocity The velocity or null
  108183. */
  108184. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108185. /**
  108186. * Execute a function with the physics plugin native code
  108187. * Provide a function the will have two variables - the world object and the physics body object
  108188. * @param func The function to execute with the physics plugin native code
  108189. */
  108190. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108191. /**
  108192. * Register a function that will be executed before the physics world is stepping forward
  108193. * @param func The function to execute before the physics world is stepped forward
  108194. */
  108195. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108196. /**
  108197. * Unregister a function that will be executed before the physics world is stepping forward
  108198. * @param func The function to execute before the physics world is stepped forward
  108199. */
  108200. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108201. /**
  108202. * Register a function that will be executed after the physics step
  108203. * @param func The function to execute after physics step
  108204. */
  108205. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108206. /**
  108207. * Unregisters a function that will be executed after the physics step
  108208. * @param func The function to execute after physics step
  108209. */
  108210. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108211. /**
  108212. * register a function that will be executed when this impostor collides against a different body
  108213. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108214. * @param func Callback that is executed on collision
  108215. */
  108216. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108217. /**
  108218. * Unregisters the physics imposter on contact
  108219. * @param collideAgainst The physics object to collide against
  108220. * @param func Callback to execute on collision
  108221. */
  108222. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108223. private _tmpQuat;
  108224. private _tmpQuat2;
  108225. /**
  108226. * Get the parent rotation
  108227. * @returns The parent rotation
  108228. */
  108229. getParentsRotation(): Quaternion;
  108230. /**
  108231. * this function is executed by the physics engine.
  108232. */
  108233. beforeStep: () => void;
  108234. /**
  108235. * this function is executed by the physics engine
  108236. */
  108237. afterStep: () => void;
  108238. /**
  108239. * Legacy collision detection event support
  108240. */
  108241. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108242. /**
  108243. * event and body object due to cannon's event-based architecture.
  108244. */
  108245. onCollide: (e: {
  108246. body: any;
  108247. }) => void;
  108248. /**
  108249. * Apply a force
  108250. * @param force The force to apply
  108251. * @param contactPoint The contact point for the force
  108252. * @returns The physics imposter
  108253. */
  108254. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108255. /**
  108256. * Apply an impulse
  108257. * @param force The impulse force
  108258. * @param contactPoint The contact point for the impulse force
  108259. * @returns The physics imposter
  108260. */
  108261. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108262. /**
  108263. * A help function to create a joint
  108264. * @param otherImpostor A physics imposter used to create a joint
  108265. * @param jointType The type of joint
  108266. * @param jointData The data for the joint
  108267. * @returns The physics imposter
  108268. */
  108269. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108270. /**
  108271. * Add a joint to this impostor with a different impostor
  108272. * @param otherImpostor A physics imposter used to add a joint
  108273. * @param joint The joint to add
  108274. * @returns The physics imposter
  108275. */
  108276. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108277. /**
  108278. * Add an anchor to a cloth impostor
  108279. * @param otherImpostor rigid impostor to anchor to
  108280. * @param width ratio across width from 0 to 1
  108281. * @param height ratio up height from 0 to 1
  108282. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108283. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108284. * @returns impostor the soft imposter
  108285. */
  108286. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108287. /**
  108288. * Add a hook to a rope impostor
  108289. * @param otherImpostor rigid impostor to anchor to
  108290. * @param length ratio across rope from 0 to 1
  108291. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108292. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108293. * @returns impostor the rope imposter
  108294. */
  108295. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108296. /**
  108297. * Will keep this body still, in a sleep mode.
  108298. * @returns the physics imposter
  108299. */
  108300. sleep(): PhysicsImpostor;
  108301. /**
  108302. * Wake the body up.
  108303. * @returns The physics imposter
  108304. */
  108305. wakeUp(): PhysicsImpostor;
  108306. /**
  108307. * Clones the physics imposter
  108308. * @param newObject The physics imposter clones to this physics-enabled object
  108309. * @returns A nullable physics imposter
  108310. */
  108311. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108312. /**
  108313. * Disposes the physics imposter
  108314. */
  108315. dispose(): void;
  108316. /**
  108317. * Sets the delta position
  108318. * @param position The delta position amount
  108319. */
  108320. setDeltaPosition(position: Vector3): void;
  108321. /**
  108322. * Sets the delta rotation
  108323. * @param rotation The delta rotation amount
  108324. */
  108325. setDeltaRotation(rotation: Quaternion): void;
  108326. /**
  108327. * Gets the box size of the physics imposter and stores the result in the input parameter
  108328. * @param result Stores the box size
  108329. * @returns The physics imposter
  108330. */
  108331. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108332. /**
  108333. * Gets the radius of the physics imposter
  108334. * @returns Radius of the physics imposter
  108335. */
  108336. getRadius(): number;
  108337. /**
  108338. * Sync a bone with this impostor
  108339. * @param bone The bone to sync to the impostor.
  108340. * @param boneMesh The mesh that the bone is influencing.
  108341. * @param jointPivot The pivot of the joint / bone in local space.
  108342. * @param distToJoint Optional distance from the impostor to the joint.
  108343. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108344. */
  108345. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108346. /**
  108347. * Sync impostor to a bone
  108348. * @param bone The bone that the impostor will be synced to.
  108349. * @param boneMesh The mesh that the bone is influencing.
  108350. * @param jointPivot The pivot of the joint / bone in local space.
  108351. * @param distToJoint Optional distance from the impostor to the joint.
  108352. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108353. * @param boneAxis Optional vector3 axis the bone is aligned with
  108354. */
  108355. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108356. /**
  108357. * No-Imposter type
  108358. */
  108359. static NoImpostor: number;
  108360. /**
  108361. * Sphere-Imposter type
  108362. */
  108363. static SphereImpostor: number;
  108364. /**
  108365. * Box-Imposter type
  108366. */
  108367. static BoxImpostor: number;
  108368. /**
  108369. * Plane-Imposter type
  108370. */
  108371. static PlaneImpostor: number;
  108372. /**
  108373. * Mesh-imposter type
  108374. */
  108375. static MeshImpostor: number;
  108376. /**
  108377. * Capsule-Impostor type (Ammo.js plugin only)
  108378. */
  108379. static CapsuleImpostor: number;
  108380. /**
  108381. * Cylinder-Imposter type
  108382. */
  108383. static CylinderImpostor: number;
  108384. /**
  108385. * Particle-Imposter type
  108386. */
  108387. static ParticleImpostor: number;
  108388. /**
  108389. * Heightmap-Imposter type
  108390. */
  108391. static HeightmapImpostor: number;
  108392. /**
  108393. * ConvexHull-Impostor type (Ammo.js plugin only)
  108394. */
  108395. static ConvexHullImpostor: number;
  108396. /**
  108397. * Custom-Imposter type (Ammo.js plugin only)
  108398. */
  108399. static CustomImpostor: number;
  108400. /**
  108401. * Rope-Imposter type
  108402. */
  108403. static RopeImpostor: number;
  108404. /**
  108405. * Cloth-Imposter type
  108406. */
  108407. static ClothImpostor: number;
  108408. /**
  108409. * Softbody-Imposter type
  108410. */
  108411. static SoftbodyImpostor: number;
  108412. }
  108413. }
  108414. declare module BABYLON {
  108415. /**
  108416. * @hidden
  108417. **/
  108418. export class _CreationDataStorage {
  108419. closePath?: boolean;
  108420. closeArray?: boolean;
  108421. idx: number[];
  108422. dashSize: number;
  108423. gapSize: number;
  108424. path3D: Path3D;
  108425. pathArray: Vector3[][];
  108426. arc: number;
  108427. radius: number;
  108428. cap: number;
  108429. tessellation: number;
  108430. }
  108431. /**
  108432. * @hidden
  108433. **/
  108434. class _InstanceDataStorage {
  108435. visibleInstances: any;
  108436. batchCache: _InstancesBatch;
  108437. instancesBufferSize: number;
  108438. instancesBuffer: Nullable<Buffer>;
  108439. instancesData: Float32Array;
  108440. overridenInstanceCount: number;
  108441. isFrozen: boolean;
  108442. previousBatch: Nullable<_InstancesBatch>;
  108443. hardwareInstancedRendering: boolean;
  108444. sideOrientation: number;
  108445. manualUpdate: boolean;
  108446. previousRenderId: number;
  108447. }
  108448. /**
  108449. * @hidden
  108450. **/
  108451. export class _InstancesBatch {
  108452. mustReturn: boolean;
  108453. visibleInstances: Nullable<InstancedMesh[]>[];
  108454. renderSelf: boolean[];
  108455. hardwareInstancedRendering: boolean[];
  108456. }
  108457. /**
  108458. * @hidden
  108459. **/
  108460. class _ThinInstanceDataStorage {
  108461. instancesCount: number;
  108462. matrixBuffer: Nullable<Buffer>;
  108463. matrixBufferSize: number;
  108464. matrixData: Nullable<Float32Array>;
  108465. boundingVectors: Array<Vector3>;
  108466. worldMatrices: Nullable<Matrix[]>;
  108467. }
  108468. /**
  108469. * Class used to represent renderable models
  108470. */
  108471. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108472. /**
  108473. * Mesh side orientation : usually the external or front surface
  108474. */
  108475. static readonly FRONTSIDE: number;
  108476. /**
  108477. * Mesh side orientation : usually the internal or back surface
  108478. */
  108479. static readonly BACKSIDE: number;
  108480. /**
  108481. * Mesh side orientation : both internal and external or front and back surfaces
  108482. */
  108483. static readonly DOUBLESIDE: number;
  108484. /**
  108485. * Mesh side orientation : by default, `FRONTSIDE`
  108486. */
  108487. static readonly DEFAULTSIDE: number;
  108488. /**
  108489. * Mesh cap setting : no cap
  108490. */
  108491. static readonly NO_CAP: number;
  108492. /**
  108493. * Mesh cap setting : one cap at the beginning of the mesh
  108494. */
  108495. static readonly CAP_START: number;
  108496. /**
  108497. * Mesh cap setting : one cap at the end of the mesh
  108498. */
  108499. static readonly CAP_END: number;
  108500. /**
  108501. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108502. */
  108503. static readonly CAP_ALL: number;
  108504. /**
  108505. * Mesh pattern setting : no flip or rotate
  108506. */
  108507. static readonly NO_FLIP: number;
  108508. /**
  108509. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108510. */
  108511. static readonly FLIP_TILE: number;
  108512. /**
  108513. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108514. */
  108515. static readonly ROTATE_TILE: number;
  108516. /**
  108517. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108518. */
  108519. static readonly FLIP_ROW: number;
  108520. /**
  108521. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108522. */
  108523. static readonly ROTATE_ROW: number;
  108524. /**
  108525. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108526. */
  108527. static readonly FLIP_N_ROTATE_TILE: number;
  108528. /**
  108529. * Mesh pattern setting : rotate pattern and rotate
  108530. */
  108531. static readonly FLIP_N_ROTATE_ROW: number;
  108532. /**
  108533. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108534. */
  108535. static readonly CENTER: number;
  108536. /**
  108537. * Mesh tile positioning : part tiles on left
  108538. */
  108539. static readonly LEFT: number;
  108540. /**
  108541. * Mesh tile positioning : part tiles on right
  108542. */
  108543. static readonly RIGHT: number;
  108544. /**
  108545. * Mesh tile positioning : part tiles on top
  108546. */
  108547. static readonly TOP: number;
  108548. /**
  108549. * Mesh tile positioning : part tiles on bottom
  108550. */
  108551. static readonly BOTTOM: number;
  108552. /**
  108553. * Gets the default side orientation.
  108554. * @param orientation the orientation to value to attempt to get
  108555. * @returns the default orientation
  108556. * @hidden
  108557. */
  108558. static _GetDefaultSideOrientation(orientation?: number): number;
  108559. private _internalMeshDataInfo;
  108560. get computeBonesUsingShaders(): boolean;
  108561. set computeBonesUsingShaders(value: boolean);
  108562. /**
  108563. * An event triggered before rendering the mesh
  108564. */
  108565. get onBeforeRenderObservable(): Observable<Mesh>;
  108566. /**
  108567. * An event triggered before binding the mesh
  108568. */
  108569. get onBeforeBindObservable(): Observable<Mesh>;
  108570. /**
  108571. * An event triggered after rendering the mesh
  108572. */
  108573. get onAfterRenderObservable(): Observable<Mesh>;
  108574. /**
  108575. * An event triggered before drawing the mesh
  108576. */
  108577. get onBeforeDrawObservable(): Observable<Mesh>;
  108578. private _onBeforeDrawObserver;
  108579. /**
  108580. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108581. */
  108582. set onBeforeDraw(callback: () => void);
  108583. get hasInstances(): boolean;
  108584. get hasThinInstances(): boolean;
  108585. /**
  108586. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108587. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108588. */
  108589. delayLoadState: number;
  108590. /**
  108591. * Gets the list of instances created from this mesh
  108592. * it is not supposed to be modified manually.
  108593. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108594. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108595. */
  108596. instances: InstancedMesh[];
  108597. /**
  108598. * Gets the file containing delay loading data for this mesh
  108599. */
  108600. delayLoadingFile: string;
  108601. /** @hidden */
  108602. _binaryInfo: any;
  108603. /**
  108604. * User defined function used to change how LOD level selection is done
  108605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108606. */
  108607. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108608. /**
  108609. * Gets or sets the morph target manager
  108610. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108611. */
  108612. get morphTargetManager(): Nullable<MorphTargetManager>;
  108613. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108614. /** @hidden */
  108615. _creationDataStorage: Nullable<_CreationDataStorage>;
  108616. /** @hidden */
  108617. _geometry: Nullable<Geometry>;
  108618. /** @hidden */
  108619. _delayInfo: Array<string>;
  108620. /** @hidden */
  108621. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108622. /** @hidden */
  108623. _instanceDataStorage: _InstanceDataStorage;
  108624. /** @hidden */
  108625. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108626. private _effectiveMaterial;
  108627. /** @hidden */
  108628. _shouldGenerateFlatShading: boolean;
  108629. /** @hidden */
  108630. _originalBuilderSideOrientation: number;
  108631. /**
  108632. * Use this property to change the original side orientation defined at construction time
  108633. */
  108634. overrideMaterialSideOrientation: Nullable<number>;
  108635. /**
  108636. * Gets the source mesh (the one used to clone this one from)
  108637. */
  108638. get source(): Nullable<Mesh>;
  108639. /**
  108640. * Gets the list of clones of this mesh
  108641. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108642. * Note that useClonedMeshMap=true is the default setting
  108643. */
  108644. get cloneMeshMap(): Nullable<{
  108645. [id: string]: Mesh | undefined;
  108646. }>;
  108647. /**
  108648. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108649. */
  108650. get isUnIndexed(): boolean;
  108651. set isUnIndexed(value: boolean);
  108652. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108653. get worldMatrixInstancedBuffer(): Float32Array;
  108654. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108655. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108656. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108657. /**
  108658. * @constructor
  108659. * @param name The value used by scene.getMeshByName() to do a lookup.
  108660. * @param scene The scene to add this mesh to.
  108661. * @param parent The parent of this mesh, if it has one
  108662. * @param source An optional Mesh from which geometry is shared, cloned.
  108663. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108664. * When false, achieved by calling a clone(), also passing False.
  108665. * This will make creation of children, recursive.
  108666. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108667. */
  108668. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108669. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108670. doNotInstantiate: boolean;
  108671. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108672. /**
  108673. * Gets the class name
  108674. * @returns the string "Mesh".
  108675. */
  108676. getClassName(): string;
  108677. /** @hidden */
  108678. get _isMesh(): boolean;
  108679. /**
  108680. * Returns a description of this mesh
  108681. * @param fullDetails define if full details about this mesh must be used
  108682. * @returns a descriptive string representing this mesh
  108683. */
  108684. toString(fullDetails?: boolean): string;
  108685. /** @hidden */
  108686. _unBindEffect(): void;
  108687. /**
  108688. * Gets a boolean indicating if this mesh has LOD
  108689. */
  108690. get hasLODLevels(): boolean;
  108691. /**
  108692. * Gets the list of MeshLODLevel associated with the current mesh
  108693. * @returns an array of MeshLODLevel
  108694. */
  108695. getLODLevels(): MeshLODLevel[];
  108696. private _sortLODLevels;
  108697. /**
  108698. * Add a mesh as LOD level triggered at the given distance.
  108699. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108700. * @param distance The distance from the center of the object to show this level
  108701. * @param mesh The mesh to be added as LOD level (can be null)
  108702. * @return This mesh (for chaining)
  108703. */
  108704. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108705. /**
  108706. * Returns the LOD level mesh at the passed distance or null if not found.
  108707. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108708. * @param distance The distance from the center of the object to show this level
  108709. * @returns a Mesh or `null`
  108710. */
  108711. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108712. /**
  108713. * Remove a mesh from the LOD array
  108714. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108715. * @param mesh defines the mesh to be removed
  108716. * @return This mesh (for chaining)
  108717. */
  108718. removeLODLevel(mesh: Mesh): Mesh;
  108719. /**
  108720. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108721. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108722. * @param camera defines the camera to use to compute distance
  108723. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108724. * @return This mesh (for chaining)
  108725. */
  108726. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108727. /**
  108728. * Gets the mesh internal Geometry object
  108729. */
  108730. get geometry(): Nullable<Geometry>;
  108731. /**
  108732. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108733. * @returns the total number of vertices
  108734. */
  108735. getTotalVertices(): number;
  108736. /**
  108737. * Returns the content of an associated vertex buffer
  108738. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108739. * - VertexBuffer.PositionKind
  108740. * - VertexBuffer.UVKind
  108741. * - VertexBuffer.UV2Kind
  108742. * - VertexBuffer.UV3Kind
  108743. * - VertexBuffer.UV4Kind
  108744. * - VertexBuffer.UV5Kind
  108745. * - VertexBuffer.UV6Kind
  108746. * - VertexBuffer.ColorKind
  108747. * - VertexBuffer.MatricesIndicesKind
  108748. * - VertexBuffer.MatricesIndicesExtraKind
  108749. * - VertexBuffer.MatricesWeightsKind
  108750. * - VertexBuffer.MatricesWeightsExtraKind
  108751. * @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
  108752. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108753. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108754. */
  108755. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108756. /**
  108757. * Returns the mesh VertexBuffer object from the requested `kind`
  108758. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108759. * - VertexBuffer.PositionKind
  108760. * - VertexBuffer.NormalKind
  108761. * - VertexBuffer.UVKind
  108762. * - VertexBuffer.UV2Kind
  108763. * - VertexBuffer.UV3Kind
  108764. * - VertexBuffer.UV4Kind
  108765. * - VertexBuffer.UV5Kind
  108766. * - VertexBuffer.UV6Kind
  108767. * - VertexBuffer.ColorKind
  108768. * - VertexBuffer.MatricesIndicesKind
  108769. * - VertexBuffer.MatricesIndicesExtraKind
  108770. * - VertexBuffer.MatricesWeightsKind
  108771. * - VertexBuffer.MatricesWeightsExtraKind
  108772. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108773. */
  108774. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108775. /**
  108776. * Tests if a specific vertex buffer is associated with this mesh
  108777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108778. * - VertexBuffer.PositionKind
  108779. * - VertexBuffer.NormalKind
  108780. * - VertexBuffer.UVKind
  108781. * - VertexBuffer.UV2Kind
  108782. * - VertexBuffer.UV3Kind
  108783. * - VertexBuffer.UV4Kind
  108784. * - VertexBuffer.UV5Kind
  108785. * - VertexBuffer.UV6Kind
  108786. * - VertexBuffer.ColorKind
  108787. * - VertexBuffer.MatricesIndicesKind
  108788. * - VertexBuffer.MatricesIndicesExtraKind
  108789. * - VertexBuffer.MatricesWeightsKind
  108790. * - VertexBuffer.MatricesWeightsExtraKind
  108791. * @returns a boolean
  108792. */
  108793. isVerticesDataPresent(kind: string): boolean;
  108794. /**
  108795. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108796. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108797. * - VertexBuffer.PositionKind
  108798. * - VertexBuffer.UVKind
  108799. * - VertexBuffer.UV2Kind
  108800. * - VertexBuffer.UV3Kind
  108801. * - VertexBuffer.UV4Kind
  108802. * - VertexBuffer.UV5Kind
  108803. * - VertexBuffer.UV6Kind
  108804. * - VertexBuffer.ColorKind
  108805. * - VertexBuffer.MatricesIndicesKind
  108806. * - VertexBuffer.MatricesIndicesExtraKind
  108807. * - VertexBuffer.MatricesWeightsKind
  108808. * - VertexBuffer.MatricesWeightsExtraKind
  108809. * @returns a boolean
  108810. */
  108811. isVertexBufferUpdatable(kind: string): boolean;
  108812. /**
  108813. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108814. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108815. * - VertexBuffer.PositionKind
  108816. * - VertexBuffer.NormalKind
  108817. * - VertexBuffer.UVKind
  108818. * - VertexBuffer.UV2Kind
  108819. * - VertexBuffer.UV3Kind
  108820. * - VertexBuffer.UV4Kind
  108821. * - VertexBuffer.UV5Kind
  108822. * - VertexBuffer.UV6Kind
  108823. * - VertexBuffer.ColorKind
  108824. * - VertexBuffer.MatricesIndicesKind
  108825. * - VertexBuffer.MatricesIndicesExtraKind
  108826. * - VertexBuffer.MatricesWeightsKind
  108827. * - VertexBuffer.MatricesWeightsExtraKind
  108828. * @returns an array of strings
  108829. */
  108830. getVerticesDataKinds(): string[];
  108831. /**
  108832. * Returns a positive integer : the total number of indices in this mesh geometry.
  108833. * @returns the numner of indices or zero if the mesh has no geometry.
  108834. */
  108835. getTotalIndices(): number;
  108836. /**
  108837. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108838. * @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.
  108839. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108840. * @returns the indices array or an empty array if the mesh has no geometry
  108841. */
  108842. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108843. get isBlocked(): boolean;
  108844. /**
  108845. * Determine if the current mesh is ready to be rendered
  108846. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108847. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108848. * @returns true if all associated assets are ready (material, textures, shaders)
  108849. */
  108850. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108851. /**
  108852. * 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.
  108853. */
  108854. get areNormalsFrozen(): boolean;
  108855. /**
  108856. * 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.
  108857. * @returns the current mesh
  108858. */
  108859. freezeNormals(): Mesh;
  108860. /**
  108861. * 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
  108862. * @returns the current mesh
  108863. */
  108864. unfreezeNormals(): Mesh;
  108865. /**
  108866. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108867. */
  108868. set overridenInstanceCount(count: number);
  108869. /** @hidden */
  108870. _preActivate(): Mesh;
  108871. /** @hidden */
  108872. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108873. /** @hidden */
  108874. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108875. protected _afterComputeWorldMatrix(): void;
  108876. /** @hidden */
  108877. _postActivate(): void;
  108878. /**
  108879. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108880. * This means the mesh underlying bounding box and sphere are recomputed.
  108881. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108882. * @returns the current mesh
  108883. */
  108884. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108885. /** @hidden */
  108886. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108887. /**
  108888. * This function will subdivide the mesh into multiple submeshes
  108889. * @param count defines the expected number of submeshes
  108890. */
  108891. subdivide(count: number): void;
  108892. /**
  108893. * Copy a FloatArray into a specific associated vertex buffer
  108894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108895. * - VertexBuffer.PositionKind
  108896. * - VertexBuffer.UVKind
  108897. * - VertexBuffer.UV2Kind
  108898. * - VertexBuffer.UV3Kind
  108899. * - VertexBuffer.UV4Kind
  108900. * - VertexBuffer.UV5Kind
  108901. * - VertexBuffer.UV6Kind
  108902. * - VertexBuffer.ColorKind
  108903. * - VertexBuffer.MatricesIndicesKind
  108904. * - VertexBuffer.MatricesIndicesExtraKind
  108905. * - VertexBuffer.MatricesWeightsKind
  108906. * - VertexBuffer.MatricesWeightsExtraKind
  108907. * @param data defines the data source
  108908. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108909. * @param stride defines the data stride size (can be null)
  108910. * @returns the current mesh
  108911. */
  108912. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108913. /**
  108914. * Delete a vertex buffer associated with this mesh
  108915. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108916. * - VertexBuffer.PositionKind
  108917. * - VertexBuffer.UVKind
  108918. * - VertexBuffer.UV2Kind
  108919. * - VertexBuffer.UV3Kind
  108920. * - VertexBuffer.UV4Kind
  108921. * - VertexBuffer.UV5Kind
  108922. * - VertexBuffer.UV6Kind
  108923. * - VertexBuffer.ColorKind
  108924. * - VertexBuffer.MatricesIndicesKind
  108925. * - VertexBuffer.MatricesIndicesExtraKind
  108926. * - VertexBuffer.MatricesWeightsKind
  108927. * - VertexBuffer.MatricesWeightsExtraKind
  108928. */
  108929. removeVerticesData(kind: string): void;
  108930. /**
  108931. * Flags an associated vertex buffer as updatable
  108932. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108933. * - VertexBuffer.PositionKind
  108934. * - VertexBuffer.UVKind
  108935. * - VertexBuffer.UV2Kind
  108936. * - VertexBuffer.UV3Kind
  108937. * - VertexBuffer.UV4Kind
  108938. * - VertexBuffer.UV5Kind
  108939. * - VertexBuffer.UV6Kind
  108940. * - VertexBuffer.ColorKind
  108941. * - VertexBuffer.MatricesIndicesKind
  108942. * - VertexBuffer.MatricesIndicesExtraKind
  108943. * - VertexBuffer.MatricesWeightsKind
  108944. * - VertexBuffer.MatricesWeightsExtraKind
  108945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108946. */
  108947. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108948. /**
  108949. * Sets the mesh global Vertex Buffer
  108950. * @param buffer defines the buffer to use
  108951. * @returns the current mesh
  108952. */
  108953. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108954. /**
  108955. * Update a specific associated vertex buffer
  108956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108957. * - VertexBuffer.PositionKind
  108958. * - VertexBuffer.UVKind
  108959. * - VertexBuffer.UV2Kind
  108960. * - VertexBuffer.UV3Kind
  108961. * - VertexBuffer.UV4Kind
  108962. * - VertexBuffer.UV5Kind
  108963. * - VertexBuffer.UV6Kind
  108964. * - VertexBuffer.ColorKind
  108965. * - VertexBuffer.MatricesIndicesKind
  108966. * - VertexBuffer.MatricesIndicesExtraKind
  108967. * - VertexBuffer.MatricesWeightsKind
  108968. * - VertexBuffer.MatricesWeightsExtraKind
  108969. * @param data defines the data source
  108970. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108971. * @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)
  108972. * @returns the current mesh
  108973. */
  108974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108975. /**
  108976. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108977. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108978. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108979. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108980. * @returns the current mesh
  108981. */
  108982. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108983. /**
  108984. * Creates a un-shared specific occurence of the geometry for the mesh.
  108985. * @returns the current mesh
  108986. */
  108987. makeGeometryUnique(): Mesh;
  108988. /**
  108989. * Set the index buffer of this mesh
  108990. * @param indices defines the source data
  108991. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108992. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108993. * @returns the current mesh
  108994. */
  108995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108996. /**
  108997. * Update the current index buffer
  108998. * @param indices defines the source data
  108999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109000. * @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)
  109001. * @returns the current mesh
  109002. */
  109003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109004. /**
  109005. * Invert the geometry to move from a right handed system to a left handed one.
  109006. * @returns the current mesh
  109007. */
  109008. toLeftHanded(): Mesh;
  109009. /** @hidden */
  109010. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109011. /** @hidden */
  109012. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109013. /**
  109014. * Registers for this mesh a javascript function called just before the rendering process
  109015. * @param func defines the function to call before rendering this mesh
  109016. * @returns the current mesh
  109017. */
  109018. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109019. /**
  109020. * Disposes a previously registered javascript function called before the rendering
  109021. * @param func defines the function to remove
  109022. * @returns the current mesh
  109023. */
  109024. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109025. /**
  109026. * Registers for this mesh a javascript function called just after the rendering is complete
  109027. * @param func defines the function to call after rendering this mesh
  109028. * @returns the current mesh
  109029. */
  109030. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109031. /**
  109032. * Disposes a previously registered javascript function called after the rendering.
  109033. * @param func defines the function to remove
  109034. * @returns the current mesh
  109035. */
  109036. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109037. /** @hidden */
  109038. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109039. /** @hidden */
  109040. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109041. /** @hidden */
  109042. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109043. /** @hidden */
  109044. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109045. /** @hidden */
  109046. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109047. /** @hidden */
  109048. _rebuild(): void;
  109049. /** @hidden */
  109050. _freeze(): void;
  109051. /** @hidden */
  109052. _unFreeze(): void;
  109053. /**
  109054. * 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
  109055. * @param subMesh defines the subMesh to render
  109056. * @param enableAlphaMode defines if alpha mode can be changed
  109057. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109058. * @returns the current mesh
  109059. */
  109060. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109061. private _onBeforeDraw;
  109062. /**
  109063. * Renormalize the mesh and patch it up if there are no weights
  109064. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109065. * However in the case of zero weights then we set just a single influence to 1.
  109066. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109067. */
  109068. cleanMatrixWeights(): void;
  109069. private normalizeSkinFourWeights;
  109070. private normalizeSkinWeightsAndExtra;
  109071. /**
  109072. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109073. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109074. * the user know there was an issue with importing the mesh
  109075. * @returns a validation object with skinned, valid and report string
  109076. */
  109077. validateSkinning(): {
  109078. skinned: boolean;
  109079. valid: boolean;
  109080. report: string;
  109081. };
  109082. /** @hidden */
  109083. _checkDelayState(): Mesh;
  109084. private _queueLoad;
  109085. /**
  109086. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109087. * A mesh is in the frustum if its bounding box intersects the frustum
  109088. * @param frustumPlanes defines the frustum to test
  109089. * @returns true if the mesh is in the frustum planes
  109090. */
  109091. isInFrustum(frustumPlanes: Plane[]): boolean;
  109092. /**
  109093. * Sets the mesh material by the material or multiMaterial `id` property
  109094. * @param id is a string identifying the material or the multiMaterial
  109095. * @returns the current mesh
  109096. */
  109097. setMaterialByID(id: string): Mesh;
  109098. /**
  109099. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109100. * @returns an array of IAnimatable
  109101. */
  109102. getAnimatables(): IAnimatable[];
  109103. /**
  109104. * Modifies the mesh geometry according to the passed transformation matrix.
  109105. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109106. * The mesh normals are modified using the same transformation.
  109107. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109108. * @param transform defines the transform matrix to use
  109109. * @see https://doc.babylonjs.com/resources/baking_transformations
  109110. * @returns the current mesh
  109111. */
  109112. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109113. /**
  109114. * Modifies the mesh geometry according to its own current World Matrix.
  109115. * The mesh World Matrix is then reset.
  109116. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109117. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109118. * @see https://doc.babylonjs.com/resources/baking_transformations
  109119. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109120. * @returns the current mesh
  109121. */
  109122. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109123. /** @hidden */
  109124. get _positions(): Nullable<Vector3[]>;
  109125. /** @hidden */
  109126. _resetPointsArrayCache(): Mesh;
  109127. /** @hidden */
  109128. _generatePointsArray(): boolean;
  109129. /**
  109130. * Returns a new Mesh object generated from the current mesh properties.
  109131. * This method must not get confused with createInstance()
  109132. * @param name is a string, the name given to the new mesh
  109133. * @param newParent can be any Node object (default `null`)
  109134. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109135. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109136. * @returns a new mesh
  109137. */
  109138. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109139. /**
  109140. * Releases resources associated with this mesh.
  109141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109143. */
  109144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109145. /** @hidden */
  109146. _disposeInstanceSpecificData(): void;
  109147. /** @hidden */
  109148. _disposeThinInstanceSpecificData(): void;
  109149. /**
  109150. * Modifies the mesh geometry according to a displacement map.
  109151. * 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.
  109152. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109153. * @param url is a string, the URL from the image file is to be downloaded.
  109154. * @param minHeight is the lower limit of the displacement.
  109155. * @param maxHeight is the upper limit of the displacement.
  109156. * @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.
  109157. * @param uvOffset is an optional vector2 used to offset UV.
  109158. * @param uvScale is an optional vector2 used to scale UV.
  109159. * @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.
  109160. * @returns the Mesh.
  109161. */
  109162. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109163. /**
  109164. * Modifies the mesh geometry according to a displacementMap buffer.
  109165. * 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.
  109166. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109167. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109168. * @param heightMapWidth is the width of the buffer image.
  109169. * @param heightMapHeight is the height of the buffer image.
  109170. * @param minHeight is the lower limit of the displacement.
  109171. * @param maxHeight is the upper limit of the displacement.
  109172. * @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.
  109173. * @param uvOffset is an optional vector2 used to offset UV.
  109174. * @param uvScale is an optional vector2 used to scale UV.
  109175. * @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.
  109176. * @returns the Mesh.
  109177. */
  109178. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109179. /**
  109180. * Modify the mesh to get a flat shading rendering.
  109181. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109182. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109183. * @returns current mesh
  109184. */
  109185. convertToFlatShadedMesh(): Mesh;
  109186. /**
  109187. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109188. * In other words, more vertices, no more indices and a single bigger VBO.
  109189. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109190. * @returns current mesh
  109191. */
  109192. convertToUnIndexedMesh(): Mesh;
  109193. /**
  109194. * Inverses facet orientations.
  109195. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109196. * @param flipNormals will also inverts the normals
  109197. * @returns current mesh
  109198. */
  109199. flipFaces(flipNormals?: boolean): Mesh;
  109200. /**
  109201. * Increase the number of facets and hence vertices in a mesh
  109202. * Vertex normals are interpolated from existing vertex normals
  109203. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109204. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109205. */
  109206. increaseVertices(numberPerEdge: number): void;
  109207. /**
  109208. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109209. * This will undo any application of covertToFlatShadedMesh
  109210. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109211. */
  109212. forceSharedVertices(): void;
  109213. /** @hidden */
  109214. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109215. /** @hidden */
  109216. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109217. /**
  109218. * Creates a new InstancedMesh object from the mesh model.
  109219. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109220. * @param name defines the name of the new instance
  109221. * @returns a new InstancedMesh
  109222. */
  109223. createInstance(name: string): InstancedMesh;
  109224. /**
  109225. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109226. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109227. * @returns the current mesh
  109228. */
  109229. synchronizeInstances(): Mesh;
  109230. /**
  109231. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109232. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109233. * This should be used together with the simplification to avoid disappearing triangles.
  109234. * @param successCallback an optional success callback to be called after the optimization finished.
  109235. * @returns the current mesh
  109236. */
  109237. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109238. /**
  109239. * Serialize current mesh
  109240. * @param serializationObject defines the object which will receive the serialization data
  109241. */
  109242. serialize(serializationObject: any): void;
  109243. /** @hidden */
  109244. _syncGeometryWithMorphTargetManager(): void;
  109245. /** @hidden */
  109246. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109247. /**
  109248. * Returns a new Mesh object parsed from the source provided.
  109249. * @param parsedMesh is the source
  109250. * @param scene defines the hosting scene
  109251. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109252. * @returns a new Mesh
  109253. */
  109254. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109255. /**
  109256. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109257. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109258. * @param name defines the name of the mesh to create
  109259. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109260. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109261. * @param closePath creates a seam between the first and the last points of each path of the path array
  109262. * @param offset is taken in account only if the `pathArray` is containing a single path
  109263. * @param scene defines the hosting scene
  109264. * @param updatable defines if the mesh must be flagged as updatable
  109265. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109266. * @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)
  109267. * @returns a new Mesh
  109268. */
  109269. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109270. /**
  109271. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109272. * @param name defines the name of the mesh to create
  109273. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109274. * @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
  109275. * @param scene defines the hosting scene
  109276. * @param updatable defines if the mesh must be flagged as updatable
  109277. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109278. * @returns a new Mesh
  109279. */
  109280. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109281. /**
  109282. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109283. * @param name defines the name of the mesh to create
  109284. * @param size sets the size (float) of each box side (default 1)
  109285. * @param scene defines the hosting scene
  109286. * @param updatable defines if the mesh must be flagged as updatable
  109287. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109288. * @returns a new Mesh
  109289. */
  109290. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109291. /**
  109292. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109293. * @param name defines the name of the mesh to create
  109294. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109295. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109296. * @param scene defines the hosting scene
  109297. * @param updatable defines if the mesh must be flagged as updatable
  109298. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109299. * @returns a new Mesh
  109300. */
  109301. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109302. /**
  109303. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109304. * @param name defines the name of the mesh to create
  109305. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109306. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109307. * @param scene defines the hosting scene
  109308. * @returns a new Mesh
  109309. */
  109310. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109311. /**
  109312. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109313. * @param name defines the name of the mesh to create
  109314. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109315. * @param diameterTop set the top cap diameter (floats, default 1)
  109316. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109317. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109318. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109319. * @param scene defines the hosting scene
  109320. * @param updatable defines if the mesh must be flagged as updatable
  109321. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109322. * @returns a new Mesh
  109323. */
  109324. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109325. /**
  109326. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109327. * @param name defines the name of the mesh to create
  109328. * @param diameter sets the diameter size (float) of the torus (default 1)
  109329. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109330. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109331. * @param scene defines the hosting scene
  109332. * @param updatable defines if the mesh must be flagged as updatable
  109333. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109334. * @returns a new Mesh
  109335. */
  109336. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109337. /**
  109338. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109339. * @param name defines the name of the mesh to create
  109340. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109341. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109342. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109343. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109344. * @param p the number of windings on X axis (positive integers, default 2)
  109345. * @param q the number of windings on Y axis (positive integers, default 3)
  109346. * @param scene defines the hosting scene
  109347. * @param updatable defines if the mesh must be flagged as updatable
  109348. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109349. * @returns a new Mesh
  109350. */
  109351. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109352. /**
  109353. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109354. * @param name defines the name of the mesh to create
  109355. * @param points is an array successive Vector3
  109356. * @param scene defines the hosting scene
  109357. * @param updatable defines if the mesh must be flagged as updatable
  109358. * @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).
  109359. * @returns a new Mesh
  109360. */
  109361. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109362. /**
  109363. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109364. * @param name defines the name of the mesh to create
  109365. * @param points is an array successive Vector3
  109366. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109367. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109368. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109369. * @param scene defines the hosting scene
  109370. * @param updatable defines if the mesh must be flagged as updatable
  109371. * @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)
  109372. * @returns a new Mesh
  109373. */
  109374. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109375. /**
  109376. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109377. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109378. * 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.
  109379. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109380. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109381. * Remember you can only change the shape positions, not their number when updating a polygon.
  109382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109383. * @param name defines the name of the mesh to create
  109384. * @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
  109385. * @param scene defines the hosting scene
  109386. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109387. * @param updatable defines if the mesh must be flagged as updatable
  109388. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109389. * @param earcutInjection can be used to inject your own earcut reference
  109390. * @returns a new Mesh
  109391. */
  109392. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109393. /**
  109394. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109396. * @param name defines the name of the mesh to create
  109397. * @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
  109398. * @param depth defines the height of extrusion
  109399. * @param scene defines the hosting scene
  109400. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109401. * @param updatable defines if the mesh must be flagged as updatable
  109402. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109403. * @param earcutInjection can be used to inject your own earcut reference
  109404. * @returns a new Mesh
  109405. */
  109406. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109407. /**
  109408. * Creates an extruded shape mesh.
  109409. * 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
  109410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109412. * @param name defines the name of the mesh to create
  109413. * @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
  109414. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109415. * @param scale is the value to scale the shape
  109416. * @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
  109417. * @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
  109418. * @param scene defines the hosting scene
  109419. * @param updatable defines if the mesh must be flagged as updatable
  109420. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109421. * @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)
  109422. * @returns a new Mesh
  109423. */
  109424. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109425. /**
  109426. * Creates an custom extruded shape mesh.
  109427. * The custom extrusion is a parametric shape.
  109428. * It has no predefined shape. Its final shape will depend on the input parameters.
  109429. * Please consider using the same method from the MeshBuilder class instead
  109430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109431. * @param name defines the name of the mesh to create
  109432. * @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
  109433. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109434. * @param scaleFunction is a custom Javascript function called on each path point
  109435. * @param rotationFunction is a custom Javascript function called on each path point
  109436. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109437. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109438. * @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
  109439. * @param scene defines the hosting scene
  109440. * @param updatable defines if the mesh must be flagged as updatable
  109441. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109442. * @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)
  109443. * @returns a new Mesh
  109444. */
  109445. 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;
  109446. /**
  109447. * Creates lathe mesh.
  109448. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109449. * Please consider using the same method from the MeshBuilder class instead
  109450. * @param name defines the name of the mesh to create
  109451. * @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
  109452. * @param radius is the radius value of the lathe
  109453. * @param tessellation is the side number of the lathe.
  109454. * @param scene defines the hosting scene
  109455. * @param updatable defines if the mesh must be flagged as updatable
  109456. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109457. * @returns a new Mesh
  109458. */
  109459. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109460. /**
  109461. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109462. * @param name defines the name of the mesh to create
  109463. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109464. * @param scene defines the hosting scene
  109465. * @param updatable defines if the mesh must be flagged as updatable
  109466. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109467. * @returns a new Mesh
  109468. */
  109469. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109470. /**
  109471. * Creates a ground mesh.
  109472. * Please consider using the same method from the MeshBuilder class instead
  109473. * @param name defines the name of the mesh to create
  109474. * @param width set the width of the ground
  109475. * @param height set the height of the ground
  109476. * @param subdivisions sets the number of subdivisions per side
  109477. * @param scene defines the hosting scene
  109478. * @param updatable defines if the mesh must be flagged as updatable
  109479. * @returns a new Mesh
  109480. */
  109481. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109482. /**
  109483. * Creates a tiled ground mesh.
  109484. * Please consider using the same method from the MeshBuilder class instead
  109485. * @param name defines the name of the mesh to create
  109486. * @param xmin set the ground minimum X coordinate
  109487. * @param zmin set the ground minimum Y coordinate
  109488. * @param xmax set the ground maximum X coordinate
  109489. * @param zmax set the ground maximum Z coordinate
  109490. * @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
  109491. * @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
  109492. * @param scene defines the hosting scene
  109493. * @param updatable defines if the mesh must be flagged as updatable
  109494. * @returns a new Mesh
  109495. */
  109496. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109497. w: number;
  109498. h: number;
  109499. }, precision: {
  109500. w: number;
  109501. h: number;
  109502. }, scene: Scene, updatable?: boolean): Mesh;
  109503. /**
  109504. * Creates a ground mesh from a height map.
  109505. * Please consider using the same method from the MeshBuilder class instead
  109506. * @see https://doc.babylonjs.com/babylon101/height_map
  109507. * @param name defines the name of the mesh to create
  109508. * @param url sets the URL of the height map image resource
  109509. * @param width set the ground width size
  109510. * @param height set the ground height size
  109511. * @param subdivisions sets the number of subdivision per side
  109512. * @param minHeight is the minimum altitude on the ground
  109513. * @param maxHeight is the maximum altitude on the ground
  109514. * @param scene defines the hosting scene
  109515. * @param updatable defines if the mesh must be flagged as updatable
  109516. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109517. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109518. * @returns a new Mesh
  109519. */
  109520. 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;
  109521. /**
  109522. * Creates a tube mesh.
  109523. * The tube is a parametric shape.
  109524. * It has no predefined shape. Its final shape will depend on the input parameters.
  109525. * Please consider using the same method from the MeshBuilder class instead
  109526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109527. * @param name defines the name of the mesh to create
  109528. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109529. * @param radius sets the tube radius size
  109530. * @param tessellation is the number of sides on the tubular surface
  109531. * @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
  109532. * @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
  109533. * @param scene defines the hosting scene
  109534. * @param updatable defines if the mesh must be flagged as updatable
  109535. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109536. * @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)
  109537. * @returns a new Mesh
  109538. */
  109539. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109540. (i: number, distance: number): number;
  109541. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109542. /**
  109543. * Creates a polyhedron mesh.
  109544. * Please consider using the same method from the MeshBuilder class instead.
  109545. * * 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
  109546. * * The parameter `size` (positive float, default 1) sets the polygon size
  109547. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109548. * * 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`
  109549. * * 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
  109550. * * 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)`)
  109551. * * 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
  109552. * * 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
  109553. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109556. * @param name defines the name of the mesh to create
  109557. * @param options defines the options used to create the mesh
  109558. * @param scene defines the hosting scene
  109559. * @returns a new Mesh
  109560. */
  109561. static CreatePolyhedron(name: string, options: {
  109562. type?: number;
  109563. size?: number;
  109564. sizeX?: number;
  109565. sizeY?: number;
  109566. sizeZ?: number;
  109567. custom?: any;
  109568. faceUV?: Vector4[];
  109569. faceColors?: Color4[];
  109570. updatable?: boolean;
  109571. sideOrientation?: number;
  109572. }, scene: Scene): Mesh;
  109573. /**
  109574. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109575. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109576. * * 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`)
  109577. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109578. * * 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
  109579. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109582. * @param name defines the name of the mesh
  109583. * @param options defines the options used to create the mesh
  109584. * @param scene defines the hosting scene
  109585. * @returns a new Mesh
  109586. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109587. */
  109588. static CreateIcoSphere(name: string, options: {
  109589. radius?: number;
  109590. flat?: boolean;
  109591. subdivisions?: number;
  109592. sideOrientation?: number;
  109593. updatable?: boolean;
  109594. }, scene: Scene): Mesh;
  109595. /**
  109596. * Creates a decal mesh.
  109597. * Please consider using the same method from the MeshBuilder class instead.
  109598. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109599. * @param name defines the name of the mesh
  109600. * @param sourceMesh defines the mesh receiving the decal
  109601. * @param position sets the position of the decal in world coordinates
  109602. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109603. * @param size sets the decal scaling
  109604. * @param angle sets the angle to rotate the decal
  109605. * @returns a new Mesh
  109606. */
  109607. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109608. /** Creates a Capsule Mesh
  109609. * @param name defines the name of the mesh.
  109610. * @param options the constructors options used to shape the mesh.
  109611. * @param scene defines the scene the mesh is scoped to.
  109612. * @returns the capsule mesh
  109613. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109614. */
  109615. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109616. /**
  109617. * Prepare internal position array for software CPU skinning
  109618. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109619. */
  109620. setPositionsForCPUSkinning(): Float32Array;
  109621. /**
  109622. * Prepare internal normal array for software CPU skinning
  109623. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109624. */
  109625. setNormalsForCPUSkinning(): Float32Array;
  109626. /**
  109627. * Updates the vertex buffer by applying transformation from the bones
  109628. * @param skeleton defines the skeleton to apply to current mesh
  109629. * @returns the current mesh
  109630. */
  109631. applySkeleton(skeleton: Skeleton): Mesh;
  109632. /**
  109633. * 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
  109634. * @param meshes defines the list of meshes to scan
  109635. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109636. */
  109637. static MinMax(meshes: AbstractMesh[]): {
  109638. min: Vector3;
  109639. max: Vector3;
  109640. };
  109641. /**
  109642. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109643. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109644. * @returns a vector3
  109645. */
  109646. static Center(meshesOrMinMaxVector: {
  109647. min: Vector3;
  109648. max: Vector3;
  109649. } | AbstractMesh[]): Vector3;
  109650. /**
  109651. * Merge the array of meshes into a single mesh for performance reasons.
  109652. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109653. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109654. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109655. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109656. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109657. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109658. * @returns a new mesh
  109659. */
  109660. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109661. /** @hidden */
  109662. addInstance(instance: InstancedMesh): void;
  109663. /** @hidden */
  109664. removeInstance(instance: InstancedMesh): void;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. /**
  109669. * This is the base class of all the camera used in the application.
  109670. * @see https://doc.babylonjs.com/features/cameras
  109671. */
  109672. export class Camera extends Node {
  109673. /** @hidden */
  109674. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109675. /**
  109676. * This is the default projection mode used by the cameras.
  109677. * It helps recreating a feeling of perspective and better appreciate depth.
  109678. * This is the best way to simulate real life cameras.
  109679. */
  109680. static readonly PERSPECTIVE_CAMERA: number;
  109681. /**
  109682. * This helps creating camera with an orthographic mode.
  109683. * 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.
  109684. */
  109685. static readonly ORTHOGRAPHIC_CAMERA: number;
  109686. /**
  109687. * This is the default FOV mode for perspective cameras.
  109688. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109689. */
  109690. static readonly FOVMODE_VERTICAL_FIXED: number;
  109691. /**
  109692. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109693. */
  109694. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109695. /**
  109696. * This specifies ther is no need for a camera rig.
  109697. * Basically only one eye is rendered corresponding to the camera.
  109698. */
  109699. static readonly RIG_MODE_NONE: number;
  109700. /**
  109701. * Simulates a camera Rig with one blue eye and one red eye.
  109702. * This can be use with 3d blue and red glasses.
  109703. */
  109704. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109705. /**
  109706. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109707. */
  109708. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109709. /**
  109710. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109711. */
  109712. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109713. /**
  109714. * Defines that both eyes of the camera will be rendered over under each other.
  109715. */
  109716. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109717. /**
  109718. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109719. */
  109720. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109721. /**
  109722. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109723. */
  109724. static readonly RIG_MODE_VR: number;
  109725. /**
  109726. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109727. */
  109728. static readonly RIG_MODE_WEBVR: number;
  109729. /**
  109730. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109731. */
  109732. static readonly RIG_MODE_CUSTOM: number;
  109733. /**
  109734. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109735. */
  109736. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109737. /**
  109738. * Define the input manager associated with the camera.
  109739. */
  109740. inputs: CameraInputsManager<Camera>;
  109741. /** @hidden */
  109742. _position: Vector3;
  109743. /**
  109744. * Define the current local position of the camera in the scene
  109745. */
  109746. get position(): Vector3;
  109747. set position(newPosition: Vector3);
  109748. protected _upVector: Vector3;
  109749. /**
  109750. * The vector the camera should consider as up.
  109751. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109752. */
  109753. set upVector(vec: Vector3);
  109754. get upVector(): Vector3;
  109755. /**
  109756. * Define the current limit on the left side for an orthographic camera
  109757. * In scene unit
  109758. */
  109759. orthoLeft: Nullable<number>;
  109760. /**
  109761. * Define the current limit on the right side for an orthographic camera
  109762. * In scene unit
  109763. */
  109764. orthoRight: Nullable<number>;
  109765. /**
  109766. * Define the current limit on the bottom side for an orthographic camera
  109767. * In scene unit
  109768. */
  109769. orthoBottom: Nullable<number>;
  109770. /**
  109771. * Define the current limit on the top side for an orthographic camera
  109772. * In scene unit
  109773. */
  109774. orthoTop: Nullable<number>;
  109775. /**
  109776. * Field Of View is set in Radians. (default is 0.8)
  109777. */
  109778. fov: number;
  109779. /**
  109780. * Define the minimum distance the camera can see from.
  109781. * This is important to note that the depth buffer are not infinite and the closer it starts
  109782. * the more your scene might encounter depth fighting issue.
  109783. */
  109784. minZ: number;
  109785. /**
  109786. * Define the maximum distance the camera can see to.
  109787. * This is important to note that the depth buffer are not infinite and the further it end
  109788. * the more your scene might encounter depth fighting issue.
  109789. */
  109790. maxZ: number;
  109791. /**
  109792. * Define the default inertia of the camera.
  109793. * This helps giving a smooth feeling to the camera movement.
  109794. */
  109795. inertia: number;
  109796. /**
  109797. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109798. */
  109799. mode: number;
  109800. /**
  109801. * Define whether the camera is intermediate.
  109802. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109803. */
  109804. isIntermediate: boolean;
  109805. /**
  109806. * Define the viewport of the camera.
  109807. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109808. */
  109809. viewport: Viewport;
  109810. /**
  109811. * Restricts the camera to viewing objects with the same layerMask.
  109812. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109813. */
  109814. layerMask: number;
  109815. /**
  109816. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109817. */
  109818. fovMode: number;
  109819. /**
  109820. * Rig mode of the camera.
  109821. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109822. * This is normally controlled byt the camera themselves as internal use.
  109823. */
  109824. cameraRigMode: number;
  109825. /**
  109826. * Defines the distance between both "eyes" in case of a RIG
  109827. */
  109828. interaxialDistance: number;
  109829. /**
  109830. * Defines if stereoscopic rendering is done side by side or over under.
  109831. */
  109832. isStereoscopicSideBySide: boolean;
  109833. /**
  109834. * 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
  109835. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109836. * else in the scene. (Eg. security camera)
  109837. *
  109838. * 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)
  109839. */
  109840. customRenderTargets: RenderTargetTexture[];
  109841. /**
  109842. * When set, the camera will render to this render target instead of the default canvas
  109843. *
  109844. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109845. */
  109846. outputRenderTarget: Nullable<RenderTargetTexture>;
  109847. /**
  109848. * Observable triggered when the camera view matrix has changed.
  109849. */
  109850. onViewMatrixChangedObservable: Observable<Camera>;
  109851. /**
  109852. * Observable triggered when the camera Projection matrix has changed.
  109853. */
  109854. onProjectionMatrixChangedObservable: Observable<Camera>;
  109855. /**
  109856. * Observable triggered when the inputs have been processed.
  109857. */
  109858. onAfterCheckInputsObservable: Observable<Camera>;
  109859. /**
  109860. * Observable triggered when reset has been called and applied to the camera.
  109861. */
  109862. onRestoreStateObservable: Observable<Camera>;
  109863. /**
  109864. * Is this camera a part of a rig system?
  109865. */
  109866. isRigCamera: boolean;
  109867. /**
  109868. * If isRigCamera set to true this will be set with the parent camera.
  109869. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109870. */
  109871. rigParent?: Camera;
  109872. /** @hidden */
  109873. _cameraRigParams: any;
  109874. /** @hidden */
  109875. _rigCameras: Camera[];
  109876. /** @hidden */
  109877. _rigPostProcess: Nullable<PostProcess>;
  109878. protected _webvrViewMatrix: Matrix;
  109879. /** @hidden */
  109880. _skipRendering: boolean;
  109881. /** @hidden */
  109882. _projectionMatrix: Matrix;
  109883. /** @hidden */
  109884. _postProcesses: Nullable<PostProcess>[];
  109885. /** @hidden */
  109886. _activeMeshes: SmartArray<AbstractMesh>;
  109887. protected _globalPosition: Vector3;
  109888. /** @hidden */
  109889. _computedViewMatrix: Matrix;
  109890. private _doNotComputeProjectionMatrix;
  109891. private _transformMatrix;
  109892. private _frustumPlanes;
  109893. private _refreshFrustumPlanes;
  109894. private _storedFov;
  109895. private _stateStored;
  109896. /**
  109897. * Instantiates a new camera object.
  109898. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109899. * @see https://doc.babylonjs.com/features/cameras
  109900. * @param name Defines the name of the camera in the scene
  109901. * @param position Defines the position of the camera
  109902. * @param scene Defines the scene the camera belongs too
  109903. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109904. */
  109905. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109906. /**
  109907. * Store current camera state (fov, position, etc..)
  109908. * @returns the camera
  109909. */
  109910. storeState(): Camera;
  109911. /**
  109912. * Restores the camera state values if it has been stored. You must call storeState() first
  109913. */
  109914. protected _restoreStateValues(): boolean;
  109915. /**
  109916. * Restored camera state. You must call storeState() first.
  109917. * @returns true if restored and false otherwise
  109918. */
  109919. restoreState(): boolean;
  109920. /**
  109921. * Gets the class name of the camera.
  109922. * @returns the class name
  109923. */
  109924. getClassName(): string;
  109925. /** @hidden */
  109926. readonly _isCamera: boolean;
  109927. /**
  109928. * Gets a string representation of the camera useful for debug purpose.
  109929. * @param fullDetails Defines that a more verboe level of logging is required
  109930. * @returns the string representation
  109931. */
  109932. toString(fullDetails?: boolean): string;
  109933. /**
  109934. * Gets the current world space position of the camera.
  109935. */
  109936. get globalPosition(): Vector3;
  109937. /**
  109938. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109939. * @returns the active meshe list
  109940. */
  109941. getActiveMeshes(): SmartArray<AbstractMesh>;
  109942. /**
  109943. * Check whether a mesh is part of the current active mesh list of the camera
  109944. * @param mesh Defines the mesh to check
  109945. * @returns true if active, false otherwise
  109946. */
  109947. isActiveMesh(mesh: Mesh): boolean;
  109948. /**
  109949. * Is this camera ready to be used/rendered
  109950. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109951. * @return true if the camera is ready
  109952. */
  109953. isReady(completeCheck?: boolean): boolean;
  109954. /** @hidden */
  109955. _initCache(): void;
  109956. /** @hidden */
  109957. _updateCache(ignoreParentClass?: boolean): void;
  109958. /** @hidden */
  109959. _isSynchronized(): boolean;
  109960. /** @hidden */
  109961. _isSynchronizedViewMatrix(): boolean;
  109962. /** @hidden */
  109963. _isSynchronizedProjectionMatrix(): boolean;
  109964. /**
  109965. * Attach the input controls to a specific dom element to get the input from.
  109966. * @param element Defines the element the controls should be listened from
  109967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109968. */
  109969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109970. /**
  109971. * Detach the current controls from the specified dom element.
  109972. * @param element Defines the element to stop listening the inputs from
  109973. */
  109974. detachControl(element: HTMLElement): void;
  109975. /**
  109976. * Update the camera state according to the different inputs gathered during the frame.
  109977. */
  109978. update(): void;
  109979. /** @hidden */
  109980. _checkInputs(): void;
  109981. /** @hidden */
  109982. get rigCameras(): Camera[];
  109983. /**
  109984. * Gets the post process used by the rig cameras
  109985. */
  109986. get rigPostProcess(): Nullable<PostProcess>;
  109987. /**
  109988. * Internal, gets the first post proces.
  109989. * @returns the first post process to be run on this camera.
  109990. */
  109991. _getFirstPostProcess(): Nullable<PostProcess>;
  109992. private _cascadePostProcessesToRigCams;
  109993. /**
  109994. * Attach a post process to the camera.
  109995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109996. * @param postProcess The post process to attach to the camera
  109997. * @param insertAt The position of the post process in case several of them are in use in the scene
  109998. * @returns the position the post process has been inserted at
  109999. */
  110000. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110001. /**
  110002. * Detach a post process to the camera.
  110003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110004. * @param postProcess The post process to detach from the camera
  110005. */
  110006. detachPostProcess(postProcess: PostProcess): void;
  110007. /**
  110008. * Gets the current world matrix of the camera
  110009. */
  110010. getWorldMatrix(): Matrix;
  110011. /** @hidden */
  110012. _getViewMatrix(): Matrix;
  110013. /**
  110014. * Gets the current view matrix of the camera.
  110015. * @param force forces the camera to recompute the matrix without looking at the cached state
  110016. * @returns the view matrix
  110017. */
  110018. getViewMatrix(force?: boolean): Matrix;
  110019. /**
  110020. * Freeze the projection matrix.
  110021. * It will prevent the cache check of the camera projection compute and can speed up perf
  110022. * if no parameter of the camera are meant to change
  110023. * @param projection Defines manually a projection if necessary
  110024. */
  110025. freezeProjectionMatrix(projection?: Matrix): void;
  110026. /**
  110027. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110028. */
  110029. unfreezeProjectionMatrix(): void;
  110030. /**
  110031. * Gets the current projection matrix of the camera.
  110032. * @param force forces the camera to recompute the matrix without looking at the cached state
  110033. * @returns the projection matrix
  110034. */
  110035. getProjectionMatrix(force?: boolean): Matrix;
  110036. /**
  110037. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110038. * @returns a Matrix
  110039. */
  110040. getTransformationMatrix(): Matrix;
  110041. private _updateFrustumPlanes;
  110042. /**
  110043. * Checks if a cullable object (mesh...) is in the camera frustum
  110044. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110045. * @param target The object to check
  110046. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110047. * @returns true if the object is in frustum otherwise false
  110048. */
  110049. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110050. /**
  110051. * Checks if a cullable object (mesh...) is in the camera frustum
  110052. * Unlike isInFrustum this cheks the full bounding box
  110053. * @param target The object to check
  110054. * @returns true if the object is in frustum otherwise false
  110055. */
  110056. isCompletelyInFrustum(target: ICullable): boolean;
  110057. /**
  110058. * Gets a ray in the forward direction from the camera.
  110059. * @param length Defines the length of the ray to create
  110060. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110061. * @param origin Defines the start point of the ray which defaults to the camera position
  110062. * @returns the forward ray
  110063. */
  110064. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110065. /**
  110066. * Gets a ray in the forward direction from the camera.
  110067. * @param refRay the ray to (re)use when setting the values
  110068. * @param length Defines the length of the ray to create
  110069. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110070. * @param origin Defines the start point of the ray which defaults to the camera position
  110071. * @returns the forward ray
  110072. */
  110073. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110074. /**
  110075. * Releases resources associated with this node.
  110076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110078. */
  110079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110080. /** @hidden */
  110081. _isLeftCamera: boolean;
  110082. /**
  110083. * Gets the left camera of a rig setup in case of Rigged Camera
  110084. */
  110085. get isLeftCamera(): boolean;
  110086. /** @hidden */
  110087. _isRightCamera: boolean;
  110088. /**
  110089. * Gets the right camera of a rig setup in case of Rigged Camera
  110090. */
  110091. get isRightCamera(): boolean;
  110092. /**
  110093. * Gets the left camera of a rig setup in case of Rigged Camera
  110094. */
  110095. get leftCamera(): Nullable<FreeCamera>;
  110096. /**
  110097. * Gets the right camera of a rig setup in case of Rigged Camera
  110098. */
  110099. get rightCamera(): Nullable<FreeCamera>;
  110100. /**
  110101. * Gets the left camera target of a rig setup in case of Rigged Camera
  110102. * @returns the target position
  110103. */
  110104. getLeftTarget(): Nullable<Vector3>;
  110105. /**
  110106. * Gets the right camera target of a rig setup in case of Rigged Camera
  110107. * @returns the target position
  110108. */
  110109. getRightTarget(): Nullable<Vector3>;
  110110. /**
  110111. * @hidden
  110112. */
  110113. setCameraRigMode(mode: number, rigParams: any): void;
  110114. /** @hidden */
  110115. static _setStereoscopicRigMode(camera: Camera): void;
  110116. /** @hidden */
  110117. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110118. /** @hidden */
  110119. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110120. /** @hidden */
  110121. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110122. /** @hidden */
  110123. _getVRProjectionMatrix(): Matrix;
  110124. protected _updateCameraRotationMatrix(): void;
  110125. protected _updateWebVRCameraRotationMatrix(): void;
  110126. /**
  110127. * This function MUST be overwritten by the different WebVR cameras available.
  110128. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110129. * @hidden
  110130. */
  110131. _getWebVRProjectionMatrix(): Matrix;
  110132. /**
  110133. * This function MUST be overwritten by the different WebVR cameras available.
  110134. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110135. * @hidden
  110136. */
  110137. _getWebVRViewMatrix(): Matrix;
  110138. /** @hidden */
  110139. setCameraRigParameter(name: string, value: any): void;
  110140. /**
  110141. * needs to be overridden by children so sub has required properties to be copied
  110142. * @hidden
  110143. */
  110144. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110145. /**
  110146. * May need to be overridden by children
  110147. * @hidden
  110148. */
  110149. _updateRigCameras(): void;
  110150. /** @hidden */
  110151. _setupInputs(): void;
  110152. /**
  110153. * Serialiaze the camera setup to a json represention
  110154. * @returns the JSON representation
  110155. */
  110156. serialize(): any;
  110157. /**
  110158. * Clones the current camera.
  110159. * @param name The cloned camera name
  110160. * @returns the cloned camera
  110161. */
  110162. clone(name: string): Camera;
  110163. /**
  110164. * Gets the direction of the camera relative to a given local axis.
  110165. * @param localAxis Defines the reference axis to provide a relative direction.
  110166. * @return the direction
  110167. */
  110168. getDirection(localAxis: Vector3): Vector3;
  110169. /**
  110170. * Returns the current camera absolute rotation
  110171. */
  110172. get absoluteRotation(): Quaternion;
  110173. /**
  110174. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110175. * @param localAxis Defines the reference axis to provide a relative direction.
  110176. * @param result Defines the vector to store the result in
  110177. */
  110178. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110179. /**
  110180. * Gets a camera constructor for a given camera type
  110181. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110182. * @param name The name of the camera the result will be able to instantiate
  110183. * @param scene The scene the result will construct the camera in
  110184. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110185. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110186. * @returns a factory method to construc the camera
  110187. */
  110188. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110189. /**
  110190. * Compute the world matrix of the camera.
  110191. * @returns the camera world matrix
  110192. */
  110193. computeWorldMatrix(): Matrix;
  110194. /**
  110195. * Parse a JSON and creates the camera from the parsed information
  110196. * @param parsedCamera The JSON to parse
  110197. * @param scene The scene to instantiate the camera in
  110198. * @returns the newly constructed camera
  110199. */
  110200. static Parse(parsedCamera: any, scene: Scene): Camera;
  110201. }
  110202. }
  110203. declare module BABYLON {
  110204. /**
  110205. * Class containing static functions to help procedurally build meshes
  110206. */
  110207. export class DiscBuilder {
  110208. /**
  110209. * Creates a plane polygonal mesh. By default, this is a disc
  110210. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110211. * * 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
  110212. * * 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
  110213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110216. * @param name defines the name of the mesh
  110217. * @param options defines the options used to create the mesh
  110218. * @param scene defines the hosting scene
  110219. * @returns the plane polygonal mesh
  110220. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110221. */
  110222. static CreateDisc(name: string, options: {
  110223. radius?: number;
  110224. tessellation?: number;
  110225. arc?: number;
  110226. updatable?: boolean;
  110227. sideOrientation?: number;
  110228. frontUVs?: Vector4;
  110229. backUVs?: Vector4;
  110230. }, scene?: Nullable<Scene>): Mesh;
  110231. }
  110232. }
  110233. declare module BABYLON {
  110234. /**
  110235. * Options to be used when creating a FresnelParameters.
  110236. */
  110237. export type IFresnelParametersCreationOptions = {
  110238. /**
  110239. * Define the color used on edges (grazing angle)
  110240. */
  110241. leftColor?: Color3;
  110242. /**
  110243. * Define the color used on center
  110244. */
  110245. rightColor?: Color3;
  110246. /**
  110247. * Define bias applied to computed fresnel term
  110248. */
  110249. bias?: number;
  110250. /**
  110251. * Defined the power exponent applied to fresnel term
  110252. */
  110253. power?: number;
  110254. /**
  110255. * Define if the fresnel effect is enable or not.
  110256. */
  110257. isEnabled?: boolean;
  110258. };
  110259. /**
  110260. * Serialized format for FresnelParameters.
  110261. */
  110262. export type IFresnelParametersSerialized = {
  110263. /**
  110264. * Define the color used on edges (grazing angle) [as an array]
  110265. */
  110266. leftColor: number[];
  110267. /**
  110268. * Define the color used on center [as an array]
  110269. */
  110270. rightColor: number[];
  110271. /**
  110272. * Define bias applied to computed fresnel term
  110273. */
  110274. bias: number;
  110275. /**
  110276. * Defined the power exponent applied to fresnel term
  110277. */
  110278. power?: number;
  110279. /**
  110280. * Define if the fresnel effect is enable or not.
  110281. */
  110282. isEnabled: boolean;
  110283. };
  110284. /**
  110285. * This represents all the required information to add a fresnel effect on a material:
  110286. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110287. */
  110288. export class FresnelParameters {
  110289. private _isEnabled;
  110290. /**
  110291. * Define if the fresnel effect is enable or not.
  110292. */
  110293. get isEnabled(): boolean;
  110294. set isEnabled(value: boolean);
  110295. /**
  110296. * Define the color used on edges (grazing angle)
  110297. */
  110298. leftColor: Color3;
  110299. /**
  110300. * Define the color used on center
  110301. */
  110302. rightColor: Color3;
  110303. /**
  110304. * Define bias applied to computed fresnel term
  110305. */
  110306. bias: number;
  110307. /**
  110308. * Defined the power exponent applied to fresnel term
  110309. */
  110310. power: number;
  110311. /**
  110312. * Creates a new FresnelParameters object.
  110313. *
  110314. * @param options provide your own settings to optionally to override defaults
  110315. */
  110316. constructor(options?: IFresnelParametersCreationOptions);
  110317. /**
  110318. * Clones the current fresnel and its valuues
  110319. * @returns a clone fresnel configuration
  110320. */
  110321. clone(): FresnelParameters;
  110322. /**
  110323. * Determines equality between FresnelParameters objects
  110324. * @param otherFresnelParameters defines the second operand
  110325. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110326. */
  110327. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110328. /**
  110329. * Serializes the current fresnel parameters to a JSON representation.
  110330. * @return the JSON serialization
  110331. */
  110332. serialize(): IFresnelParametersSerialized;
  110333. /**
  110334. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110335. * @param parsedFresnelParameters Define the JSON representation
  110336. * @returns the parsed parameters
  110337. */
  110338. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110339. }
  110340. }
  110341. declare module BABYLON {
  110342. /**
  110343. * This groups all the flags used to control the materials channel.
  110344. */
  110345. export class MaterialFlags {
  110346. private static _DiffuseTextureEnabled;
  110347. /**
  110348. * Are diffuse textures enabled in the application.
  110349. */
  110350. static get DiffuseTextureEnabled(): boolean;
  110351. static set DiffuseTextureEnabled(value: boolean);
  110352. private static _DetailTextureEnabled;
  110353. /**
  110354. * Are detail textures enabled in the application.
  110355. */
  110356. static get DetailTextureEnabled(): boolean;
  110357. static set DetailTextureEnabled(value: boolean);
  110358. private static _AmbientTextureEnabled;
  110359. /**
  110360. * Are ambient textures enabled in the application.
  110361. */
  110362. static get AmbientTextureEnabled(): boolean;
  110363. static set AmbientTextureEnabled(value: boolean);
  110364. private static _OpacityTextureEnabled;
  110365. /**
  110366. * Are opacity textures enabled in the application.
  110367. */
  110368. static get OpacityTextureEnabled(): boolean;
  110369. static set OpacityTextureEnabled(value: boolean);
  110370. private static _ReflectionTextureEnabled;
  110371. /**
  110372. * Are reflection textures enabled in the application.
  110373. */
  110374. static get ReflectionTextureEnabled(): boolean;
  110375. static set ReflectionTextureEnabled(value: boolean);
  110376. private static _EmissiveTextureEnabled;
  110377. /**
  110378. * Are emissive textures enabled in the application.
  110379. */
  110380. static get EmissiveTextureEnabled(): boolean;
  110381. static set EmissiveTextureEnabled(value: boolean);
  110382. private static _SpecularTextureEnabled;
  110383. /**
  110384. * Are specular textures enabled in the application.
  110385. */
  110386. static get SpecularTextureEnabled(): boolean;
  110387. static set SpecularTextureEnabled(value: boolean);
  110388. private static _BumpTextureEnabled;
  110389. /**
  110390. * Are bump textures enabled in the application.
  110391. */
  110392. static get BumpTextureEnabled(): boolean;
  110393. static set BumpTextureEnabled(value: boolean);
  110394. private static _LightmapTextureEnabled;
  110395. /**
  110396. * Are lightmap textures enabled in the application.
  110397. */
  110398. static get LightmapTextureEnabled(): boolean;
  110399. static set LightmapTextureEnabled(value: boolean);
  110400. private static _RefractionTextureEnabled;
  110401. /**
  110402. * Are refraction textures enabled in the application.
  110403. */
  110404. static get RefractionTextureEnabled(): boolean;
  110405. static set RefractionTextureEnabled(value: boolean);
  110406. private static _ColorGradingTextureEnabled;
  110407. /**
  110408. * Are color grading textures enabled in the application.
  110409. */
  110410. static get ColorGradingTextureEnabled(): boolean;
  110411. static set ColorGradingTextureEnabled(value: boolean);
  110412. private static _FresnelEnabled;
  110413. /**
  110414. * Are fresnels enabled in the application.
  110415. */
  110416. static get FresnelEnabled(): boolean;
  110417. static set FresnelEnabled(value: boolean);
  110418. private static _ClearCoatTextureEnabled;
  110419. /**
  110420. * Are clear coat textures enabled in the application.
  110421. */
  110422. static get ClearCoatTextureEnabled(): boolean;
  110423. static set ClearCoatTextureEnabled(value: boolean);
  110424. private static _ClearCoatBumpTextureEnabled;
  110425. /**
  110426. * Are clear coat bump textures enabled in the application.
  110427. */
  110428. static get ClearCoatBumpTextureEnabled(): boolean;
  110429. static set ClearCoatBumpTextureEnabled(value: boolean);
  110430. private static _ClearCoatTintTextureEnabled;
  110431. /**
  110432. * Are clear coat tint textures enabled in the application.
  110433. */
  110434. static get ClearCoatTintTextureEnabled(): boolean;
  110435. static set ClearCoatTintTextureEnabled(value: boolean);
  110436. private static _SheenTextureEnabled;
  110437. /**
  110438. * Are sheen textures enabled in the application.
  110439. */
  110440. static get SheenTextureEnabled(): boolean;
  110441. static set SheenTextureEnabled(value: boolean);
  110442. private static _AnisotropicTextureEnabled;
  110443. /**
  110444. * Are anisotropic textures enabled in the application.
  110445. */
  110446. static get AnisotropicTextureEnabled(): boolean;
  110447. static set AnisotropicTextureEnabled(value: boolean);
  110448. private static _ThicknessTextureEnabled;
  110449. /**
  110450. * Are thickness textures enabled in the application.
  110451. */
  110452. static get ThicknessTextureEnabled(): boolean;
  110453. static set ThicknessTextureEnabled(value: boolean);
  110454. }
  110455. }
  110456. declare module BABYLON {
  110457. /** @hidden */
  110458. export var defaultFragmentDeclaration: {
  110459. name: string;
  110460. shader: string;
  110461. };
  110462. }
  110463. declare module BABYLON {
  110464. /** @hidden */
  110465. export var defaultUboDeclaration: {
  110466. name: string;
  110467. shader: string;
  110468. };
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var prePassDeclaration: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. /** @hidden */
  110479. export var lightFragmentDeclaration: {
  110480. name: string;
  110481. shader: string;
  110482. };
  110483. }
  110484. declare module BABYLON {
  110485. /** @hidden */
  110486. export var lightUboDeclaration: {
  110487. name: string;
  110488. shader: string;
  110489. };
  110490. }
  110491. declare module BABYLON {
  110492. /** @hidden */
  110493. export var lightsFragmentFunctions: {
  110494. name: string;
  110495. shader: string;
  110496. };
  110497. }
  110498. declare module BABYLON {
  110499. /** @hidden */
  110500. export var shadowsFragmentFunctions: {
  110501. name: string;
  110502. shader: string;
  110503. };
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var fresnelFunction: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /** @hidden */
  110514. export var bumpFragmentMainFunctions: {
  110515. name: string;
  110516. shader: string;
  110517. };
  110518. }
  110519. declare module BABYLON {
  110520. /** @hidden */
  110521. export var bumpFragmentFunctions: {
  110522. name: string;
  110523. shader: string;
  110524. };
  110525. }
  110526. declare module BABYLON {
  110527. /** @hidden */
  110528. export var logDepthDeclaration: {
  110529. name: string;
  110530. shader: string;
  110531. };
  110532. }
  110533. declare module BABYLON {
  110534. /** @hidden */
  110535. export var bumpFragment: {
  110536. name: string;
  110537. shader: string;
  110538. };
  110539. }
  110540. declare module BABYLON {
  110541. /** @hidden */
  110542. export var depthPrePass: {
  110543. name: string;
  110544. shader: string;
  110545. };
  110546. }
  110547. declare module BABYLON {
  110548. /** @hidden */
  110549. export var lightFragment: {
  110550. name: string;
  110551. shader: string;
  110552. };
  110553. }
  110554. declare module BABYLON {
  110555. /** @hidden */
  110556. export var logDepthFragment: {
  110557. name: string;
  110558. shader: string;
  110559. };
  110560. }
  110561. declare module BABYLON {
  110562. /** @hidden */
  110563. export var defaultPixelShader: {
  110564. name: string;
  110565. shader: string;
  110566. };
  110567. }
  110568. declare module BABYLON {
  110569. /** @hidden */
  110570. export var defaultVertexDeclaration: {
  110571. name: string;
  110572. shader: string;
  110573. };
  110574. }
  110575. declare module BABYLON {
  110576. /** @hidden */
  110577. export var bumpVertexDeclaration: {
  110578. name: string;
  110579. shader: string;
  110580. };
  110581. }
  110582. declare module BABYLON {
  110583. /** @hidden */
  110584. export var bumpVertex: {
  110585. name: string;
  110586. shader: string;
  110587. };
  110588. }
  110589. declare module BABYLON {
  110590. /** @hidden */
  110591. export var fogVertex: {
  110592. name: string;
  110593. shader: string;
  110594. };
  110595. }
  110596. declare module BABYLON {
  110597. /** @hidden */
  110598. export var shadowsVertex: {
  110599. name: string;
  110600. shader: string;
  110601. };
  110602. }
  110603. declare module BABYLON {
  110604. /** @hidden */
  110605. export var pointCloudVertex: {
  110606. name: string;
  110607. shader: string;
  110608. };
  110609. }
  110610. declare module BABYLON {
  110611. /** @hidden */
  110612. export var logDepthVertex: {
  110613. name: string;
  110614. shader: string;
  110615. };
  110616. }
  110617. declare module BABYLON {
  110618. /** @hidden */
  110619. export var defaultVertexShader: {
  110620. name: string;
  110621. shader: string;
  110622. };
  110623. }
  110624. declare module BABYLON {
  110625. /**
  110626. * @hidden
  110627. */
  110628. export interface IMaterialDetailMapDefines {
  110629. DETAIL: boolean;
  110630. DETAILDIRECTUV: number;
  110631. DETAIL_NORMALBLENDMETHOD: number;
  110632. /** @hidden */
  110633. _areTexturesDirty: boolean;
  110634. }
  110635. /**
  110636. * Define the code related to the detail map parameters of a material
  110637. *
  110638. * Inspired from:
  110639. * 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
  110640. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110641. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110642. */
  110643. export class DetailMapConfiguration {
  110644. private _texture;
  110645. /**
  110646. * The detail texture of the material.
  110647. */
  110648. texture: Nullable<BaseTexture>;
  110649. /**
  110650. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110651. * Bigger values mean stronger blending
  110652. */
  110653. diffuseBlendLevel: number;
  110654. /**
  110655. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110656. * Bigger values mean stronger blending. Only used with PBR materials
  110657. */
  110658. roughnessBlendLevel: number;
  110659. /**
  110660. * Defines how strong the bump effect from the detail map is
  110661. * Bigger values mean stronger effect
  110662. */
  110663. bumpLevel: number;
  110664. private _normalBlendMethod;
  110665. /**
  110666. * The method used to blend the bump and detail normals together
  110667. */
  110668. normalBlendMethod: number;
  110669. private _isEnabled;
  110670. /**
  110671. * Enable or disable the detail map on this material
  110672. */
  110673. isEnabled: boolean;
  110674. /** @hidden */
  110675. private _internalMarkAllSubMeshesAsTexturesDirty;
  110676. /** @hidden */
  110677. _markAllSubMeshesAsTexturesDirty(): void;
  110678. /**
  110679. * Instantiate a new detail map
  110680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110681. */
  110682. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110683. /**
  110684. * Gets whether the submesh is ready to be used or not.
  110685. * @param defines the list of "defines" to update.
  110686. * @param scene defines the scene the material belongs to.
  110687. * @returns - boolean indicating that the submesh is ready or not.
  110688. */
  110689. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110690. /**
  110691. * Update the defines for detail map usage
  110692. * @param defines the list of "defines" to update.
  110693. * @param scene defines the scene the material belongs to.
  110694. */
  110695. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110696. /**
  110697. * Binds the material data.
  110698. * @param uniformBuffer defines the Uniform buffer to fill in.
  110699. * @param scene defines the scene the material belongs to.
  110700. * @param isFrozen defines whether the material is frozen or not.
  110701. */
  110702. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110703. /**
  110704. * Checks to see if a texture is used in the material.
  110705. * @param texture - Base texture to use.
  110706. * @returns - Boolean specifying if a texture is used in the material.
  110707. */
  110708. hasTexture(texture: BaseTexture): boolean;
  110709. /**
  110710. * Returns an array of the actively used textures.
  110711. * @param activeTextures Array of BaseTextures
  110712. */
  110713. getActiveTextures(activeTextures: BaseTexture[]): void;
  110714. /**
  110715. * Returns the animatable textures.
  110716. * @param animatables Array of animatable textures.
  110717. */
  110718. getAnimatables(animatables: IAnimatable[]): void;
  110719. /**
  110720. * Disposes the resources of the material.
  110721. * @param forceDisposeTextures - Forces the disposal of all textures.
  110722. */
  110723. dispose(forceDisposeTextures?: boolean): void;
  110724. /**
  110725. * Get the current class name useful for serialization or dynamic coding.
  110726. * @returns "DetailMap"
  110727. */
  110728. getClassName(): string;
  110729. /**
  110730. * Add the required uniforms to the current list.
  110731. * @param uniforms defines the current uniform list.
  110732. */
  110733. static AddUniforms(uniforms: string[]): void;
  110734. /**
  110735. * Add the required samplers to the current list.
  110736. * @param samplers defines the current sampler list.
  110737. */
  110738. static AddSamplers(samplers: string[]): void;
  110739. /**
  110740. * Add the required uniforms to the current buffer.
  110741. * @param uniformBuffer defines the current uniform buffer.
  110742. */
  110743. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110744. /**
  110745. * Makes a duplicate of the current instance into another one.
  110746. * @param detailMap define the instance where to copy the info
  110747. */
  110748. copyTo(detailMap: DetailMapConfiguration): void;
  110749. /**
  110750. * Serializes this detail map instance
  110751. * @returns - An object with the serialized instance.
  110752. */
  110753. serialize(): any;
  110754. /**
  110755. * Parses a detail map setting from a serialized object.
  110756. * @param source - Serialized object.
  110757. * @param scene Defines the scene we are parsing for
  110758. * @param rootUrl Defines the rootUrl to load from
  110759. */
  110760. parse(source: any, scene: Scene, rootUrl: string): void;
  110761. }
  110762. }
  110763. declare module BABYLON {
  110764. /** @hidden */
  110765. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110766. MAINUV1: boolean;
  110767. MAINUV2: boolean;
  110768. DIFFUSE: boolean;
  110769. DIFFUSEDIRECTUV: number;
  110770. DETAIL: boolean;
  110771. DETAILDIRECTUV: number;
  110772. DETAIL_NORMALBLENDMETHOD: number;
  110773. AMBIENT: boolean;
  110774. AMBIENTDIRECTUV: number;
  110775. OPACITY: boolean;
  110776. OPACITYDIRECTUV: number;
  110777. OPACITYRGB: boolean;
  110778. REFLECTION: boolean;
  110779. EMISSIVE: boolean;
  110780. EMISSIVEDIRECTUV: number;
  110781. SPECULAR: boolean;
  110782. SPECULARDIRECTUV: number;
  110783. BUMP: boolean;
  110784. BUMPDIRECTUV: number;
  110785. PARALLAX: boolean;
  110786. PARALLAXOCCLUSION: boolean;
  110787. SPECULAROVERALPHA: boolean;
  110788. CLIPPLANE: boolean;
  110789. CLIPPLANE2: boolean;
  110790. CLIPPLANE3: boolean;
  110791. CLIPPLANE4: boolean;
  110792. CLIPPLANE5: boolean;
  110793. CLIPPLANE6: boolean;
  110794. ALPHATEST: boolean;
  110795. DEPTHPREPASS: boolean;
  110796. ALPHAFROMDIFFUSE: boolean;
  110797. POINTSIZE: boolean;
  110798. FOG: boolean;
  110799. SPECULARTERM: boolean;
  110800. DIFFUSEFRESNEL: boolean;
  110801. OPACITYFRESNEL: boolean;
  110802. REFLECTIONFRESNEL: boolean;
  110803. REFRACTIONFRESNEL: boolean;
  110804. EMISSIVEFRESNEL: boolean;
  110805. FRESNEL: boolean;
  110806. NORMAL: boolean;
  110807. UV1: boolean;
  110808. UV2: boolean;
  110809. VERTEXCOLOR: boolean;
  110810. VERTEXALPHA: boolean;
  110811. NUM_BONE_INFLUENCERS: number;
  110812. BonesPerMesh: number;
  110813. BONETEXTURE: boolean;
  110814. INSTANCES: boolean;
  110815. THIN_INSTANCES: boolean;
  110816. GLOSSINESS: boolean;
  110817. ROUGHNESS: boolean;
  110818. EMISSIVEASILLUMINATION: boolean;
  110819. LINKEMISSIVEWITHDIFFUSE: boolean;
  110820. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110821. LIGHTMAP: boolean;
  110822. LIGHTMAPDIRECTUV: number;
  110823. OBJECTSPACE_NORMALMAP: boolean;
  110824. USELIGHTMAPASSHADOWMAP: boolean;
  110825. REFLECTIONMAP_3D: boolean;
  110826. REFLECTIONMAP_SPHERICAL: boolean;
  110827. REFLECTIONMAP_PLANAR: boolean;
  110828. REFLECTIONMAP_CUBIC: boolean;
  110829. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110830. REFLECTIONMAP_PROJECTION: boolean;
  110831. REFLECTIONMAP_SKYBOX: boolean;
  110832. REFLECTIONMAP_EXPLICIT: boolean;
  110833. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110834. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110835. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110836. INVERTCUBICMAP: boolean;
  110837. LOGARITHMICDEPTH: boolean;
  110838. REFRACTION: boolean;
  110839. REFRACTIONMAP_3D: boolean;
  110840. REFLECTIONOVERALPHA: boolean;
  110841. TWOSIDEDLIGHTING: boolean;
  110842. SHADOWFLOAT: boolean;
  110843. MORPHTARGETS: boolean;
  110844. MORPHTARGETS_NORMAL: boolean;
  110845. MORPHTARGETS_TANGENT: boolean;
  110846. MORPHTARGETS_UV: boolean;
  110847. NUM_MORPH_INFLUENCERS: number;
  110848. NONUNIFORMSCALING: boolean;
  110849. PREMULTIPLYALPHA: boolean;
  110850. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110851. ALPHABLEND: boolean;
  110852. PREPASS: boolean;
  110853. PREPASS_IRRADIANCE: boolean;
  110854. PREPASS_IRRADIANCE_INDEX: number;
  110855. PREPASS_ALBEDO: boolean;
  110856. PREPASS_ALBEDO_INDEX: number;
  110857. PREPASS_DEPTHNORMAL: boolean;
  110858. PREPASS_DEPTHNORMAL_INDEX: number;
  110859. SCENE_MRT_COUNT: number;
  110860. RGBDLIGHTMAP: boolean;
  110861. RGBDREFLECTION: boolean;
  110862. RGBDREFRACTION: boolean;
  110863. IMAGEPROCESSING: boolean;
  110864. VIGNETTE: boolean;
  110865. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110866. VIGNETTEBLENDMODEOPAQUE: boolean;
  110867. TONEMAPPING: boolean;
  110868. TONEMAPPING_ACES: boolean;
  110869. CONTRAST: boolean;
  110870. COLORCURVES: boolean;
  110871. COLORGRADING: boolean;
  110872. COLORGRADING3D: boolean;
  110873. SAMPLER3DGREENDEPTH: boolean;
  110874. SAMPLER3DBGRMAP: boolean;
  110875. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110876. MULTIVIEW: boolean;
  110877. /**
  110878. * If the reflection texture on this material is in linear color space
  110879. * @hidden
  110880. */
  110881. IS_REFLECTION_LINEAR: boolean;
  110882. /**
  110883. * If the refraction texture on this material is in linear color space
  110884. * @hidden
  110885. */
  110886. IS_REFRACTION_LINEAR: boolean;
  110887. EXPOSURE: boolean;
  110888. constructor();
  110889. setReflectionMode(modeToEnable: string): void;
  110890. }
  110891. /**
  110892. * This is the default material used in Babylon. It is the best trade off between quality
  110893. * and performances.
  110894. * @see https://doc.babylonjs.com/babylon101/materials
  110895. */
  110896. export class StandardMaterial extends PushMaterial {
  110897. private _diffuseTexture;
  110898. /**
  110899. * The basic texture of the material as viewed under a light.
  110900. */
  110901. diffuseTexture: Nullable<BaseTexture>;
  110902. private _ambientTexture;
  110903. /**
  110904. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110905. */
  110906. ambientTexture: Nullable<BaseTexture>;
  110907. private _opacityTexture;
  110908. /**
  110909. * Define the transparency of the material from a texture.
  110910. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110911. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110912. */
  110913. opacityTexture: Nullable<BaseTexture>;
  110914. private _reflectionTexture;
  110915. /**
  110916. * Define the texture used to display the reflection.
  110917. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110918. */
  110919. reflectionTexture: Nullable<BaseTexture>;
  110920. private _emissiveTexture;
  110921. /**
  110922. * Define texture of the material as if self lit.
  110923. * This will be mixed in the final result even in the absence of light.
  110924. */
  110925. emissiveTexture: Nullable<BaseTexture>;
  110926. private _specularTexture;
  110927. /**
  110928. * Define how the color and intensity of the highlight given by the light in the material.
  110929. */
  110930. specularTexture: Nullable<BaseTexture>;
  110931. private _bumpTexture;
  110932. /**
  110933. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110934. * 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.
  110935. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110936. */
  110937. bumpTexture: Nullable<BaseTexture>;
  110938. private _lightmapTexture;
  110939. /**
  110940. * Complex lighting can be computationally expensive to compute at runtime.
  110941. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110942. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110943. */
  110944. lightmapTexture: Nullable<BaseTexture>;
  110945. private _refractionTexture;
  110946. /**
  110947. * Define the texture used to display the refraction.
  110948. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110949. */
  110950. refractionTexture: Nullable<BaseTexture>;
  110951. /**
  110952. * The color of the material lit by the environmental background lighting.
  110953. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110954. */
  110955. ambientColor: Color3;
  110956. /**
  110957. * The basic color of the material as viewed under a light.
  110958. */
  110959. diffuseColor: Color3;
  110960. /**
  110961. * Define how the color and intensity of the highlight given by the light in the material.
  110962. */
  110963. specularColor: Color3;
  110964. /**
  110965. * Define the color of the material as if self lit.
  110966. * This will be mixed in the final result even in the absence of light.
  110967. */
  110968. emissiveColor: Color3;
  110969. /**
  110970. * Defines how sharp are the highlights in the material.
  110971. * The bigger the value the sharper giving a more glossy feeling to the result.
  110972. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110973. */
  110974. specularPower: number;
  110975. private _useAlphaFromDiffuseTexture;
  110976. /**
  110977. * Does the transparency come from the diffuse texture alpha channel.
  110978. */
  110979. useAlphaFromDiffuseTexture: boolean;
  110980. private _useEmissiveAsIllumination;
  110981. /**
  110982. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110983. */
  110984. useEmissiveAsIllumination: boolean;
  110985. private _linkEmissiveWithDiffuse;
  110986. /**
  110987. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110988. * the emissive level when the final color is close to one.
  110989. */
  110990. linkEmissiveWithDiffuse: boolean;
  110991. private _useSpecularOverAlpha;
  110992. /**
  110993. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110994. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110995. */
  110996. useSpecularOverAlpha: boolean;
  110997. private _useReflectionOverAlpha;
  110998. /**
  110999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111001. */
  111002. useReflectionOverAlpha: boolean;
  111003. private _disableLighting;
  111004. /**
  111005. * Does lights from the scene impacts this material.
  111006. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111007. */
  111008. disableLighting: boolean;
  111009. private _useObjectSpaceNormalMap;
  111010. /**
  111011. * Allows using an object space normal map (instead of tangent space).
  111012. */
  111013. useObjectSpaceNormalMap: boolean;
  111014. private _useParallax;
  111015. /**
  111016. * Is parallax enabled or not.
  111017. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111018. */
  111019. useParallax: boolean;
  111020. private _useParallaxOcclusion;
  111021. /**
  111022. * Is parallax occlusion enabled or not.
  111023. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111024. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111025. */
  111026. useParallaxOcclusion: boolean;
  111027. /**
  111028. * 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.
  111029. */
  111030. parallaxScaleBias: number;
  111031. private _roughness;
  111032. /**
  111033. * Helps to define how blurry the reflections should appears in the material.
  111034. */
  111035. roughness: number;
  111036. /**
  111037. * In case of refraction, define the value of the index of refraction.
  111038. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111039. */
  111040. indexOfRefraction: number;
  111041. /**
  111042. * Invert the refraction texture alongside the y axis.
  111043. * It can be useful with procedural textures or probe for instance.
  111044. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111045. */
  111046. invertRefractionY: boolean;
  111047. /**
  111048. * Defines the alpha limits in alpha test mode.
  111049. */
  111050. alphaCutOff: number;
  111051. private _useLightmapAsShadowmap;
  111052. /**
  111053. * In case of light mapping, define whether the map contains light or shadow informations.
  111054. */
  111055. useLightmapAsShadowmap: boolean;
  111056. private _diffuseFresnelParameters;
  111057. /**
  111058. * Define the diffuse fresnel parameters of the material.
  111059. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111060. */
  111061. diffuseFresnelParameters: FresnelParameters;
  111062. private _opacityFresnelParameters;
  111063. /**
  111064. * Define the opacity fresnel parameters of the material.
  111065. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111066. */
  111067. opacityFresnelParameters: FresnelParameters;
  111068. private _reflectionFresnelParameters;
  111069. /**
  111070. * Define the reflection fresnel parameters of the material.
  111071. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111072. */
  111073. reflectionFresnelParameters: FresnelParameters;
  111074. private _refractionFresnelParameters;
  111075. /**
  111076. * Define the refraction fresnel parameters of the material.
  111077. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111078. */
  111079. refractionFresnelParameters: FresnelParameters;
  111080. private _emissiveFresnelParameters;
  111081. /**
  111082. * Define the emissive fresnel parameters of the material.
  111083. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111084. */
  111085. emissiveFresnelParameters: FresnelParameters;
  111086. private _useReflectionFresnelFromSpecular;
  111087. /**
  111088. * If true automatically deducts the fresnels values from the material specularity.
  111089. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111090. */
  111091. useReflectionFresnelFromSpecular: boolean;
  111092. private _useGlossinessFromSpecularMapAlpha;
  111093. /**
  111094. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111095. */
  111096. useGlossinessFromSpecularMapAlpha: boolean;
  111097. private _maxSimultaneousLights;
  111098. /**
  111099. * Defines the maximum number of lights that can be used in the material
  111100. */
  111101. maxSimultaneousLights: number;
  111102. private _invertNormalMapX;
  111103. /**
  111104. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111105. */
  111106. invertNormalMapX: boolean;
  111107. private _invertNormalMapY;
  111108. /**
  111109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111110. */
  111111. invertNormalMapY: boolean;
  111112. private _twoSidedLighting;
  111113. /**
  111114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111115. */
  111116. twoSidedLighting: boolean;
  111117. /**
  111118. * Default configuration related to image processing available in the standard Material.
  111119. */
  111120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111121. /**
  111122. * Gets the image processing configuration used either in this material.
  111123. */
  111124. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111125. /**
  111126. * Sets the Default image processing configuration used either in the this material.
  111127. *
  111128. * If sets to null, the scene one is in use.
  111129. */
  111130. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111131. /**
  111132. * Keep track of the image processing observer to allow dispose and replace.
  111133. */
  111134. private _imageProcessingObserver;
  111135. /**
  111136. * Attaches a new image processing configuration to the Standard Material.
  111137. * @param configuration
  111138. */
  111139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111140. /**
  111141. * Gets wether the color curves effect is enabled.
  111142. */
  111143. get cameraColorCurvesEnabled(): boolean;
  111144. /**
  111145. * Sets wether the color curves effect is enabled.
  111146. */
  111147. set cameraColorCurvesEnabled(value: boolean);
  111148. /**
  111149. * Gets wether the color grading effect is enabled.
  111150. */
  111151. get cameraColorGradingEnabled(): boolean;
  111152. /**
  111153. * Gets wether the color grading effect is enabled.
  111154. */
  111155. set cameraColorGradingEnabled(value: boolean);
  111156. /**
  111157. * Gets wether tonemapping is enabled or not.
  111158. */
  111159. get cameraToneMappingEnabled(): boolean;
  111160. /**
  111161. * Sets wether tonemapping is enabled or not
  111162. */
  111163. set cameraToneMappingEnabled(value: boolean);
  111164. /**
  111165. * The camera exposure used on this material.
  111166. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111167. * This corresponds to a photographic exposure.
  111168. */
  111169. get cameraExposure(): number;
  111170. /**
  111171. * The camera exposure used on this material.
  111172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111173. * This corresponds to a photographic exposure.
  111174. */
  111175. set cameraExposure(value: number);
  111176. /**
  111177. * Gets The camera contrast used on this material.
  111178. */
  111179. get cameraContrast(): number;
  111180. /**
  111181. * Sets The camera contrast used on this material.
  111182. */
  111183. set cameraContrast(value: number);
  111184. /**
  111185. * Gets the Color Grading 2D Lookup Texture.
  111186. */
  111187. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111188. /**
  111189. * Sets the Color Grading 2D Lookup Texture.
  111190. */
  111191. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111192. /**
  111193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111195. * 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;
  111196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111197. */
  111198. get cameraColorCurves(): Nullable<ColorCurves>;
  111199. /**
  111200. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111201. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111202. * 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;
  111203. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111204. */
  111205. set cameraColorCurves(value: Nullable<ColorCurves>);
  111206. /**
  111207. * Can this material render to several textures at once
  111208. */
  111209. get canRenderToMRT(): boolean;
  111210. /**
  111211. * Defines the detail map parameters for the material.
  111212. */
  111213. readonly detailMap: DetailMapConfiguration;
  111214. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111215. protected _worldViewProjectionMatrix: Matrix;
  111216. protected _globalAmbientColor: Color3;
  111217. protected _useLogarithmicDepth: boolean;
  111218. protected _rebuildInParallel: boolean;
  111219. /**
  111220. * Instantiates a new standard material.
  111221. * This is the default material used in Babylon. It is the best trade off between quality
  111222. * and performances.
  111223. * @see https://doc.babylonjs.com/babylon101/materials
  111224. * @param name Define the name of the material in the scene
  111225. * @param scene Define the scene the material belong to
  111226. */
  111227. constructor(name: string, scene: Scene);
  111228. /**
  111229. * Gets a boolean indicating that current material needs to register RTT
  111230. */
  111231. get hasRenderTargetTextures(): boolean;
  111232. /**
  111233. * Gets the current class name of the material e.g. "StandardMaterial"
  111234. * Mainly use in serialization.
  111235. * @returns the class name
  111236. */
  111237. getClassName(): string;
  111238. /**
  111239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111240. * You can try switching to logarithmic depth.
  111241. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111242. */
  111243. get useLogarithmicDepth(): boolean;
  111244. set useLogarithmicDepth(value: boolean);
  111245. /**
  111246. * Specifies if the material will require alpha blending
  111247. * @returns a boolean specifying if alpha blending is needed
  111248. */
  111249. needAlphaBlending(): boolean;
  111250. /**
  111251. * Specifies if this material should be rendered in alpha test mode
  111252. * @returns a boolean specifying if an alpha test is needed.
  111253. */
  111254. needAlphaTesting(): boolean;
  111255. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111256. /**
  111257. * Get the texture used for alpha test purpose.
  111258. * @returns the diffuse texture in case of the standard material.
  111259. */
  111260. getAlphaTestTexture(): Nullable<BaseTexture>;
  111261. /**
  111262. * Get if the submesh is ready to be used and all its information available.
  111263. * Child classes can use it to update shaders
  111264. * @param mesh defines the mesh to check
  111265. * @param subMesh defines which submesh to check
  111266. * @param useInstances specifies that instances should be used
  111267. * @returns a boolean indicating that the submesh is ready or not
  111268. */
  111269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111270. /**
  111271. * Builds the material UBO layouts.
  111272. * Used internally during the effect preparation.
  111273. */
  111274. buildUniformLayout(): void;
  111275. /**
  111276. * Unbinds the material from the mesh
  111277. */
  111278. unbind(): void;
  111279. /**
  111280. * Binds the submesh to this material by preparing the effect and shader to draw
  111281. * @param world defines the world transformation matrix
  111282. * @param mesh defines the mesh containing the submesh
  111283. * @param subMesh defines the submesh to bind the material to
  111284. */
  111285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111286. /**
  111287. * Get the list of animatables in the material.
  111288. * @returns the list of animatables object used in the material
  111289. */
  111290. getAnimatables(): IAnimatable[];
  111291. /**
  111292. * Gets the active textures from the material
  111293. * @returns an array of textures
  111294. */
  111295. getActiveTextures(): BaseTexture[];
  111296. /**
  111297. * Specifies if the material uses a texture
  111298. * @param texture defines the texture to check against the material
  111299. * @returns a boolean specifying if the material uses the texture
  111300. */
  111301. hasTexture(texture: BaseTexture): boolean;
  111302. /**
  111303. * Disposes the material
  111304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111306. */
  111307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111308. /**
  111309. * Makes a duplicate of the material, and gives it a new name
  111310. * @param name defines the new name for the duplicated material
  111311. * @returns the cloned material
  111312. */
  111313. clone(name: string): StandardMaterial;
  111314. /**
  111315. * Serializes this material in a JSON representation
  111316. * @returns the serialized material object
  111317. */
  111318. serialize(): any;
  111319. /**
  111320. * Creates a standard material from parsed material data
  111321. * @param source defines the JSON representation of the material
  111322. * @param scene defines the hosting scene
  111323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111324. * @returns a new standard material
  111325. */
  111326. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111327. /**
  111328. * Are diffuse textures enabled in the application.
  111329. */
  111330. static get DiffuseTextureEnabled(): boolean;
  111331. static set DiffuseTextureEnabled(value: boolean);
  111332. /**
  111333. * Are detail textures enabled in the application.
  111334. */
  111335. static get DetailTextureEnabled(): boolean;
  111336. static set DetailTextureEnabled(value: boolean);
  111337. /**
  111338. * Are ambient textures enabled in the application.
  111339. */
  111340. static get AmbientTextureEnabled(): boolean;
  111341. static set AmbientTextureEnabled(value: boolean);
  111342. /**
  111343. * Are opacity textures enabled in the application.
  111344. */
  111345. static get OpacityTextureEnabled(): boolean;
  111346. static set OpacityTextureEnabled(value: boolean);
  111347. /**
  111348. * Are reflection textures enabled in the application.
  111349. */
  111350. static get ReflectionTextureEnabled(): boolean;
  111351. static set ReflectionTextureEnabled(value: boolean);
  111352. /**
  111353. * Are emissive textures enabled in the application.
  111354. */
  111355. static get EmissiveTextureEnabled(): boolean;
  111356. static set EmissiveTextureEnabled(value: boolean);
  111357. /**
  111358. * Are specular textures enabled in the application.
  111359. */
  111360. static get SpecularTextureEnabled(): boolean;
  111361. static set SpecularTextureEnabled(value: boolean);
  111362. /**
  111363. * Are bump textures enabled in the application.
  111364. */
  111365. static get BumpTextureEnabled(): boolean;
  111366. static set BumpTextureEnabled(value: boolean);
  111367. /**
  111368. * Are lightmap textures enabled in the application.
  111369. */
  111370. static get LightmapTextureEnabled(): boolean;
  111371. static set LightmapTextureEnabled(value: boolean);
  111372. /**
  111373. * Are refraction textures enabled in the application.
  111374. */
  111375. static get RefractionTextureEnabled(): boolean;
  111376. static set RefractionTextureEnabled(value: boolean);
  111377. /**
  111378. * Are color grading textures enabled in the application.
  111379. */
  111380. static get ColorGradingTextureEnabled(): boolean;
  111381. static set ColorGradingTextureEnabled(value: boolean);
  111382. /**
  111383. * Are fresnels enabled in the application.
  111384. */
  111385. static get FresnelEnabled(): boolean;
  111386. static set FresnelEnabled(value: boolean);
  111387. }
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111392. *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.
  111393. * The SPS is also a particle system. It provides some methods to manage the particles.
  111394. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111395. *
  111396. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111397. */
  111398. export class SolidParticleSystem implements IDisposable {
  111399. /**
  111400. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111401. * Example : var p = SPS.particles[i];
  111402. */
  111403. particles: SolidParticle[];
  111404. /**
  111405. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111406. */
  111407. nbParticles: number;
  111408. /**
  111409. * If the particles must ever face the camera (default false). Useful for planar particles.
  111410. */
  111411. billboard: boolean;
  111412. /**
  111413. * Recompute normals when adding a shape
  111414. */
  111415. recomputeNormals: boolean;
  111416. /**
  111417. * This a counter ofr your own usage. It's not set by any SPS functions.
  111418. */
  111419. counter: number;
  111420. /**
  111421. * The SPS name. This name is also given to the underlying mesh.
  111422. */
  111423. name: string;
  111424. /**
  111425. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111426. */
  111427. mesh: Mesh;
  111428. /**
  111429. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111430. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111431. */
  111432. vars: any;
  111433. /**
  111434. * This array is populated when the SPS is set as 'pickable'.
  111435. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111436. * Each element of this array is an object `{idx: int, faceId: int}`.
  111437. * `idx` is the picked particle index in the `SPS.particles` array
  111438. * `faceId` is the picked face index counted within this particle.
  111439. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111440. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111441. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111442. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111443. */
  111444. pickedParticles: {
  111445. idx: number;
  111446. faceId: number;
  111447. }[];
  111448. /**
  111449. * This array is populated when the SPS is set as 'pickable'
  111450. * Each key of this array is a submesh index.
  111451. * Each element of this array is a second array defined like this :
  111452. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111453. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111454. * `idx` is the picked particle index in the `SPS.particles` array
  111455. * `faceId` is the picked face index counted within this particle.
  111456. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111457. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111458. */
  111459. pickedBySubMesh: {
  111460. idx: number;
  111461. faceId: number;
  111462. }[][];
  111463. /**
  111464. * This array is populated when `enableDepthSort` is set to true.
  111465. * Each element of this array is an instance of the class DepthSortedParticle.
  111466. */
  111467. depthSortedParticles: DepthSortedParticle[];
  111468. /**
  111469. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111470. * @hidden
  111471. */
  111472. _bSphereOnly: boolean;
  111473. /**
  111474. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111475. * @hidden
  111476. */
  111477. _bSphereRadiusFactor: number;
  111478. private _scene;
  111479. private _positions;
  111480. private _indices;
  111481. private _normals;
  111482. private _colors;
  111483. private _uvs;
  111484. private _indices32;
  111485. private _positions32;
  111486. private _normals32;
  111487. private _fixedNormal32;
  111488. private _colors32;
  111489. private _uvs32;
  111490. private _index;
  111491. private _updatable;
  111492. private _pickable;
  111493. private _isVisibilityBoxLocked;
  111494. private _alwaysVisible;
  111495. private _depthSort;
  111496. private _expandable;
  111497. private _shapeCounter;
  111498. private _copy;
  111499. private _color;
  111500. private _computeParticleColor;
  111501. private _computeParticleTexture;
  111502. private _computeParticleRotation;
  111503. private _computeParticleVertex;
  111504. private _computeBoundingBox;
  111505. private _depthSortParticles;
  111506. private _camera;
  111507. private _mustUnrotateFixedNormals;
  111508. private _particlesIntersect;
  111509. private _needs32Bits;
  111510. private _isNotBuilt;
  111511. private _lastParticleId;
  111512. private _idxOfId;
  111513. private _multimaterialEnabled;
  111514. private _useModelMaterial;
  111515. private _indicesByMaterial;
  111516. private _materialIndexes;
  111517. private _depthSortFunction;
  111518. private _materialSortFunction;
  111519. private _materials;
  111520. private _multimaterial;
  111521. private _materialIndexesById;
  111522. private _defaultMaterial;
  111523. private _autoUpdateSubMeshes;
  111524. private _tmpVertex;
  111525. /**
  111526. * Creates a SPS (Solid Particle System) object.
  111527. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111528. * @param scene (Scene) is the scene in which the SPS is added.
  111529. * @param options defines the options of the sps e.g.
  111530. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111531. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111532. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111533. * * 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.
  111534. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111535. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111536. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111537. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111538. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111539. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111540. */
  111541. constructor(name: string, scene: Scene, options?: {
  111542. updatable?: boolean;
  111543. isPickable?: boolean;
  111544. enableDepthSort?: boolean;
  111545. particleIntersection?: boolean;
  111546. boundingSphereOnly?: boolean;
  111547. bSphereRadiusFactor?: number;
  111548. expandable?: boolean;
  111549. useModelMaterial?: boolean;
  111550. enableMultiMaterial?: boolean;
  111551. });
  111552. /**
  111553. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111554. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111555. * @returns the created mesh
  111556. */
  111557. buildMesh(): Mesh;
  111558. /**
  111559. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111560. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111561. * Thus the particles generated from `digest()` have their property `position` set yet.
  111562. * @param mesh ( Mesh ) is the mesh to be digested
  111563. * @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
  111564. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111565. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111566. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111567. * @returns the current SPS
  111568. */
  111569. digest(mesh: Mesh, options?: {
  111570. facetNb?: number;
  111571. number?: number;
  111572. delta?: number;
  111573. storage?: [];
  111574. }): SolidParticleSystem;
  111575. /**
  111576. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111577. * @hidden
  111578. */
  111579. private _unrotateFixedNormals;
  111580. /**
  111581. * Resets the temporary working copy particle
  111582. * @hidden
  111583. */
  111584. private _resetCopy;
  111585. /**
  111586. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111587. * @param p the current index in the positions array to be updated
  111588. * @param ind the current index in the indices array
  111589. * @param shape a Vector3 array, the shape geometry
  111590. * @param positions the positions array to be updated
  111591. * @param meshInd the shape indices array
  111592. * @param indices the indices array to be updated
  111593. * @param meshUV the shape uv array
  111594. * @param uvs the uv array to be updated
  111595. * @param meshCol the shape color array
  111596. * @param colors the color array to be updated
  111597. * @param meshNor the shape normals array
  111598. * @param normals the normals array to be updated
  111599. * @param idx the particle index
  111600. * @param idxInShape the particle index in its shape
  111601. * @param options the addShape() method passed options
  111602. * @model the particle model
  111603. * @hidden
  111604. */
  111605. private _meshBuilder;
  111606. /**
  111607. * Returns a shape Vector3 array from positions float array
  111608. * @param positions float array
  111609. * @returns a vector3 array
  111610. * @hidden
  111611. */
  111612. private _posToShape;
  111613. /**
  111614. * Returns a shapeUV array from a float uvs (array deep copy)
  111615. * @param uvs as a float array
  111616. * @returns a shapeUV array
  111617. * @hidden
  111618. */
  111619. private _uvsToShapeUV;
  111620. /**
  111621. * Adds a new particle object in the particles array
  111622. * @param idx particle index in particles array
  111623. * @param id particle id
  111624. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111625. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111626. * @param model particle ModelShape object
  111627. * @param shapeId model shape identifier
  111628. * @param idxInShape index of the particle in the current model
  111629. * @param bInfo model bounding info object
  111630. * @param storage target storage array, if any
  111631. * @hidden
  111632. */
  111633. private _addParticle;
  111634. /**
  111635. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111636. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111637. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111638. * @param nb (positive integer) the number of particles to be created from this model
  111639. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111640. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111641. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111642. * @returns the number of shapes in the system
  111643. */
  111644. addShape(mesh: Mesh, nb: number, options?: {
  111645. positionFunction?: any;
  111646. vertexFunction?: any;
  111647. storage?: [];
  111648. }): number;
  111649. /**
  111650. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111651. * @hidden
  111652. */
  111653. private _rebuildParticle;
  111654. /**
  111655. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111656. * @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.
  111657. * @returns the SPS.
  111658. */
  111659. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111660. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111661. * Returns an array with the removed particles.
  111662. * 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.
  111663. * The SPS can't be empty so at least one particle needs to remain in place.
  111664. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111665. * @param start index of the first particle to remove
  111666. * @param end index of the last particle to remove (included)
  111667. * @returns an array populated with the removed particles
  111668. */
  111669. removeParticles(start: number, end: number): SolidParticle[];
  111670. /**
  111671. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111672. * @param solidParticleArray an array populated with Solid Particles objects
  111673. * @returns the SPS
  111674. */
  111675. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111676. /**
  111677. * Creates a new particle and modifies the SPS mesh geometry :
  111678. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111679. * - calls _addParticle() to populate the particle array
  111680. * factorized code from addShape() and insertParticlesFromArray()
  111681. * @param idx particle index in the particles array
  111682. * @param i particle index in its shape
  111683. * @param modelShape particle ModelShape object
  111684. * @param shape shape vertex array
  111685. * @param meshInd shape indices array
  111686. * @param meshUV shape uv array
  111687. * @param meshCol shape color array
  111688. * @param meshNor shape normals array
  111689. * @param bbInfo shape bounding info
  111690. * @param storage target particle storage
  111691. * @options addShape() passed options
  111692. * @hidden
  111693. */
  111694. private _insertNewParticle;
  111695. /**
  111696. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111697. * This method calls `updateParticle()` for each particle of the SPS.
  111698. * For an animated SPS, it is usually called within the render loop.
  111699. * 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.
  111700. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111701. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111702. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111703. * @returns the SPS.
  111704. */
  111705. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111706. /**
  111707. * Disposes the SPS.
  111708. */
  111709. dispose(): void;
  111710. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111711. * idx is the particle index in the SPS
  111712. * faceId is the picked face index counted within this particle.
  111713. * Returns null if the pickInfo can't identify a picked particle.
  111714. * @param pickingInfo (PickingInfo object)
  111715. * @returns {idx: number, faceId: number} or null
  111716. */
  111717. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111718. idx: number;
  111719. faceId: number;
  111720. }>;
  111721. /**
  111722. * Returns a SolidParticle object from its identifier : particle.id
  111723. * @param id (integer) the particle Id
  111724. * @returns the searched particle or null if not found in the SPS.
  111725. */
  111726. getParticleById(id: number): Nullable<SolidParticle>;
  111727. /**
  111728. * Returns a new array populated with the particles having the passed shapeId.
  111729. * @param shapeId (integer) the shape identifier
  111730. * @returns a new solid particle array
  111731. */
  111732. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111733. /**
  111734. * Populates the passed array "ref" with the particles having the passed shapeId.
  111735. * @param shapeId the shape identifier
  111736. * @returns the SPS
  111737. * @param ref
  111738. */
  111739. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111740. /**
  111741. * Computes the required SubMeshes according the materials assigned to the particles.
  111742. * @returns the solid particle system.
  111743. * Does nothing if called before the SPS mesh is built.
  111744. */
  111745. computeSubMeshes(): SolidParticleSystem;
  111746. /**
  111747. * Sorts the solid particles by material when MultiMaterial is enabled.
  111748. * Updates the indices32 array.
  111749. * Updates the indicesByMaterial array.
  111750. * Updates the mesh indices array.
  111751. * @returns the SPS
  111752. * @hidden
  111753. */
  111754. private _sortParticlesByMaterial;
  111755. /**
  111756. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111757. * @hidden
  111758. */
  111759. private _setMaterialIndexesById;
  111760. /**
  111761. * Returns an array with unique values of Materials from the passed array
  111762. * @param array the material array to be checked and filtered
  111763. * @hidden
  111764. */
  111765. private _filterUniqueMaterialId;
  111766. /**
  111767. * Sets a new Standard Material as _defaultMaterial if not already set.
  111768. * @hidden
  111769. */
  111770. private _setDefaultMaterial;
  111771. /**
  111772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111773. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111774. * @returns the SPS.
  111775. */
  111776. refreshVisibleSize(): SolidParticleSystem;
  111777. /**
  111778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111779. * @param size the size (float) of the visibility box
  111780. * note : this doesn't lock the SPS mesh bounding box.
  111781. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111782. */
  111783. setVisibilityBox(size: number): void;
  111784. /**
  111785. * Gets whether the SPS as always visible or not
  111786. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111787. */
  111788. get isAlwaysVisible(): boolean;
  111789. /**
  111790. * Sets the SPS as always visible or not
  111791. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111792. */
  111793. set isAlwaysVisible(val: boolean);
  111794. /**
  111795. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111796. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111797. */
  111798. set isVisibilityBoxLocked(val: boolean);
  111799. /**
  111800. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111801. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111802. */
  111803. get isVisibilityBoxLocked(): boolean;
  111804. /**
  111805. * Tells to `setParticles()` to compute the particle rotations or not.
  111806. * Default value : true. The SPS is faster when it's set to false.
  111807. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111808. */
  111809. set computeParticleRotation(val: boolean);
  111810. /**
  111811. * Tells to `setParticles()` to compute the particle colors or not.
  111812. * Default value : true. The SPS is faster when it's set to false.
  111813. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111814. */
  111815. set computeParticleColor(val: boolean);
  111816. set computeParticleTexture(val: boolean);
  111817. /**
  111818. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111819. * Default value : false. The SPS is faster when it's set to false.
  111820. * Note : the particle custom vertex positions aren't stored values.
  111821. */
  111822. set computeParticleVertex(val: boolean);
  111823. /**
  111824. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111825. */
  111826. set computeBoundingBox(val: boolean);
  111827. /**
  111828. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111829. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111830. * Default : `true`
  111831. */
  111832. set depthSortParticles(val: boolean);
  111833. /**
  111834. * Gets if `setParticles()` computes the particle rotations or not.
  111835. * Default value : true. The SPS is faster when it's set to false.
  111836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111837. */
  111838. get computeParticleRotation(): boolean;
  111839. /**
  111840. * Gets if `setParticles()` computes the particle colors or not.
  111841. * Default value : true. The SPS is faster when it's set to false.
  111842. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111843. */
  111844. get computeParticleColor(): boolean;
  111845. /**
  111846. * Gets if `setParticles()` computes the particle textures or not.
  111847. * Default value : true. The SPS is faster when it's set to false.
  111848. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111849. */
  111850. get computeParticleTexture(): boolean;
  111851. /**
  111852. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111853. * Default value : false. The SPS is faster when it's set to false.
  111854. * Note : the particle custom vertex positions aren't stored values.
  111855. */
  111856. get computeParticleVertex(): boolean;
  111857. /**
  111858. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111859. */
  111860. get computeBoundingBox(): boolean;
  111861. /**
  111862. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111863. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111864. * Default : `true`
  111865. */
  111866. get depthSortParticles(): boolean;
  111867. /**
  111868. * Gets if the SPS is created as expandable at construction time.
  111869. * Default : `false`
  111870. */
  111871. get expandable(): boolean;
  111872. /**
  111873. * Gets if the SPS supports the Multi Materials
  111874. */
  111875. get multimaterialEnabled(): boolean;
  111876. /**
  111877. * Gets if the SPS uses the model materials for its own multimaterial.
  111878. */
  111879. get useModelMaterial(): boolean;
  111880. /**
  111881. * The SPS used material array.
  111882. */
  111883. get materials(): Material[];
  111884. /**
  111885. * Sets the SPS MultiMaterial from the passed materials.
  111886. * Note : the passed array is internally copied and not used then by reference.
  111887. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111888. */
  111889. setMultiMaterial(materials: Material[]): void;
  111890. /**
  111891. * The SPS computed multimaterial object
  111892. */
  111893. get multimaterial(): MultiMaterial;
  111894. set multimaterial(mm: MultiMaterial);
  111895. /**
  111896. * If the subMeshes must be updated on the next call to setParticles()
  111897. */
  111898. get autoUpdateSubMeshes(): boolean;
  111899. set autoUpdateSubMeshes(val: boolean);
  111900. /**
  111901. * This function does nothing. It may be overwritten to set all the particle first values.
  111902. * The SPS doesn't call this function, you may have to call it by your own.
  111903. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111904. */
  111905. initParticles(): void;
  111906. /**
  111907. * This function does nothing. It may be overwritten to recycle a particle.
  111908. * The SPS doesn't call this function, you may have to call it by your own.
  111909. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111910. * @param particle The particle to recycle
  111911. * @returns the recycled particle
  111912. */
  111913. recycleParticle(particle: SolidParticle): SolidParticle;
  111914. /**
  111915. * Updates a particle : this function should be overwritten by the user.
  111916. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111917. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111918. * @example : just set a particle position or velocity and recycle conditions
  111919. * @param particle The particle to update
  111920. * @returns the updated particle
  111921. */
  111922. updateParticle(particle: SolidParticle): SolidParticle;
  111923. /**
  111924. * Updates a vertex of a particle : it can be overwritten by the user.
  111925. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111926. * @param particle the current particle
  111927. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111928. * @param pt the index of the current vertex in the particle shape
  111929. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111930. * @example : just set a vertex particle position or color
  111931. * @returns the sps
  111932. */
  111933. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111934. /**
  111935. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111936. * This does nothing and may be overwritten by the user.
  111937. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111938. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111939. * @param update the boolean update value actually passed to setParticles()
  111940. */
  111941. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111942. /**
  111943. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111944. * This will be passed three parameters.
  111945. * This does nothing and may be overwritten by the user.
  111946. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111947. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111948. * @param update the boolean update value actually passed to setParticles()
  111949. */
  111950. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111951. }
  111952. }
  111953. declare module BABYLON {
  111954. /**
  111955. * Represents one particle of a solid particle system.
  111956. */
  111957. export class SolidParticle {
  111958. /**
  111959. * particle global index
  111960. */
  111961. idx: number;
  111962. /**
  111963. * particle identifier
  111964. */
  111965. id: number;
  111966. /**
  111967. * The color of the particle
  111968. */
  111969. color: Nullable<Color4>;
  111970. /**
  111971. * The world space position of the particle.
  111972. */
  111973. position: Vector3;
  111974. /**
  111975. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111976. */
  111977. rotation: Vector3;
  111978. /**
  111979. * The world space rotation quaternion of the particle.
  111980. */
  111981. rotationQuaternion: Nullable<Quaternion>;
  111982. /**
  111983. * The scaling of the particle.
  111984. */
  111985. scaling: Vector3;
  111986. /**
  111987. * The uvs of the particle.
  111988. */
  111989. uvs: Vector4;
  111990. /**
  111991. * The current speed of the particle.
  111992. */
  111993. velocity: Vector3;
  111994. /**
  111995. * The pivot point in the particle local space.
  111996. */
  111997. pivot: Vector3;
  111998. /**
  111999. * Must the particle be translated from its pivot point in its local space ?
  112000. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112001. * Default : false
  112002. */
  112003. translateFromPivot: boolean;
  112004. /**
  112005. * Is the particle active or not ?
  112006. */
  112007. alive: boolean;
  112008. /**
  112009. * Is the particle visible or not ?
  112010. */
  112011. isVisible: boolean;
  112012. /**
  112013. * Index of this particle in the global "positions" array (Internal use)
  112014. * @hidden
  112015. */
  112016. _pos: number;
  112017. /**
  112018. * @hidden Index of this particle in the global "indices" array (Internal use)
  112019. */
  112020. _ind: number;
  112021. /**
  112022. * @hidden ModelShape of this particle (Internal use)
  112023. */
  112024. _model: ModelShape;
  112025. /**
  112026. * ModelShape id of this particle
  112027. */
  112028. shapeId: number;
  112029. /**
  112030. * Index of the particle in its shape id
  112031. */
  112032. idxInShape: number;
  112033. /**
  112034. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112035. */
  112036. _modelBoundingInfo: BoundingInfo;
  112037. /**
  112038. * @hidden Particle BoundingInfo object (Internal use)
  112039. */
  112040. _boundingInfo: BoundingInfo;
  112041. /**
  112042. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112043. */
  112044. _sps: SolidParticleSystem;
  112045. /**
  112046. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112047. */
  112048. _stillInvisible: boolean;
  112049. /**
  112050. * @hidden Last computed particle rotation matrix
  112051. */
  112052. _rotationMatrix: number[];
  112053. /**
  112054. * Parent particle Id, if any.
  112055. * Default null.
  112056. */
  112057. parentId: Nullable<number>;
  112058. /**
  112059. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112060. */
  112061. materialIndex: Nullable<number>;
  112062. /**
  112063. * Custom object or properties.
  112064. */
  112065. props: Nullable<any>;
  112066. /**
  112067. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112068. * The possible values are :
  112069. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112070. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112071. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112072. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112073. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112074. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112075. * */
  112076. cullingStrategy: number;
  112077. /**
  112078. * @hidden Internal global position in the SPS.
  112079. */
  112080. _globalPosition: Vector3;
  112081. /**
  112082. * Creates a Solid Particle object.
  112083. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112084. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112085. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112086. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112087. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112088. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112089. * @param shapeId (integer) is the model shape identifier in the SPS.
  112090. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112091. * @param sps defines the sps it is associated to
  112092. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112093. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112094. */
  112095. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112096. /**
  112097. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112098. * @param target the particle target
  112099. * @returns the current particle
  112100. */
  112101. copyToRef(target: SolidParticle): SolidParticle;
  112102. /**
  112103. * Legacy support, changed scale to scaling
  112104. */
  112105. get scale(): Vector3;
  112106. /**
  112107. * Legacy support, changed scale to scaling
  112108. */
  112109. set scale(scale: Vector3);
  112110. /**
  112111. * Legacy support, changed quaternion to rotationQuaternion
  112112. */
  112113. get quaternion(): Nullable<Quaternion>;
  112114. /**
  112115. * Legacy support, changed quaternion to rotationQuaternion
  112116. */
  112117. set quaternion(q: Nullable<Quaternion>);
  112118. /**
  112119. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112120. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112121. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112122. * @returns true if it intersects
  112123. */
  112124. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112125. /**
  112126. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112127. * A particle is in the frustum if its bounding box intersects the frustum
  112128. * @param frustumPlanes defines the frustum to test
  112129. * @returns true if the particle is in the frustum planes
  112130. */
  112131. isInFrustum(frustumPlanes: Plane[]): boolean;
  112132. /**
  112133. * get the rotation matrix of the particle
  112134. * @hidden
  112135. */
  112136. getRotationMatrix(m: Matrix): void;
  112137. }
  112138. /**
  112139. * Represents the shape of the model used by one particle of a solid particle system.
  112140. * SPS internal tool, don't use it manually.
  112141. */
  112142. export class ModelShape {
  112143. /**
  112144. * The shape id
  112145. * @hidden
  112146. */
  112147. shapeID: number;
  112148. /**
  112149. * flat array of model positions (internal use)
  112150. * @hidden
  112151. */
  112152. _shape: Vector3[];
  112153. /**
  112154. * flat array of model UVs (internal use)
  112155. * @hidden
  112156. */
  112157. _shapeUV: number[];
  112158. /**
  112159. * color array of the model
  112160. * @hidden
  112161. */
  112162. _shapeColors: number[];
  112163. /**
  112164. * indices array of the model
  112165. * @hidden
  112166. */
  112167. _indices: number[];
  112168. /**
  112169. * normals array of the model
  112170. * @hidden
  112171. */
  112172. _normals: number[];
  112173. /**
  112174. * length of the shape in the model indices array (internal use)
  112175. * @hidden
  112176. */
  112177. _indicesLength: number;
  112178. /**
  112179. * Custom position function (internal use)
  112180. * @hidden
  112181. */
  112182. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112183. /**
  112184. * Custom vertex function (internal use)
  112185. * @hidden
  112186. */
  112187. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112188. /**
  112189. * Model material (internal use)
  112190. * @hidden
  112191. */
  112192. _material: Nullable<Material>;
  112193. /**
  112194. * 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.
  112195. * SPS internal tool, don't use it manually.
  112196. * @hidden
  112197. */
  112198. 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>);
  112199. }
  112200. /**
  112201. * Represents a Depth Sorted Particle in the solid particle system.
  112202. * @hidden
  112203. */
  112204. export class DepthSortedParticle {
  112205. /**
  112206. * Particle index
  112207. */
  112208. idx: number;
  112209. /**
  112210. * Index of the particle in the "indices" array
  112211. */
  112212. ind: number;
  112213. /**
  112214. * Length of the particle shape in the "indices" array
  112215. */
  112216. indicesLength: number;
  112217. /**
  112218. * Squared distance from the particle to the camera
  112219. */
  112220. sqDistance: number;
  112221. /**
  112222. * Material index when used with MultiMaterials
  112223. */
  112224. materialIndex: number;
  112225. /**
  112226. * Creates a new sorted particle
  112227. * @param materialIndex
  112228. */
  112229. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112230. }
  112231. /**
  112232. * Represents a solid particle vertex
  112233. */
  112234. export class SolidParticleVertex {
  112235. /**
  112236. * Vertex position
  112237. */
  112238. position: Vector3;
  112239. /**
  112240. * Vertex color
  112241. */
  112242. color: Color4;
  112243. /**
  112244. * Vertex UV
  112245. */
  112246. uv: Vector2;
  112247. /**
  112248. * Creates a new solid particle vertex
  112249. */
  112250. constructor();
  112251. /** Vertex x coordinate */
  112252. get x(): number;
  112253. set x(val: number);
  112254. /** Vertex y coordinate */
  112255. get y(): number;
  112256. set y(val: number);
  112257. /** Vertex z coordinate */
  112258. get z(): number;
  112259. set z(val: number);
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /**
  112264. * @hidden
  112265. */
  112266. export class _MeshCollisionData {
  112267. _checkCollisions: boolean;
  112268. _collisionMask: number;
  112269. _collisionGroup: number;
  112270. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112271. _collider: Nullable<Collider>;
  112272. _oldPositionForCollisions: Vector3;
  112273. _diffPositionForCollisions: Vector3;
  112274. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112275. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112276. _collisionResponse: boolean;
  112277. }
  112278. }
  112279. declare module BABYLON {
  112280. /** @hidden */
  112281. class _FacetDataStorage {
  112282. facetPositions: Vector3[];
  112283. facetNormals: Vector3[];
  112284. facetPartitioning: number[][];
  112285. facetNb: number;
  112286. partitioningSubdivisions: number;
  112287. partitioningBBoxRatio: number;
  112288. facetDataEnabled: boolean;
  112289. facetParameters: any;
  112290. bbSize: Vector3;
  112291. subDiv: {
  112292. max: number;
  112293. X: number;
  112294. Y: number;
  112295. Z: number;
  112296. };
  112297. facetDepthSort: boolean;
  112298. facetDepthSortEnabled: boolean;
  112299. depthSortedIndices: IndicesArray;
  112300. depthSortedFacets: {
  112301. ind: number;
  112302. sqDistance: number;
  112303. }[];
  112304. facetDepthSortFunction: (f1: {
  112305. ind: number;
  112306. sqDistance: number;
  112307. }, f2: {
  112308. ind: number;
  112309. sqDistance: number;
  112310. }) => number;
  112311. facetDepthSortFrom: Vector3;
  112312. facetDepthSortOrigin: Vector3;
  112313. invertedMatrix: Matrix;
  112314. }
  112315. /**
  112316. * @hidden
  112317. **/
  112318. class _InternalAbstractMeshDataInfo {
  112319. _hasVertexAlpha: boolean;
  112320. _useVertexColors: boolean;
  112321. _numBoneInfluencers: number;
  112322. _applyFog: boolean;
  112323. _receiveShadows: boolean;
  112324. _facetData: _FacetDataStorage;
  112325. _visibility: number;
  112326. _skeleton: Nullable<Skeleton>;
  112327. _layerMask: number;
  112328. _computeBonesUsingShaders: boolean;
  112329. _isActive: boolean;
  112330. _onlyForInstances: boolean;
  112331. _isActiveIntermediate: boolean;
  112332. _onlyForInstancesIntermediate: boolean;
  112333. _actAsRegularMesh: boolean;
  112334. }
  112335. /**
  112336. * Class used to store all common mesh properties
  112337. */
  112338. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112339. /** No occlusion */
  112340. static OCCLUSION_TYPE_NONE: number;
  112341. /** Occlusion set to optimisitic */
  112342. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112343. /** Occlusion set to strict */
  112344. static OCCLUSION_TYPE_STRICT: number;
  112345. /** Use an accurante occlusion algorithm */
  112346. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112347. /** Use a conservative occlusion algorithm */
  112348. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112349. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112350. * Test order :
  112351. * Is the bounding sphere outside the frustum ?
  112352. * If not, are the bounding box vertices outside the frustum ?
  112353. * It not, then the cullable object is in the frustum.
  112354. */
  112355. static readonly CULLINGSTRATEGY_STANDARD: number;
  112356. /** Culling strategy : Bounding Sphere Only.
  112357. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112358. * It's also less accurate than the standard because some not visible objects can still be selected.
  112359. * Test : is the bounding sphere outside the frustum ?
  112360. * If not, then the cullable object is in the frustum.
  112361. */
  112362. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112363. /** Culling strategy : Optimistic Inclusion.
  112364. * This in an inclusion test first, then the standard exclusion test.
  112365. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112366. * 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.
  112367. * Anyway, it's as accurate as the standard strategy.
  112368. * Test :
  112369. * Is the cullable object bounding sphere center in the frustum ?
  112370. * If not, apply the default culling strategy.
  112371. */
  112372. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112373. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112374. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112375. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112376. * 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.
  112377. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112378. * Test :
  112379. * Is the cullable object bounding sphere center in the frustum ?
  112380. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112381. */
  112382. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112383. /**
  112384. * No billboard
  112385. */
  112386. static get BILLBOARDMODE_NONE(): number;
  112387. /** Billboard on X axis */
  112388. static get BILLBOARDMODE_X(): number;
  112389. /** Billboard on Y axis */
  112390. static get BILLBOARDMODE_Y(): number;
  112391. /** Billboard on Z axis */
  112392. static get BILLBOARDMODE_Z(): number;
  112393. /** Billboard on all axes */
  112394. static get BILLBOARDMODE_ALL(): number;
  112395. /** Billboard on using position instead of orientation */
  112396. static get BILLBOARDMODE_USE_POSITION(): number;
  112397. /** @hidden */
  112398. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112399. /**
  112400. * The culling strategy to use to check whether the mesh must be rendered or not.
  112401. * This value can be changed at any time and will be used on the next render mesh selection.
  112402. * The possible values are :
  112403. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112404. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112405. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112406. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112407. * Please read each static variable documentation to get details about the culling process.
  112408. * */
  112409. cullingStrategy: number;
  112410. /**
  112411. * Gets the number of facets in the mesh
  112412. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112413. */
  112414. get facetNb(): number;
  112415. /**
  112416. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112418. */
  112419. get partitioningSubdivisions(): number;
  112420. set partitioningSubdivisions(nb: number);
  112421. /**
  112422. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112423. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112424. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112425. */
  112426. get partitioningBBoxRatio(): number;
  112427. set partitioningBBoxRatio(ratio: number);
  112428. /**
  112429. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112430. * Works only for updatable meshes.
  112431. * Doesn't work with multi-materials
  112432. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112433. */
  112434. get mustDepthSortFacets(): boolean;
  112435. set mustDepthSortFacets(sort: boolean);
  112436. /**
  112437. * The location (Vector3) where the facet depth sort must be computed from.
  112438. * By default, the active camera position.
  112439. * Used only when facet depth sort is enabled
  112440. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112441. */
  112442. get facetDepthSortFrom(): Vector3;
  112443. set facetDepthSortFrom(location: Vector3);
  112444. /**
  112445. * gets a boolean indicating if facetData is enabled
  112446. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112447. */
  112448. get isFacetDataEnabled(): boolean;
  112449. /** @hidden */
  112450. _updateNonUniformScalingState(value: boolean): boolean;
  112451. /**
  112452. * An event triggered when this mesh collides with another one
  112453. */
  112454. onCollideObservable: Observable<AbstractMesh>;
  112455. /** Set a function to call when this mesh collides with another one */
  112456. set onCollide(callback: () => void);
  112457. /**
  112458. * An event triggered when the collision's position changes
  112459. */
  112460. onCollisionPositionChangeObservable: Observable<Vector3>;
  112461. /** Set a function to call when the collision's position changes */
  112462. set onCollisionPositionChange(callback: () => void);
  112463. /**
  112464. * An event triggered when material is changed
  112465. */
  112466. onMaterialChangedObservable: Observable<AbstractMesh>;
  112467. /**
  112468. * Gets or sets the orientation for POV movement & rotation
  112469. */
  112470. definedFacingForward: boolean;
  112471. /** @hidden */
  112472. _occlusionQuery: Nullable<WebGLQuery>;
  112473. /** @hidden */
  112474. _renderingGroup: Nullable<RenderingGroup>;
  112475. /**
  112476. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112477. */
  112478. get visibility(): number;
  112479. /**
  112480. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112481. */
  112482. set visibility(value: number);
  112483. /** Gets or sets the alpha index used to sort transparent meshes
  112484. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112485. */
  112486. alphaIndex: number;
  112487. /**
  112488. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112489. */
  112490. isVisible: boolean;
  112491. /**
  112492. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112493. */
  112494. isPickable: boolean;
  112495. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112496. showSubMeshesBoundingBox: boolean;
  112497. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112498. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112499. */
  112500. isBlocker: boolean;
  112501. /**
  112502. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112503. */
  112504. enablePointerMoveEvents: boolean;
  112505. private _renderingGroupId;
  112506. /**
  112507. * Specifies the rendering group id for this mesh (0 by default)
  112508. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112509. */
  112510. get renderingGroupId(): number;
  112511. set renderingGroupId(value: number);
  112512. private _material;
  112513. /** Gets or sets current material */
  112514. get material(): Nullable<Material>;
  112515. set material(value: Nullable<Material>);
  112516. /**
  112517. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112518. * @see https://doc.babylonjs.com/babylon101/shadows
  112519. */
  112520. get receiveShadows(): boolean;
  112521. set receiveShadows(value: boolean);
  112522. /** Defines color to use when rendering outline */
  112523. outlineColor: Color3;
  112524. /** Define width to use when rendering outline */
  112525. outlineWidth: number;
  112526. /** Defines color to use when rendering overlay */
  112527. overlayColor: Color3;
  112528. /** Defines alpha to use when rendering overlay */
  112529. overlayAlpha: number;
  112530. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112531. get hasVertexAlpha(): boolean;
  112532. set hasVertexAlpha(value: boolean);
  112533. /** 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) */
  112534. get useVertexColors(): boolean;
  112535. set useVertexColors(value: boolean);
  112536. /**
  112537. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112538. */
  112539. get computeBonesUsingShaders(): boolean;
  112540. set computeBonesUsingShaders(value: boolean);
  112541. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112542. get numBoneInfluencers(): number;
  112543. set numBoneInfluencers(value: number);
  112544. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112545. get applyFog(): boolean;
  112546. set applyFog(value: boolean);
  112547. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112548. useOctreeForRenderingSelection: boolean;
  112549. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112550. useOctreeForPicking: boolean;
  112551. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112552. useOctreeForCollisions: boolean;
  112553. /**
  112554. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112555. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112556. */
  112557. get layerMask(): number;
  112558. set layerMask(value: number);
  112559. /**
  112560. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112561. */
  112562. alwaysSelectAsActiveMesh: boolean;
  112563. /**
  112564. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112565. */
  112566. doNotSyncBoundingInfo: boolean;
  112567. /**
  112568. * Gets or sets the current action manager
  112569. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112570. */
  112571. actionManager: Nullable<AbstractActionManager>;
  112572. private _meshCollisionData;
  112573. /**
  112574. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112575. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112576. */
  112577. ellipsoid: Vector3;
  112578. /**
  112579. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112580. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112581. */
  112582. ellipsoidOffset: Vector3;
  112583. /**
  112584. * Gets or sets a collision mask used to mask collisions (default is -1).
  112585. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112586. */
  112587. get collisionMask(): number;
  112588. set collisionMask(mask: number);
  112589. /**
  112590. * Gets or sets a collision response flag (default is true).
  112591. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112592. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112593. * to respond to the collision.
  112594. */
  112595. get collisionResponse(): boolean;
  112596. set collisionResponse(response: boolean);
  112597. /**
  112598. * Gets or sets the current collision group mask (-1 by default).
  112599. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112600. */
  112601. get collisionGroup(): number;
  112602. set collisionGroup(mask: number);
  112603. /**
  112604. * Gets or sets current surrounding meshes (null by default).
  112605. *
  112606. * By default collision detection is tested against every mesh in the scene.
  112607. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112608. * meshes will be tested for the collision.
  112609. *
  112610. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112611. */
  112612. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112613. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112614. /**
  112615. * Defines edge width used when edgesRenderer is enabled
  112616. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112617. */
  112618. edgesWidth: number;
  112619. /**
  112620. * Defines edge color used when edgesRenderer is enabled
  112621. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112622. */
  112623. edgesColor: Color4;
  112624. /** @hidden */
  112625. _edgesRenderer: Nullable<IEdgesRenderer>;
  112626. /** @hidden */
  112627. _masterMesh: Nullable<AbstractMesh>;
  112628. /** @hidden */
  112629. _boundingInfo: Nullable<BoundingInfo>;
  112630. /** @hidden */
  112631. _renderId: number;
  112632. /**
  112633. * Gets or sets the list of subMeshes
  112634. * @see https://doc.babylonjs.com/how_to/multi_materials
  112635. */
  112636. subMeshes: SubMesh[];
  112637. /** @hidden */
  112638. _intersectionsInProgress: AbstractMesh[];
  112639. /** @hidden */
  112640. _unIndexed: boolean;
  112641. /** @hidden */
  112642. _lightSources: Light[];
  112643. /** Gets the list of lights affecting that mesh */
  112644. get lightSources(): Light[];
  112645. /** @hidden */
  112646. get _positions(): Nullable<Vector3[]>;
  112647. /** @hidden */
  112648. _waitingData: {
  112649. lods: Nullable<any>;
  112650. actions: Nullable<any>;
  112651. freezeWorldMatrix: Nullable<boolean>;
  112652. };
  112653. /** @hidden */
  112654. _bonesTransformMatrices: Nullable<Float32Array>;
  112655. /** @hidden */
  112656. _transformMatrixTexture: Nullable<RawTexture>;
  112657. /**
  112658. * Gets or sets a skeleton to apply skining transformations
  112659. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112660. */
  112661. set skeleton(value: Nullable<Skeleton>);
  112662. get skeleton(): Nullable<Skeleton>;
  112663. /**
  112664. * An event triggered when the mesh is rebuilt.
  112665. */
  112666. onRebuildObservable: Observable<AbstractMesh>;
  112667. /**
  112668. * Creates a new AbstractMesh
  112669. * @param name defines the name of the mesh
  112670. * @param scene defines the hosting scene
  112671. */
  112672. constructor(name: string, scene?: Nullable<Scene>);
  112673. /**
  112674. * Returns the string "AbstractMesh"
  112675. * @returns "AbstractMesh"
  112676. */
  112677. getClassName(): string;
  112678. /**
  112679. * Gets a string representation of the current mesh
  112680. * @param fullDetails defines a boolean indicating if full details must be included
  112681. * @returns a string representation of the current mesh
  112682. */
  112683. toString(fullDetails?: boolean): string;
  112684. /**
  112685. * @hidden
  112686. */
  112687. protected _getEffectiveParent(): Nullable<Node>;
  112688. /** @hidden */
  112689. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112690. /** @hidden */
  112691. _rebuild(): void;
  112692. /** @hidden */
  112693. _resyncLightSources(): void;
  112694. /** @hidden */
  112695. _resyncLightSource(light: Light): void;
  112696. /** @hidden */
  112697. _unBindEffect(): void;
  112698. /** @hidden */
  112699. _removeLightSource(light: Light, dispose: boolean): void;
  112700. private _markSubMeshesAsDirty;
  112701. /** @hidden */
  112702. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112703. /** @hidden */
  112704. _markSubMeshesAsAttributesDirty(): void;
  112705. /** @hidden */
  112706. _markSubMeshesAsMiscDirty(): void;
  112707. /**
  112708. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112709. */
  112710. get scaling(): Vector3;
  112711. set scaling(newScaling: Vector3);
  112712. /**
  112713. * Returns true if the mesh is blocked. Implemented by child classes
  112714. */
  112715. get isBlocked(): boolean;
  112716. /**
  112717. * Returns the mesh itself by default. Implemented by child classes
  112718. * @param camera defines the camera to use to pick the right LOD level
  112719. * @returns the currentAbstractMesh
  112720. */
  112721. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112722. /**
  112723. * Returns 0 by default. Implemented by child classes
  112724. * @returns an integer
  112725. */
  112726. getTotalVertices(): number;
  112727. /**
  112728. * Returns a positive integer : the total number of indices in this mesh geometry.
  112729. * @returns the numner of indices or zero if the mesh has no geometry.
  112730. */
  112731. getTotalIndices(): number;
  112732. /**
  112733. * Returns null by default. Implemented by child classes
  112734. * @returns null
  112735. */
  112736. getIndices(): Nullable<IndicesArray>;
  112737. /**
  112738. * Returns the array of the requested vertex data kind. Implemented by child classes
  112739. * @param kind defines the vertex data kind to use
  112740. * @returns null
  112741. */
  112742. getVerticesData(kind: string): Nullable<FloatArray>;
  112743. /**
  112744. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112745. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112746. * Note that a new underlying VertexBuffer object is created each call.
  112747. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112748. * @param kind defines vertex data kind:
  112749. * * VertexBuffer.PositionKind
  112750. * * VertexBuffer.UVKind
  112751. * * VertexBuffer.UV2Kind
  112752. * * VertexBuffer.UV3Kind
  112753. * * VertexBuffer.UV4Kind
  112754. * * VertexBuffer.UV5Kind
  112755. * * VertexBuffer.UV6Kind
  112756. * * VertexBuffer.ColorKind
  112757. * * VertexBuffer.MatricesIndicesKind
  112758. * * VertexBuffer.MatricesIndicesExtraKind
  112759. * * VertexBuffer.MatricesWeightsKind
  112760. * * VertexBuffer.MatricesWeightsExtraKind
  112761. * @param data defines the data source
  112762. * @param updatable defines if the data must be flagged as updatable (or static)
  112763. * @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
  112764. * @returns the current mesh
  112765. */
  112766. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112767. /**
  112768. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112769. * If the mesh has no geometry, it is simply returned as it is.
  112770. * @param kind defines vertex data kind:
  112771. * * VertexBuffer.PositionKind
  112772. * * VertexBuffer.UVKind
  112773. * * VertexBuffer.UV2Kind
  112774. * * VertexBuffer.UV3Kind
  112775. * * VertexBuffer.UV4Kind
  112776. * * VertexBuffer.UV5Kind
  112777. * * VertexBuffer.UV6Kind
  112778. * * VertexBuffer.ColorKind
  112779. * * VertexBuffer.MatricesIndicesKind
  112780. * * VertexBuffer.MatricesIndicesExtraKind
  112781. * * VertexBuffer.MatricesWeightsKind
  112782. * * VertexBuffer.MatricesWeightsExtraKind
  112783. * @param data defines the data source
  112784. * @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
  112785. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112786. * @returns the current mesh
  112787. */
  112788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112789. /**
  112790. * Sets the mesh indices,
  112791. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112792. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112793. * @param totalVertices Defines the total number of vertices
  112794. * @returns the current mesh
  112795. */
  112796. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112797. /**
  112798. * Gets a boolean indicating if specific vertex data is present
  112799. * @param kind defines the vertex data kind to use
  112800. * @returns true is data kind is present
  112801. */
  112802. isVerticesDataPresent(kind: string): boolean;
  112803. /**
  112804. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112805. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112806. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112807. * @returns a BoundingInfo
  112808. */
  112809. getBoundingInfo(): BoundingInfo;
  112810. /**
  112811. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112812. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112813. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112814. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112815. * @returns the current mesh
  112816. */
  112817. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112818. /**
  112819. * Overwrite the current bounding info
  112820. * @param boundingInfo defines the new bounding info
  112821. * @returns the current mesh
  112822. */
  112823. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112824. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112825. get useBones(): boolean;
  112826. /** @hidden */
  112827. _preActivate(): void;
  112828. /** @hidden */
  112829. _preActivateForIntermediateRendering(renderId: number): void;
  112830. /** @hidden */
  112831. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112832. /** @hidden */
  112833. _postActivate(): void;
  112834. /** @hidden */
  112835. _freeze(): void;
  112836. /** @hidden */
  112837. _unFreeze(): void;
  112838. /**
  112839. * Gets the current world matrix
  112840. * @returns a Matrix
  112841. */
  112842. getWorldMatrix(): Matrix;
  112843. /** @hidden */
  112844. _getWorldMatrixDeterminant(): number;
  112845. /**
  112846. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112847. */
  112848. get isAnInstance(): boolean;
  112849. /**
  112850. * Gets a boolean indicating if this mesh has instances
  112851. */
  112852. get hasInstances(): boolean;
  112853. /**
  112854. * Gets a boolean indicating if this mesh has thin instances
  112855. */
  112856. get hasThinInstances(): boolean;
  112857. /**
  112858. * Perform relative position change from the point of view of behind the front of the mesh.
  112859. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112860. * Supports definition of mesh facing forward or backward
  112861. * @param amountRight defines the distance on the right axis
  112862. * @param amountUp defines the distance on the up axis
  112863. * @param amountForward defines the distance on the forward axis
  112864. * @returns the current mesh
  112865. */
  112866. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112867. /**
  112868. * Calculate relative position change from the point of view of behind the front of the mesh.
  112869. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112870. * Supports definition of mesh facing forward or backward
  112871. * @param amountRight defines the distance on the right axis
  112872. * @param amountUp defines the distance on the up axis
  112873. * @param amountForward defines the distance on the forward axis
  112874. * @returns the new displacement vector
  112875. */
  112876. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112877. /**
  112878. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112879. * Supports definition of mesh facing forward or backward
  112880. * @param flipBack defines the flip
  112881. * @param twirlClockwise defines the twirl
  112882. * @param tiltRight defines the tilt
  112883. * @returns the current mesh
  112884. */
  112885. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112886. /**
  112887. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112888. * Supports definition of mesh facing forward or backward.
  112889. * @param flipBack defines the flip
  112890. * @param twirlClockwise defines the twirl
  112891. * @param tiltRight defines the tilt
  112892. * @returns the new rotation vector
  112893. */
  112894. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112895. /**
  112896. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112897. * This means the mesh underlying bounding box and sphere are recomputed.
  112898. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112899. * @returns the current mesh
  112900. */
  112901. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112902. /** @hidden */
  112903. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112904. /** @hidden */
  112905. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112906. /** @hidden */
  112907. _updateBoundingInfo(): AbstractMesh;
  112908. /** @hidden */
  112909. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112910. /** @hidden */
  112911. protected _afterComputeWorldMatrix(): void;
  112912. /** @hidden */
  112913. get _effectiveMesh(): AbstractMesh;
  112914. /**
  112915. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112916. * A mesh is in the frustum if its bounding box intersects the frustum
  112917. * @param frustumPlanes defines the frustum to test
  112918. * @returns true if the mesh is in the frustum planes
  112919. */
  112920. isInFrustum(frustumPlanes: Plane[]): boolean;
  112921. /**
  112922. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112923. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112924. * @param frustumPlanes defines the frustum to test
  112925. * @returns true if the mesh is completely in the frustum planes
  112926. */
  112927. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112928. /**
  112929. * True if the mesh intersects another mesh or a SolidParticle object
  112930. * @param mesh defines a target mesh or SolidParticle to test
  112931. * @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)
  112932. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112933. * @returns true if there is an intersection
  112934. */
  112935. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112936. /**
  112937. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112938. * @param point defines the point to test
  112939. * @returns true if there is an intersection
  112940. */
  112941. intersectsPoint(point: Vector3): boolean;
  112942. /**
  112943. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112944. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112945. */
  112946. get checkCollisions(): boolean;
  112947. set checkCollisions(collisionEnabled: boolean);
  112948. /**
  112949. * Gets Collider object used to compute collisions (not physics)
  112950. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112951. */
  112952. get collider(): Nullable<Collider>;
  112953. /**
  112954. * Move the mesh using collision engine
  112955. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112956. * @param displacement defines the requested displacement vector
  112957. * @returns the current mesh
  112958. */
  112959. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112960. private _onCollisionPositionChange;
  112961. /** @hidden */
  112962. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112963. /** @hidden */
  112964. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112965. /** @hidden */
  112966. _checkCollision(collider: Collider): AbstractMesh;
  112967. /** @hidden */
  112968. _generatePointsArray(): boolean;
  112969. /**
  112970. * Checks if the passed Ray intersects with the mesh
  112971. * @param ray defines the ray to use
  112972. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112973. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112974. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112975. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112976. * @returns the picking info
  112977. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112978. */
  112979. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112980. /**
  112981. * Clones the current mesh
  112982. * @param name defines the mesh name
  112983. * @param newParent defines the new mesh parent
  112984. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112985. * @returns the new mesh
  112986. */
  112987. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112988. /**
  112989. * Disposes all the submeshes of the current meshnp
  112990. * @returns the current mesh
  112991. */
  112992. releaseSubMeshes(): AbstractMesh;
  112993. /**
  112994. * Releases resources associated with this abstract mesh.
  112995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112997. */
  112998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112999. /**
  113000. * Adds the passed mesh as a child to the current mesh
  113001. * @param mesh defines the child mesh
  113002. * @returns the current mesh
  113003. */
  113004. addChild(mesh: AbstractMesh): AbstractMesh;
  113005. /**
  113006. * Removes the passed mesh from the current mesh children list
  113007. * @param mesh defines the child mesh
  113008. * @returns the current mesh
  113009. */
  113010. removeChild(mesh: AbstractMesh): AbstractMesh;
  113011. /** @hidden */
  113012. private _initFacetData;
  113013. /**
  113014. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113015. * This method can be called within the render loop.
  113016. * 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
  113017. * @returns the current mesh
  113018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113019. */
  113020. updateFacetData(): AbstractMesh;
  113021. /**
  113022. * Returns the facetLocalNormals array.
  113023. * The normals are expressed in the mesh local spac
  113024. * @returns an array of Vector3
  113025. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113026. */
  113027. getFacetLocalNormals(): Vector3[];
  113028. /**
  113029. * Returns the facetLocalPositions array.
  113030. * The facet positions are expressed in the mesh local space
  113031. * @returns an array of Vector3
  113032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113033. */
  113034. getFacetLocalPositions(): Vector3[];
  113035. /**
  113036. * Returns the facetLocalPartioning array
  113037. * @returns an array of array of numbers
  113038. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113039. */
  113040. getFacetLocalPartitioning(): number[][];
  113041. /**
  113042. * Returns the i-th facet position in the world system.
  113043. * This method allocates a new Vector3 per call
  113044. * @param i defines the facet index
  113045. * @returns a new Vector3
  113046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113047. */
  113048. getFacetPosition(i: number): Vector3;
  113049. /**
  113050. * Sets the reference Vector3 with the i-th facet position in the world system
  113051. * @param i defines the facet index
  113052. * @param ref defines the target vector
  113053. * @returns the current mesh
  113054. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113055. */
  113056. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113057. /**
  113058. * Returns the i-th facet normal in the world system.
  113059. * This method allocates a new Vector3 per call
  113060. * @param i defines the facet index
  113061. * @returns a new Vector3
  113062. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113063. */
  113064. getFacetNormal(i: number): Vector3;
  113065. /**
  113066. * Sets the reference Vector3 with the i-th facet normal in the world system
  113067. * @param i defines the facet index
  113068. * @param ref defines the target vector
  113069. * @returns the current mesh
  113070. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113071. */
  113072. getFacetNormalToRef(i: number, ref: Vector3): this;
  113073. /**
  113074. * 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)
  113075. * @param x defines x coordinate
  113076. * @param y defines y coordinate
  113077. * @param z defines z coordinate
  113078. * @returns the array of facet indexes
  113079. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113080. */
  113081. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113082. /**
  113083. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113084. * @param projected sets as the (x,y,z) world projection on the facet
  113085. * @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
  113086. * @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
  113087. * @param x defines x coordinate
  113088. * @param y defines y coordinate
  113089. * @param z defines z coordinate
  113090. * @returns the face index if found (or null instead)
  113091. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113092. */
  113093. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113094. /**
  113095. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113096. * @param projected sets as the (x,y,z) local projection on the facet
  113097. * @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
  113098. * @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
  113099. * @param x defines x coordinate
  113100. * @param y defines y coordinate
  113101. * @param z defines z coordinate
  113102. * @returns the face index if found (or null instead)
  113103. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113104. */
  113105. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113106. /**
  113107. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113108. * @returns the parameters
  113109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113110. */
  113111. getFacetDataParameters(): any;
  113112. /**
  113113. * Disables the feature FacetData and frees the related memory
  113114. * @returns the current mesh
  113115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113116. */
  113117. disableFacetData(): AbstractMesh;
  113118. /**
  113119. * Updates the AbstractMesh indices array
  113120. * @param indices defines the data source
  113121. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113122. * @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)
  113123. * @returns the current mesh
  113124. */
  113125. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113126. /**
  113127. * Creates new normals data for the mesh
  113128. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113129. * @returns the current mesh
  113130. */
  113131. createNormals(updatable: boolean): AbstractMesh;
  113132. /**
  113133. * Align the mesh with a normal
  113134. * @param normal defines the normal to use
  113135. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113136. * @returns the current mesh
  113137. */
  113138. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113139. /** @hidden */
  113140. _checkOcclusionQuery(): boolean;
  113141. /**
  113142. * Disables the mesh edge rendering mode
  113143. * @returns the currentAbstractMesh
  113144. */
  113145. disableEdgesRendering(): AbstractMesh;
  113146. /**
  113147. * Enables the edge rendering mode on the mesh.
  113148. * This mode makes the mesh edges visible
  113149. * @param epsilon defines the maximal distance between two angles to detect a face
  113150. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113151. * @returns the currentAbstractMesh
  113152. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113153. */
  113154. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113155. /**
  113156. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113157. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113158. */
  113159. getConnectedParticleSystems(): IParticleSystem[];
  113160. }
  113161. }
  113162. declare module BABYLON {
  113163. /**
  113164. * Interface used to define ActionEvent
  113165. */
  113166. export interface IActionEvent {
  113167. /** The mesh or sprite that triggered the action */
  113168. source: any;
  113169. /** The X mouse cursor position at the time of the event */
  113170. pointerX: number;
  113171. /** The Y mouse cursor position at the time of the event */
  113172. pointerY: number;
  113173. /** The mesh that is currently pointed at (can be null) */
  113174. meshUnderPointer: Nullable<AbstractMesh>;
  113175. /** the original (browser) event that triggered the ActionEvent */
  113176. sourceEvent?: any;
  113177. /** additional data for the event */
  113178. additionalData?: any;
  113179. }
  113180. /**
  113181. * ActionEvent is the event being sent when an action is triggered.
  113182. */
  113183. export class ActionEvent implements IActionEvent {
  113184. /** The mesh or sprite that triggered the action */
  113185. source: any;
  113186. /** The X mouse cursor position at the time of the event */
  113187. pointerX: number;
  113188. /** The Y mouse cursor position at the time of the event */
  113189. pointerY: number;
  113190. /** The mesh that is currently pointed at (can be null) */
  113191. meshUnderPointer: Nullable<AbstractMesh>;
  113192. /** the original (browser) event that triggered the ActionEvent */
  113193. sourceEvent?: any;
  113194. /** additional data for the event */
  113195. additionalData?: any;
  113196. /**
  113197. * Creates a new ActionEvent
  113198. * @param source The mesh or sprite that triggered the action
  113199. * @param pointerX The X mouse cursor position at the time of the event
  113200. * @param pointerY The Y mouse cursor position at the time of the event
  113201. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113202. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113203. * @param additionalData additional data for the event
  113204. */
  113205. constructor(
  113206. /** The mesh or sprite that triggered the action */
  113207. source: any,
  113208. /** The X mouse cursor position at the time of the event */
  113209. pointerX: number,
  113210. /** The Y mouse cursor position at the time of the event */
  113211. pointerY: number,
  113212. /** The mesh that is currently pointed at (can be null) */
  113213. meshUnderPointer: Nullable<AbstractMesh>,
  113214. /** the original (browser) event that triggered the ActionEvent */
  113215. sourceEvent?: any,
  113216. /** additional data for the event */
  113217. additionalData?: any);
  113218. /**
  113219. * Helper function to auto-create an ActionEvent from a source mesh.
  113220. * @param source The source mesh that triggered the event
  113221. * @param evt The original (browser) event
  113222. * @param additionalData additional data for the event
  113223. * @returns the new ActionEvent
  113224. */
  113225. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113226. /**
  113227. * Helper function to auto-create an ActionEvent from a source sprite
  113228. * @param source The source sprite that triggered the event
  113229. * @param scene Scene associated with the sprite
  113230. * @param evt The original (browser) event
  113231. * @param additionalData additional data for the event
  113232. * @returns the new ActionEvent
  113233. */
  113234. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113235. /**
  113236. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113237. * @param scene the scene where the event occurred
  113238. * @param evt The original (browser) event
  113239. * @returns the new ActionEvent
  113240. */
  113241. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113242. /**
  113243. * Helper function to auto-create an ActionEvent from a primitive
  113244. * @param prim defines the target primitive
  113245. * @param pointerPos defines the pointer position
  113246. * @param evt The original (browser) event
  113247. * @param additionalData additional data for the event
  113248. * @returns the new ActionEvent
  113249. */
  113250. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113251. }
  113252. }
  113253. declare module BABYLON {
  113254. /**
  113255. * Abstract class used to decouple action Manager from scene and meshes.
  113256. * Do not instantiate.
  113257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113258. */
  113259. export abstract class AbstractActionManager implements IDisposable {
  113260. /** Gets the list of active triggers */
  113261. static Triggers: {
  113262. [key: string]: number;
  113263. };
  113264. /** Gets the cursor to use when hovering items */
  113265. hoverCursor: string;
  113266. /** Gets the list of actions */
  113267. actions: IAction[];
  113268. /**
  113269. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113270. */
  113271. isRecursive: boolean;
  113272. /**
  113273. * Releases all associated resources
  113274. */
  113275. abstract dispose(): void;
  113276. /**
  113277. * Does this action manager has pointer triggers
  113278. */
  113279. abstract get hasPointerTriggers(): boolean;
  113280. /**
  113281. * Does this action manager has pick triggers
  113282. */
  113283. abstract get hasPickTriggers(): boolean;
  113284. /**
  113285. * Process a specific trigger
  113286. * @param trigger defines the trigger to process
  113287. * @param evt defines the event details to be processed
  113288. */
  113289. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113290. /**
  113291. * Does this action manager handles actions of any of the given triggers
  113292. * @param triggers defines the triggers to be tested
  113293. * @return a boolean indicating whether one (or more) of the triggers is handled
  113294. */
  113295. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113296. /**
  113297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113298. * speed.
  113299. * @param triggerA defines the trigger to be tested
  113300. * @param triggerB defines the trigger to be tested
  113301. * @return a boolean indicating whether one (or more) of the triggers is handled
  113302. */
  113303. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113304. /**
  113305. * Does this action manager handles actions of a given trigger
  113306. * @param trigger defines the trigger to be tested
  113307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113308. * @return whether the trigger is handled
  113309. */
  113310. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113311. /**
  113312. * Serialize this manager to a JSON object
  113313. * @param name defines the property name to store this manager
  113314. * @returns a JSON representation of this manager
  113315. */
  113316. abstract serialize(name: string): any;
  113317. /**
  113318. * Registers an action to this action manager
  113319. * @param action defines the action to be registered
  113320. * @return the action amended (prepared) after registration
  113321. */
  113322. abstract registerAction(action: IAction): Nullable<IAction>;
  113323. /**
  113324. * Unregisters an action to this action manager
  113325. * @param action defines the action to be unregistered
  113326. * @return a boolean indicating whether the action has been unregistered
  113327. */
  113328. abstract unregisterAction(action: IAction): Boolean;
  113329. /**
  113330. * Does exist one action manager with at least one trigger
  113331. **/
  113332. static get HasTriggers(): boolean;
  113333. /**
  113334. * Does exist one action manager with at least one pick trigger
  113335. **/
  113336. static get HasPickTriggers(): boolean;
  113337. /**
  113338. * Does exist one action manager that handles actions of a given trigger
  113339. * @param trigger defines the trigger to be tested
  113340. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113341. **/
  113342. static HasSpecificTrigger(trigger: number): boolean;
  113343. }
  113344. }
  113345. declare module BABYLON {
  113346. /**
  113347. * Defines how a node can be built from a string name.
  113348. */
  113349. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113350. /**
  113351. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113352. */
  113353. export class Node implements IBehaviorAware<Node> {
  113354. /** @hidden */
  113355. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113356. private static _NodeConstructors;
  113357. /**
  113358. * Add a new node constructor
  113359. * @param type defines the type name of the node to construct
  113360. * @param constructorFunc defines the constructor function
  113361. */
  113362. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113363. /**
  113364. * Returns a node constructor based on type name
  113365. * @param type defines the type name
  113366. * @param name defines the new node name
  113367. * @param scene defines the hosting scene
  113368. * @param options defines optional options to transmit to constructors
  113369. * @returns the new constructor or null
  113370. */
  113371. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113372. /**
  113373. * Gets or sets the name of the node
  113374. */
  113375. name: string;
  113376. /**
  113377. * Gets or sets the id of the node
  113378. */
  113379. id: string;
  113380. /**
  113381. * Gets or sets the unique id of the node
  113382. */
  113383. uniqueId: number;
  113384. /**
  113385. * Gets or sets a string used to store user defined state for the node
  113386. */
  113387. state: string;
  113388. /**
  113389. * Gets or sets an object used to store user defined information for the node
  113390. */
  113391. metadata: any;
  113392. /**
  113393. * For internal use only. Please do not use.
  113394. */
  113395. reservedDataStore: any;
  113396. /**
  113397. * List of inspectable custom properties (used by the Inspector)
  113398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113399. */
  113400. inspectableCustomProperties: IInspectable[];
  113401. private _doNotSerialize;
  113402. /**
  113403. * Gets or sets a boolean used to define if the node must be serialized
  113404. */
  113405. get doNotSerialize(): boolean;
  113406. set doNotSerialize(value: boolean);
  113407. /** @hidden */
  113408. _isDisposed: boolean;
  113409. /**
  113410. * Gets a list of Animations associated with the node
  113411. */
  113412. animations: Animation[];
  113413. protected _ranges: {
  113414. [name: string]: Nullable<AnimationRange>;
  113415. };
  113416. /**
  113417. * Callback raised when the node is ready to be used
  113418. */
  113419. onReady: Nullable<(node: Node) => void>;
  113420. private _isEnabled;
  113421. private _isParentEnabled;
  113422. private _isReady;
  113423. /** @hidden */
  113424. _currentRenderId: number;
  113425. private _parentUpdateId;
  113426. /** @hidden */
  113427. _childUpdateId: number;
  113428. /** @hidden */
  113429. _waitingParentId: Nullable<string>;
  113430. /** @hidden */
  113431. _scene: Scene;
  113432. /** @hidden */
  113433. _cache: any;
  113434. private _parentNode;
  113435. private _children;
  113436. /** @hidden */
  113437. _worldMatrix: Matrix;
  113438. /** @hidden */
  113439. _worldMatrixDeterminant: number;
  113440. /** @hidden */
  113441. _worldMatrixDeterminantIsDirty: boolean;
  113442. /** @hidden */
  113443. private _sceneRootNodesIndex;
  113444. /**
  113445. * Gets a boolean indicating if the node has been disposed
  113446. * @returns true if the node was disposed
  113447. */
  113448. isDisposed(): boolean;
  113449. /**
  113450. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113451. * @see https://doc.babylonjs.com/how_to/parenting
  113452. */
  113453. set parent(parent: Nullable<Node>);
  113454. get parent(): Nullable<Node>;
  113455. /** @hidden */
  113456. _addToSceneRootNodes(): void;
  113457. /** @hidden */
  113458. _removeFromSceneRootNodes(): void;
  113459. private _animationPropertiesOverride;
  113460. /**
  113461. * Gets or sets the animation properties override
  113462. */
  113463. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113464. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113465. /**
  113466. * Gets a string identifying the name of the class
  113467. * @returns "Node" string
  113468. */
  113469. getClassName(): string;
  113470. /** @hidden */
  113471. readonly _isNode: boolean;
  113472. /**
  113473. * An event triggered when the mesh is disposed
  113474. */
  113475. onDisposeObservable: Observable<Node>;
  113476. private _onDisposeObserver;
  113477. /**
  113478. * Sets a callback that will be raised when the node will be disposed
  113479. */
  113480. set onDispose(callback: () => void);
  113481. /**
  113482. * Creates a new Node
  113483. * @param name the name and id to be given to this node
  113484. * @param scene the scene this node will be added to
  113485. */
  113486. constructor(name: string, scene?: Nullable<Scene>);
  113487. /**
  113488. * Gets the scene of the node
  113489. * @returns a scene
  113490. */
  113491. getScene(): Scene;
  113492. /**
  113493. * Gets the engine of the node
  113494. * @returns a Engine
  113495. */
  113496. getEngine(): Engine;
  113497. private _behaviors;
  113498. /**
  113499. * Attach a behavior to the node
  113500. * @see https://doc.babylonjs.com/features/behaviour
  113501. * @param behavior defines the behavior to attach
  113502. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113503. * @returns the current Node
  113504. */
  113505. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113506. /**
  113507. * Remove an attached behavior
  113508. * @see https://doc.babylonjs.com/features/behaviour
  113509. * @param behavior defines the behavior to attach
  113510. * @returns the current Node
  113511. */
  113512. removeBehavior(behavior: Behavior<Node>): Node;
  113513. /**
  113514. * Gets the list of attached behaviors
  113515. * @see https://doc.babylonjs.com/features/behaviour
  113516. */
  113517. get behaviors(): Behavior<Node>[];
  113518. /**
  113519. * Gets an attached behavior by name
  113520. * @param name defines the name of the behavior to look for
  113521. * @see https://doc.babylonjs.com/features/behaviour
  113522. * @returns null if behavior was not found else the requested behavior
  113523. */
  113524. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113525. /**
  113526. * Returns the latest update of the World matrix
  113527. * @returns a Matrix
  113528. */
  113529. getWorldMatrix(): Matrix;
  113530. /** @hidden */
  113531. _getWorldMatrixDeterminant(): number;
  113532. /**
  113533. * Returns directly the latest state of the mesh World matrix.
  113534. * A Matrix is returned.
  113535. */
  113536. get worldMatrixFromCache(): Matrix;
  113537. /** @hidden */
  113538. _initCache(): void;
  113539. /** @hidden */
  113540. updateCache(force?: boolean): void;
  113541. /** @hidden */
  113542. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113543. /** @hidden */
  113544. _updateCache(ignoreParentClass?: boolean): void;
  113545. /** @hidden */
  113546. _isSynchronized(): boolean;
  113547. /** @hidden */
  113548. _markSyncedWithParent(): void;
  113549. /** @hidden */
  113550. isSynchronizedWithParent(): boolean;
  113551. /** @hidden */
  113552. isSynchronized(): boolean;
  113553. /**
  113554. * Is this node ready to be used/rendered
  113555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113556. * @return true if the node is ready
  113557. */
  113558. isReady(completeCheck?: boolean): boolean;
  113559. /**
  113560. * Is this node enabled?
  113561. * 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
  113562. * @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
  113563. * @return whether this node (and its parent) is enabled
  113564. */
  113565. isEnabled(checkAncestors?: boolean): boolean;
  113566. /** @hidden */
  113567. protected _syncParentEnabledState(): void;
  113568. /**
  113569. * Set the enabled state of this node
  113570. * @param value defines the new enabled state
  113571. */
  113572. setEnabled(value: boolean): void;
  113573. /**
  113574. * Is this node a descendant of the given node?
  113575. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113576. * @param ancestor defines the parent node to inspect
  113577. * @returns a boolean indicating if this node is a descendant of the given node
  113578. */
  113579. isDescendantOf(ancestor: Node): boolean;
  113580. /** @hidden */
  113581. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113582. /**
  113583. * Will return all nodes that have this node as ascendant
  113584. * @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
  113585. * @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
  113586. * @return all children nodes of all types
  113587. */
  113588. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113589. /**
  113590. * Get all child-meshes of this node
  113591. * @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)
  113592. * @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
  113593. * @returns an array of AbstractMesh
  113594. */
  113595. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113596. /**
  113597. * Get all direct children of this node
  113598. * @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
  113599. * @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)
  113600. * @returns an array of Node
  113601. */
  113602. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113603. /** @hidden */
  113604. _setReady(state: boolean): void;
  113605. /**
  113606. * Get an animation by name
  113607. * @param name defines the name of the animation to look for
  113608. * @returns null if not found else the requested animation
  113609. */
  113610. getAnimationByName(name: string): Nullable<Animation>;
  113611. /**
  113612. * Creates an animation range for this node
  113613. * @param name defines the name of the range
  113614. * @param from defines the starting key
  113615. * @param to defines the end key
  113616. */
  113617. createAnimationRange(name: string, from: number, to: number): void;
  113618. /**
  113619. * Delete a specific animation range
  113620. * @param name defines the name of the range to delete
  113621. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113622. */
  113623. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113624. /**
  113625. * Get an animation range by name
  113626. * @param name defines the name of the animation range to look for
  113627. * @returns null if not found else the requested animation range
  113628. */
  113629. getAnimationRange(name: string): Nullable<AnimationRange>;
  113630. /**
  113631. * Gets the list of all animation ranges defined on this node
  113632. * @returns an array
  113633. */
  113634. getAnimationRanges(): Nullable<AnimationRange>[];
  113635. /**
  113636. * Will start the animation sequence
  113637. * @param name defines the range frames for animation sequence
  113638. * @param loop defines if the animation should loop (false by default)
  113639. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113640. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113641. * @returns the object created for this animation. If range does not exist, it will return null
  113642. */
  113643. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113644. /**
  113645. * Serialize animation ranges into a JSON compatible object
  113646. * @returns serialization object
  113647. */
  113648. serializeAnimationRanges(): any;
  113649. /**
  113650. * Computes the world matrix of the node
  113651. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113652. * @returns the world matrix
  113653. */
  113654. computeWorldMatrix(force?: boolean): Matrix;
  113655. /**
  113656. * Releases resources associated with this node.
  113657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113659. */
  113660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113661. /**
  113662. * Parse animation range data from a serialization object and store them into a given node
  113663. * @param node defines where to store the animation ranges
  113664. * @param parsedNode defines the serialization object to read data from
  113665. * @param scene defines the hosting scene
  113666. */
  113667. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113668. /**
  113669. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113670. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113671. * @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
  113672. * @returns the new bounding vectors
  113673. */
  113674. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113675. min: Vector3;
  113676. max: Vector3;
  113677. };
  113678. }
  113679. }
  113680. declare module BABYLON {
  113681. /**
  113682. * @hidden
  113683. */
  113684. export class _IAnimationState {
  113685. key: number;
  113686. repeatCount: number;
  113687. workValue?: any;
  113688. loopMode?: number;
  113689. offsetValue?: any;
  113690. highLimitValue?: any;
  113691. }
  113692. /**
  113693. * Class used to store any kind of animation
  113694. */
  113695. export class Animation {
  113696. /**Name of the animation */
  113697. name: string;
  113698. /**Property to animate */
  113699. targetProperty: string;
  113700. /**The frames per second of the animation */
  113701. framePerSecond: number;
  113702. /**The data type of the animation */
  113703. dataType: number;
  113704. /**The loop mode of the animation */
  113705. loopMode?: number | undefined;
  113706. /**Specifies if blending should be enabled */
  113707. enableBlending?: boolean | undefined;
  113708. /**
  113709. * Use matrix interpolation instead of using direct key value when animating matrices
  113710. */
  113711. static AllowMatricesInterpolation: boolean;
  113712. /**
  113713. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113714. */
  113715. static AllowMatrixDecomposeForInterpolation: boolean;
  113716. /** Define the Url to load snippets */
  113717. static SnippetUrl: string;
  113718. /** Snippet ID if the animation was created from the snippet server */
  113719. snippetId: string;
  113720. /**
  113721. * Stores the key frames of the animation
  113722. */
  113723. private _keys;
  113724. /**
  113725. * Stores the easing function of the animation
  113726. */
  113727. private _easingFunction;
  113728. /**
  113729. * @hidden Internal use only
  113730. */
  113731. _runtimeAnimations: RuntimeAnimation[];
  113732. /**
  113733. * The set of event that will be linked to this animation
  113734. */
  113735. private _events;
  113736. /**
  113737. * Stores an array of target property paths
  113738. */
  113739. targetPropertyPath: string[];
  113740. /**
  113741. * Stores the blending speed of the animation
  113742. */
  113743. blendingSpeed: number;
  113744. /**
  113745. * Stores the animation ranges for the animation
  113746. */
  113747. private _ranges;
  113748. /**
  113749. * @hidden Internal use
  113750. */
  113751. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113752. /**
  113753. * Sets up an animation
  113754. * @param property The property to animate
  113755. * @param animationType The animation type to apply
  113756. * @param framePerSecond The frames per second of the animation
  113757. * @param easingFunction The easing function used in the animation
  113758. * @returns The created animation
  113759. */
  113760. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113761. /**
  113762. * Create and start an animation on a node
  113763. * @param name defines the name of the global animation that will be run on all nodes
  113764. * @param node defines the root node where the animation will take place
  113765. * @param targetProperty defines property to animate
  113766. * @param framePerSecond defines the number of frame per second yo use
  113767. * @param totalFrame defines the number of frames in total
  113768. * @param from defines the initial value
  113769. * @param to defines the final value
  113770. * @param loopMode defines which loop mode you want to use (off by default)
  113771. * @param easingFunction defines the easing function to use (linear by default)
  113772. * @param onAnimationEnd defines the callback to call when animation end
  113773. * @returns the animatable created for this animation
  113774. */
  113775. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113776. /**
  113777. * Create and start an animation on a node and its descendants
  113778. * @param name defines the name of the global animation that will be run on all nodes
  113779. * @param node defines the root node where the animation will take place
  113780. * @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
  113781. * @param targetProperty defines property to animate
  113782. * @param framePerSecond defines the number of frame per second to use
  113783. * @param totalFrame defines the number of frames in total
  113784. * @param from defines the initial value
  113785. * @param to defines the final value
  113786. * @param loopMode defines which loop mode you want to use (off by default)
  113787. * @param easingFunction defines the easing function to use (linear by default)
  113788. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113789. * @returns the list of animatables created for all nodes
  113790. * @example https://www.babylonjs-playground.com/#MH0VLI
  113791. */
  113792. 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[]>;
  113793. /**
  113794. * Creates a new animation, merges it with the existing animations and starts it
  113795. * @param name Name of the animation
  113796. * @param node Node which contains the scene that begins the animations
  113797. * @param targetProperty Specifies which property to animate
  113798. * @param framePerSecond The frames per second of the animation
  113799. * @param totalFrame The total number of frames
  113800. * @param from The frame at the beginning of the animation
  113801. * @param to The frame at the end of the animation
  113802. * @param loopMode Specifies the loop mode of the animation
  113803. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113804. * @param onAnimationEnd Callback to run once the animation is complete
  113805. * @returns Nullable animation
  113806. */
  113807. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113808. /**
  113809. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113810. * @param sourceAnimation defines the Animation containing keyframes to convert
  113811. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113812. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113813. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113814. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113815. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113816. */
  113817. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113818. /**
  113819. * Transition property of an host to the target Value
  113820. * @param property The property to transition
  113821. * @param targetValue The target Value of the property
  113822. * @param host The object where the property to animate belongs
  113823. * @param scene Scene used to run the animation
  113824. * @param frameRate Framerate (in frame/s) to use
  113825. * @param transition The transition type we want to use
  113826. * @param duration The duration of the animation, in milliseconds
  113827. * @param onAnimationEnd Callback trigger at the end of the animation
  113828. * @returns Nullable animation
  113829. */
  113830. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113831. /**
  113832. * Return the array of runtime animations currently using this animation
  113833. */
  113834. get runtimeAnimations(): RuntimeAnimation[];
  113835. /**
  113836. * Specifies if any of the runtime animations are currently running
  113837. */
  113838. get hasRunningRuntimeAnimations(): boolean;
  113839. /**
  113840. * Initializes the animation
  113841. * @param name Name of the animation
  113842. * @param targetProperty Property to animate
  113843. * @param framePerSecond The frames per second of the animation
  113844. * @param dataType The data type of the animation
  113845. * @param loopMode The loop mode of the animation
  113846. * @param enableBlending Specifies if blending should be enabled
  113847. */
  113848. constructor(
  113849. /**Name of the animation */
  113850. name: string,
  113851. /**Property to animate */
  113852. targetProperty: string,
  113853. /**The frames per second of the animation */
  113854. framePerSecond: number,
  113855. /**The data type of the animation */
  113856. dataType: number,
  113857. /**The loop mode of the animation */
  113858. loopMode?: number | undefined,
  113859. /**Specifies if blending should be enabled */
  113860. enableBlending?: boolean | undefined);
  113861. /**
  113862. * Converts the animation to a string
  113863. * @param fullDetails support for multiple levels of logging within scene loading
  113864. * @returns String form of the animation
  113865. */
  113866. toString(fullDetails?: boolean): string;
  113867. /**
  113868. * Add an event to this animation
  113869. * @param event Event to add
  113870. */
  113871. addEvent(event: AnimationEvent): void;
  113872. /**
  113873. * Remove all events found at the given frame
  113874. * @param frame The frame to remove events from
  113875. */
  113876. removeEvents(frame: number): void;
  113877. /**
  113878. * Retrieves all the events from the animation
  113879. * @returns Events from the animation
  113880. */
  113881. getEvents(): AnimationEvent[];
  113882. /**
  113883. * Creates an animation range
  113884. * @param name Name of the animation range
  113885. * @param from Starting frame of the animation range
  113886. * @param to Ending frame of the animation
  113887. */
  113888. createRange(name: string, from: number, to: number): void;
  113889. /**
  113890. * Deletes an animation range by name
  113891. * @param name Name of the animation range to delete
  113892. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113893. */
  113894. deleteRange(name: string, deleteFrames?: boolean): void;
  113895. /**
  113896. * Gets the animation range by name, or null if not defined
  113897. * @param name Name of the animation range
  113898. * @returns Nullable animation range
  113899. */
  113900. getRange(name: string): Nullable<AnimationRange>;
  113901. /**
  113902. * Gets the key frames from the animation
  113903. * @returns The key frames of the animation
  113904. */
  113905. getKeys(): Array<IAnimationKey>;
  113906. /**
  113907. * Gets the highest frame rate of the animation
  113908. * @returns Highest frame rate of the animation
  113909. */
  113910. getHighestFrame(): number;
  113911. /**
  113912. * Gets the easing function of the animation
  113913. * @returns Easing function of the animation
  113914. */
  113915. getEasingFunction(): IEasingFunction;
  113916. /**
  113917. * Sets the easing function of the animation
  113918. * @param easingFunction A custom mathematical formula for animation
  113919. */
  113920. setEasingFunction(easingFunction: EasingFunction): void;
  113921. /**
  113922. * Interpolates a scalar linearly
  113923. * @param startValue Start value of the animation curve
  113924. * @param endValue End value of the animation curve
  113925. * @param gradient Scalar amount to interpolate
  113926. * @returns Interpolated scalar value
  113927. */
  113928. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113929. /**
  113930. * Interpolates a scalar cubically
  113931. * @param startValue Start value of the animation curve
  113932. * @param outTangent End tangent of the animation
  113933. * @param endValue End value of the animation curve
  113934. * @param inTangent Start tangent of the animation curve
  113935. * @param gradient Scalar amount to interpolate
  113936. * @returns Interpolated scalar value
  113937. */
  113938. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113939. /**
  113940. * Interpolates a quaternion using a spherical linear interpolation
  113941. * @param startValue Start value of the animation curve
  113942. * @param endValue End value of the animation curve
  113943. * @param gradient Scalar amount to interpolate
  113944. * @returns Interpolated quaternion value
  113945. */
  113946. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113947. /**
  113948. * Interpolates a quaternion cubically
  113949. * @param startValue Start value of the animation curve
  113950. * @param outTangent End tangent of the animation curve
  113951. * @param endValue End value of the animation curve
  113952. * @param inTangent Start tangent of the animation curve
  113953. * @param gradient Scalar amount to interpolate
  113954. * @returns Interpolated quaternion value
  113955. */
  113956. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113957. /**
  113958. * Interpolates a Vector3 linearl
  113959. * @param startValue Start value of the animation curve
  113960. * @param endValue End value of the animation curve
  113961. * @param gradient Scalar amount to interpolate
  113962. * @returns Interpolated scalar value
  113963. */
  113964. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113965. /**
  113966. * Interpolates a Vector3 cubically
  113967. * @param startValue Start value of the animation curve
  113968. * @param outTangent End tangent of the animation
  113969. * @param endValue End value of the animation curve
  113970. * @param inTangent Start tangent of the animation curve
  113971. * @param gradient Scalar amount to interpolate
  113972. * @returns InterpolatedVector3 value
  113973. */
  113974. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113975. /**
  113976. * Interpolates a Vector2 linearly
  113977. * @param startValue Start value of the animation curve
  113978. * @param endValue End value of the animation curve
  113979. * @param gradient Scalar amount to interpolate
  113980. * @returns Interpolated Vector2 value
  113981. */
  113982. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113983. /**
  113984. * Interpolates a Vector2 cubically
  113985. * @param startValue Start value of the animation curve
  113986. * @param outTangent End tangent of the animation
  113987. * @param endValue End value of the animation curve
  113988. * @param inTangent Start tangent of the animation curve
  113989. * @param gradient Scalar amount to interpolate
  113990. * @returns Interpolated Vector2 value
  113991. */
  113992. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113993. /**
  113994. * Interpolates a size linearly
  113995. * @param startValue Start value of the animation curve
  113996. * @param endValue End value of the animation curve
  113997. * @param gradient Scalar amount to interpolate
  113998. * @returns Interpolated Size value
  113999. */
  114000. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114001. /**
  114002. * Interpolates a Color3 linearly
  114003. * @param startValue Start value of the animation curve
  114004. * @param endValue End value of the animation curve
  114005. * @param gradient Scalar amount to interpolate
  114006. * @returns Interpolated Color3 value
  114007. */
  114008. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114009. /**
  114010. * Interpolates a Color4 linearly
  114011. * @param startValue Start value of the animation curve
  114012. * @param endValue End value of the animation curve
  114013. * @param gradient Scalar amount to interpolate
  114014. * @returns Interpolated Color3 value
  114015. */
  114016. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114017. /**
  114018. * @hidden Internal use only
  114019. */
  114020. _getKeyValue(value: any): any;
  114021. /**
  114022. * @hidden Internal use only
  114023. */
  114024. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114025. /**
  114026. * Defines the function to use to interpolate matrices
  114027. * @param startValue defines the start matrix
  114028. * @param endValue defines the end matrix
  114029. * @param gradient defines the gradient between both matrices
  114030. * @param result defines an optional target matrix where to store the interpolation
  114031. * @returns the interpolated matrix
  114032. */
  114033. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114034. /**
  114035. * Makes a copy of the animation
  114036. * @returns Cloned animation
  114037. */
  114038. clone(): Animation;
  114039. /**
  114040. * Sets the key frames of the animation
  114041. * @param values The animation key frames to set
  114042. */
  114043. setKeys(values: Array<IAnimationKey>): void;
  114044. /**
  114045. * Serializes the animation to an object
  114046. * @returns Serialized object
  114047. */
  114048. serialize(): any;
  114049. /**
  114050. * Float animation type
  114051. */
  114052. static readonly ANIMATIONTYPE_FLOAT: number;
  114053. /**
  114054. * Vector3 animation type
  114055. */
  114056. static readonly ANIMATIONTYPE_VECTOR3: number;
  114057. /**
  114058. * Quaternion animation type
  114059. */
  114060. static readonly ANIMATIONTYPE_QUATERNION: number;
  114061. /**
  114062. * Matrix animation type
  114063. */
  114064. static readonly ANIMATIONTYPE_MATRIX: number;
  114065. /**
  114066. * Color3 animation type
  114067. */
  114068. static readonly ANIMATIONTYPE_COLOR3: number;
  114069. /**
  114070. * Color3 animation type
  114071. */
  114072. static readonly ANIMATIONTYPE_COLOR4: number;
  114073. /**
  114074. * Vector2 animation type
  114075. */
  114076. static readonly ANIMATIONTYPE_VECTOR2: number;
  114077. /**
  114078. * Size animation type
  114079. */
  114080. static readonly ANIMATIONTYPE_SIZE: number;
  114081. /**
  114082. * Relative Loop Mode
  114083. */
  114084. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114085. /**
  114086. * Cycle Loop Mode
  114087. */
  114088. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114089. /**
  114090. * Constant Loop Mode
  114091. */
  114092. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114093. /** @hidden */
  114094. static _UniversalLerp(left: any, right: any, amount: number): any;
  114095. /**
  114096. * Parses an animation object and creates an animation
  114097. * @param parsedAnimation Parsed animation object
  114098. * @returns Animation object
  114099. */
  114100. static Parse(parsedAnimation: any): Animation;
  114101. /**
  114102. * Appends the serialized animations from the source animations
  114103. * @param source Source containing the animations
  114104. * @param destination Target to store the animations
  114105. */
  114106. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114107. /**
  114108. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114109. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114110. * @param url defines the url to load from
  114111. * @returns a promise that will resolve to the new animation or an array of animations
  114112. */
  114113. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114114. /**
  114115. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114116. * @param snippetId defines the snippet to load
  114117. * @returns a promise that will resolve to the new animation or a new array of animations
  114118. */
  114119. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114120. }
  114121. }
  114122. declare module BABYLON {
  114123. /**
  114124. * Interface containing an array of animations
  114125. */
  114126. export interface IAnimatable {
  114127. /**
  114128. * Array of animations
  114129. */
  114130. animations: Nullable<Array<Animation>>;
  114131. }
  114132. }
  114133. declare module BABYLON {
  114134. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114135. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114136. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114137. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114138. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114139. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114140. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114141. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114142. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114143. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114144. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114145. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114146. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114147. /**
  114148. * Decorator used to define property that can be serialized as reference to a camera
  114149. * @param sourceName defines the name of the property to decorate
  114150. */
  114151. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114152. /**
  114153. * Class used to help serialization objects
  114154. */
  114155. export class SerializationHelper {
  114156. /** @hidden */
  114157. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114158. /** @hidden */
  114159. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114160. /** @hidden */
  114161. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114162. /** @hidden */
  114163. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114164. /**
  114165. * Appends the serialized animations from the source animations
  114166. * @param source Source containing the animations
  114167. * @param destination Target to store the animations
  114168. */
  114169. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114170. /**
  114171. * Static function used to serialized a specific entity
  114172. * @param entity defines the entity to serialize
  114173. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114174. * @returns a JSON compatible object representing the serialization of the entity
  114175. */
  114176. static Serialize<T>(entity: T, serializationObject?: any): any;
  114177. /**
  114178. * Creates a new entity from a serialization data object
  114179. * @param creationFunction defines a function used to instanciated the new entity
  114180. * @param source defines the source serialization data
  114181. * @param scene defines the hosting scene
  114182. * @param rootUrl defines the root url for resources
  114183. * @returns a new entity
  114184. */
  114185. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114186. /**
  114187. * Clones an object
  114188. * @param creationFunction defines the function used to instanciate the new object
  114189. * @param source defines the source object
  114190. * @returns the cloned object
  114191. */
  114192. static Clone<T>(creationFunction: () => T, source: T): T;
  114193. /**
  114194. * Instanciates a new object based on a source one (some data will be shared between both object)
  114195. * @param creationFunction defines the function used to instanciate the new object
  114196. * @param source defines the source object
  114197. * @returns the new object
  114198. */
  114199. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114200. }
  114201. }
  114202. declare module BABYLON {
  114203. /**
  114204. * Base class of all the textures in babylon.
  114205. * It groups all the common properties the materials, post process, lights... might need
  114206. * in order to make a correct use of the texture.
  114207. */
  114208. export class BaseTexture implements IAnimatable {
  114209. /**
  114210. * Default anisotropic filtering level for the application.
  114211. * It is set to 4 as a good tradeoff between perf and quality.
  114212. */
  114213. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114214. /**
  114215. * Gets or sets the unique id of the texture
  114216. */
  114217. uniqueId: number;
  114218. /**
  114219. * Define the name of the texture.
  114220. */
  114221. name: string;
  114222. /**
  114223. * Gets or sets an object used to store user defined information.
  114224. */
  114225. metadata: any;
  114226. /**
  114227. * For internal use only. Please do not use.
  114228. */
  114229. reservedDataStore: any;
  114230. private _hasAlpha;
  114231. /**
  114232. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114233. */
  114234. set hasAlpha(value: boolean);
  114235. get hasAlpha(): boolean;
  114236. /**
  114237. * Defines if the alpha value should be determined via the rgb values.
  114238. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114239. */
  114240. getAlphaFromRGB: boolean;
  114241. /**
  114242. * Intensity or strength of the texture.
  114243. * It is commonly used by materials to fine tune the intensity of the texture
  114244. */
  114245. level: number;
  114246. /**
  114247. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114248. * This is part of the texture as textures usually maps to one uv set.
  114249. */
  114250. coordinatesIndex: number;
  114251. protected _coordinatesMode: number;
  114252. /**
  114253. * How a texture is mapped.
  114254. *
  114255. * | Value | Type | Description |
  114256. * | ----- | ----------------------------------- | ----------- |
  114257. * | 0 | EXPLICIT_MODE | |
  114258. * | 1 | SPHERICAL_MODE | |
  114259. * | 2 | PLANAR_MODE | |
  114260. * | 3 | CUBIC_MODE | |
  114261. * | 4 | PROJECTION_MODE | |
  114262. * | 5 | SKYBOX_MODE | |
  114263. * | 6 | INVCUBIC_MODE | |
  114264. * | 7 | EQUIRECTANGULAR_MODE | |
  114265. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114266. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114267. */
  114268. set coordinatesMode(value: number);
  114269. get coordinatesMode(): number;
  114270. private _wrapU;
  114271. /**
  114272. * | Value | Type | Description |
  114273. * | ----- | ------------------ | ----------- |
  114274. * | 0 | CLAMP_ADDRESSMODE | |
  114275. * | 1 | WRAP_ADDRESSMODE | |
  114276. * | 2 | MIRROR_ADDRESSMODE | |
  114277. */
  114278. get wrapU(): number;
  114279. set wrapU(value: number);
  114280. private _wrapV;
  114281. /**
  114282. * | Value | Type | Description |
  114283. * | ----- | ------------------ | ----------- |
  114284. * | 0 | CLAMP_ADDRESSMODE | |
  114285. * | 1 | WRAP_ADDRESSMODE | |
  114286. * | 2 | MIRROR_ADDRESSMODE | |
  114287. */
  114288. get wrapV(): number;
  114289. set wrapV(value: number);
  114290. /**
  114291. * | Value | Type | Description |
  114292. * | ----- | ------------------ | ----------- |
  114293. * | 0 | CLAMP_ADDRESSMODE | |
  114294. * | 1 | WRAP_ADDRESSMODE | |
  114295. * | 2 | MIRROR_ADDRESSMODE | |
  114296. */
  114297. wrapR: number;
  114298. /**
  114299. * With compliant hardware and browser (supporting anisotropic filtering)
  114300. * this defines the level of anisotropic filtering in the texture.
  114301. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114302. */
  114303. anisotropicFilteringLevel: number;
  114304. /**
  114305. * Define if the texture is a cube texture or if false a 2d texture.
  114306. */
  114307. get isCube(): boolean;
  114308. set isCube(value: boolean);
  114309. /**
  114310. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114311. */
  114312. get is3D(): boolean;
  114313. set is3D(value: boolean);
  114314. /**
  114315. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114316. */
  114317. get is2DArray(): boolean;
  114318. set is2DArray(value: boolean);
  114319. private _gammaSpace;
  114320. /**
  114321. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114322. * HDR texture are usually stored in linear space.
  114323. * This only impacts the PBR and Background materials
  114324. */
  114325. get gammaSpace(): boolean;
  114326. set gammaSpace(gamma: boolean);
  114327. /**
  114328. * Gets or sets whether or not the texture contains RGBD data.
  114329. */
  114330. get isRGBD(): boolean;
  114331. set isRGBD(value: boolean);
  114332. /**
  114333. * Is Z inverted in the texture (useful in a cube texture).
  114334. */
  114335. invertZ: boolean;
  114336. /**
  114337. * Are mip maps generated for this texture or not.
  114338. */
  114339. get noMipmap(): boolean;
  114340. /**
  114341. * @hidden
  114342. */
  114343. lodLevelInAlpha: boolean;
  114344. /**
  114345. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114346. */
  114347. get lodGenerationOffset(): number;
  114348. set lodGenerationOffset(value: number);
  114349. /**
  114350. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114351. */
  114352. get lodGenerationScale(): number;
  114353. set lodGenerationScale(value: number);
  114354. /**
  114355. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114356. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114357. * average roughness values.
  114358. */
  114359. get linearSpecularLOD(): boolean;
  114360. set linearSpecularLOD(value: boolean);
  114361. /**
  114362. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114363. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114364. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114365. */
  114366. get irradianceTexture(): Nullable<BaseTexture>;
  114367. set irradianceTexture(value: Nullable<BaseTexture>);
  114368. /**
  114369. * Define if the texture is a render target.
  114370. */
  114371. isRenderTarget: boolean;
  114372. /**
  114373. * Define the unique id of the texture in the scene.
  114374. */
  114375. get uid(): string;
  114376. /** @hidden */
  114377. _prefiltered: boolean;
  114378. /**
  114379. * Return a string representation of the texture.
  114380. * @returns the texture as a string
  114381. */
  114382. toString(): string;
  114383. /**
  114384. * Get the class name of the texture.
  114385. * @returns "BaseTexture"
  114386. */
  114387. getClassName(): string;
  114388. /**
  114389. * Define the list of animation attached to the texture.
  114390. */
  114391. animations: Animation[];
  114392. /**
  114393. * An event triggered when the texture is disposed.
  114394. */
  114395. onDisposeObservable: Observable<BaseTexture>;
  114396. private _onDisposeObserver;
  114397. /**
  114398. * Callback triggered when the texture has been disposed.
  114399. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114400. */
  114401. set onDispose(callback: () => void);
  114402. /**
  114403. * Define the current state of the loading sequence when in delayed load mode.
  114404. */
  114405. delayLoadState: number;
  114406. protected _scene: Nullable<Scene>;
  114407. protected _engine: Nullable<ThinEngine>;
  114408. /** @hidden */
  114409. _texture: Nullable<InternalTexture>;
  114410. private _uid;
  114411. /**
  114412. * Define if the texture is preventinga material to render or not.
  114413. * If not and the texture is not ready, the engine will use a default black texture instead.
  114414. */
  114415. get isBlocking(): boolean;
  114416. /**
  114417. * Instantiates a new BaseTexture.
  114418. * Base class of all the textures in babylon.
  114419. * It groups all the common properties the materials, post process, lights... might need
  114420. * in order to make a correct use of the texture.
  114421. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114422. */
  114423. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114424. /**
  114425. * Get the scene the texture belongs to.
  114426. * @returns the scene or null if undefined
  114427. */
  114428. getScene(): Nullable<Scene>;
  114429. /** @hidden */
  114430. protected _getEngine(): Nullable<ThinEngine>;
  114431. /**
  114432. * Get the texture transform matrix used to offset tile the texture for istance.
  114433. * @returns the transformation matrix
  114434. */
  114435. getTextureMatrix(): Matrix;
  114436. /**
  114437. * Get the texture reflection matrix used to rotate/transform the reflection.
  114438. * @returns the reflection matrix
  114439. */
  114440. getReflectionTextureMatrix(): Matrix;
  114441. /**
  114442. * Get the underlying lower level texture from Babylon.
  114443. * @returns the insternal texture
  114444. */
  114445. getInternalTexture(): Nullable<InternalTexture>;
  114446. /**
  114447. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114448. * @returns true if ready or not blocking
  114449. */
  114450. isReadyOrNotBlocking(): boolean;
  114451. /**
  114452. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114453. * @returns true if fully ready
  114454. */
  114455. isReady(): boolean;
  114456. private _cachedSize;
  114457. /**
  114458. * Get the size of the texture.
  114459. * @returns the texture size.
  114460. */
  114461. getSize(): ISize;
  114462. /**
  114463. * Get the base size of the texture.
  114464. * It can be different from the size if the texture has been resized for POT for instance
  114465. * @returns the base size
  114466. */
  114467. getBaseSize(): ISize;
  114468. /**
  114469. * Update the sampling mode of the texture.
  114470. * Default is Trilinear mode.
  114471. *
  114472. * | Value | Type | Description |
  114473. * | ----- | ------------------ | ----------- |
  114474. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114475. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114476. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114477. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114478. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114479. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114480. * | 7 | NEAREST_LINEAR | |
  114481. * | 8 | NEAREST_NEAREST | |
  114482. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114483. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114484. * | 11 | LINEAR_LINEAR | |
  114485. * | 12 | LINEAR_NEAREST | |
  114486. *
  114487. * > _mag_: magnification filter (close to the viewer)
  114488. * > _min_: minification filter (far from the viewer)
  114489. * > _mip_: filter used between mip map levels
  114490. *@param samplingMode Define the new sampling mode of the texture
  114491. */
  114492. updateSamplingMode(samplingMode: number): void;
  114493. /**
  114494. * Scales the texture if is `canRescale()`
  114495. * @param ratio the resize factor we want to use to rescale
  114496. */
  114497. scale(ratio: number): void;
  114498. /**
  114499. * Get if the texture can rescale.
  114500. */
  114501. get canRescale(): boolean;
  114502. /** @hidden */
  114503. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114504. /** @hidden */
  114505. _rebuild(): void;
  114506. /**
  114507. * Triggers the load sequence in delayed load mode.
  114508. */
  114509. delayLoad(): void;
  114510. /**
  114511. * Clones the texture.
  114512. * @returns the cloned texture
  114513. */
  114514. clone(): Nullable<BaseTexture>;
  114515. /**
  114516. * Get the texture underlying type (INT, FLOAT...)
  114517. */
  114518. get textureType(): number;
  114519. /**
  114520. * Get the texture underlying format (RGB, RGBA...)
  114521. */
  114522. get textureFormat(): number;
  114523. /**
  114524. * Indicates that textures need to be re-calculated for all materials
  114525. */
  114526. protected _markAllSubMeshesAsTexturesDirty(): void;
  114527. /**
  114528. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114529. * This will returns an RGBA array buffer containing either in values (0-255) or
  114530. * float values (0-1) depending of the underlying buffer type.
  114531. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114532. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114533. * @param buffer defines a user defined buffer to fill with data (can be null)
  114534. * @returns The Array buffer containing the pixels data.
  114535. */
  114536. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114537. /**
  114538. * Release and destroy the underlying lower level texture aka internalTexture.
  114539. */
  114540. releaseInternalTexture(): void;
  114541. /** @hidden */
  114542. get _lodTextureHigh(): Nullable<BaseTexture>;
  114543. /** @hidden */
  114544. get _lodTextureMid(): Nullable<BaseTexture>;
  114545. /** @hidden */
  114546. get _lodTextureLow(): Nullable<BaseTexture>;
  114547. /**
  114548. * Dispose the texture and release its associated resources.
  114549. */
  114550. dispose(): void;
  114551. /**
  114552. * Serialize the texture into a JSON representation that can be parsed later on.
  114553. * @returns the JSON representation of the texture
  114554. */
  114555. serialize(): any;
  114556. /**
  114557. * Helper function to be called back once a list of texture contains only ready textures.
  114558. * @param textures Define the list of textures to wait for
  114559. * @param callback Define the callback triggered once the entire list will be ready
  114560. */
  114561. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114562. private static _isScene;
  114563. }
  114564. }
  114565. declare module BABYLON {
  114566. /**
  114567. * Options to be used when creating an effect.
  114568. */
  114569. export interface IEffectCreationOptions {
  114570. /**
  114571. * Atrributes that will be used in the shader.
  114572. */
  114573. attributes: string[];
  114574. /**
  114575. * Uniform varible names that will be set in the shader.
  114576. */
  114577. uniformsNames: string[];
  114578. /**
  114579. * Uniform buffer variable names that will be set in the shader.
  114580. */
  114581. uniformBuffersNames: string[];
  114582. /**
  114583. * Sampler texture variable names that will be set in the shader.
  114584. */
  114585. samplers: string[];
  114586. /**
  114587. * Define statements that will be set in the shader.
  114588. */
  114589. defines: any;
  114590. /**
  114591. * Possible fallbacks for this effect to improve performance when needed.
  114592. */
  114593. fallbacks: Nullable<IEffectFallbacks>;
  114594. /**
  114595. * Callback that will be called when the shader is compiled.
  114596. */
  114597. onCompiled: Nullable<(effect: Effect) => void>;
  114598. /**
  114599. * Callback that will be called if an error occurs during shader compilation.
  114600. */
  114601. onError: Nullable<(effect: Effect, errors: string) => void>;
  114602. /**
  114603. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114604. */
  114605. indexParameters?: any;
  114606. /**
  114607. * Max number of lights that can be used in the shader.
  114608. */
  114609. maxSimultaneousLights?: number;
  114610. /**
  114611. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114612. */
  114613. transformFeedbackVaryings?: Nullable<string[]>;
  114614. /**
  114615. * 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
  114616. */
  114617. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114618. /**
  114619. * Is this effect rendering to several color attachments ?
  114620. */
  114621. multiTarget?: boolean;
  114622. }
  114623. /**
  114624. * Effect containing vertex and fragment shader that can be executed on an object.
  114625. */
  114626. export class Effect implements IDisposable {
  114627. /**
  114628. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114629. */
  114630. static ShadersRepository: string;
  114631. /**
  114632. * Enable logging of the shader code when a compilation error occurs
  114633. */
  114634. static LogShaderCodeOnCompilationError: boolean;
  114635. /**
  114636. * Name of the effect.
  114637. */
  114638. name: any;
  114639. /**
  114640. * String container all the define statements that should be set on the shader.
  114641. */
  114642. defines: string;
  114643. /**
  114644. * Callback that will be called when the shader is compiled.
  114645. */
  114646. onCompiled: Nullable<(effect: Effect) => void>;
  114647. /**
  114648. * Callback that will be called if an error occurs during shader compilation.
  114649. */
  114650. onError: Nullable<(effect: Effect, errors: string) => void>;
  114651. /**
  114652. * Callback that will be called when effect is bound.
  114653. */
  114654. onBind: Nullable<(effect: Effect) => void>;
  114655. /**
  114656. * Unique ID of the effect.
  114657. */
  114658. uniqueId: number;
  114659. /**
  114660. * Observable that will be called when the shader is compiled.
  114661. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114662. */
  114663. onCompileObservable: Observable<Effect>;
  114664. /**
  114665. * Observable that will be called if an error occurs during shader compilation.
  114666. */
  114667. onErrorObservable: Observable<Effect>;
  114668. /** @hidden */
  114669. _onBindObservable: Nullable<Observable<Effect>>;
  114670. /**
  114671. * @hidden
  114672. * Specifies if the effect was previously ready
  114673. */
  114674. _wasPreviouslyReady: boolean;
  114675. /**
  114676. * Observable that will be called when effect is bound.
  114677. */
  114678. get onBindObservable(): Observable<Effect>;
  114679. /** @hidden */
  114680. _bonesComputationForcedToCPU: boolean;
  114681. /** @hidden */
  114682. _multiTarget: boolean;
  114683. private static _uniqueIdSeed;
  114684. private _engine;
  114685. private _uniformBuffersNames;
  114686. private _uniformBuffersNamesList;
  114687. private _uniformsNames;
  114688. private _samplerList;
  114689. private _samplers;
  114690. private _isReady;
  114691. private _compilationError;
  114692. private _allFallbacksProcessed;
  114693. private _attributesNames;
  114694. private _attributes;
  114695. private _attributeLocationByName;
  114696. private _uniforms;
  114697. /**
  114698. * Key for the effect.
  114699. * @hidden
  114700. */
  114701. _key: string;
  114702. private _indexParameters;
  114703. private _fallbacks;
  114704. private _vertexSourceCode;
  114705. private _fragmentSourceCode;
  114706. private _vertexSourceCodeOverride;
  114707. private _fragmentSourceCodeOverride;
  114708. private _transformFeedbackVaryings;
  114709. /**
  114710. * Compiled shader to webGL program.
  114711. * @hidden
  114712. */
  114713. _pipelineContext: Nullable<IPipelineContext>;
  114714. private _valueCache;
  114715. private static _baseCache;
  114716. /**
  114717. * Instantiates an effect.
  114718. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114719. * @param baseName Name of the effect.
  114720. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114721. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114722. * @param samplers List of sampler variables that will be passed to the shader.
  114723. * @param engine Engine to be used to render the effect
  114724. * @param defines Define statements to be added to the shader.
  114725. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114726. * @param onCompiled Callback that will be called when the shader is compiled.
  114727. * @param onError Callback that will be called if an error occurs during shader compilation.
  114728. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114729. */
  114730. 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);
  114731. private _useFinalCode;
  114732. /**
  114733. * Unique key for this effect
  114734. */
  114735. get key(): string;
  114736. /**
  114737. * If the effect has been compiled and prepared.
  114738. * @returns if the effect is compiled and prepared.
  114739. */
  114740. isReady(): boolean;
  114741. private _isReadyInternal;
  114742. /**
  114743. * The engine the effect was initialized with.
  114744. * @returns the engine.
  114745. */
  114746. getEngine(): Engine;
  114747. /**
  114748. * The pipeline context for this effect
  114749. * @returns the associated pipeline context
  114750. */
  114751. getPipelineContext(): Nullable<IPipelineContext>;
  114752. /**
  114753. * The set of names of attribute variables for the shader.
  114754. * @returns An array of attribute names.
  114755. */
  114756. getAttributesNames(): string[];
  114757. /**
  114758. * Returns the attribute at the given index.
  114759. * @param index The index of the attribute.
  114760. * @returns The location of the attribute.
  114761. */
  114762. getAttributeLocation(index: number): number;
  114763. /**
  114764. * Returns the attribute based on the name of the variable.
  114765. * @param name of the attribute to look up.
  114766. * @returns the attribute location.
  114767. */
  114768. getAttributeLocationByName(name: string): number;
  114769. /**
  114770. * The number of attributes.
  114771. * @returns the numnber of attributes.
  114772. */
  114773. getAttributesCount(): number;
  114774. /**
  114775. * Gets the index of a uniform variable.
  114776. * @param uniformName of the uniform to look up.
  114777. * @returns the index.
  114778. */
  114779. getUniformIndex(uniformName: string): number;
  114780. /**
  114781. * Returns the attribute based on the name of the variable.
  114782. * @param uniformName of the uniform to look up.
  114783. * @returns the location of the uniform.
  114784. */
  114785. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114786. /**
  114787. * Returns an array of sampler variable names
  114788. * @returns The array of sampler variable names.
  114789. */
  114790. getSamplers(): string[];
  114791. /**
  114792. * Returns an array of uniform variable names
  114793. * @returns The array of uniform variable names.
  114794. */
  114795. getUniformNames(): string[];
  114796. /**
  114797. * Returns an array of uniform buffer variable names
  114798. * @returns The array of uniform buffer variable names.
  114799. */
  114800. getUniformBuffersNames(): string[];
  114801. /**
  114802. * Returns the index parameters used to create the effect
  114803. * @returns The index parameters object
  114804. */
  114805. getIndexParameters(): any;
  114806. /**
  114807. * The error from the last compilation.
  114808. * @returns the error string.
  114809. */
  114810. getCompilationError(): string;
  114811. /**
  114812. * Gets a boolean indicating that all fallbacks were used during compilation
  114813. * @returns true if all fallbacks were used
  114814. */
  114815. allFallbacksProcessed(): boolean;
  114816. /**
  114817. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114818. * @param func The callback to be used.
  114819. */
  114820. executeWhenCompiled(func: (effect: Effect) => void): void;
  114821. private _checkIsReady;
  114822. private _loadShader;
  114823. /**
  114824. * Gets the vertex shader source code of this effect
  114825. */
  114826. get vertexSourceCode(): string;
  114827. /**
  114828. * Gets the fragment shader source code of this effect
  114829. */
  114830. get fragmentSourceCode(): string;
  114831. /**
  114832. * Recompiles the webGL program
  114833. * @param vertexSourceCode The source code for the vertex shader.
  114834. * @param fragmentSourceCode The source code for the fragment shader.
  114835. * @param onCompiled Callback called when completed.
  114836. * @param onError Callback called on error.
  114837. * @hidden
  114838. */
  114839. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114840. /**
  114841. * Prepares the effect
  114842. * @hidden
  114843. */
  114844. _prepareEffect(): void;
  114845. private _getShaderCodeAndErrorLine;
  114846. private _processCompilationErrors;
  114847. /**
  114848. * Checks if the effect is supported. (Must be called after compilation)
  114849. */
  114850. get isSupported(): boolean;
  114851. /**
  114852. * Binds a texture to the engine to be used as output of the shader.
  114853. * @param channel Name of the output variable.
  114854. * @param texture Texture to bind.
  114855. * @hidden
  114856. */
  114857. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114858. /**
  114859. * Sets a texture on the engine to be used in the shader.
  114860. * @param channel Name of the sampler variable.
  114861. * @param texture Texture to set.
  114862. */
  114863. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114864. /**
  114865. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114866. * @param channel Name of the sampler variable.
  114867. * @param texture Texture to set.
  114868. */
  114869. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114870. /**
  114871. * Sets an array of textures on the engine to be used in the shader.
  114872. * @param channel Name of the variable.
  114873. * @param textures Textures to set.
  114874. */
  114875. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114876. /**
  114877. * 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)
  114878. * @param channel Name of the sampler variable.
  114879. * @param postProcess Post process to get the input texture from.
  114880. */
  114881. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114882. /**
  114883. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114884. * 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)
  114885. * @param channel Name of the sampler variable.
  114886. * @param postProcess Post process to get the output texture from.
  114887. */
  114888. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114889. /** @hidden */
  114890. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114891. /** @hidden */
  114892. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114893. /** @hidden */
  114894. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114895. /** @hidden */
  114896. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114897. /**
  114898. * Binds a buffer to a uniform.
  114899. * @param buffer Buffer to bind.
  114900. * @param name Name of the uniform variable to bind to.
  114901. */
  114902. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114903. /**
  114904. * Binds block to a uniform.
  114905. * @param blockName Name of the block to bind.
  114906. * @param index Index to bind.
  114907. */
  114908. bindUniformBlock(blockName: string, index: number): void;
  114909. /**
  114910. * Sets an interger value on a uniform variable.
  114911. * @param uniformName Name of the variable.
  114912. * @param value Value to be set.
  114913. * @returns this effect.
  114914. */
  114915. setInt(uniformName: string, value: number): Effect;
  114916. /**
  114917. * Sets an int array on a uniform variable.
  114918. * @param uniformName Name of the variable.
  114919. * @param array array to be set.
  114920. * @returns this effect.
  114921. */
  114922. setIntArray(uniformName: string, array: Int32Array): Effect;
  114923. /**
  114924. * 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)
  114925. * @param uniformName Name of the variable.
  114926. * @param array array to be set.
  114927. * @returns this effect.
  114928. */
  114929. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114930. /**
  114931. * 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)
  114932. * @param uniformName Name of the variable.
  114933. * @param array array to be set.
  114934. * @returns this effect.
  114935. */
  114936. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114937. /**
  114938. * 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)
  114939. * @param uniformName Name of the variable.
  114940. * @param array array to be set.
  114941. * @returns this effect.
  114942. */
  114943. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114944. /**
  114945. * Sets an float array on a uniform variable.
  114946. * @param uniformName Name of the variable.
  114947. * @param array array to be set.
  114948. * @returns this effect.
  114949. */
  114950. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114951. /**
  114952. * 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)
  114953. * @param uniformName Name of the variable.
  114954. * @param array array to be set.
  114955. * @returns this effect.
  114956. */
  114957. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114958. /**
  114959. * 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)
  114960. * @param uniformName Name of the variable.
  114961. * @param array array to be set.
  114962. * @returns this effect.
  114963. */
  114964. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114965. /**
  114966. * 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)
  114967. * @param uniformName Name of the variable.
  114968. * @param array array to be set.
  114969. * @returns this effect.
  114970. */
  114971. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114972. /**
  114973. * Sets an array on a uniform variable.
  114974. * @param uniformName Name of the variable.
  114975. * @param array array to be set.
  114976. * @returns this effect.
  114977. */
  114978. setArray(uniformName: string, array: number[]): Effect;
  114979. /**
  114980. * 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)
  114981. * @param uniformName Name of the variable.
  114982. * @param array array to be set.
  114983. * @returns this effect.
  114984. */
  114985. setArray2(uniformName: string, array: number[]): Effect;
  114986. /**
  114987. * 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)
  114988. * @param uniformName Name of the variable.
  114989. * @param array array to be set.
  114990. * @returns this effect.
  114991. */
  114992. setArray3(uniformName: string, array: number[]): Effect;
  114993. /**
  114994. * 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)
  114995. * @param uniformName Name of the variable.
  114996. * @param array array to be set.
  114997. * @returns this effect.
  114998. */
  114999. setArray4(uniformName: string, array: number[]): Effect;
  115000. /**
  115001. * Sets matrices on a uniform variable.
  115002. * @param uniformName Name of the variable.
  115003. * @param matrices matrices to be set.
  115004. * @returns this effect.
  115005. */
  115006. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115007. /**
  115008. * Sets matrix on a uniform variable.
  115009. * @param uniformName Name of the variable.
  115010. * @param matrix matrix to be set.
  115011. * @returns this effect.
  115012. */
  115013. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115014. /**
  115015. * 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)
  115016. * @param uniformName Name of the variable.
  115017. * @param matrix matrix to be set.
  115018. * @returns this effect.
  115019. */
  115020. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115021. /**
  115022. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115023. * @param uniformName Name of the variable.
  115024. * @param matrix matrix to be set.
  115025. * @returns this effect.
  115026. */
  115027. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115028. /**
  115029. * Sets a float on a uniform variable.
  115030. * @param uniformName Name of the variable.
  115031. * @param value value to be set.
  115032. * @returns this effect.
  115033. */
  115034. setFloat(uniformName: string, value: number): Effect;
  115035. /**
  115036. * Sets a boolean on a uniform variable.
  115037. * @param uniformName Name of the variable.
  115038. * @param bool value to be set.
  115039. * @returns this effect.
  115040. */
  115041. setBool(uniformName: string, bool: boolean): Effect;
  115042. /**
  115043. * Sets a Vector2 on a uniform variable.
  115044. * @param uniformName Name of the variable.
  115045. * @param vector2 vector2 to be set.
  115046. * @returns this effect.
  115047. */
  115048. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115049. /**
  115050. * Sets a float2 on a uniform variable.
  115051. * @param uniformName Name of the variable.
  115052. * @param x First float in float2.
  115053. * @param y Second float in float2.
  115054. * @returns this effect.
  115055. */
  115056. setFloat2(uniformName: string, x: number, y: number): Effect;
  115057. /**
  115058. * Sets a Vector3 on a uniform variable.
  115059. * @param uniformName Name of the variable.
  115060. * @param vector3 Value to be set.
  115061. * @returns this effect.
  115062. */
  115063. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115064. /**
  115065. * Sets a float3 on a uniform variable.
  115066. * @param uniformName Name of the variable.
  115067. * @param x First float in float3.
  115068. * @param y Second float in float3.
  115069. * @param z Third float in float3.
  115070. * @returns this effect.
  115071. */
  115072. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115073. /**
  115074. * Sets a Vector4 on a uniform variable.
  115075. * @param uniformName Name of the variable.
  115076. * @param vector4 Value to be set.
  115077. * @returns this effect.
  115078. */
  115079. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115080. /**
  115081. * Sets a float4 on a uniform variable.
  115082. * @param uniformName Name of the variable.
  115083. * @param x First float in float4.
  115084. * @param y Second float in float4.
  115085. * @param z Third float in float4.
  115086. * @param w Fourth float in float4.
  115087. * @returns this effect.
  115088. */
  115089. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115090. /**
  115091. * Sets a Color3 on a uniform variable.
  115092. * @param uniformName Name of the variable.
  115093. * @param color3 Value to be set.
  115094. * @returns this effect.
  115095. */
  115096. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115097. /**
  115098. * Sets a Color4 on a uniform variable.
  115099. * @param uniformName Name of the variable.
  115100. * @param color3 Value to be set.
  115101. * @param alpha Alpha value to be set.
  115102. * @returns this effect.
  115103. */
  115104. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115105. /**
  115106. * Sets a Color4 on a uniform variable
  115107. * @param uniformName defines the name of the variable
  115108. * @param color4 defines the value to be set
  115109. * @returns this effect.
  115110. */
  115111. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115112. /** Release all associated resources */
  115113. dispose(): void;
  115114. /**
  115115. * This function will add a new shader to the shader store
  115116. * @param name the name of the shader
  115117. * @param pixelShader optional pixel shader content
  115118. * @param vertexShader optional vertex shader content
  115119. */
  115120. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115121. /**
  115122. * Store of each shader (The can be looked up using effect.key)
  115123. */
  115124. static ShadersStore: {
  115125. [key: string]: string;
  115126. };
  115127. /**
  115128. * Store of each included file for a shader (The can be looked up using effect.key)
  115129. */
  115130. static IncludesShadersStore: {
  115131. [key: string]: string;
  115132. };
  115133. /**
  115134. * Resets the cache of effects.
  115135. */
  115136. static ResetCache(): void;
  115137. }
  115138. }
  115139. declare module BABYLON {
  115140. /**
  115141. * Interface used to describe the capabilities of the engine relatively to the current browser
  115142. */
  115143. export interface EngineCapabilities {
  115144. /** Maximum textures units per fragment shader */
  115145. maxTexturesImageUnits: number;
  115146. /** Maximum texture units per vertex shader */
  115147. maxVertexTextureImageUnits: number;
  115148. /** Maximum textures units in the entire pipeline */
  115149. maxCombinedTexturesImageUnits: number;
  115150. /** Maximum texture size */
  115151. maxTextureSize: number;
  115152. /** Maximum texture samples */
  115153. maxSamples?: number;
  115154. /** Maximum cube texture size */
  115155. maxCubemapTextureSize: number;
  115156. /** Maximum render texture size */
  115157. maxRenderTextureSize: number;
  115158. /** Maximum number of vertex attributes */
  115159. maxVertexAttribs: number;
  115160. /** Maximum number of varyings */
  115161. maxVaryingVectors: number;
  115162. /** Maximum number of uniforms per vertex shader */
  115163. maxVertexUniformVectors: number;
  115164. /** Maximum number of uniforms per fragment shader */
  115165. maxFragmentUniformVectors: number;
  115166. /** Defines if standard derivates (dx/dy) are supported */
  115167. standardDerivatives: boolean;
  115168. /** Defines if s3tc texture compression is supported */
  115169. s3tc?: WEBGL_compressed_texture_s3tc;
  115170. /** Defines if pvrtc texture compression is supported */
  115171. pvrtc: any;
  115172. /** Defines if etc1 texture compression is supported */
  115173. etc1: any;
  115174. /** Defines if etc2 texture compression is supported */
  115175. etc2: any;
  115176. /** Defines if astc texture compression is supported */
  115177. astc: any;
  115178. /** Defines if bptc texture compression is supported */
  115179. bptc: any;
  115180. /** Defines if float textures are supported */
  115181. textureFloat: boolean;
  115182. /** Defines if vertex array objects are supported */
  115183. vertexArrayObject: boolean;
  115184. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115185. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115186. /** Gets the maximum level of anisotropy supported */
  115187. maxAnisotropy: number;
  115188. /** Defines if instancing is supported */
  115189. instancedArrays: boolean;
  115190. /** Defines if 32 bits indices are supported */
  115191. uintIndices: boolean;
  115192. /** Defines if high precision shaders are supported */
  115193. highPrecisionShaderSupported: boolean;
  115194. /** Defines if depth reading in the fragment shader is supported */
  115195. fragmentDepthSupported: boolean;
  115196. /** Defines if float texture linear filtering is supported*/
  115197. textureFloatLinearFiltering: boolean;
  115198. /** Defines if rendering to float textures is supported */
  115199. textureFloatRender: boolean;
  115200. /** Defines if half float textures are supported*/
  115201. textureHalfFloat: boolean;
  115202. /** Defines if half float texture linear filtering is supported*/
  115203. textureHalfFloatLinearFiltering: boolean;
  115204. /** Defines if rendering to half float textures is supported */
  115205. textureHalfFloatRender: boolean;
  115206. /** Defines if textureLOD shader command is supported */
  115207. textureLOD: boolean;
  115208. /** Defines if draw buffers extension is supported */
  115209. drawBuffersExtension: boolean;
  115210. /** Defines if depth textures are supported */
  115211. depthTextureExtension: boolean;
  115212. /** Defines if float color buffer are supported */
  115213. colorBufferFloat: boolean;
  115214. /** Gets disjoint timer query extension (null if not supported) */
  115215. timerQuery?: EXT_disjoint_timer_query;
  115216. /** Defines if timestamp can be used with timer query */
  115217. canUseTimestampForTimerQuery: boolean;
  115218. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115219. multiview?: any;
  115220. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115221. oculusMultiview?: any;
  115222. /** Function used to let the system compiles shaders in background */
  115223. parallelShaderCompile?: {
  115224. COMPLETION_STATUS_KHR: number;
  115225. };
  115226. /** Max number of texture samples for MSAA */
  115227. maxMSAASamples: number;
  115228. /** Defines if the blend min max extension is supported */
  115229. blendMinMax: boolean;
  115230. }
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * @hidden
  115235. **/
  115236. export class DepthCullingState {
  115237. private _isDepthTestDirty;
  115238. private _isDepthMaskDirty;
  115239. private _isDepthFuncDirty;
  115240. private _isCullFaceDirty;
  115241. private _isCullDirty;
  115242. private _isZOffsetDirty;
  115243. private _isFrontFaceDirty;
  115244. private _depthTest;
  115245. private _depthMask;
  115246. private _depthFunc;
  115247. private _cull;
  115248. private _cullFace;
  115249. private _zOffset;
  115250. private _frontFace;
  115251. /**
  115252. * Initializes the state.
  115253. */
  115254. constructor();
  115255. get isDirty(): boolean;
  115256. get zOffset(): number;
  115257. set zOffset(value: number);
  115258. get cullFace(): Nullable<number>;
  115259. set cullFace(value: Nullable<number>);
  115260. get cull(): Nullable<boolean>;
  115261. set cull(value: Nullable<boolean>);
  115262. get depthFunc(): Nullable<number>;
  115263. set depthFunc(value: Nullable<number>);
  115264. get depthMask(): boolean;
  115265. set depthMask(value: boolean);
  115266. get depthTest(): boolean;
  115267. set depthTest(value: boolean);
  115268. get frontFace(): Nullable<number>;
  115269. set frontFace(value: Nullable<number>);
  115270. reset(): void;
  115271. apply(gl: WebGLRenderingContext): void;
  115272. }
  115273. }
  115274. declare module BABYLON {
  115275. /**
  115276. * @hidden
  115277. **/
  115278. export class StencilState {
  115279. /** 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 */
  115280. static readonly ALWAYS: number;
  115281. /** Passed to stencilOperation to specify that stencil value must be kept */
  115282. static readonly KEEP: number;
  115283. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115284. static readonly REPLACE: number;
  115285. private _isStencilTestDirty;
  115286. private _isStencilMaskDirty;
  115287. private _isStencilFuncDirty;
  115288. private _isStencilOpDirty;
  115289. private _stencilTest;
  115290. private _stencilMask;
  115291. private _stencilFunc;
  115292. private _stencilFuncRef;
  115293. private _stencilFuncMask;
  115294. private _stencilOpStencilFail;
  115295. private _stencilOpDepthFail;
  115296. private _stencilOpStencilDepthPass;
  115297. get isDirty(): boolean;
  115298. get stencilFunc(): number;
  115299. set stencilFunc(value: number);
  115300. get stencilFuncRef(): number;
  115301. set stencilFuncRef(value: number);
  115302. get stencilFuncMask(): number;
  115303. set stencilFuncMask(value: number);
  115304. get stencilOpStencilFail(): number;
  115305. set stencilOpStencilFail(value: number);
  115306. get stencilOpDepthFail(): number;
  115307. set stencilOpDepthFail(value: number);
  115308. get stencilOpStencilDepthPass(): number;
  115309. set stencilOpStencilDepthPass(value: number);
  115310. get stencilMask(): number;
  115311. set stencilMask(value: number);
  115312. get stencilTest(): boolean;
  115313. set stencilTest(value: boolean);
  115314. constructor();
  115315. reset(): void;
  115316. apply(gl: WebGLRenderingContext): void;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * @hidden
  115322. **/
  115323. export class AlphaState {
  115324. private _isAlphaBlendDirty;
  115325. private _isBlendFunctionParametersDirty;
  115326. private _isBlendEquationParametersDirty;
  115327. private _isBlendConstantsDirty;
  115328. private _alphaBlend;
  115329. private _blendFunctionParameters;
  115330. private _blendEquationParameters;
  115331. private _blendConstants;
  115332. /**
  115333. * Initializes the state.
  115334. */
  115335. constructor();
  115336. get isDirty(): boolean;
  115337. get alphaBlend(): boolean;
  115338. set alphaBlend(value: boolean);
  115339. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115340. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115341. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115342. reset(): void;
  115343. apply(gl: WebGLRenderingContext): void;
  115344. }
  115345. }
  115346. declare module BABYLON {
  115347. /** @hidden */
  115348. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115349. attributeProcessor(attribute: string): string;
  115350. varyingProcessor(varying: string, isFragment: boolean): string;
  115351. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115352. }
  115353. }
  115354. declare module BABYLON {
  115355. /**
  115356. * Interface for attribute information associated with buffer instanciation
  115357. */
  115358. export interface InstancingAttributeInfo {
  115359. /**
  115360. * Name of the GLSL attribute
  115361. * if attribute index is not specified, this is used to retrieve the index from the effect
  115362. */
  115363. attributeName: string;
  115364. /**
  115365. * Index/offset of the attribute in the vertex shader
  115366. * if not specified, this will be computes from the name.
  115367. */
  115368. index?: number;
  115369. /**
  115370. * size of the attribute, 1, 2, 3 or 4
  115371. */
  115372. attributeSize: number;
  115373. /**
  115374. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115375. */
  115376. offset: number;
  115377. /**
  115378. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115379. * default to 1
  115380. */
  115381. divisor?: number;
  115382. /**
  115383. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115384. * default is FLOAT
  115385. */
  115386. attributeType?: number;
  115387. /**
  115388. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115389. */
  115390. normalized?: boolean;
  115391. }
  115392. }
  115393. declare module BABYLON {
  115394. interface ThinEngine {
  115395. /**
  115396. * Update a video texture
  115397. * @param texture defines the texture to update
  115398. * @param video defines the video element to use
  115399. * @param invertY defines if data must be stored with Y axis inverted
  115400. */
  115401. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115402. }
  115403. }
  115404. declare module BABYLON {
  115405. interface ThinEngine {
  115406. /**
  115407. * Creates a dynamic texture
  115408. * @param width defines the width of the texture
  115409. * @param height defines the height of the texture
  115410. * @param generateMipMaps defines if the engine should generate the mip levels
  115411. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115412. * @returns the dynamic texture inside an InternalTexture
  115413. */
  115414. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115415. /**
  115416. * Update the content of a dynamic texture
  115417. * @param texture defines the texture to update
  115418. * @param canvas defines the canvas containing the source
  115419. * @param invertY defines if data must be stored with Y axis inverted
  115420. * @param premulAlpha defines if alpha is stored as premultiplied
  115421. * @param format defines the format of the data
  115422. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115423. */
  115424. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115425. }
  115426. }
  115427. declare module BABYLON {
  115428. /**
  115429. * Settings for finer control over video usage
  115430. */
  115431. export interface VideoTextureSettings {
  115432. /**
  115433. * Applies `autoplay` to video, if specified
  115434. */
  115435. autoPlay?: boolean;
  115436. /**
  115437. * Applies `loop` to video, if specified
  115438. */
  115439. loop?: boolean;
  115440. /**
  115441. * Automatically updates internal texture from video at every frame in the render loop
  115442. */
  115443. autoUpdateTexture: boolean;
  115444. /**
  115445. * Image src displayed during the video loading or until the user interacts with the video.
  115446. */
  115447. poster?: string;
  115448. }
  115449. /**
  115450. * If you want to display a video in your scene, this is the special texture for that.
  115451. * This special texture works similar to other textures, with the exception of a few parameters.
  115452. * @see https://doc.babylonjs.com/how_to/video_texture
  115453. */
  115454. export class VideoTexture extends Texture {
  115455. /**
  115456. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115457. */
  115458. readonly autoUpdateTexture: boolean;
  115459. /**
  115460. * The video instance used by the texture internally
  115461. */
  115462. readonly video: HTMLVideoElement;
  115463. private _onUserActionRequestedObservable;
  115464. /**
  115465. * Event triggerd when a dom action is required by the user to play the video.
  115466. * This happens due to recent changes in browser policies preventing video to auto start.
  115467. */
  115468. get onUserActionRequestedObservable(): Observable<Texture>;
  115469. private _generateMipMaps;
  115470. private _stillImageCaptured;
  115471. private _displayingPosterTexture;
  115472. private _settings;
  115473. private _createInternalTextureOnEvent;
  115474. private _frameId;
  115475. private _currentSrc;
  115476. /**
  115477. * Creates a video texture.
  115478. * If you want to display a video in your scene, this is the special texture for that.
  115479. * This special texture works similar to other textures, with the exception of a few parameters.
  115480. * @see https://doc.babylonjs.com/how_to/video_texture
  115481. * @param name optional name, will detect from video source, if not defined
  115482. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115483. * @param scene is obviously the current scene.
  115484. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115485. * @param invertY is false by default but can be used to invert video on Y axis
  115486. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115487. * @param settings allows finer control over video usage
  115488. */
  115489. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115490. private _getName;
  115491. private _getVideo;
  115492. private _createInternalTexture;
  115493. private reset;
  115494. /**
  115495. * @hidden Internal method to initiate `update`.
  115496. */
  115497. _rebuild(): void;
  115498. /**
  115499. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115500. */
  115501. update(): void;
  115502. /**
  115503. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115504. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115505. */
  115506. updateTexture(isVisible: boolean): void;
  115507. protected _updateInternalTexture: () => void;
  115508. /**
  115509. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115510. * @param url New url.
  115511. */
  115512. updateURL(url: string): void;
  115513. /**
  115514. * Clones the texture.
  115515. * @returns the cloned texture
  115516. */
  115517. clone(): VideoTexture;
  115518. /**
  115519. * Dispose the texture and release its associated resources.
  115520. */
  115521. dispose(): void;
  115522. /**
  115523. * Creates a video texture straight from a stream.
  115524. * @param scene Define the scene the texture should be created in
  115525. * @param stream Define the stream the texture should be created from
  115526. * @returns The created video texture as a promise
  115527. */
  115528. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115529. /**
  115530. * Creates a video texture straight from your WebCam video feed.
  115531. * @param scene Define the scene the texture should be created in
  115532. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115533. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115534. * @returns The created video texture as a promise
  115535. */
  115536. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115537. minWidth: number;
  115538. maxWidth: number;
  115539. minHeight: number;
  115540. maxHeight: number;
  115541. deviceId: string;
  115542. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115543. /**
  115544. * Creates a video texture straight from your WebCam video feed.
  115545. * @param scene Define the scene the texture should be created in
  115546. * @param onReady Define a callback to triggered once the texture will be ready
  115547. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115548. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115549. */
  115550. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115551. minWidth: number;
  115552. maxWidth: number;
  115553. minHeight: number;
  115554. maxHeight: number;
  115555. deviceId: string;
  115556. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115557. }
  115558. }
  115559. declare module BABYLON {
  115560. /**
  115561. * Defines the interface used by objects working like Scene
  115562. * @hidden
  115563. */
  115564. export interface ISceneLike {
  115565. _addPendingData(data: any): void;
  115566. _removePendingData(data: any): void;
  115567. offlineProvider: IOfflineProvider;
  115568. }
  115569. /**
  115570. * Information about the current host
  115571. */
  115572. export interface HostInformation {
  115573. /**
  115574. * Defines if the current host is a mobile
  115575. */
  115576. isMobile: boolean;
  115577. }
  115578. /** Interface defining initialization parameters for Engine class */
  115579. export interface EngineOptions extends WebGLContextAttributes {
  115580. /**
  115581. * Defines if the engine should no exceed a specified device ratio
  115582. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115583. */
  115584. limitDeviceRatio?: number;
  115585. /**
  115586. * Defines if webvr should be enabled automatically
  115587. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115588. */
  115589. autoEnableWebVR?: boolean;
  115590. /**
  115591. * Defines if webgl2 should be turned off even if supported
  115592. * @see https://doc.babylonjs.com/features/webgl2
  115593. */
  115594. disableWebGL2Support?: boolean;
  115595. /**
  115596. * Defines if webaudio should be initialized as well
  115597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115598. */
  115599. audioEngine?: boolean;
  115600. /**
  115601. * Defines if animations should run using a deterministic lock step
  115602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115603. */
  115604. deterministicLockstep?: boolean;
  115605. /** Defines the maximum steps to use with deterministic lock step mode */
  115606. lockstepMaxSteps?: number;
  115607. /** Defines the seconds between each deterministic lock step */
  115608. timeStep?: number;
  115609. /**
  115610. * Defines that engine should ignore context lost events
  115611. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115612. */
  115613. doNotHandleContextLost?: boolean;
  115614. /**
  115615. * Defines that engine should ignore modifying touch action attribute and style
  115616. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115617. */
  115618. doNotHandleTouchAction?: boolean;
  115619. /**
  115620. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115621. */
  115622. useHighPrecisionFloats?: boolean;
  115623. /**
  115624. * Make the canvas XR Compatible for XR sessions
  115625. */
  115626. xrCompatible?: boolean;
  115627. /**
  115628. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115629. */
  115630. useHighPrecisionMatrix?: boolean;
  115631. }
  115632. /**
  115633. * The base engine class (root of all engines)
  115634. */
  115635. export class ThinEngine {
  115636. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115637. static ExceptionList: ({
  115638. key: string;
  115639. capture: string;
  115640. captureConstraint: number;
  115641. targets: string[];
  115642. } | {
  115643. key: string;
  115644. capture: null;
  115645. captureConstraint: null;
  115646. targets: string[];
  115647. })[];
  115648. /** @hidden */
  115649. static _TextureLoaders: IInternalTextureLoader[];
  115650. /**
  115651. * Returns the current npm package of the sdk
  115652. */
  115653. static get NpmPackage(): string;
  115654. /**
  115655. * Returns the current version of the framework
  115656. */
  115657. static get Version(): string;
  115658. /**
  115659. * Returns a string describing the current engine
  115660. */
  115661. get description(): string;
  115662. /**
  115663. * Gets or sets the epsilon value used by collision engine
  115664. */
  115665. static CollisionsEpsilon: number;
  115666. /**
  115667. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115668. */
  115669. static get ShadersRepository(): string;
  115670. static set ShadersRepository(value: string);
  115671. /** @hidden */
  115672. _shaderProcessor: IShaderProcessor;
  115673. /**
  115674. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115675. */
  115676. forcePOTTextures: boolean;
  115677. /**
  115678. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115679. */
  115680. isFullscreen: boolean;
  115681. /**
  115682. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115683. */
  115684. cullBackFaces: boolean;
  115685. /**
  115686. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115687. */
  115688. renderEvenInBackground: boolean;
  115689. /**
  115690. * Gets or sets a boolean indicating that cache can be kept between frames
  115691. */
  115692. preventCacheWipeBetweenFrames: boolean;
  115693. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115694. validateShaderPrograms: boolean;
  115695. /**
  115696. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115697. * This can provide greater z depth for distant objects.
  115698. */
  115699. useReverseDepthBuffer: boolean;
  115700. /**
  115701. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115702. */
  115703. disableUniformBuffers: boolean;
  115704. /** @hidden */
  115705. _uniformBuffers: UniformBuffer[];
  115706. /**
  115707. * Gets a boolean indicating that the engine supports uniform buffers
  115708. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115709. */
  115710. get supportsUniformBuffers(): boolean;
  115711. /** @hidden */
  115712. _gl: WebGLRenderingContext;
  115713. /** @hidden */
  115714. _webGLVersion: number;
  115715. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115716. protected _windowIsBackground: boolean;
  115717. protected _creationOptions: EngineOptions;
  115718. protected _highPrecisionShadersAllowed: boolean;
  115719. /** @hidden */
  115720. get _shouldUseHighPrecisionShader(): boolean;
  115721. /**
  115722. * Gets a boolean indicating that only power of 2 textures are supported
  115723. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115724. */
  115725. get needPOTTextures(): boolean;
  115726. /** @hidden */
  115727. _badOS: boolean;
  115728. /** @hidden */
  115729. _badDesktopOS: boolean;
  115730. private _hardwareScalingLevel;
  115731. /** @hidden */
  115732. _caps: EngineCapabilities;
  115733. private _isStencilEnable;
  115734. private _glVersion;
  115735. private _glRenderer;
  115736. private _glVendor;
  115737. /** @hidden */
  115738. _videoTextureSupported: boolean;
  115739. protected _renderingQueueLaunched: boolean;
  115740. protected _activeRenderLoops: (() => void)[];
  115741. /**
  115742. * Observable signaled when a context lost event is raised
  115743. */
  115744. onContextLostObservable: Observable<ThinEngine>;
  115745. /**
  115746. * Observable signaled when a context restored event is raised
  115747. */
  115748. onContextRestoredObservable: Observable<ThinEngine>;
  115749. private _onContextLost;
  115750. private _onContextRestored;
  115751. protected _contextWasLost: boolean;
  115752. /** @hidden */
  115753. _doNotHandleContextLost: boolean;
  115754. /**
  115755. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115757. */
  115758. get doNotHandleContextLost(): boolean;
  115759. set doNotHandleContextLost(value: boolean);
  115760. /**
  115761. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115762. */
  115763. disableVertexArrayObjects: boolean;
  115764. /** @hidden */
  115765. protected _colorWrite: boolean;
  115766. /** @hidden */
  115767. protected _colorWriteChanged: boolean;
  115768. /** @hidden */
  115769. protected _depthCullingState: DepthCullingState;
  115770. /** @hidden */
  115771. protected _stencilState: StencilState;
  115772. /** @hidden */
  115773. _alphaState: AlphaState;
  115774. /** @hidden */
  115775. _alphaMode: number;
  115776. /** @hidden */
  115777. _alphaEquation: number;
  115778. /** @hidden */
  115779. _internalTexturesCache: InternalTexture[];
  115780. /** @hidden */
  115781. protected _activeChannel: number;
  115782. private _currentTextureChannel;
  115783. /** @hidden */
  115784. protected _boundTexturesCache: {
  115785. [key: string]: Nullable<InternalTexture>;
  115786. };
  115787. /** @hidden */
  115788. protected _currentEffect: Nullable<Effect>;
  115789. /** @hidden */
  115790. protected _currentProgram: Nullable<WebGLProgram>;
  115791. private _compiledEffects;
  115792. private _vertexAttribArraysEnabled;
  115793. /** @hidden */
  115794. protected _cachedViewport: Nullable<IViewportLike>;
  115795. private _cachedVertexArrayObject;
  115796. /** @hidden */
  115797. protected _cachedVertexBuffers: any;
  115798. /** @hidden */
  115799. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115800. /** @hidden */
  115801. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115802. /** @hidden */
  115803. _currentRenderTarget: Nullable<InternalTexture>;
  115804. private _uintIndicesCurrentlySet;
  115805. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115806. /** @hidden */
  115807. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115808. /** @hidden */
  115809. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115810. private _currentBufferPointers;
  115811. private _currentInstanceLocations;
  115812. private _currentInstanceBuffers;
  115813. private _textureUnits;
  115814. /** @hidden */
  115815. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115816. /** @hidden */
  115817. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115818. /** @hidden */
  115819. _boundRenderFunction: any;
  115820. private _vaoRecordInProgress;
  115821. private _mustWipeVertexAttributes;
  115822. private _emptyTexture;
  115823. private _emptyCubeTexture;
  115824. private _emptyTexture3D;
  115825. private _emptyTexture2DArray;
  115826. /** @hidden */
  115827. _frameHandler: number;
  115828. private _nextFreeTextureSlots;
  115829. private _maxSimultaneousTextures;
  115830. private _activeRequests;
  115831. /** @hidden */
  115832. _transformTextureUrl: Nullable<(url: string) => string>;
  115833. /**
  115834. * Gets information about the current host
  115835. */
  115836. hostInformation: HostInformation;
  115837. protected get _supportsHardwareTextureRescaling(): boolean;
  115838. private _framebufferDimensionsObject;
  115839. /**
  115840. * sets the object from which width and height will be taken from when getting render width and height
  115841. * Will fallback to the gl object
  115842. * @param dimensions the framebuffer width and height that will be used.
  115843. */
  115844. set framebufferDimensionsObject(dimensions: Nullable<{
  115845. framebufferWidth: number;
  115846. framebufferHeight: number;
  115847. }>);
  115848. /**
  115849. * Gets the current viewport
  115850. */
  115851. get currentViewport(): Nullable<IViewportLike>;
  115852. /**
  115853. * Gets the default empty texture
  115854. */
  115855. get emptyTexture(): InternalTexture;
  115856. /**
  115857. * Gets the default empty 3D texture
  115858. */
  115859. get emptyTexture3D(): InternalTexture;
  115860. /**
  115861. * Gets the default empty 2D array texture
  115862. */
  115863. get emptyTexture2DArray(): InternalTexture;
  115864. /**
  115865. * Gets the default empty cube texture
  115866. */
  115867. get emptyCubeTexture(): InternalTexture;
  115868. /**
  115869. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115870. */
  115871. readonly premultipliedAlpha: boolean;
  115872. /**
  115873. * Observable event triggered before each texture is initialized
  115874. */
  115875. onBeforeTextureInitObservable: Observable<Texture>;
  115876. /**
  115877. * Creates a new engine
  115878. * @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
  115879. * @param antialias defines enable antialiasing (default: false)
  115880. * @param options defines further options to be sent to the getContext() function
  115881. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115882. */
  115883. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115884. private _rebuildInternalTextures;
  115885. private _rebuildEffects;
  115886. /**
  115887. * Gets a boolean indicating if all created effects are ready
  115888. * @returns true if all effects are ready
  115889. */
  115890. areAllEffectsReady(): boolean;
  115891. protected _rebuildBuffers(): void;
  115892. protected _initGLContext(): void;
  115893. /**
  115894. * Gets version of the current webGL context
  115895. */
  115896. get webGLVersion(): number;
  115897. /**
  115898. * Gets a string identifying the name of the class
  115899. * @returns "Engine" string
  115900. */
  115901. getClassName(): string;
  115902. /**
  115903. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115904. */
  115905. get isStencilEnable(): boolean;
  115906. /** @hidden */
  115907. _prepareWorkingCanvas(): void;
  115908. /**
  115909. * Reset the texture cache to empty state
  115910. */
  115911. resetTextureCache(): void;
  115912. /**
  115913. * Gets an object containing information about the current webGL context
  115914. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115915. */
  115916. getGlInfo(): {
  115917. vendor: string;
  115918. renderer: string;
  115919. version: string;
  115920. };
  115921. /**
  115922. * Defines the hardware scaling level.
  115923. * By default the hardware scaling level is computed from the window device ratio.
  115924. * 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.
  115925. * @param level defines the level to use
  115926. */
  115927. setHardwareScalingLevel(level: number): void;
  115928. /**
  115929. * Gets the current hardware scaling level.
  115930. * By default the hardware scaling level is computed from the window device ratio.
  115931. * 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.
  115932. * @returns a number indicating the current hardware scaling level
  115933. */
  115934. getHardwareScalingLevel(): number;
  115935. /**
  115936. * Gets the list of loaded textures
  115937. * @returns an array containing all loaded textures
  115938. */
  115939. getLoadedTexturesCache(): InternalTexture[];
  115940. /**
  115941. * Gets the object containing all engine capabilities
  115942. * @returns the EngineCapabilities object
  115943. */
  115944. getCaps(): EngineCapabilities;
  115945. /**
  115946. * stop executing a render loop function and remove it from the execution array
  115947. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115948. */
  115949. stopRenderLoop(renderFunction?: () => void): void;
  115950. /** @hidden */
  115951. _renderLoop(): void;
  115952. /**
  115953. * Gets the HTML canvas attached with the current webGL context
  115954. * @returns a HTML canvas
  115955. */
  115956. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115957. /**
  115958. * Gets host window
  115959. * @returns the host window object
  115960. */
  115961. getHostWindow(): Nullable<Window>;
  115962. /**
  115963. * Gets the current render width
  115964. * @param useScreen defines if screen size must be used (or the current render target if any)
  115965. * @returns a number defining the current render width
  115966. */
  115967. getRenderWidth(useScreen?: boolean): number;
  115968. /**
  115969. * Gets the current render height
  115970. * @param useScreen defines if screen size must be used (or the current render target if any)
  115971. * @returns a number defining the current render height
  115972. */
  115973. getRenderHeight(useScreen?: boolean): number;
  115974. /**
  115975. * Can be used to override the current requestAnimationFrame requester.
  115976. * @hidden
  115977. */
  115978. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115979. /**
  115980. * Register and execute a render loop. The engine can have more than one render function
  115981. * @param renderFunction defines the function to continuously execute
  115982. */
  115983. runRenderLoop(renderFunction: () => void): void;
  115984. /**
  115985. * Clear the current render buffer or the current render target (if any is set up)
  115986. * @param color defines the color to use
  115987. * @param backBuffer defines if the back buffer must be cleared
  115988. * @param depth defines if the depth buffer must be cleared
  115989. * @param stencil defines if the stencil buffer must be cleared
  115990. */
  115991. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115992. private _viewportCached;
  115993. /** @hidden */
  115994. _viewport(x: number, y: number, width: number, height: number): void;
  115995. /**
  115996. * Set the WebGL's viewport
  115997. * @param viewport defines the viewport element to be used
  115998. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115999. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116000. */
  116001. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116002. /**
  116003. * Begin a new frame
  116004. */
  116005. beginFrame(): void;
  116006. /**
  116007. * Enf the current frame
  116008. */
  116009. endFrame(): void;
  116010. /**
  116011. * Resize the view according to the canvas' size
  116012. */
  116013. resize(): void;
  116014. /**
  116015. * Force a specific size of the canvas
  116016. * @param width defines the new canvas' width
  116017. * @param height defines the new canvas' height
  116018. * @returns true if the size was changed
  116019. */
  116020. setSize(width: number, height: number): boolean;
  116021. /**
  116022. * Binds the frame buffer to the specified texture.
  116023. * @param texture The texture to render to or null for the default canvas
  116024. * @param faceIndex The face of the texture to render to in case of cube texture
  116025. * @param requiredWidth The width of the target to render to
  116026. * @param requiredHeight The height of the target to render to
  116027. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116028. * @param lodLevel defines the lod level to bind to the frame buffer
  116029. * @param layer defines the 2d array index to bind to frame buffer to
  116030. */
  116031. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116032. /** @hidden */
  116033. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116034. /**
  116035. * Unbind the current render target texture from the webGL context
  116036. * @param texture defines the render target texture to unbind
  116037. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116038. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116039. */
  116040. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116041. /**
  116042. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116043. */
  116044. flushFramebuffer(): void;
  116045. /**
  116046. * Unbind the current render target and bind the default framebuffer
  116047. */
  116048. restoreDefaultFramebuffer(): void;
  116049. /** @hidden */
  116050. protected _resetVertexBufferBinding(): void;
  116051. /**
  116052. * Creates a vertex buffer
  116053. * @param data the data for the vertex buffer
  116054. * @returns the new WebGL static buffer
  116055. */
  116056. createVertexBuffer(data: DataArray): DataBuffer;
  116057. private _createVertexBuffer;
  116058. /**
  116059. * Creates a dynamic vertex buffer
  116060. * @param data the data for the dynamic vertex buffer
  116061. * @returns the new WebGL dynamic buffer
  116062. */
  116063. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116064. protected _resetIndexBufferBinding(): void;
  116065. /**
  116066. * Creates a new index buffer
  116067. * @param indices defines the content of the index buffer
  116068. * @param updatable defines if the index buffer must be updatable
  116069. * @returns a new webGL buffer
  116070. */
  116071. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116072. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116073. /**
  116074. * Bind a webGL buffer to the webGL context
  116075. * @param buffer defines the buffer to bind
  116076. */
  116077. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116078. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116079. private bindBuffer;
  116080. /**
  116081. * update the bound buffer with the given data
  116082. * @param data defines the data to update
  116083. */
  116084. updateArrayBuffer(data: Float32Array): void;
  116085. private _vertexAttribPointer;
  116086. /** @hidden */
  116087. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116088. private _bindVertexBuffersAttributes;
  116089. /**
  116090. * Records a vertex array object
  116091. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116092. * @param vertexBuffers defines the list of vertex buffers to store
  116093. * @param indexBuffer defines the index buffer to store
  116094. * @param effect defines the effect to store
  116095. * @returns the new vertex array object
  116096. */
  116097. recordVertexArrayObject(vertexBuffers: {
  116098. [key: string]: VertexBuffer;
  116099. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116100. /**
  116101. * Bind a specific vertex array object
  116102. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116103. * @param vertexArrayObject defines the vertex array object to bind
  116104. * @param indexBuffer defines the index buffer to bind
  116105. */
  116106. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116107. /**
  116108. * Bind webGl buffers directly to the webGL context
  116109. * @param vertexBuffer defines the vertex buffer to bind
  116110. * @param indexBuffer defines the index buffer to bind
  116111. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116112. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116113. * @param effect defines the effect associated with the vertex buffer
  116114. */
  116115. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116116. private _unbindVertexArrayObject;
  116117. /**
  116118. * Bind a list of vertex buffers to the webGL context
  116119. * @param vertexBuffers defines the list of vertex buffers to bind
  116120. * @param indexBuffer defines the index buffer to bind
  116121. * @param effect defines the effect associated with the vertex buffers
  116122. */
  116123. bindBuffers(vertexBuffers: {
  116124. [key: string]: Nullable<VertexBuffer>;
  116125. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116126. /**
  116127. * Unbind all instance attributes
  116128. */
  116129. unbindInstanceAttributes(): void;
  116130. /**
  116131. * Release and free the memory of a vertex array object
  116132. * @param vao defines the vertex array object to delete
  116133. */
  116134. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116135. /** @hidden */
  116136. _releaseBuffer(buffer: DataBuffer): boolean;
  116137. protected _deleteBuffer(buffer: DataBuffer): void;
  116138. /**
  116139. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116140. * @param instancesBuffer defines the webGL buffer to update and bind
  116141. * @param data defines the data to store in the buffer
  116142. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116143. */
  116144. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116145. /**
  116146. * Bind the content of a webGL buffer used with instantiation
  116147. * @param instancesBuffer defines the webGL buffer to bind
  116148. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116149. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116150. */
  116151. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116152. /**
  116153. * Disable the instance attribute corresponding to the name in parameter
  116154. * @param name defines the name of the attribute to disable
  116155. */
  116156. disableInstanceAttributeByName(name: string): void;
  116157. /**
  116158. * Disable the instance attribute corresponding to the location in parameter
  116159. * @param attributeLocation defines the attribute location of the attribute to disable
  116160. */
  116161. disableInstanceAttribute(attributeLocation: number): void;
  116162. /**
  116163. * Disable the attribute corresponding to the location in parameter
  116164. * @param attributeLocation defines the attribute location of the attribute to disable
  116165. */
  116166. disableAttributeByIndex(attributeLocation: number): void;
  116167. /**
  116168. * Send a draw order
  116169. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116170. * @param indexStart defines the starting index
  116171. * @param indexCount defines the number of index to draw
  116172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116173. */
  116174. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116175. /**
  116176. * Draw a list of points
  116177. * @param verticesStart defines the index of first vertex to draw
  116178. * @param verticesCount defines the count of vertices to draw
  116179. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116180. */
  116181. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116182. /**
  116183. * Draw a list of unindexed primitives
  116184. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116185. * @param verticesStart defines the index of first vertex to draw
  116186. * @param verticesCount defines the count of vertices to draw
  116187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116188. */
  116189. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116190. /**
  116191. * Draw a list of indexed primitives
  116192. * @param fillMode defines the primitive to use
  116193. * @param indexStart defines the starting index
  116194. * @param indexCount defines the number of index to draw
  116195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116196. */
  116197. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116198. /**
  116199. * Draw a list of unindexed primitives
  116200. * @param fillMode defines the primitive to use
  116201. * @param verticesStart defines the index of first vertex to draw
  116202. * @param verticesCount defines the count of vertices to draw
  116203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116204. */
  116205. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116206. private _drawMode;
  116207. /** @hidden */
  116208. protected _reportDrawCall(): void;
  116209. /** @hidden */
  116210. _releaseEffect(effect: Effect): void;
  116211. /** @hidden */
  116212. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116213. /**
  116214. * Create a new effect (used to store vertex/fragment shaders)
  116215. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116216. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116217. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116218. * @param samplers defines an array of string used to represent textures
  116219. * @param defines defines the string containing the defines to use to compile the shaders
  116220. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116221. * @param onCompiled defines a function to call when the effect creation is successful
  116222. * @param onError defines a function to call when the effect creation has failed
  116223. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116224. * @returns the new Effect
  116225. */
  116226. 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;
  116227. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116228. private _compileShader;
  116229. private _compileRawShader;
  116230. /** @hidden */
  116231. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116232. /**
  116233. * Directly creates a webGL program
  116234. * @param pipelineContext defines the pipeline context to attach to
  116235. * @param vertexCode defines the vertex shader code to use
  116236. * @param fragmentCode defines the fragment shader code to use
  116237. * @param context defines the webGL context to use (if not set, the current one will be used)
  116238. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116239. * @returns the new webGL program
  116240. */
  116241. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116242. /**
  116243. * Creates a webGL program
  116244. * @param pipelineContext defines the pipeline context to attach to
  116245. * @param vertexCode defines the vertex shader code to use
  116246. * @param fragmentCode defines the fragment shader code to use
  116247. * @param defines defines the string containing the defines to use to compile the shaders
  116248. * @param context defines the webGL context to use (if not set, the current one will be used)
  116249. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116250. * @returns the new webGL program
  116251. */
  116252. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116253. /**
  116254. * Creates a new pipeline context
  116255. * @returns the new pipeline
  116256. */
  116257. createPipelineContext(): IPipelineContext;
  116258. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116259. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116260. /** @hidden */
  116261. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116262. /** @hidden */
  116263. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116264. /** @hidden */
  116265. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116266. /**
  116267. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116268. * @param pipelineContext defines the pipeline context to use
  116269. * @param uniformsNames defines the list of uniform names
  116270. * @returns an array of webGL uniform locations
  116271. */
  116272. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116273. /**
  116274. * Gets the lsit of active attributes for a given webGL program
  116275. * @param pipelineContext defines the pipeline context to use
  116276. * @param attributesNames defines the list of attribute names to get
  116277. * @returns an array of indices indicating the offset of each attribute
  116278. */
  116279. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116280. /**
  116281. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116282. * @param effect defines the effect to activate
  116283. */
  116284. enableEffect(effect: Nullable<Effect>): void;
  116285. /**
  116286. * Set the value of an uniform to a number (int)
  116287. * @param uniform defines the webGL uniform location where to store the value
  116288. * @param value defines the int number to store
  116289. * @returns true if the value was set
  116290. */
  116291. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116292. /**
  116293. * Set the value of an uniform to an array of int32
  116294. * @param uniform defines the webGL uniform location where to store the value
  116295. * @param array defines the array of int32 to store
  116296. * @returns true if the value was set
  116297. */
  116298. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116299. /**
  116300. * Set the value of an uniform to an array of int32 (stored as vec2)
  116301. * @param uniform defines the webGL uniform location where to store the value
  116302. * @param array defines the array of int32 to store
  116303. * @returns true if the value was set
  116304. */
  116305. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116306. /**
  116307. * Set the value of an uniform to an array of int32 (stored as vec3)
  116308. * @param uniform defines the webGL uniform location where to store the value
  116309. * @param array defines the array of int32 to store
  116310. * @returns true if the value was set
  116311. */
  116312. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116313. /**
  116314. * Set the value of an uniform to an array of int32 (stored as vec4)
  116315. * @param uniform defines the webGL uniform location where to store the value
  116316. * @param array defines the array of int32 to store
  116317. * @returns true if the value was set
  116318. */
  116319. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116320. /**
  116321. * Set the value of an uniform to an array of number
  116322. * @param uniform defines the webGL uniform location where to store the value
  116323. * @param array defines the array of number to store
  116324. * @returns true if the value was set
  116325. */
  116326. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116327. /**
  116328. * Set the value of an uniform to an array of number (stored as vec2)
  116329. * @param uniform defines the webGL uniform location where to store the value
  116330. * @param array defines the array of number to store
  116331. * @returns true if the value was set
  116332. */
  116333. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116334. /**
  116335. * Set the value of an uniform to an array of number (stored as vec3)
  116336. * @param uniform defines the webGL uniform location where to store the value
  116337. * @param array defines the array of number to store
  116338. * @returns true if the value was set
  116339. */
  116340. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116341. /**
  116342. * Set the value of an uniform to an array of number (stored as vec4)
  116343. * @param uniform defines the webGL uniform location where to store the value
  116344. * @param array defines the array of number to store
  116345. * @returns true if the value was set
  116346. */
  116347. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116348. /**
  116349. * Set the value of an uniform to an array of float32 (stored as matrices)
  116350. * @param uniform defines the webGL uniform location where to store the value
  116351. * @param matrices defines the array of float32 to store
  116352. * @returns true if the value was set
  116353. */
  116354. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116355. /**
  116356. * Set the value of an uniform to a matrix (3x3)
  116357. * @param uniform defines the webGL uniform location where to store the value
  116358. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116359. * @returns true if the value was set
  116360. */
  116361. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116362. /**
  116363. * Set the value of an uniform to a matrix (2x2)
  116364. * @param uniform defines the webGL uniform location where to store the value
  116365. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116366. * @returns true if the value was set
  116367. */
  116368. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116369. /**
  116370. * Set the value of an uniform to a number (float)
  116371. * @param uniform defines the webGL uniform location where to store the value
  116372. * @param value defines the float number to store
  116373. * @returns true if the value was transfered
  116374. */
  116375. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116376. /**
  116377. * Set the value of an uniform to a vec2
  116378. * @param uniform defines the webGL uniform location where to store the value
  116379. * @param x defines the 1st component of the value
  116380. * @param y defines the 2nd component of the value
  116381. * @returns true if the value was set
  116382. */
  116383. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116384. /**
  116385. * Set the value of an uniform to a vec3
  116386. * @param uniform defines the webGL uniform location where to store the value
  116387. * @param x defines the 1st component of the value
  116388. * @param y defines the 2nd component of the value
  116389. * @param z defines the 3rd component of the value
  116390. * @returns true if the value was set
  116391. */
  116392. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116393. /**
  116394. * Set the value of an uniform to a vec4
  116395. * @param uniform defines the webGL uniform location where to store the value
  116396. * @param x defines the 1st component of the value
  116397. * @param y defines the 2nd component of the value
  116398. * @param z defines the 3rd component of the value
  116399. * @param w defines the 4th component of the value
  116400. * @returns true if the value was set
  116401. */
  116402. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116403. /**
  116404. * Apply all cached states (depth, culling, stencil and alpha)
  116405. */
  116406. applyStates(): void;
  116407. /**
  116408. * Enable or disable color writing
  116409. * @param enable defines the state to set
  116410. */
  116411. setColorWrite(enable: boolean): void;
  116412. /**
  116413. * Gets a boolean indicating if color writing is enabled
  116414. * @returns the current color writing state
  116415. */
  116416. getColorWrite(): boolean;
  116417. /**
  116418. * Gets the depth culling state manager
  116419. */
  116420. get depthCullingState(): DepthCullingState;
  116421. /**
  116422. * Gets the alpha state manager
  116423. */
  116424. get alphaState(): AlphaState;
  116425. /**
  116426. * Gets the stencil state manager
  116427. */
  116428. get stencilState(): StencilState;
  116429. /**
  116430. * Clears the list of texture accessible through engine.
  116431. * This can help preventing texture load conflict due to name collision.
  116432. */
  116433. clearInternalTexturesCache(): void;
  116434. /**
  116435. * Force the entire cache to be cleared
  116436. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116437. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116438. */
  116439. wipeCaches(bruteForce?: boolean): void;
  116440. /** @hidden */
  116441. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116442. min: number;
  116443. mag: number;
  116444. };
  116445. /** @hidden */
  116446. _createTexture(): WebGLTexture;
  116447. /**
  116448. * Usually called from Texture.ts.
  116449. * Passed information to create a WebGLTexture
  116450. * @param url defines a value which contains one of the following:
  116451. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116452. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116453. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116455. * @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)
  116456. * @param scene needed for loading to the correct scene
  116457. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116458. * @param onLoad optional callback to be called upon successful completion
  116459. * @param onError optional callback to be called upon failure
  116460. * @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
  116461. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116462. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116463. * @param forcedExtension defines the extension to use to pick the right loader
  116464. * @param mimeType defines an optional mime type
  116465. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116466. */
  116467. 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;
  116468. /**
  116469. * Loads an image as an HTMLImageElement.
  116470. * @param input url string, ArrayBuffer, or Blob to load
  116471. * @param onLoad callback called when the image successfully loads
  116472. * @param onError callback called when the image fails to load
  116473. * @param offlineProvider offline provider for caching
  116474. * @param mimeType optional mime type
  116475. * @returns the HTMLImageElement of the loaded image
  116476. * @hidden
  116477. */
  116478. 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>;
  116479. /**
  116480. * @hidden
  116481. */
  116482. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116483. private _unpackFlipYCached;
  116484. /**
  116485. * In case you are sharing the context with other applications, it might
  116486. * be interested to not cache the unpack flip y state to ensure a consistent
  116487. * value would be set.
  116488. */
  116489. enableUnpackFlipYCached: boolean;
  116490. /** @hidden */
  116491. _unpackFlipY(value: boolean): void;
  116492. /** @hidden */
  116493. _getUnpackAlignement(): number;
  116494. private _getTextureTarget;
  116495. /**
  116496. * Update the sampling mode of a given texture
  116497. * @param samplingMode defines the required sampling mode
  116498. * @param texture defines the texture to update
  116499. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116500. */
  116501. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116502. /**
  116503. * Update the sampling mode of a given texture
  116504. * @param texture defines the texture to update
  116505. * @param wrapU defines the texture wrap mode of the u coordinates
  116506. * @param wrapV defines the texture wrap mode of the v coordinates
  116507. * @param wrapR defines the texture wrap mode of the r coordinates
  116508. */
  116509. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116510. /** @hidden */
  116511. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116512. width: number;
  116513. height: number;
  116514. layers?: number;
  116515. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116516. /** @hidden */
  116517. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116518. /** @hidden */
  116519. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116520. /**
  116521. * Update a portion of an internal texture
  116522. * @param texture defines the texture to update
  116523. * @param imageData defines the data to store into the texture
  116524. * @param xOffset defines the x coordinates of the update rectangle
  116525. * @param yOffset defines the y coordinates of the update rectangle
  116526. * @param width defines the width of the update rectangle
  116527. * @param height defines the height of the update rectangle
  116528. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116529. * @param lod defines the lod level to update (0 by default)
  116530. */
  116531. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116532. /** @hidden */
  116533. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116534. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116535. private _prepareWebGLTexture;
  116536. /** @hidden */
  116537. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116538. private _getDepthStencilBuffer;
  116539. /** @hidden */
  116540. _releaseFramebufferObjects(texture: InternalTexture): void;
  116541. /** @hidden */
  116542. _releaseTexture(texture: InternalTexture): void;
  116543. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116544. protected _setProgram(program: WebGLProgram): void;
  116545. protected _boundUniforms: {
  116546. [key: number]: WebGLUniformLocation;
  116547. };
  116548. /**
  116549. * Binds an effect to the webGL context
  116550. * @param effect defines the effect to bind
  116551. */
  116552. bindSamplers(effect: Effect): void;
  116553. private _activateCurrentTexture;
  116554. /** @hidden */
  116555. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116556. /** @hidden */
  116557. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116558. /**
  116559. * Unbind all textures from the webGL context
  116560. */
  116561. unbindAllTextures(): void;
  116562. /**
  116563. * Sets a texture to the according uniform.
  116564. * @param channel The texture channel
  116565. * @param uniform The uniform to set
  116566. * @param texture The texture to apply
  116567. */
  116568. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116569. private _bindSamplerUniformToChannel;
  116570. private _getTextureWrapMode;
  116571. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116572. /**
  116573. * Sets an array of texture to the webGL context
  116574. * @param channel defines the channel where the texture array must be set
  116575. * @param uniform defines the associated uniform location
  116576. * @param textures defines the array of textures to bind
  116577. */
  116578. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116579. /** @hidden */
  116580. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116581. private _setTextureParameterFloat;
  116582. private _setTextureParameterInteger;
  116583. /**
  116584. * Unbind all vertex attributes from the webGL context
  116585. */
  116586. unbindAllAttributes(): void;
  116587. /**
  116588. * 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
  116589. */
  116590. releaseEffects(): void;
  116591. /**
  116592. * Dispose and release all associated resources
  116593. */
  116594. dispose(): void;
  116595. /**
  116596. * Attach a new callback raised when context lost event is fired
  116597. * @param callback defines the callback to call
  116598. */
  116599. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116600. /**
  116601. * Attach a new callback raised when context restored event is fired
  116602. * @param callback defines the callback to call
  116603. */
  116604. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116605. /**
  116606. * Get the current error code of the webGL context
  116607. * @returns the error code
  116608. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116609. */
  116610. getError(): number;
  116611. private _canRenderToFloatFramebuffer;
  116612. private _canRenderToHalfFloatFramebuffer;
  116613. private _canRenderToFramebuffer;
  116614. /** @hidden */
  116615. _getWebGLTextureType(type: number): number;
  116616. /** @hidden */
  116617. _getInternalFormat(format: number): number;
  116618. /** @hidden */
  116619. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116620. /** @hidden */
  116621. _getRGBAMultiSampleBufferFormat(type: number): number;
  116622. /** @hidden */
  116623. _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;
  116624. /**
  116625. * Loads a file from a url
  116626. * @param url url to load
  116627. * @param onSuccess callback called when the file successfully loads
  116628. * @param onProgress callback called while file is loading (if the server supports this mode)
  116629. * @param offlineProvider defines the offline provider for caching
  116630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116631. * @param onError callback called when the file fails to load
  116632. * @returns a file request object
  116633. * @hidden
  116634. */
  116635. 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;
  116636. /**
  116637. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116638. * @param x defines the x coordinate of the rectangle where pixels must be read
  116639. * @param y defines the y coordinate of the rectangle where pixels must be read
  116640. * @param width defines the width of the rectangle where pixels must be read
  116641. * @param height defines the height of the rectangle where pixels must be read
  116642. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116643. * @returns a Uint8Array containing RGBA colors
  116644. */
  116645. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116646. private static _isSupported;
  116647. /**
  116648. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116649. * @returns true if the engine can be created
  116650. * @ignorenaming
  116651. */
  116652. static isSupported(): boolean;
  116653. /**
  116654. * Find the next highest power of two.
  116655. * @param x Number to start search from.
  116656. * @return Next highest power of two.
  116657. */
  116658. static CeilingPOT(x: number): number;
  116659. /**
  116660. * Find the next lowest power of two.
  116661. * @param x Number to start search from.
  116662. * @return Next lowest power of two.
  116663. */
  116664. static FloorPOT(x: number): number;
  116665. /**
  116666. * Find the nearest power of two.
  116667. * @param x Number to start search from.
  116668. * @return Next nearest power of two.
  116669. */
  116670. static NearestPOT(x: number): number;
  116671. /**
  116672. * Get the closest exponent of two
  116673. * @param value defines the value to approximate
  116674. * @param max defines the maximum value to return
  116675. * @param mode defines how to define the closest value
  116676. * @returns closest exponent of two of the given value
  116677. */
  116678. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116679. /**
  116680. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116681. * @param func - the function to be called
  116682. * @param requester - the object that will request the next frame. Falls back to window.
  116683. * @returns frame number
  116684. */
  116685. static QueueNewFrame(func: () => void, requester?: any): number;
  116686. /**
  116687. * Gets host document
  116688. * @returns the host document object
  116689. */
  116690. getHostDocument(): Nullable<Document>;
  116691. }
  116692. }
  116693. declare module BABYLON {
  116694. /**
  116695. * Class representing spherical harmonics coefficients to the 3rd degree
  116696. */
  116697. export class SphericalHarmonics {
  116698. /**
  116699. * Defines whether or not the harmonics have been prescaled for rendering.
  116700. */
  116701. preScaled: boolean;
  116702. /**
  116703. * The l0,0 coefficients of the spherical harmonics
  116704. */
  116705. l00: Vector3;
  116706. /**
  116707. * The l1,-1 coefficients of the spherical harmonics
  116708. */
  116709. l1_1: Vector3;
  116710. /**
  116711. * The l1,0 coefficients of the spherical harmonics
  116712. */
  116713. l10: Vector3;
  116714. /**
  116715. * The l1,1 coefficients of the spherical harmonics
  116716. */
  116717. l11: Vector3;
  116718. /**
  116719. * The l2,-2 coefficients of the spherical harmonics
  116720. */
  116721. l2_2: Vector3;
  116722. /**
  116723. * The l2,-1 coefficients of the spherical harmonics
  116724. */
  116725. l2_1: Vector3;
  116726. /**
  116727. * The l2,0 coefficients of the spherical harmonics
  116728. */
  116729. l20: Vector3;
  116730. /**
  116731. * The l2,1 coefficients of the spherical harmonics
  116732. */
  116733. l21: Vector3;
  116734. /**
  116735. * The l2,2 coefficients of the spherical harmonics
  116736. */
  116737. l22: Vector3;
  116738. /**
  116739. * Adds a light to the spherical harmonics
  116740. * @param direction the direction of the light
  116741. * @param color the color of the light
  116742. * @param deltaSolidAngle the delta solid angle of the light
  116743. */
  116744. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116745. /**
  116746. * Scales the spherical harmonics by the given amount
  116747. * @param scale the amount to scale
  116748. */
  116749. scaleInPlace(scale: number): void;
  116750. /**
  116751. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116752. *
  116753. * ```
  116754. * E_lm = A_l * L_lm
  116755. * ```
  116756. *
  116757. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116758. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116759. * the scaling factors are given in equation 9.
  116760. */
  116761. convertIncidentRadianceToIrradiance(): void;
  116762. /**
  116763. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116764. *
  116765. * ```
  116766. * L = (1/pi) * E * rho
  116767. * ```
  116768. *
  116769. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116770. */
  116771. convertIrradianceToLambertianRadiance(): void;
  116772. /**
  116773. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116774. * required operations at run time.
  116775. *
  116776. * This is simply done by scaling back the SH with Ylm constants parameter.
  116777. * The trigonometric part being applied by the shader at run time.
  116778. */
  116779. preScaleForRendering(): void;
  116780. /**
  116781. * Constructs a spherical harmonics from an array.
  116782. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116783. * @returns the spherical harmonics
  116784. */
  116785. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116786. /**
  116787. * Gets the spherical harmonics from polynomial
  116788. * @param polynomial the spherical polynomial
  116789. * @returns the spherical harmonics
  116790. */
  116791. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116792. }
  116793. /**
  116794. * Class representing spherical polynomial coefficients to the 3rd degree
  116795. */
  116796. export class SphericalPolynomial {
  116797. private _harmonics;
  116798. /**
  116799. * The spherical harmonics used to create the polynomials.
  116800. */
  116801. get preScaledHarmonics(): SphericalHarmonics;
  116802. /**
  116803. * The x coefficients of the spherical polynomial
  116804. */
  116805. x: Vector3;
  116806. /**
  116807. * The y coefficients of the spherical polynomial
  116808. */
  116809. y: Vector3;
  116810. /**
  116811. * The z coefficients of the spherical polynomial
  116812. */
  116813. z: Vector3;
  116814. /**
  116815. * The xx coefficients of the spherical polynomial
  116816. */
  116817. xx: Vector3;
  116818. /**
  116819. * The yy coefficients of the spherical polynomial
  116820. */
  116821. yy: Vector3;
  116822. /**
  116823. * The zz coefficients of the spherical polynomial
  116824. */
  116825. zz: Vector3;
  116826. /**
  116827. * The xy coefficients of the spherical polynomial
  116828. */
  116829. xy: Vector3;
  116830. /**
  116831. * The yz coefficients of the spherical polynomial
  116832. */
  116833. yz: Vector3;
  116834. /**
  116835. * The zx coefficients of the spherical polynomial
  116836. */
  116837. zx: Vector3;
  116838. /**
  116839. * Adds an ambient color to the spherical polynomial
  116840. * @param color the color to add
  116841. */
  116842. addAmbient(color: Color3): void;
  116843. /**
  116844. * Scales the spherical polynomial by the given amount
  116845. * @param scale the amount to scale
  116846. */
  116847. scaleInPlace(scale: number): void;
  116848. /**
  116849. * Gets the spherical polynomial from harmonics
  116850. * @param harmonics the spherical harmonics
  116851. * @returns the spherical polynomial
  116852. */
  116853. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116854. /**
  116855. * Constructs a spherical polynomial from an array.
  116856. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116857. * @returns the spherical polynomial
  116858. */
  116859. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116860. }
  116861. }
  116862. declare module BABYLON {
  116863. /**
  116864. * Defines the source of the internal texture
  116865. */
  116866. export enum InternalTextureSource {
  116867. /**
  116868. * The source of the texture data is unknown
  116869. */
  116870. Unknown = 0,
  116871. /**
  116872. * Texture data comes from an URL
  116873. */
  116874. Url = 1,
  116875. /**
  116876. * Texture data is only used for temporary storage
  116877. */
  116878. Temp = 2,
  116879. /**
  116880. * Texture data comes from raw data (ArrayBuffer)
  116881. */
  116882. Raw = 3,
  116883. /**
  116884. * Texture content is dynamic (video or dynamic texture)
  116885. */
  116886. Dynamic = 4,
  116887. /**
  116888. * Texture content is generated by rendering to it
  116889. */
  116890. RenderTarget = 5,
  116891. /**
  116892. * Texture content is part of a multi render target process
  116893. */
  116894. MultiRenderTarget = 6,
  116895. /**
  116896. * Texture data comes from a cube data file
  116897. */
  116898. Cube = 7,
  116899. /**
  116900. * Texture data comes from a raw cube data
  116901. */
  116902. CubeRaw = 8,
  116903. /**
  116904. * Texture data come from a prefiltered cube data file
  116905. */
  116906. CubePrefiltered = 9,
  116907. /**
  116908. * Texture content is raw 3D data
  116909. */
  116910. Raw3D = 10,
  116911. /**
  116912. * Texture content is raw 2D array data
  116913. */
  116914. Raw2DArray = 11,
  116915. /**
  116916. * Texture content is a depth texture
  116917. */
  116918. Depth = 12,
  116919. /**
  116920. * Texture data comes from a raw cube data encoded with RGBD
  116921. */
  116922. CubeRawRGBD = 13
  116923. }
  116924. /**
  116925. * Class used to store data associated with WebGL texture data for the engine
  116926. * This class should not be used directly
  116927. */
  116928. export class InternalTexture {
  116929. /** @hidden */
  116930. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116931. /**
  116932. * Defines if the texture is ready
  116933. */
  116934. isReady: boolean;
  116935. /**
  116936. * Defines if the texture is a cube texture
  116937. */
  116938. isCube: boolean;
  116939. /**
  116940. * Defines if the texture contains 3D data
  116941. */
  116942. is3D: boolean;
  116943. /**
  116944. * Defines if the texture contains 2D array data
  116945. */
  116946. is2DArray: boolean;
  116947. /**
  116948. * Defines if the texture contains multiview data
  116949. */
  116950. isMultiview: boolean;
  116951. /**
  116952. * Gets the URL used to load this texture
  116953. */
  116954. url: string;
  116955. /**
  116956. * Gets the sampling mode of the texture
  116957. */
  116958. samplingMode: number;
  116959. /**
  116960. * Gets a boolean indicating if the texture needs mipmaps generation
  116961. */
  116962. generateMipMaps: boolean;
  116963. /**
  116964. * Gets the number of samples used by the texture (WebGL2+ only)
  116965. */
  116966. samples: number;
  116967. /**
  116968. * Gets the type of the texture (int, float...)
  116969. */
  116970. type: number;
  116971. /**
  116972. * Gets the format of the texture (RGB, RGBA...)
  116973. */
  116974. format: number;
  116975. /**
  116976. * Observable called when the texture is loaded
  116977. */
  116978. onLoadedObservable: Observable<InternalTexture>;
  116979. /**
  116980. * Gets the width of the texture
  116981. */
  116982. width: number;
  116983. /**
  116984. * Gets the height of the texture
  116985. */
  116986. height: number;
  116987. /**
  116988. * Gets the depth of the texture
  116989. */
  116990. depth: number;
  116991. /**
  116992. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116993. */
  116994. baseWidth: number;
  116995. /**
  116996. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116997. */
  116998. baseHeight: number;
  116999. /**
  117000. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117001. */
  117002. baseDepth: number;
  117003. /**
  117004. * Gets a boolean indicating if the texture is inverted on Y axis
  117005. */
  117006. invertY: boolean;
  117007. /** @hidden */
  117008. _invertVScale: boolean;
  117009. /** @hidden */
  117010. _associatedChannel: number;
  117011. /** @hidden */
  117012. _source: InternalTextureSource;
  117013. /** @hidden */
  117014. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117015. /** @hidden */
  117016. _bufferView: Nullable<ArrayBufferView>;
  117017. /** @hidden */
  117018. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117019. /** @hidden */
  117020. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117021. /** @hidden */
  117022. _size: number;
  117023. /** @hidden */
  117024. _extension: string;
  117025. /** @hidden */
  117026. _files: Nullable<string[]>;
  117027. /** @hidden */
  117028. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117029. /** @hidden */
  117030. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117031. /** @hidden */
  117032. _framebuffer: Nullable<WebGLFramebuffer>;
  117033. /** @hidden */
  117034. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117035. /** @hidden */
  117036. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117037. /** @hidden */
  117038. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117039. /** @hidden */
  117040. _attachments: Nullable<number[]>;
  117041. /** @hidden */
  117042. _textureArray: Nullable<InternalTexture[]>;
  117043. /** @hidden */
  117044. _cachedCoordinatesMode: Nullable<number>;
  117045. /** @hidden */
  117046. _cachedWrapU: Nullable<number>;
  117047. /** @hidden */
  117048. _cachedWrapV: Nullable<number>;
  117049. /** @hidden */
  117050. _cachedWrapR: Nullable<number>;
  117051. /** @hidden */
  117052. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117053. /** @hidden */
  117054. _isDisabled: boolean;
  117055. /** @hidden */
  117056. _compression: Nullable<string>;
  117057. /** @hidden */
  117058. _generateStencilBuffer: boolean;
  117059. /** @hidden */
  117060. _generateDepthBuffer: boolean;
  117061. /** @hidden */
  117062. _comparisonFunction: number;
  117063. /** @hidden */
  117064. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117065. /** @hidden */
  117066. _lodGenerationScale: number;
  117067. /** @hidden */
  117068. _lodGenerationOffset: number;
  117069. /** @hidden */
  117070. _depthStencilTexture: Nullable<InternalTexture>;
  117071. /** @hidden */
  117072. _colorTextureArray: Nullable<WebGLTexture>;
  117073. /** @hidden */
  117074. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117075. /** @hidden */
  117076. _lodTextureHigh: Nullable<BaseTexture>;
  117077. /** @hidden */
  117078. _lodTextureMid: Nullable<BaseTexture>;
  117079. /** @hidden */
  117080. _lodTextureLow: Nullable<BaseTexture>;
  117081. /** @hidden */
  117082. _isRGBD: boolean;
  117083. /** @hidden */
  117084. _linearSpecularLOD: boolean;
  117085. /** @hidden */
  117086. _irradianceTexture: Nullable<BaseTexture>;
  117087. /** @hidden */
  117088. _webGLTexture: Nullable<WebGLTexture>;
  117089. /** @hidden */
  117090. _references: number;
  117091. /** @hidden */
  117092. _gammaSpace: Nullable<boolean>;
  117093. private _engine;
  117094. /**
  117095. * Gets the Engine the texture belongs to.
  117096. * @returns The babylon engine
  117097. */
  117098. getEngine(): ThinEngine;
  117099. /**
  117100. * Gets the data source type of the texture
  117101. */
  117102. get source(): InternalTextureSource;
  117103. /**
  117104. * Creates a new InternalTexture
  117105. * @param engine defines the engine to use
  117106. * @param source defines the type of data that will be used
  117107. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117108. */
  117109. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117110. /**
  117111. * Increments the number of references (ie. the number of Texture that point to it)
  117112. */
  117113. incrementReferences(): void;
  117114. /**
  117115. * Change the size of the texture (not the size of the content)
  117116. * @param width defines the new width
  117117. * @param height defines the new height
  117118. * @param depth defines the new depth (1 by default)
  117119. */
  117120. updateSize(width: int, height: int, depth?: int): void;
  117121. /** @hidden */
  117122. _rebuild(): void;
  117123. /** @hidden */
  117124. _swapAndDie(target: InternalTexture): void;
  117125. /**
  117126. * Dispose the current allocated resources
  117127. */
  117128. dispose(): void;
  117129. }
  117130. }
  117131. declare module BABYLON {
  117132. /**
  117133. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117134. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117135. */
  117136. export class Analyser {
  117137. /**
  117138. * Gets or sets the smoothing
  117139. * @ignorenaming
  117140. */
  117141. SMOOTHING: number;
  117142. /**
  117143. * Gets or sets the FFT table size
  117144. * @ignorenaming
  117145. */
  117146. FFT_SIZE: number;
  117147. /**
  117148. * Gets or sets the bar graph amplitude
  117149. * @ignorenaming
  117150. */
  117151. BARGRAPHAMPLITUDE: number;
  117152. /**
  117153. * Gets or sets the position of the debug canvas
  117154. * @ignorenaming
  117155. */
  117156. DEBUGCANVASPOS: {
  117157. x: number;
  117158. y: number;
  117159. };
  117160. /**
  117161. * Gets or sets the debug canvas size
  117162. * @ignorenaming
  117163. */
  117164. DEBUGCANVASSIZE: {
  117165. width: number;
  117166. height: number;
  117167. };
  117168. private _byteFreqs;
  117169. private _byteTime;
  117170. private _floatFreqs;
  117171. private _webAudioAnalyser;
  117172. private _debugCanvas;
  117173. private _debugCanvasContext;
  117174. private _scene;
  117175. private _registerFunc;
  117176. private _audioEngine;
  117177. /**
  117178. * Creates a new analyser
  117179. * @param scene defines hosting scene
  117180. */
  117181. constructor(scene: Scene);
  117182. /**
  117183. * Get the number of data values you will have to play with for the visualization
  117184. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117185. * @returns a number
  117186. */
  117187. getFrequencyBinCount(): number;
  117188. /**
  117189. * Gets the current frequency data as a byte array
  117190. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117191. * @returns a Uint8Array
  117192. */
  117193. getByteFrequencyData(): Uint8Array;
  117194. /**
  117195. * Gets the current waveform as a byte array
  117196. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117197. * @returns a Uint8Array
  117198. */
  117199. getByteTimeDomainData(): Uint8Array;
  117200. /**
  117201. * Gets the current frequency data as a float array
  117202. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117203. * @returns a Float32Array
  117204. */
  117205. getFloatFrequencyData(): Float32Array;
  117206. /**
  117207. * Renders the debug canvas
  117208. */
  117209. drawDebugCanvas(): void;
  117210. /**
  117211. * Stops rendering the debug canvas and removes it
  117212. */
  117213. stopDebugCanvas(): void;
  117214. /**
  117215. * Connects two audio nodes
  117216. * @param inputAudioNode defines first node to connect
  117217. * @param outputAudioNode defines second node to connect
  117218. */
  117219. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117220. /**
  117221. * Releases all associated resources
  117222. */
  117223. dispose(): void;
  117224. }
  117225. }
  117226. declare module BABYLON {
  117227. /**
  117228. * This represents an audio engine and it is responsible
  117229. * to play, synchronize and analyse sounds throughout the application.
  117230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117231. */
  117232. export interface IAudioEngine extends IDisposable {
  117233. /**
  117234. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117235. */
  117236. readonly canUseWebAudio: boolean;
  117237. /**
  117238. * Gets the current AudioContext if available.
  117239. */
  117240. readonly audioContext: Nullable<AudioContext>;
  117241. /**
  117242. * The master gain node defines the global audio volume of your audio engine.
  117243. */
  117244. readonly masterGain: GainNode;
  117245. /**
  117246. * Gets whether or not mp3 are supported by your browser.
  117247. */
  117248. readonly isMP3supported: boolean;
  117249. /**
  117250. * Gets whether or not ogg are supported by your browser.
  117251. */
  117252. readonly isOGGsupported: boolean;
  117253. /**
  117254. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117255. * @ignoreNaming
  117256. */
  117257. WarnedWebAudioUnsupported: boolean;
  117258. /**
  117259. * Defines if the audio engine relies on a custom unlocked button.
  117260. * In this case, the embedded button will not be displayed.
  117261. */
  117262. useCustomUnlockedButton: boolean;
  117263. /**
  117264. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117265. */
  117266. readonly unlocked: boolean;
  117267. /**
  117268. * Event raised when audio has been unlocked on the browser.
  117269. */
  117270. onAudioUnlockedObservable: Observable<AudioEngine>;
  117271. /**
  117272. * Event raised when audio has been locked on the browser.
  117273. */
  117274. onAudioLockedObservable: Observable<AudioEngine>;
  117275. /**
  117276. * Flags the audio engine in Locked state.
  117277. * This happens due to new browser policies preventing audio to autoplay.
  117278. */
  117279. lock(): void;
  117280. /**
  117281. * Unlocks the audio engine once a user action has been done on the dom.
  117282. * This is helpful to resume play once browser policies have been satisfied.
  117283. */
  117284. unlock(): void;
  117285. /**
  117286. * Gets the global volume sets on the master gain.
  117287. * @returns the global volume if set or -1 otherwise
  117288. */
  117289. getGlobalVolume(): number;
  117290. /**
  117291. * Sets the global volume of your experience (sets on the master gain).
  117292. * @param newVolume Defines the new global volume of the application
  117293. */
  117294. setGlobalVolume(newVolume: number): void;
  117295. /**
  117296. * Connect the audio engine to an audio analyser allowing some amazing
  117297. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117298. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117299. * @param analyser The analyser to connect to the engine
  117300. */
  117301. connectToAnalyser(analyser: Analyser): void;
  117302. }
  117303. /**
  117304. * This represents the default audio engine used in babylon.
  117305. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117307. */
  117308. export class AudioEngine implements IAudioEngine {
  117309. private _audioContext;
  117310. private _audioContextInitialized;
  117311. private _muteButton;
  117312. private _hostElement;
  117313. /**
  117314. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117315. */
  117316. canUseWebAudio: boolean;
  117317. /**
  117318. * The master gain node defines the global audio volume of your audio engine.
  117319. */
  117320. masterGain: GainNode;
  117321. /**
  117322. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117323. * @ignoreNaming
  117324. */
  117325. WarnedWebAudioUnsupported: boolean;
  117326. /**
  117327. * Gets whether or not mp3 are supported by your browser.
  117328. */
  117329. isMP3supported: boolean;
  117330. /**
  117331. * Gets whether or not ogg are supported by your browser.
  117332. */
  117333. isOGGsupported: boolean;
  117334. /**
  117335. * Gets whether audio has been unlocked on the device.
  117336. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117337. * a user interaction has happened.
  117338. */
  117339. unlocked: boolean;
  117340. /**
  117341. * Defines if the audio engine relies on a custom unlocked button.
  117342. * In this case, the embedded button will not be displayed.
  117343. */
  117344. useCustomUnlockedButton: boolean;
  117345. /**
  117346. * Event raised when audio has been unlocked on the browser.
  117347. */
  117348. onAudioUnlockedObservable: Observable<AudioEngine>;
  117349. /**
  117350. * Event raised when audio has been locked on the browser.
  117351. */
  117352. onAudioLockedObservable: Observable<AudioEngine>;
  117353. /**
  117354. * Gets the current AudioContext if available.
  117355. */
  117356. get audioContext(): Nullable<AudioContext>;
  117357. private _connectedAnalyser;
  117358. /**
  117359. * Instantiates a new audio engine.
  117360. *
  117361. * There should be only one per page as some browsers restrict the number
  117362. * of audio contexts you can create.
  117363. * @param hostElement defines the host element where to display the mute icon if necessary
  117364. */
  117365. constructor(hostElement?: Nullable<HTMLElement>);
  117366. /**
  117367. * Flags the audio engine in Locked state.
  117368. * This happens due to new browser policies preventing audio to autoplay.
  117369. */
  117370. lock(): void;
  117371. /**
  117372. * Unlocks the audio engine once a user action has been done on the dom.
  117373. * This is helpful to resume play once browser policies have been satisfied.
  117374. */
  117375. unlock(): void;
  117376. private _resumeAudioContext;
  117377. private _initializeAudioContext;
  117378. private _tryToRun;
  117379. private _triggerRunningState;
  117380. private _triggerSuspendedState;
  117381. private _displayMuteButton;
  117382. private _moveButtonToTopLeft;
  117383. private _onResize;
  117384. private _hideMuteButton;
  117385. /**
  117386. * Destroy and release the resources associated with the audio ccontext.
  117387. */
  117388. dispose(): void;
  117389. /**
  117390. * Gets the global volume sets on the master gain.
  117391. * @returns the global volume if set or -1 otherwise
  117392. */
  117393. getGlobalVolume(): number;
  117394. /**
  117395. * Sets the global volume of your experience (sets on the master gain).
  117396. * @param newVolume Defines the new global volume of the application
  117397. */
  117398. setGlobalVolume(newVolume: number): void;
  117399. /**
  117400. * Connect the audio engine to an audio analyser allowing some amazing
  117401. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117403. * @param analyser The analyser to connect to the engine
  117404. */
  117405. connectToAnalyser(analyser: Analyser): void;
  117406. }
  117407. }
  117408. declare module BABYLON {
  117409. /**
  117410. * Interface used to present a loading screen while loading a scene
  117411. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117412. */
  117413. export interface ILoadingScreen {
  117414. /**
  117415. * Function called to display the loading screen
  117416. */
  117417. displayLoadingUI: () => void;
  117418. /**
  117419. * Function called to hide the loading screen
  117420. */
  117421. hideLoadingUI: () => void;
  117422. /**
  117423. * Gets or sets the color to use for the background
  117424. */
  117425. loadingUIBackgroundColor: string;
  117426. /**
  117427. * Gets or sets the text to display while loading
  117428. */
  117429. loadingUIText: string;
  117430. }
  117431. /**
  117432. * Class used for the default loading screen
  117433. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117434. */
  117435. export class DefaultLoadingScreen implements ILoadingScreen {
  117436. private _renderingCanvas;
  117437. private _loadingText;
  117438. private _loadingDivBackgroundColor;
  117439. private _loadingDiv;
  117440. private _loadingTextDiv;
  117441. /** Gets or sets the logo url to use for the default loading screen */
  117442. static DefaultLogoUrl: string;
  117443. /** Gets or sets the spinner url to use for the default loading screen */
  117444. static DefaultSpinnerUrl: string;
  117445. /**
  117446. * Creates a new default loading screen
  117447. * @param _renderingCanvas defines the canvas used to render the scene
  117448. * @param _loadingText defines the default text to display
  117449. * @param _loadingDivBackgroundColor defines the default background color
  117450. */
  117451. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117452. /**
  117453. * Function called to display the loading screen
  117454. */
  117455. displayLoadingUI(): void;
  117456. /**
  117457. * Function called to hide the loading screen
  117458. */
  117459. hideLoadingUI(): void;
  117460. /**
  117461. * Gets or sets the text to display while loading
  117462. */
  117463. set loadingUIText(text: string);
  117464. get loadingUIText(): string;
  117465. /**
  117466. * Gets or sets the color to use for the background
  117467. */
  117468. get loadingUIBackgroundColor(): string;
  117469. set loadingUIBackgroundColor(color: string);
  117470. private _resizeLoadingUI;
  117471. }
  117472. }
  117473. declare module BABYLON {
  117474. /**
  117475. * Interface for any object that can request an animation frame
  117476. */
  117477. export interface ICustomAnimationFrameRequester {
  117478. /**
  117479. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117480. */
  117481. renderFunction?: Function;
  117482. /**
  117483. * Called to request the next frame to render to
  117484. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117485. */
  117486. requestAnimationFrame: Function;
  117487. /**
  117488. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117490. */
  117491. requestID?: number;
  117492. }
  117493. }
  117494. declare module BABYLON {
  117495. /**
  117496. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117497. */
  117498. export class PerformanceMonitor {
  117499. private _enabled;
  117500. private _rollingFrameTime;
  117501. private _lastFrameTimeMs;
  117502. /**
  117503. * constructor
  117504. * @param frameSampleSize The number of samples required to saturate the sliding window
  117505. */
  117506. constructor(frameSampleSize?: number);
  117507. /**
  117508. * Samples current frame
  117509. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117510. */
  117511. sampleFrame(timeMs?: number): void;
  117512. /**
  117513. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117514. */
  117515. get averageFrameTime(): number;
  117516. /**
  117517. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117518. */
  117519. get averageFrameTimeVariance(): number;
  117520. /**
  117521. * Returns the frame time of the most recent frame
  117522. */
  117523. get instantaneousFrameTime(): number;
  117524. /**
  117525. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117526. */
  117527. get averageFPS(): number;
  117528. /**
  117529. * Returns the average framerate in frames per second using the most recent frame time
  117530. */
  117531. get instantaneousFPS(): number;
  117532. /**
  117533. * Returns true if enough samples have been taken to completely fill the sliding window
  117534. */
  117535. get isSaturated(): boolean;
  117536. /**
  117537. * Enables contributions to the sliding window sample set
  117538. */
  117539. enable(): void;
  117540. /**
  117541. * Disables contributions to the sliding window sample set
  117542. * Samples will not be interpolated over the disabled period
  117543. */
  117544. disable(): void;
  117545. /**
  117546. * Returns true if sampling is enabled
  117547. */
  117548. get isEnabled(): boolean;
  117549. /**
  117550. * Resets performance monitor
  117551. */
  117552. reset(): void;
  117553. }
  117554. /**
  117555. * RollingAverage
  117556. *
  117557. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117558. */
  117559. export class RollingAverage {
  117560. /**
  117561. * Current average
  117562. */
  117563. average: number;
  117564. /**
  117565. * Current variance
  117566. */
  117567. variance: number;
  117568. protected _samples: Array<number>;
  117569. protected _sampleCount: number;
  117570. protected _pos: number;
  117571. protected _m2: number;
  117572. /**
  117573. * constructor
  117574. * @param length The number of samples required to saturate the sliding window
  117575. */
  117576. constructor(length: number);
  117577. /**
  117578. * Adds a sample to the sample set
  117579. * @param v The sample value
  117580. */
  117581. add(v: number): void;
  117582. /**
  117583. * Returns previously added values or null if outside of history or outside the sliding window domain
  117584. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117585. * @return Value previously recorded with add() or null if outside of range
  117586. */
  117587. history(i: number): number;
  117588. /**
  117589. * Returns true if enough samples have been taken to completely fill the sliding window
  117590. * @return true if sample-set saturated
  117591. */
  117592. isSaturated(): boolean;
  117593. /**
  117594. * Resets the rolling average (equivalent to 0 samples taken so far)
  117595. */
  117596. reset(): void;
  117597. /**
  117598. * Wraps a value around the sample range boundaries
  117599. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117600. * @return Wrapped position in sample range
  117601. */
  117602. protected _wrapPosition(i: number): number;
  117603. }
  117604. }
  117605. declare module BABYLON {
  117606. /**
  117607. * This class is used to track a performance counter which is number based.
  117608. * The user has access to many properties which give statistics of different nature.
  117609. *
  117610. * The implementer can track two kinds of Performance Counter: time and count.
  117611. * 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.
  117612. * 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.
  117613. */
  117614. export class PerfCounter {
  117615. /**
  117616. * Gets or sets a global boolean to turn on and off all the counters
  117617. */
  117618. static Enabled: boolean;
  117619. /**
  117620. * Returns the smallest value ever
  117621. */
  117622. get min(): number;
  117623. /**
  117624. * Returns the biggest value ever
  117625. */
  117626. get max(): number;
  117627. /**
  117628. * Returns the average value since the performance counter is running
  117629. */
  117630. get average(): number;
  117631. /**
  117632. * Returns the average value of the last second the counter was monitored
  117633. */
  117634. get lastSecAverage(): number;
  117635. /**
  117636. * Returns the current value
  117637. */
  117638. get current(): number;
  117639. /**
  117640. * Gets the accumulated total
  117641. */
  117642. get total(): number;
  117643. /**
  117644. * Gets the total value count
  117645. */
  117646. get count(): number;
  117647. /**
  117648. * Creates a new counter
  117649. */
  117650. constructor();
  117651. /**
  117652. * Call this method to start monitoring a new frame.
  117653. * 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.
  117654. */
  117655. fetchNewFrame(): void;
  117656. /**
  117657. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117658. * @param newCount the count value to add to the monitored count
  117659. * @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.
  117660. */
  117661. addCount(newCount: number, fetchResult: boolean): void;
  117662. /**
  117663. * Start monitoring this performance counter
  117664. */
  117665. beginMonitoring(): void;
  117666. /**
  117667. * Compute the time lapsed since the previous beginMonitoring() call.
  117668. * @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
  117669. */
  117670. endMonitoring(newFrame?: boolean): void;
  117671. private _fetchResult;
  117672. private _startMonitoringTime;
  117673. private _min;
  117674. private _max;
  117675. private _average;
  117676. private _current;
  117677. private _totalValueCount;
  117678. private _totalAccumulated;
  117679. private _lastSecAverage;
  117680. private _lastSecAccumulated;
  117681. private _lastSecTime;
  117682. private _lastSecValueCount;
  117683. }
  117684. }
  117685. declare module BABYLON {
  117686. interface ThinEngine {
  117687. /** @hidden */
  117688. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117689. }
  117690. }
  117691. declare module BABYLON {
  117692. /**
  117693. * Defines the interface used by display changed events
  117694. */
  117695. export interface IDisplayChangedEventArgs {
  117696. /** Gets the vrDisplay object (if any) */
  117697. vrDisplay: Nullable<any>;
  117698. /** Gets a boolean indicating if webVR is supported */
  117699. vrSupported: boolean;
  117700. }
  117701. /**
  117702. * Defines the interface used by objects containing a viewport (like a camera)
  117703. */
  117704. interface IViewportOwnerLike {
  117705. /**
  117706. * Gets or sets the viewport
  117707. */
  117708. viewport: IViewportLike;
  117709. }
  117710. /**
  117711. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117712. */
  117713. export class Engine extends ThinEngine {
  117714. /** Defines that alpha blending is disabled */
  117715. static readonly ALPHA_DISABLE: number;
  117716. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117717. static readonly ALPHA_ADD: number;
  117718. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117719. static readonly ALPHA_COMBINE: number;
  117720. /** Defines that alpha blending to DEST - SRC * DEST */
  117721. static readonly ALPHA_SUBTRACT: number;
  117722. /** Defines that alpha blending to SRC * DEST */
  117723. static readonly ALPHA_MULTIPLY: number;
  117724. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117725. static readonly ALPHA_MAXIMIZED: number;
  117726. /** Defines that alpha blending to SRC + DEST */
  117727. static readonly ALPHA_ONEONE: number;
  117728. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117729. static readonly ALPHA_PREMULTIPLIED: number;
  117730. /**
  117731. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117732. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117733. */
  117734. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117735. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117736. static readonly ALPHA_INTERPOLATE: number;
  117737. /**
  117738. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117739. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117740. */
  117741. static readonly ALPHA_SCREENMODE: number;
  117742. /** Defines that the ressource is not delayed*/
  117743. static readonly DELAYLOADSTATE_NONE: number;
  117744. /** Defines that the ressource was successfully delay loaded */
  117745. static readonly DELAYLOADSTATE_LOADED: number;
  117746. /** Defines that the ressource is currently delay loading */
  117747. static readonly DELAYLOADSTATE_LOADING: number;
  117748. /** Defines that the ressource is delayed and has not started loading */
  117749. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117751. static readonly NEVER: number;
  117752. /** 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 */
  117753. static readonly ALWAYS: number;
  117754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117755. static readonly LESS: number;
  117756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117757. static readonly EQUAL: number;
  117758. /** 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 */
  117759. static readonly LEQUAL: number;
  117760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117761. static readonly GREATER: number;
  117762. /** 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 */
  117763. static readonly GEQUAL: number;
  117764. /** 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 */
  117765. static readonly NOTEQUAL: number;
  117766. /** Passed to stencilOperation to specify that stencil value must be kept */
  117767. static readonly KEEP: number;
  117768. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117769. static readonly REPLACE: number;
  117770. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117771. static readonly INCR: number;
  117772. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117773. static readonly DECR: number;
  117774. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117775. static readonly INVERT: number;
  117776. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117777. static readonly INCR_WRAP: number;
  117778. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117779. static readonly DECR_WRAP: number;
  117780. /** Texture is not repeating outside of 0..1 UVs */
  117781. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117782. /** Texture is repeating outside of 0..1 UVs */
  117783. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117784. /** Texture is repeating and mirrored */
  117785. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117786. /** ALPHA */
  117787. static readonly TEXTUREFORMAT_ALPHA: number;
  117788. /** LUMINANCE */
  117789. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117790. /** LUMINANCE_ALPHA */
  117791. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117792. /** RGB */
  117793. static readonly TEXTUREFORMAT_RGB: number;
  117794. /** RGBA */
  117795. static readonly TEXTUREFORMAT_RGBA: number;
  117796. /** RED */
  117797. static readonly TEXTUREFORMAT_RED: number;
  117798. /** RED (2nd reference) */
  117799. static readonly TEXTUREFORMAT_R: number;
  117800. /** RG */
  117801. static readonly TEXTUREFORMAT_RG: number;
  117802. /** RED_INTEGER */
  117803. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117804. /** RED_INTEGER (2nd reference) */
  117805. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117806. /** RG_INTEGER */
  117807. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117808. /** RGB_INTEGER */
  117809. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117810. /** RGBA_INTEGER */
  117811. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117812. /** UNSIGNED_BYTE */
  117813. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117814. /** UNSIGNED_BYTE (2nd reference) */
  117815. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117816. /** FLOAT */
  117817. static readonly TEXTURETYPE_FLOAT: number;
  117818. /** HALF_FLOAT */
  117819. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117820. /** BYTE */
  117821. static readonly TEXTURETYPE_BYTE: number;
  117822. /** SHORT */
  117823. static readonly TEXTURETYPE_SHORT: number;
  117824. /** UNSIGNED_SHORT */
  117825. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117826. /** INT */
  117827. static readonly TEXTURETYPE_INT: number;
  117828. /** UNSIGNED_INT */
  117829. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117830. /** UNSIGNED_SHORT_4_4_4_4 */
  117831. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117832. /** UNSIGNED_SHORT_5_5_5_1 */
  117833. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117834. /** UNSIGNED_SHORT_5_6_5 */
  117835. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117836. /** UNSIGNED_INT_2_10_10_10_REV */
  117837. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117838. /** UNSIGNED_INT_24_8 */
  117839. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117840. /** UNSIGNED_INT_10F_11F_11F_REV */
  117841. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117842. /** UNSIGNED_INT_5_9_9_9_REV */
  117843. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117844. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117845. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117846. /** nearest is mag = nearest and min = nearest and mip = linear */
  117847. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117849. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117850. /** Trilinear is mag = linear and min = linear and mip = linear */
  117851. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117852. /** nearest is mag = nearest and min = nearest and mip = linear */
  117853. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117855. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117856. /** Trilinear is mag = linear and min = linear and mip = linear */
  117857. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117858. /** mag = nearest and min = nearest and mip = nearest */
  117859. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117860. /** mag = nearest and min = linear and mip = nearest */
  117861. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117862. /** mag = nearest and min = linear and mip = linear */
  117863. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117864. /** mag = nearest and min = linear and mip = none */
  117865. static readonly TEXTURE_NEAREST_LINEAR: number;
  117866. /** mag = nearest and min = nearest and mip = none */
  117867. static readonly TEXTURE_NEAREST_NEAREST: number;
  117868. /** mag = linear and min = nearest and mip = nearest */
  117869. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117870. /** mag = linear and min = nearest and mip = linear */
  117871. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117872. /** mag = linear and min = linear and mip = none */
  117873. static readonly TEXTURE_LINEAR_LINEAR: number;
  117874. /** mag = linear and min = nearest and mip = none */
  117875. static readonly TEXTURE_LINEAR_NEAREST: number;
  117876. /** Explicit coordinates mode */
  117877. static readonly TEXTURE_EXPLICIT_MODE: number;
  117878. /** Spherical coordinates mode */
  117879. static readonly TEXTURE_SPHERICAL_MODE: number;
  117880. /** Planar coordinates mode */
  117881. static readonly TEXTURE_PLANAR_MODE: number;
  117882. /** Cubic coordinates mode */
  117883. static readonly TEXTURE_CUBIC_MODE: number;
  117884. /** Projection coordinates mode */
  117885. static readonly TEXTURE_PROJECTION_MODE: number;
  117886. /** Skybox coordinates mode */
  117887. static readonly TEXTURE_SKYBOX_MODE: number;
  117888. /** Inverse Cubic coordinates mode */
  117889. static readonly TEXTURE_INVCUBIC_MODE: number;
  117890. /** Equirectangular coordinates mode */
  117891. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117892. /** Equirectangular Fixed coordinates mode */
  117893. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117894. /** Equirectangular Fixed Mirrored coordinates mode */
  117895. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117896. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117897. static readonly SCALEMODE_FLOOR: number;
  117898. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117899. static readonly SCALEMODE_NEAREST: number;
  117900. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117901. static readonly SCALEMODE_CEILING: number;
  117902. /**
  117903. * Returns the current npm package of the sdk
  117904. */
  117905. static get NpmPackage(): string;
  117906. /**
  117907. * Returns the current version of the framework
  117908. */
  117909. static get Version(): string;
  117910. /** Gets the list of created engines */
  117911. static get Instances(): Engine[];
  117912. /**
  117913. * Gets the latest created engine
  117914. */
  117915. static get LastCreatedEngine(): Nullable<Engine>;
  117916. /**
  117917. * Gets the latest created scene
  117918. */
  117919. static get LastCreatedScene(): Nullable<Scene>;
  117920. /**
  117921. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117922. * @param flag defines which part of the materials must be marked as dirty
  117923. * @param predicate defines a predicate used to filter which materials should be affected
  117924. */
  117925. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117926. /**
  117927. * Method called to create the default loading screen.
  117928. * This can be overriden in your own app.
  117929. * @param canvas The rendering canvas element
  117930. * @returns The loading screen
  117931. */
  117932. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117933. /**
  117934. * Method called to create the default rescale post process on each engine.
  117935. */
  117936. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117937. /**
  117938. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117939. **/
  117940. enableOfflineSupport: boolean;
  117941. /**
  117942. * 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)
  117943. **/
  117944. disableManifestCheck: boolean;
  117945. /**
  117946. * Gets the list of created scenes
  117947. */
  117948. scenes: Scene[];
  117949. /**
  117950. * Event raised when a new scene is created
  117951. */
  117952. onNewSceneAddedObservable: Observable<Scene>;
  117953. /**
  117954. * Gets the list of created postprocesses
  117955. */
  117956. postProcesses: PostProcess[];
  117957. /**
  117958. * Gets a boolean indicating if the pointer is currently locked
  117959. */
  117960. isPointerLock: boolean;
  117961. /**
  117962. * Observable event triggered each time the rendering canvas is resized
  117963. */
  117964. onResizeObservable: Observable<Engine>;
  117965. /**
  117966. * Observable event triggered each time the canvas loses focus
  117967. */
  117968. onCanvasBlurObservable: Observable<Engine>;
  117969. /**
  117970. * Observable event triggered each time the canvas gains focus
  117971. */
  117972. onCanvasFocusObservable: Observable<Engine>;
  117973. /**
  117974. * Observable event triggered each time the canvas receives pointerout event
  117975. */
  117976. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117977. /**
  117978. * Observable raised when the engine begins a new frame
  117979. */
  117980. onBeginFrameObservable: Observable<Engine>;
  117981. /**
  117982. * If set, will be used to request the next animation frame for the render loop
  117983. */
  117984. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117985. /**
  117986. * Observable raised when the engine ends the current frame
  117987. */
  117988. onEndFrameObservable: Observable<Engine>;
  117989. /**
  117990. * Observable raised when the engine is about to compile a shader
  117991. */
  117992. onBeforeShaderCompilationObservable: Observable<Engine>;
  117993. /**
  117994. * Observable raised when the engine has jsut compiled a shader
  117995. */
  117996. onAfterShaderCompilationObservable: Observable<Engine>;
  117997. /**
  117998. * Gets the audio engine
  117999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118000. * @ignorenaming
  118001. */
  118002. static audioEngine: IAudioEngine;
  118003. /**
  118004. * Default AudioEngine factory responsible of creating the Audio Engine.
  118005. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118006. */
  118007. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118008. /**
  118009. * Default offline support factory responsible of creating a tool used to store data locally.
  118010. * By default, this will create a Database object if the workload has been embedded.
  118011. */
  118012. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118013. private _loadingScreen;
  118014. private _pointerLockRequested;
  118015. private _rescalePostProcess;
  118016. private _deterministicLockstep;
  118017. private _lockstepMaxSteps;
  118018. private _timeStep;
  118019. protected get _supportsHardwareTextureRescaling(): boolean;
  118020. private _fps;
  118021. private _deltaTime;
  118022. /** @hidden */
  118023. _drawCalls: PerfCounter;
  118024. /** 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 */
  118025. canvasTabIndex: number;
  118026. /**
  118027. * Turn this value on if you want to pause FPS computation when in background
  118028. */
  118029. disablePerformanceMonitorInBackground: boolean;
  118030. private _performanceMonitor;
  118031. /**
  118032. * Gets the performance monitor attached to this engine
  118033. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118034. */
  118035. get performanceMonitor(): PerformanceMonitor;
  118036. private _onFocus;
  118037. private _onBlur;
  118038. private _onCanvasPointerOut;
  118039. private _onCanvasBlur;
  118040. private _onCanvasFocus;
  118041. private _onFullscreenChange;
  118042. private _onPointerLockChange;
  118043. /**
  118044. * Gets the HTML element used to attach event listeners
  118045. * @returns a HTML element
  118046. */
  118047. getInputElement(): Nullable<HTMLElement>;
  118048. /**
  118049. * Creates a new engine
  118050. * @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
  118051. * @param antialias defines enable antialiasing (default: false)
  118052. * @param options defines further options to be sent to the getContext() function
  118053. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118054. */
  118055. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118056. /**
  118057. * Gets current aspect ratio
  118058. * @param viewportOwner defines the camera to use to get the aspect ratio
  118059. * @param useScreen defines if screen size must be used (or the current render target if any)
  118060. * @returns a number defining the aspect ratio
  118061. */
  118062. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118063. /**
  118064. * Gets current screen aspect ratio
  118065. * @returns a number defining the aspect ratio
  118066. */
  118067. getScreenAspectRatio(): number;
  118068. /**
  118069. * Gets the client rect of the HTML canvas attached with the current webGL context
  118070. * @returns a client rectanglee
  118071. */
  118072. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118073. /**
  118074. * Gets the client rect of the HTML element used for events
  118075. * @returns a client rectanglee
  118076. */
  118077. getInputElementClientRect(): Nullable<ClientRect>;
  118078. /**
  118079. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118081. * @returns true if engine is in deterministic lock step mode
  118082. */
  118083. isDeterministicLockStep(): boolean;
  118084. /**
  118085. * Gets the max steps when engine is running in deterministic lock step
  118086. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118087. * @returns the max steps
  118088. */
  118089. getLockstepMaxSteps(): number;
  118090. /**
  118091. * Returns the time in ms between steps when using deterministic lock step.
  118092. * @returns time step in (ms)
  118093. */
  118094. getTimeStep(): number;
  118095. /**
  118096. * Force the mipmap generation for the given render target texture
  118097. * @param texture defines the render target texture to use
  118098. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118099. */
  118100. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118101. /** States */
  118102. /**
  118103. * Set various states to the webGL context
  118104. * @param culling defines backface culling state
  118105. * @param zOffset defines the value to apply to zOffset (0 by default)
  118106. * @param force defines if states must be applied even if cache is up to date
  118107. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118108. */
  118109. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118110. /**
  118111. * Set the z offset to apply to current rendering
  118112. * @param value defines the offset to apply
  118113. */
  118114. setZOffset(value: number): void;
  118115. /**
  118116. * Gets the current value of the zOffset
  118117. * @returns the current zOffset state
  118118. */
  118119. getZOffset(): number;
  118120. /**
  118121. * Enable or disable depth buffering
  118122. * @param enable defines the state to set
  118123. */
  118124. setDepthBuffer(enable: boolean): void;
  118125. /**
  118126. * Gets a boolean indicating if depth writing is enabled
  118127. * @returns the current depth writing state
  118128. */
  118129. getDepthWrite(): boolean;
  118130. /**
  118131. * Enable or disable depth writing
  118132. * @param enable defines the state to set
  118133. */
  118134. setDepthWrite(enable: boolean): void;
  118135. /**
  118136. * Gets a boolean indicating if stencil buffer is enabled
  118137. * @returns the current stencil buffer state
  118138. */
  118139. getStencilBuffer(): boolean;
  118140. /**
  118141. * Enable or disable the stencil buffer
  118142. * @param enable defines if the stencil buffer must be enabled or disabled
  118143. */
  118144. setStencilBuffer(enable: boolean): void;
  118145. /**
  118146. * Gets the current stencil mask
  118147. * @returns a number defining the new stencil mask to use
  118148. */
  118149. getStencilMask(): number;
  118150. /**
  118151. * Sets the current stencil mask
  118152. * @param mask defines the new stencil mask to use
  118153. */
  118154. setStencilMask(mask: number): void;
  118155. /**
  118156. * Gets the current stencil function
  118157. * @returns a number defining the stencil function to use
  118158. */
  118159. getStencilFunction(): number;
  118160. /**
  118161. * Gets the current stencil reference value
  118162. * @returns a number defining the stencil reference value to use
  118163. */
  118164. getStencilFunctionReference(): number;
  118165. /**
  118166. * Gets the current stencil mask
  118167. * @returns a number defining the stencil mask to use
  118168. */
  118169. getStencilFunctionMask(): number;
  118170. /**
  118171. * Sets the current stencil function
  118172. * @param stencilFunc defines the new stencil function to use
  118173. */
  118174. setStencilFunction(stencilFunc: number): void;
  118175. /**
  118176. * Sets the current stencil reference
  118177. * @param reference defines the new stencil reference to use
  118178. */
  118179. setStencilFunctionReference(reference: number): void;
  118180. /**
  118181. * Sets the current stencil mask
  118182. * @param mask defines the new stencil mask to use
  118183. */
  118184. setStencilFunctionMask(mask: number): void;
  118185. /**
  118186. * Gets the current stencil operation when stencil fails
  118187. * @returns a number defining stencil operation to use when stencil fails
  118188. */
  118189. getStencilOperationFail(): number;
  118190. /**
  118191. * Gets the current stencil operation when depth fails
  118192. * @returns a number defining stencil operation to use when depth fails
  118193. */
  118194. getStencilOperationDepthFail(): number;
  118195. /**
  118196. * Gets the current stencil operation when stencil passes
  118197. * @returns a number defining stencil operation to use when stencil passes
  118198. */
  118199. getStencilOperationPass(): number;
  118200. /**
  118201. * Sets the stencil operation to use when stencil fails
  118202. * @param operation defines the stencil operation to use when stencil fails
  118203. */
  118204. setStencilOperationFail(operation: number): void;
  118205. /**
  118206. * Sets the stencil operation to use when depth fails
  118207. * @param operation defines the stencil operation to use when depth fails
  118208. */
  118209. setStencilOperationDepthFail(operation: number): void;
  118210. /**
  118211. * Sets the stencil operation to use when stencil passes
  118212. * @param operation defines the stencil operation to use when stencil passes
  118213. */
  118214. setStencilOperationPass(operation: number): void;
  118215. /**
  118216. * Sets a boolean indicating if the dithering state is enabled or disabled
  118217. * @param value defines the dithering state
  118218. */
  118219. setDitheringState(value: boolean): void;
  118220. /**
  118221. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118222. * @param value defines the rasterizer state
  118223. */
  118224. setRasterizerState(value: boolean): void;
  118225. /**
  118226. * Gets the current depth function
  118227. * @returns a number defining the depth function
  118228. */
  118229. getDepthFunction(): Nullable<number>;
  118230. /**
  118231. * Sets the current depth function
  118232. * @param depthFunc defines the function to use
  118233. */
  118234. setDepthFunction(depthFunc: number): void;
  118235. /**
  118236. * Sets the current depth function to GREATER
  118237. */
  118238. setDepthFunctionToGreater(): void;
  118239. /**
  118240. * Sets the current depth function to GEQUAL
  118241. */
  118242. setDepthFunctionToGreaterOrEqual(): void;
  118243. /**
  118244. * Sets the current depth function to LESS
  118245. */
  118246. setDepthFunctionToLess(): void;
  118247. /**
  118248. * Sets the current depth function to LEQUAL
  118249. */
  118250. setDepthFunctionToLessOrEqual(): void;
  118251. private _cachedStencilBuffer;
  118252. private _cachedStencilFunction;
  118253. private _cachedStencilMask;
  118254. private _cachedStencilOperationPass;
  118255. private _cachedStencilOperationFail;
  118256. private _cachedStencilOperationDepthFail;
  118257. private _cachedStencilReference;
  118258. /**
  118259. * Caches the the state of the stencil buffer
  118260. */
  118261. cacheStencilState(): void;
  118262. /**
  118263. * Restores the state of the stencil buffer
  118264. */
  118265. restoreStencilState(): void;
  118266. /**
  118267. * Directly set the WebGL Viewport
  118268. * @param x defines the x coordinate of the viewport (in screen space)
  118269. * @param y defines the y coordinate of the viewport (in screen space)
  118270. * @param width defines the width of the viewport (in screen space)
  118271. * @param height defines the height of the viewport (in screen space)
  118272. * @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
  118273. */
  118274. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118275. /**
  118276. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118277. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118278. * @param y defines the y-coordinate of the corner of the clear rectangle
  118279. * @param width defines the width of the clear rectangle
  118280. * @param height defines the height of the clear rectangle
  118281. * @param clearColor defines the clear color
  118282. */
  118283. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118284. /**
  118285. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118286. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118287. * @param y defines the y-coordinate of the corner of the clear rectangle
  118288. * @param width defines the width of the clear rectangle
  118289. * @param height defines the height of the clear rectangle
  118290. */
  118291. enableScissor(x: number, y: number, width: number, height: number): void;
  118292. /**
  118293. * Disable previously set scissor test rectangle
  118294. */
  118295. disableScissor(): void;
  118296. protected _reportDrawCall(): void;
  118297. /**
  118298. * Initializes a webVR display and starts listening to display change events
  118299. * The onVRDisplayChangedObservable will be notified upon these changes
  118300. * @returns The onVRDisplayChangedObservable
  118301. */
  118302. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118303. /** @hidden */
  118304. _prepareVRComponent(): void;
  118305. /** @hidden */
  118306. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118307. /** @hidden */
  118308. _submitVRFrame(): void;
  118309. /**
  118310. * Call this function to leave webVR mode
  118311. * Will do nothing if webVR is not supported or if there is no webVR device
  118312. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118313. */
  118314. disableVR(): void;
  118315. /**
  118316. * Gets a boolean indicating that the system is in VR mode and is presenting
  118317. * @returns true if VR mode is engaged
  118318. */
  118319. isVRPresenting(): boolean;
  118320. /** @hidden */
  118321. _requestVRFrame(): void;
  118322. /** @hidden */
  118323. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118324. /**
  118325. * Gets the source code of the vertex shader associated with a specific webGL program
  118326. * @param program defines the program to use
  118327. * @returns a string containing the source code of the vertex shader associated with the program
  118328. */
  118329. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118330. /**
  118331. * Gets the source code of the fragment shader associated with a specific webGL program
  118332. * @param program defines the program to use
  118333. * @returns a string containing the source code of the fragment shader associated with the program
  118334. */
  118335. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118336. /**
  118337. * Sets a depth stencil texture from a render target to the according uniform.
  118338. * @param channel The texture channel
  118339. * @param uniform The uniform to set
  118340. * @param texture The render target texture containing the depth stencil texture to apply
  118341. */
  118342. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118343. /**
  118344. * Sets a texture to the webGL context from a postprocess
  118345. * @param channel defines the channel to use
  118346. * @param postProcess defines the source postprocess
  118347. */
  118348. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118349. /**
  118350. * Binds the output of the passed in post process to the texture channel specified
  118351. * @param channel The channel the texture should be bound to
  118352. * @param postProcess The post process which's output should be bound
  118353. */
  118354. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118355. protected _rebuildBuffers(): void;
  118356. /** @hidden */
  118357. _renderFrame(): void;
  118358. _renderLoop(): void;
  118359. /** @hidden */
  118360. _renderViews(): boolean;
  118361. /**
  118362. * Toggle full screen mode
  118363. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118364. */
  118365. switchFullscreen(requestPointerLock: boolean): void;
  118366. /**
  118367. * Enters full screen mode
  118368. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118369. */
  118370. enterFullscreen(requestPointerLock: boolean): void;
  118371. /**
  118372. * Exits full screen mode
  118373. */
  118374. exitFullscreen(): void;
  118375. /**
  118376. * Enters Pointerlock mode
  118377. */
  118378. enterPointerlock(): void;
  118379. /**
  118380. * Exits Pointerlock mode
  118381. */
  118382. exitPointerlock(): void;
  118383. /**
  118384. * Begin a new frame
  118385. */
  118386. beginFrame(): void;
  118387. /**
  118388. * Enf the current frame
  118389. */
  118390. endFrame(): void;
  118391. resize(): void;
  118392. /**
  118393. * Force a specific size of the canvas
  118394. * @param width defines the new canvas' width
  118395. * @param height defines the new canvas' height
  118396. * @returns true if the size was changed
  118397. */
  118398. setSize(width: number, height: number): boolean;
  118399. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118400. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118401. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118402. _releaseTexture(texture: InternalTexture): void;
  118403. /**
  118404. * @hidden
  118405. * Rescales a texture
  118406. * @param source input texutre
  118407. * @param destination destination texture
  118408. * @param scene scene to use to render the resize
  118409. * @param internalFormat format to use when resizing
  118410. * @param onComplete callback to be called when resize has completed
  118411. */
  118412. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118413. /**
  118414. * Gets the current framerate
  118415. * @returns a number representing the framerate
  118416. */
  118417. getFps(): number;
  118418. /**
  118419. * Gets the time spent between current and previous frame
  118420. * @returns a number representing the delta time in ms
  118421. */
  118422. getDeltaTime(): number;
  118423. private _measureFps;
  118424. /** @hidden */
  118425. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118426. /**
  118427. * Updates the sample count of a render target texture
  118428. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118429. * @param texture defines the texture to update
  118430. * @param samples defines the sample count to set
  118431. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118432. */
  118433. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118434. /**
  118435. * Updates a depth texture Comparison Mode and Function.
  118436. * If the comparison Function is equal to 0, the mode will be set to none.
  118437. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118438. * @param texture The texture to set the comparison function for
  118439. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118440. */
  118441. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118442. /**
  118443. * Creates a webGL buffer to use with instanciation
  118444. * @param capacity defines the size of the buffer
  118445. * @returns the webGL buffer
  118446. */
  118447. createInstancesBuffer(capacity: number): DataBuffer;
  118448. /**
  118449. * Delete a webGL buffer used with instanciation
  118450. * @param buffer defines the webGL buffer to delete
  118451. */
  118452. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118453. private _clientWaitAsync;
  118454. /** @hidden */
  118455. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118456. dispose(): void;
  118457. private _disableTouchAction;
  118458. /**
  118459. * Display the loading screen
  118460. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118461. */
  118462. displayLoadingUI(): void;
  118463. /**
  118464. * Hide the loading screen
  118465. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118466. */
  118467. hideLoadingUI(): void;
  118468. /**
  118469. * Gets the current loading screen object
  118470. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118471. */
  118472. get loadingScreen(): ILoadingScreen;
  118473. /**
  118474. * Sets the current loading screen object
  118475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118476. */
  118477. set loadingScreen(loadingScreen: ILoadingScreen);
  118478. /**
  118479. * Sets the current loading screen text
  118480. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118481. */
  118482. set loadingUIText(text: string);
  118483. /**
  118484. * Sets the current loading screen background color
  118485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118486. */
  118487. set loadingUIBackgroundColor(color: string);
  118488. /** Pointerlock and fullscreen */
  118489. /**
  118490. * Ask the browser to promote the current element to pointerlock mode
  118491. * @param element defines the DOM element to promote
  118492. */
  118493. static _RequestPointerlock(element: HTMLElement): void;
  118494. /**
  118495. * Asks the browser to exit pointerlock mode
  118496. */
  118497. static _ExitPointerlock(): void;
  118498. /**
  118499. * Ask the browser to promote the current element to fullscreen rendering mode
  118500. * @param element defines the DOM element to promote
  118501. */
  118502. static _RequestFullscreen(element: HTMLElement): void;
  118503. /**
  118504. * Asks the browser to exit fullscreen mode
  118505. */
  118506. static _ExitFullscreen(): void;
  118507. }
  118508. }
  118509. declare module BABYLON {
  118510. /**
  118511. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118512. * during the life time of the application.
  118513. */
  118514. export class EngineStore {
  118515. /** Gets the list of created engines */
  118516. static Instances: Engine[];
  118517. /** @hidden */
  118518. static _LastCreatedScene: Nullable<Scene>;
  118519. /**
  118520. * Gets the latest created engine
  118521. */
  118522. static get LastCreatedEngine(): Nullable<Engine>;
  118523. /**
  118524. * Gets the latest created scene
  118525. */
  118526. static get LastCreatedScene(): Nullable<Scene>;
  118527. /**
  118528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118529. * @ignorenaming
  118530. */
  118531. static UseFallbackTexture: boolean;
  118532. /**
  118533. * Texture content used if a texture cannot loaded
  118534. * @ignorenaming
  118535. */
  118536. static FallbackTexture: string;
  118537. }
  118538. }
  118539. declare module BABYLON {
  118540. /**
  118541. * Helper class that provides a small promise polyfill
  118542. */
  118543. export class PromisePolyfill {
  118544. /**
  118545. * Static function used to check if the polyfill is required
  118546. * If this is the case then the function will inject the polyfill to window.Promise
  118547. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118548. */
  118549. static Apply(force?: boolean): void;
  118550. }
  118551. }
  118552. declare module BABYLON {
  118553. /**
  118554. * Interface for screenshot methods with describe argument called `size` as object with options
  118555. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118556. */
  118557. export interface IScreenshotSize {
  118558. /**
  118559. * number in pixels for canvas height
  118560. */
  118561. height?: number;
  118562. /**
  118563. * multiplier allowing render at a higher or lower resolution
  118564. * If value is defined then height and width will be ignored and taken from camera
  118565. */
  118566. precision?: number;
  118567. /**
  118568. * number in pixels for canvas width
  118569. */
  118570. width?: number;
  118571. }
  118572. }
  118573. declare module BABYLON {
  118574. interface IColor4Like {
  118575. r: float;
  118576. g: float;
  118577. b: float;
  118578. a: float;
  118579. }
  118580. /**
  118581. * Class containing a set of static utilities functions
  118582. */
  118583. export class Tools {
  118584. /**
  118585. * Gets or sets the base URL to use to load assets
  118586. */
  118587. static get BaseUrl(): string;
  118588. static set BaseUrl(value: string);
  118589. /**
  118590. * Enable/Disable Custom HTTP Request Headers globally.
  118591. * default = false
  118592. * @see CustomRequestHeaders
  118593. */
  118594. static UseCustomRequestHeaders: boolean;
  118595. /**
  118596. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118597. * i.e. when loading files, where the server/service expects an Authorization header
  118598. */
  118599. static CustomRequestHeaders: {
  118600. [key: string]: string;
  118601. };
  118602. /**
  118603. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118604. */
  118605. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118606. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118607. /**
  118608. * Default behaviour for cors in the application.
  118609. * It can be a string if the expected behavior is identical in the entire app.
  118610. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118611. */
  118612. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118613. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118614. /**
  118615. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118616. * @ignorenaming
  118617. */
  118618. static get UseFallbackTexture(): boolean;
  118619. static set UseFallbackTexture(value: boolean);
  118620. /**
  118621. * Use this object to register external classes like custom textures or material
  118622. * to allow the laoders to instantiate them
  118623. */
  118624. static get RegisteredExternalClasses(): {
  118625. [key: string]: Object;
  118626. };
  118627. static set RegisteredExternalClasses(classes: {
  118628. [key: string]: Object;
  118629. });
  118630. /**
  118631. * Texture content used if a texture cannot loaded
  118632. * @ignorenaming
  118633. */
  118634. static get fallbackTexture(): string;
  118635. static set fallbackTexture(value: string);
  118636. /**
  118637. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118638. * @param u defines the coordinate on X axis
  118639. * @param v defines the coordinate on Y axis
  118640. * @param width defines the width of the source data
  118641. * @param height defines the height of the source data
  118642. * @param pixels defines the source byte array
  118643. * @param color defines the output color
  118644. */
  118645. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118646. /**
  118647. * Interpolates between a and b via alpha
  118648. * @param a The lower value (returned when alpha = 0)
  118649. * @param b The upper value (returned when alpha = 1)
  118650. * @param alpha The interpolation-factor
  118651. * @return The mixed value
  118652. */
  118653. static Mix(a: number, b: number, alpha: number): number;
  118654. /**
  118655. * Tries to instantiate a new object from a given class name
  118656. * @param className defines the class name to instantiate
  118657. * @returns the new object or null if the system was not able to do the instantiation
  118658. */
  118659. static Instantiate(className: string): any;
  118660. /**
  118661. * Provides a slice function that will work even on IE
  118662. * @param data defines the array to slice
  118663. * @param start defines the start of the data (optional)
  118664. * @param end defines the end of the data (optional)
  118665. * @returns the new sliced array
  118666. */
  118667. static Slice<T>(data: T, start?: number, end?: number): T;
  118668. /**
  118669. * Polyfill for setImmediate
  118670. * @param action defines the action to execute after the current execution block
  118671. */
  118672. static SetImmediate(action: () => void): void;
  118673. /**
  118674. * Function indicating if a number is an exponent of 2
  118675. * @param value defines the value to test
  118676. * @returns true if the value is an exponent of 2
  118677. */
  118678. static IsExponentOfTwo(value: number): boolean;
  118679. private static _tmpFloatArray;
  118680. /**
  118681. * Returns the nearest 32-bit single precision float representation of a Number
  118682. * @param value A Number. If the parameter is of a different type, it will get converted
  118683. * to a number or to NaN if it cannot be converted
  118684. * @returns number
  118685. */
  118686. static FloatRound(value: number): number;
  118687. /**
  118688. * Extracts the filename from a path
  118689. * @param path defines the path to use
  118690. * @returns the filename
  118691. */
  118692. static GetFilename(path: string): string;
  118693. /**
  118694. * Extracts the "folder" part of a path (everything before the filename).
  118695. * @param uri The URI to extract the info from
  118696. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118697. * @returns The "folder" part of the path
  118698. */
  118699. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118700. /**
  118701. * Extracts text content from a DOM element hierarchy
  118702. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118703. */
  118704. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118705. /**
  118706. * Convert an angle in radians to degrees
  118707. * @param angle defines the angle to convert
  118708. * @returns the angle in degrees
  118709. */
  118710. static ToDegrees(angle: number): number;
  118711. /**
  118712. * Convert an angle in degrees to radians
  118713. * @param angle defines the angle to convert
  118714. * @returns the angle in radians
  118715. */
  118716. static ToRadians(angle: number): number;
  118717. /**
  118718. * Returns an array if obj is not an array
  118719. * @param obj defines the object to evaluate as an array
  118720. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118721. * @returns either obj directly if obj is an array or a new array containing obj
  118722. */
  118723. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118724. /**
  118725. * Gets the pointer prefix to use
  118726. * @param engine defines the engine we are finding the prefix for
  118727. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118728. */
  118729. static GetPointerPrefix(engine: Engine): string;
  118730. /**
  118731. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118732. * @param url define the url we are trying
  118733. * @param element define the dom element where to configure the cors policy
  118734. */
  118735. static SetCorsBehavior(url: string | string[], element: {
  118736. crossOrigin: string | null;
  118737. }): void;
  118738. /**
  118739. * Removes unwanted characters from an url
  118740. * @param url defines the url to clean
  118741. * @returns the cleaned url
  118742. */
  118743. static CleanUrl(url: string): string;
  118744. /**
  118745. * Gets or sets a function used to pre-process url before using them to load assets
  118746. */
  118747. static get PreprocessUrl(): (url: string) => string;
  118748. static set PreprocessUrl(processor: (url: string) => string);
  118749. /**
  118750. * Loads an image as an HTMLImageElement.
  118751. * @param input url string, ArrayBuffer, or Blob to load
  118752. * @param onLoad callback called when the image successfully loads
  118753. * @param onError callback called when the image fails to load
  118754. * @param offlineProvider offline provider for caching
  118755. * @param mimeType optional mime type
  118756. * @returns the HTMLImageElement of the loaded image
  118757. */
  118758. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118759. /**
  118760. * Loads a file from a url
  118761. * @param url url string, ArrayBuffer, or Blob to load
  118762. * @param onSuccess callback called when the file successfully loads
  118763. * @param onProgress callback called while file is loading (if the server supports this mode)
  118764. * @param offlineProvider defines the offline provider for caching
  118765. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118766. * @param onError callback called when the file fails to load
  118767. * @returns a file request object
  118768. */
  118769. 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;
  118770. /**
  118771. * Loads a file from a url
  118772. * @param url the file url to load
  118773. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118774. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118775. */
  118776. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118777. /**
  118778. * Load a script (identified by an url). When the url returns, the
  118779. * content of this file is added into a new script element, attached to the DOM (body element)
  118780. * @param scriptUrl defines the url of the script to laod
  118781. * @param onSuccess defines the callback called when the script is loaded
  118782. * @param onError defines the callback to call if an error occurs
  118783. * @param scriptId defines the id of the script element
  118784. */
  118785. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118786. /**
  118787. * Load an asynchronous script (identified by an url). When the url returns, the
  118788. * content of this file is added into a new script element, attached to the DOM (body element)
  118789. * @param scriptUrl defines the url of the script to laod
  118790. * @param scriptId defines the id of the script element
  118791. * @returns a promise request object
  118792. */
  118793. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118794. /**
  118795. * Loads a file from a blob
  118796. * @param fileToLoad defines the blob to use
  118797. * @param callback defines the callback to call when data is loaded
  118798. * @param progressCallback defines the callback to call during loading process
  118799. * @returns a file request object
  118800. */
  118801. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118802. /**
  118803. * Reads a file from a File object
  118804. * @param file defines the file to load
  118805. * @param onSuccess defines the callback to call when data is loaded
  118806. * @param onProgress defines the callback to call during loading process
  118807. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118808. * @param onError defines the callback to call when an error occurs
  118809. * @returns a file request object
  118810. */
  118811. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118812. /**
  118813. * Creates a data url from a given string content
  118814. * @param content defines the content to convert
  118815. * @returns the new data url link
  118816. */
  118817. static FileAsURL(content: string): string;
  118818. /**
  118819. * Format the given number to a specific decimal format
  118820. * @param value defines the number to format
  118821. * @param decimals defines the number of decimals to use
  118822. * @returns the formatted string
  118823. */
  118824. static Format(value: number, decimals?: number): string;
  118825. /**
  118826. * Tries to copy an object by duplicating every property
  118827. * @param source defines the source object
  118828. * @param destination defines the target object
  118829. * @param doNotCopyList defines a list of properties to avoid
  118830. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118831. */
  118832. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118833. /**
  118834. * Gets a boolean indicating if the given object has no own property
  118835. * @param obj defines the object to test
  118836. * @returns true if object has no own property
  118837. */
  118838. static IsEmpty(obj: any): boolean;
  118839. /**
  118840. * Function used to register events at window level
  118841. * @param windowElement defines the Window object to use
  118842. * @param events defines the events to register
  118843. */
  118844. static RegisterTopRootEvents(windowElement: Window, events: {
  118845. name: string;
  118846. handler: Nullable<(e: FocusEvent) => any>;
  118847. }[]): void;
  118848. /**
  118849. * Function used to unregister events from window level
  118850. * @param windowElement defines the Window object to use
  118851. * @param events defines the events to unregister
  118852. */
  118853. static UnregisterTopRootEvents(windowElement: Window, events: {
  118854. name: string;
  118855. handler: Nullable<(e: FocusEvent) => any>;
  118856. }[]): void;
  118857. /**
  118858. * @ignore
  118859. */
  118860. static _ScreenshotCanvas: HTMLCanvasElement;
  118861. /**
  118862. * Dumps the current bound framebuffer
  118863. * @param width defines the rendering width
  118864. * @param height defines the rendering height
  118865. * @param engine defines the hosting engine
  118866. * @param successCallback defines the callback triggered once the data are available
  118867. * @param mimeType defines the mime type of the result
  118868. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118869. */
  118870. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118871. /**
  118872. * Converts the canvas data to blob.
  118873. * This acts as a polyfill for browsers not supporting the to blob function.
  118874. * @param canvas Defines the canvas to extract the data from
  118875. * @param successCallback Defines the callback triggered once the data are available
  118876. * @param mimeType Defines the mime type of the result
  118877. */
  118878. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118879. /**
  118880. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118881. * @param successCallback defines the callback triggered once the data are available
  118882. * @param mimeType defines the mime type of the result
  118883. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118884. */
  118885. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118886. /**
  118887. * Downloads a blob in the browser
  118888. * @param blob defines the blob to download
  118889. * @param fileName defines the name of the downloaded file
  118890. */
  118891. static Download(blob: Blob, fileName: string): void;
  118892. /**
  118893. * Captures a screenshot of the current rendering
  118894. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118895. * @param engine defines the rendering engine
  118896. * @param camera defines the source camera
  118897. * @param size This parameter can be set to a single number or to an object with the
  118898. * following (optional) properties: precision, width, height. If a single number is passed,
  118899. * it will be used for both width and height. If an object is passed, the screenshot size
  118900. * will be derived from the parameters. The precision property is a multiplier allowing
  118901. * rendering at a higher or lower resolution
  118902. * @param successCallback defines the callback receives a single parameter which contains the
  118903. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118904. * src parameter of an <img> to display it
  118905. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118906. * Check your browser for supported MIME types
  118907. */
  118908. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118909. /**
  118910. * Captures a screenshot of the current rendering
  118911. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118912. * @param engine defines the rendering engine
  118913. * @param camera defines the source camera
  118914. * @param size This parameter can be set to a single number or to an object with the
  118915. * following (optional) properties: precision, width, height. If a single number is passed,
  118916. * it will be used for both width and height. If an object is passed, the screenshot size
  118917. * will be derived from the parameters. The precision property is a multiplier allowing
  118918. * rendering at a higher or lower resolution
  118919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118920. * Check your browser for supported MIME types
  118921. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118922. * to the src parameter of an <img> to display it
  118923. */
  118924. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118925. /**
  118926. * Generates an image screenshot from the specified camera.
  118927. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118928. * @param engine The engine to use for rendering
  118929. * @param camera The camera to use for rendering
  118930. * @param size This parameter can be set to a single number or to an object with the
  118931. * following (optional) properties: precision, width, height. If a single number is passed,
  118932. * it will be used for both width and height. If an object is passed, the screenshot size
  118933. * will be derived from the parameters. The precision property is a multiplier allowing
  118934. * rendering at a higher or lower resolution
  118935. * @param successCallback The callback receives a single parameter which contains the
  118936. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118937. * src parameter of an <img> to display it
  118938. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118939. * Check your browser for supported MIME types
  118940. * @param samples Texture samples (default: 1)
  118941. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118942. * @param fileName A name for for the downloaded file.
  118943. */
  118944. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118945. /**
  118946. * Generates an image screenshot from the specified camera.
  118947. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118948. * @param engine The engine to use for rendering
  118949. * @param camera The camera to use for rendering
  118950. * @param size This parameter can be set to a single number or to an object with the
  118951. * following (optional) properties: precision, width, height. If a single number is passed,
  118952. * it will be used for both width and height. If an object is passed, the screenshot size
  118953. * will be derived from the parameters. The precision property is a multiplier allowing
  118954. * rendering at a higher or lower resolution
  118955. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118956. * Check your browser for supported MIME types
  118957. * @param samples Texture samples (default: 1)
  118958. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118959. * @param fileName A name for for the downloaded file.
  118960. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118961. * to the src parameter of an <img> to display it
  118962. */
  118963. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118964. /**
  118965. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118966. * Be aware Math.random() could cause collisions, but:
  118967. * "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"
  118968. * @returns a pseudo random id
  118969. */
  118970. static RandomId(): string;
  118971. /**
  118972. * Test if the given uri is a base64 string
  118973. * @param uri The uri to test
  118974. * @return True if the uri is a base64 string or false otherwise
  118975. */
  118976. static IsBase64(uri: string): boolean;
  118977. /**
  118978. * Decode the given base64 uri.
  118979. * @param uri The uri to decode
  118980. * @return The decoded base64 data.
  118981. */
  118982. static DecodeBase64(uri: string): ArrayBuffer;
  118983. /**
  118984. * Gets the absolute url.
  118985. * @param url the input url
  118986. * @return the absolute url
  118987. */
  118988. static GetAbsoluteUrl(url: string): string;
  118989. /**
  118990. * No log
  118991. */
  118992. static readonly NoneLogLevel: number;
  118993. /**
  118994. * Only message logs
  118995. */
  118996. static readonly MessageLogLevel: number;
  118997. /**
  118998. * Only warning logs
  118999. */
  119000. static readonly WarningLogLevel: number;
  119001. /**
  119002. * Only error logs
  119003. */
  119004. static readonly ErrorLogLevel: number;
  119005. /**
  119006. * All logs
  119007. */
  119008. static readonly AllLogLevel: number;
  119009. /**
  119010. * Gets a value indicating the number of loading errors
  119011. * @ignorenaming
  119012. */
  119013. static get errorsCount(): number;
  119014. /**
  119015. * Callback called when a new log is added
  119016. */
  119017. static OnNewCacheEntry: (entry: string) => void;
  119018. /**
  119019. * Log a message to the console
  119020. * @param message defines the message to log
  119021. */
  119022. static Log(message: string): void;
  119023. /**
  119024. * Write a warning message to the console
  119025. * @param message defines the message to log
  119026. */
  119027. static Warn(message: string): void;
  119028. /**
  119029. * Write an error message to the console
  119030. * @param message defines the message to log
  119031. */
  119032. static Error(message: string): void;
  119033. /**
  119034. * Gets current log cache (list of logs)
  119035. */
  119036. static get LogCache(): string;
  119037. /**
  119038. * Clears the log cache
  119039. */
  119040. static ClearLogCache(): void;
  119041. /**
  119042. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119043. */
  119044. static set LogLevels(level: number);
  119045. /**
  119046. * Checks if the window object exists
  119047. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119048. */
  119049. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119050. /**
  119051. * No performance log
  119052. */
  119053. static readonly PerformanceNoneLogLevel: number;
  119054. /**
  119055. * Use user marks to log performance
  119056. */
  119057. static readonly PerformanceUserMarkLogLevel: number;
  119058. /**
  119059. * Log performance to the console
  119060. */
  119061. static readonly PerformanceConsoleLogLevel: number;
  119062. private static _performance;
  119063. /**
  119064. * Sets the current performance log level
  119065. */
  119066. static set PerformanceLogLevel(level: number);
  119067. private static _StartPerformanceCounterDisabled;
  119068. private static _EndPerformanceCounterDisabled;
  119069. private static _StartUserMark;
  119070. private static _EndUserMark;
  119071. private static _StartPerformanceConsole;
  119072. private static _EndPerformanceConsole;
  119073. /**
  119074. * Starts a performance counter
  119075. */
  119076. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119077. /**
  119078. * Ends a specific performance coutner
  119079. */
  119080. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119081. /**
  119082. * Gets either window.performance.now() if supported or Date.now() else
  119083. */
  119084. static get Now(): number;
  119085. /**
  119086. * This method will return the name of the class used to create the instance of the given object.
  119087. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119088. * @param object the object to get the class name from
  119089. * @param isType defines if the object is actually a type
  119090. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119091. */
  119092. static GetClassName(object: any, isType?: boolean): string;
  119093. /**
  119094. * Gets the first element of an array satisfying a given predicate
  119095. * @param array defines the array to browse
  119096. * @param predicate defines the predicate to use
  119097. * @returns null if not found or the element
  119098. */
  119099. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119100. /**
  119101. * This method will return the name of the full name of the class, including its owning module (if any).
  119102. * 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).
  119103. * @param object the object to get the class name from
  119104. * @param isType defines if the object is actually a type
  119105. * @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.
  119106. * @ignorenaming
  119107. */
  119108. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119109. /**
  119110. * Returns a promise that resolves after the given amount of time.
  119111. * @param delay Number of milliseconds to delay
  119112. * @returns Promise that resolves after the given amount of time
  119113. */
  119114. static DelayAsync(delay: number): Promise<void>;
  119115. /**
  119116. * Utility function to detect if the current user agent is Safari
  119117. * @returns whether or not the current user agent is safari
  119118. */
  119119. static IsSafari(): boolean;
  119120. }
  119121. /**
  119122. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119123. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119124. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119125. * @param name The name of the class, case should be preserved
  119126. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119127. */
  119128. export function className(name: string, module?: string): (target: Object) => void;
  119129. /**
  119130. * An implementation of a loop for asynchronous functions.
  119131. */
  119132. export class AsyncLoop {
  119133. /**
  119134. * Defines the number of iterations for the loop
  119135. */
  119136. iterations: number;
  119137. /**
  119138. * Defines the current index of the loop.
  119139. */
  119140. index: number;
  119141. private _done;
  119142. private _fn;
  119143. private _successCallback;
  119144. /**
  119145. * Constructor.
  119146. * @param iterations the number of iterations.
  119147. * @param func the function to run each iteration
  119148. * @param successCallback the callback that will be called upon succesful execution
  119149. * @param offset starting offset.
  119150. */
  119151. constructor(
  119152. /**
  119153. * Defines the number of iterations for the loop
  119154. */
  119155. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119156. /**
  119157. * Execute the next iteration. Must be called after the last iteration was finished.
  119158. */
  119159. executeNext(): void;
  119160. /**
  119161. * Break the loop and run the success callback.
  119162. */
  119163. breakLoop(): void;
  119164. /**
  119165. * Create and run an async loop.
  119166. * @param iterations the number of iterations.
  119167. * @param fn the function to run each iteration
  119168. * @param successCallback the callback that will be called upon succesful execution
  119169. * @param offset starting offset.
  119170. * @returns the created async loop object
  119171. */
  119172. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119173. /**
  119174. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119175. * @param iterations total number of iterations
  119176. * @param syncedIterations number of synchronous iterations in each async iteration.
  119177. * @param fn the function to call each iteration.
  119178. * @param callback a success call back that will be called when iterating stops.
  119179. * @param breakFunction a break condition (optional)
  119180. * @param timeout timeout settings for the setTimeout function. default - 0.
  119181. * @returns the created async loop object
  119182. */
  119183. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119184. }
  119185. }
  119186. declare module BABYLON {
  119187. /**
  119188. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119189. * The underlying implementation relies on an associative array to ensure the best performances.
  119190. * The value can be anything including 'null' but except 'undefined'
  119191. */
  119192. export class StringDictionary<T> {
  119193. /**
  119194. * This will clear this dictionary and copy the content from the 'source' one.
  119195. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119196. * @param source the dictionary to take the content from and copy to this dictionary
  119197. */
  119198. copyFrom(source: StringDictionary<T>): void;
  119199. /**
  119200. * Get a value based from its key
  119201. * @param key the given key to get the matching value from
  119202. * @return the value if found, otherwise undefined is returned
  119203. */
  119204. get(key: string): T | undefined;
  119205. /**
  119206. * Get a value from its key or add it if it doesn't exist.
  119207. * This method will ensure you that a given key/data will be present in the dictionary.
  119208. * @param key the given key to get the matching value from
  119209. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119210. * The factory will only be invoked if there's no data for the given key.
  119211. * @return the value corresponding to the key.
  119212. */
  119213. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119214. /**
  119215. * Get a value from its key if present in the dictionary otherwise add it
  119216. * @param key the key to get the value from
  119217. * @param val if there's no such key/value pair in the dictionary add it with this value
  119218. * @return the value corresponding to the key
  119219. */
  119220. getOrAdd(key: string, val: T): T;
  119221. /**
  119222. * Check if there's a given key in the dictionary
  119223. * @param key the key to check for
  119224. * @return true if the key is present, false otherwise
  119225. */
  119226. contains(key: string): boolean;
  119227. /**
  119228. * Add a new key and its corresponding value
  119229. * @param key the key to add
  119230. * @param value the value corresponding to the key
  119231. * @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
  119232. */
  119233. add(key: string, value: T): boolean;
  119234. /**
  119235. * Update a specific value associated to a key
  119236. * @param key defines the key to use
  119237. * @param value defines the value to store
  119238. * @returns true if the value was updated (or false if the key was not found)
  119239. */
  119240. set(key: string, value: T): boolean;
  119241. /**
  119242. * Get the element of the given key and remove it from the dictionary
  119243. * @param key defines the key to search
  119244. * @returns the value associated with the key or null if not found
  119245. */
  119246. getAndRemove(key: string): Nullable<T>;
  119247. /**
  119248. * Remove a key/value from the dictionary.
  119249. * @param key the key to remove
  119250. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119251. */
  119252. remove(key: string): boolean;
  119253. /**
  119254. * Clear the whole content of the dictionary
  119255. */
  119256. clear(): void;
  119257. /**
  119258. * Gets the current count
  119259. */
  119260. get count(): number;
  119261. /**
  119262. * Execute a callback on each key/val of the dictionary.
  119263. * Note that you can remove any element in this dictionary in the callback implementation
  119264. * @param callback the callback to execute on a given key/value pair
  119265. */
  119266. forEach(callback: (key: string, val: T) => void): void;
  119267. /**
  119268. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119269. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119270. * Note that you can remove any element in this dictionary in the callback implementation
  119271. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119272. * @returns the first item
  119273. */
  119274. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119275. private _count;
  119276. private _data;
  119277. }
  119278. }
  119279. declare module BABYLON {
  119280. /** @hidden */
  119281. export interface ICollisionCoordinator {
  119282. createCollider(): Collider;
  119283. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119284. init(scene: Scene): void;
  119285. }
  119286. /** @hidden */
  119287. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119288. private _scene;
  119289. private _scaledPosition;
  119290. private _scaledVelocity;
  119291. private _finalPosition;
  119292. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119293. createCollider(): Collider;
  119294. init(scene: Scene): void;
  119295. private _collideWithWorld;
  119296. }
  119297. }
  119298. declare module BABYLON {
  119299. /**
  119300. * Class used to manage all inputs for the scene.
  119301. */
  119302. export class InputManager {
  119303. /** The distance in pixel that you have to move to prevent some events */
  119304. static DragMovementThreshold: number;
  119305. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119306. static LongPressDelay: number;
  119307. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119308. static DoubleClickDelay: number;
  119309. /** If you need to check double click without raising a single click at first click, enable this flag */
  119310. static ExclusiveDoubleClickMode: boolean;
  119311. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  119312. private _alreadyAttached;
  119313. private _wheelEventName;
  119314. private _onPointerMove;
  119315. private _onPointerDown;
  119316. private _onPointerUp;
  119317. private _initClickEvent;
  119318. private _initActionManager;
  119319. private _delayedSimpleClick;
  119320. private _delayedSimpleClickTimeout;
  119321. private _previousDelayedSimpleClickTimeout;
  119322. private _meshPickProceed;
  119323. private _previousButtonPressed;
  119324. private _currentPickResult;
  119325. private _previousPickResult;
  119326. private _totalPointersPressed;
  119327. private _doubleClickOccured;
  119328. private _pointerOverMesh;
  119329. private _pickedDownMesh;
  119330. private _pickedUpMesh;
  119331. private _pointerX;
  119332. private _pointerY;
  119333. private _unTranslatedPointerX;
  119334. private _unTranslatedPointerY;
  119335. private _startingPointerPosition;
  119336. private _previousStartingPointerPosition;
  119337. private _startingPointerTime;
  119338. private _previousStartingPointerTime;
  119339. private _pointerCaptures;
  119340. private _meshUnderPointerId;
  119341. private _onKeyDown;
  119342. private _onKeyUp;
  119343. private _onCanvasFocusObserver;
  119344. private _onCanvasBlurObserver;
  119345. private _scene;
  119346. /**
  119347. * Creates a new InputManager
  119348. * @param scene defines the hosting scene
  119349. */
  119350. constructor(scene: Scene);
  119351. /**
  119352. * Gets the mesh that is currently under the pointer
  119353. */
  119354. get meshUnderPointer(): Nullable<AbstractMesh>;
  119355. /**
  119356. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119357. * @param pointerId the pointer id to use
  119358. * @returns The mesh under this pointer id or null if not found
  119359. */
  119360. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119361. /**
  119362. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119363. */
  119364. get unTranslatedPointer(): Vector2;
  119365. /**
  119366. * Gets or sets the current on-screen X position of the pointer
  119367. */
  119368. get pointerX(): number;
  119369. set pointerX(value: number);
  119370. /**
  119371. * Gets or sets the current on-screen Y position of the pointer
  119372. */
  119373. get pointerY(): number;
  119374. set pointerY(value: number);
  119375. private _updatePointerPosition;
  119376. private _processPointerMove;
  119377. private _setRayOnPointerInfo;
  119378. private _checkPrePointerObservable;
  119379. /**
  119380. * Use this method to simulate a pointer move on a mesh
  119381. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119382. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119383. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119384. */
  119385. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119386. /**
  119387. * Use this method to simulate a pointer down on a mesh
  119388. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119389. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119390. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119391. */
  119392. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119393. private _processPointerDown;
  119394. /** @hidden */
  119395. _isPointerSwiping(): boolean;
  119396. /**
  119397. * Use this method to simulate a pointer up on a mesh
  119398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119401. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119402. */
  119403. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119404. private _processPointerUp;
  119405. /**
  119406. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119407. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119408. * @returns true if the pointer was captured
  119409. */
  119410. isPointerCaptured(pointerId?: number): boolean;
  119411. /**
  119412. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119413. * @param attachUp defines if you want to attach events to pointerup
  119414. * @param attachDown defines if you want to attach events to pointerdown
  119415. * @param attachMove defines if you want to attach events to pointermove
  119416. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119417. */
  119418. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119419. /**
  119420. * Detaches all event handlers
  119421. */
  119422. detachControl(): void;
  119423. /**
  119424. * Force the value of meshUnderPointer
  119425. * @param mesh defines the mesh to use
  119426. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119427. */
  119428. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119429. /**
  119430. * Gets the mesh under the pointer
  119431. * @returns a Mesh or null if no mesh is under the pointer
  119432. */
  119433. getPointerOverMesh(): Nullable<AbstractMesh>;
  119434. }
  119435. }
  119436. declare module BABYLON {
  119437. /**
  119438. * This class defines the direct association between an animation and a target
  119439. */
  119440. export class TargetedAnimation {
  119441. /**
  119442. * Animation to perform
  119443. */
  119444. animation: Animation;
  119445. /**
  119446. * Target to animate
  119447. */
  119448. target: any;
  119449. /**
  119450. * Returns the string "TargetedAnimation"
  119451. * @returns "TargetedAnimation"
  119452. */
  119453. getClassName(): string;
  119454. /**
  119455. * Serialize the object
  119456. * @returns the JSON object representing the current entity
  119457. */
  119458. serialize(): any;
  119459. }
  119460. /**
  119461. * Use this class to create coordinated animations on multiple targets
  119462. */
  119463. export class AnimationGroup implements IDisposable {
  119464. /** The name of the animation group */
  119465. name: string;
  119466. private _scene;
  119467. private _targetedAnimations;
  119468. private _animatables;
  119469. private _from;
  119470. private _to;
  119471. private _isStarted;
  119472. private _isPaused;
  119473. private _speedRatio;
  119474. private _loopAnimation;
  119475. private _isAdditive;
  119476. /**
  119477. * Gets or sets the unique id of the node
  119478. */
  119479. uniqueId: number;
  119480. /**
  119481. * This observable will notify when one animation have ended
  119482. */
  119483. onAnimationEndObservable: Observable<TargetedAnimation>;
  119484. /**
  119485. * Observer raised when one animation loops
  119486. */
  119487. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119488. /**
  119489. * Observer raised when all animations have looped
  119490. */
  119491. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119492. /**
  119493. * This observable will notify when all animations have ended.
  119494. */
  119495. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119496. /**
  119497. * This observable will notify when all animations have paused.
  119498. */
  119499. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119500. /**
  119501. * This observable will notify when all animations are playing.
  119502. */
  119503. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119504. /**
  119505. * Gets the first frame
  119506. */
  119507. get from(): number;
  119508. /**
  119509. * Gets the last frame
  119510. */
  119511. get to(): number;
  119512. /**
  119513. * Define if the animations are started
  119514. */
  119515. get isStarted(): boolean;
  119516. /**
  119517. * Gets a value indicating that the current group is playing
  119518. */
  119519. get isPlaying(): boolean;
  119520. /**
  119521. * Gets or sets the speed ratio to use for all animations
  119522. */
  119523. get speedRatio(): number;
  119524. /**
  119525. * Gets or sets the speed ratio to use for all animations
  119526. */
  119527. set speedRatio(value: number);
  119528. /**
  119529. * Gets or sets if all animations should loop or not
  119530. */
  119531. get loopAnimation(): boolean;
  119532. set loopAnimation(value: boolean);
  119533. /**
  119534. * Gets or sets if all animations should be evaluated additively
  119535. */
  119536. get isAdditive(): boolean;
  119537. set isAdditive(value: boolean);
  119538. /**
  119539. * Gets the targeted animations for this animation group
  119540. */
  119541. get targetedAnimations(): Array<TargetedAnimation>;
  119542. /**
  119543. * returning the list of animatables controlled by this animation group.
  119544. */
  119545. get animatables(): Array<Animatable>;
  119546. /**
  119547. * Gets the list of target animations
  119548. */
  119549. get children(): TargetedAnimation[];
  119550. /**
  119551. * Instantiates a new Animation Group.
  119552. * This helps managing several animations at once.
  119553. * @see https://doc.babylonjs.com/how_to/group
  119554. * @param name Defines the name of the group
  119555. * @param scene Defines the scene the group belongs to
  119556. */
  119557. constructor(
  119558. /** The name of the animation group */
  119559. name: string, scene?: Nullable<Scene>);
  119560. /**
  119561. * Add an animation (with its target) in the group
  119562. * @param animation defines the animation we want to add
  119563. * @param target defines the target of the animation
  119564. * @returns the TargetedAnimation object
  119565. */
  119566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119567. /**
  119568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119569. * It can add constant keys at begin or end
  119570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119572. * @returns the animation group
  119573. */
  119574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119575. private _animationLoopCount;
  119576. private _animationLoopFlags;
  119577. private _processLoop;
  119578. /**
  119579. * Start all animations on given targets
  119580. * @param loop defines if animations must loop
  119581. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119582. * @param from defines the from key (optional)
  119583. * @param to defines the to key (optional)
  119584. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119585. * @returns the current animation group
  119586. */
  119587. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119588. /**
  119589. * Pause all animations
  119590. * @returns the animation group
  119591. */
  119592. pause(): AnimationGroup;
  119593. /**
  119594. * Play all animations to initial state
  119595. * This function will start() the animations if they were not started or will restart() them if they were paused
  119596. * @param loop defines if animations must loop
  119597. * @returns the animation group
  119598. */
  119599. play(loop?: boolean): AnimationGroup;
  119600. /**
  119601. * Reset all animations to initial state
  119602. * @returns the animation group
  119603. */
  119604. reset(): AnimationGroup;
  119605. /**
  119606. * Restart animations from key 0
  119607. * @returns the animation group
  119608. */
  119609. restart(): AnimationGroup;
  119610. /**
  119611. * Stop all animations
  119612. * @returns the animation group
  119613. */
  119614. stop(): AnimationGroup;
  119615. /**
  119616. * Set animation weight for all animatables
  119617. * @param weight defines the weight to use
  119618. * @return the animationGroup
  119619. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119620. */
  119621. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119622. /**
  119623. * Synchronize and normalize all animatables with a source animatable
  119624. * @param root defines the root animatable to synchronize with
  119625. * @return the animationGroup
  119626. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119627. */
  119628. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119629. /**
  119630. * Goes to a specific frame in this animation group
  119631. * @param frame the frame number to go to
  119632. * @return the animationGroup
  119633. */
  119634. goToFrame(frame: number): AnimationGroup;
  119635. /**
  119636. * Dispose all associated resources
  119637. */
  119638. dispose(): void;
  119639. private _checkAnimationGroupEnded;
  119640. /**
  119641. * Clone the current animation group and returns a copy
  119642. * @param newName defines the name of the new group
  119643. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119644. * @returns the new aniamtion group
  119645. */
  119646. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119647. /**
  119648. * Serializes the animationGroup to an object
  119649. * @returns Serialized object
  119650. */
  119651. serialize(): any;
  119652. /**
  119653. * Returns a new AnimationGroup object parsed from the source provided.
  119654. * @param parsedAnimationGroup defines the source
  119655. * @param scene defines the scene that will receive the animationGroup
  119656. * @returns a new AnimationGroup
  119657. */
  119658. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119659. /**
  119660. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119661. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119662. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119663. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119664. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119665. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119666. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119667. */
  119668. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119669. /**
  119670. * Returns the string "AnimationGroup"
  119671. * @returns "AnimationGroup"
  119672. */
  119673. getClassName(): string;
  119674. /**
  119675. * Creates a detailled string about the object
  119676. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119677. * @returns a string representing the object
  119678. */
  119679. toString(fullDetails?: boolean): string;
  119680. }
  119681. }
  119682. declare module BABYLON {
  119683. /**
  119684. * Define an interface for all classes that will hold resources
  119685. */
  119686. export interface IDisposable {
  119687. /**
  119688. * Releases all held resources
  119689. */
  119690. dispose(): void;
  119691. }
  119692. /** Interface defining initialization parameters for Scene class */
  119693. export interface SceneOptions {
  119694. /**
  119695. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119696. * It will improve performance when the number of geometries becomes important.
  119697. */
  119698. useGeometryUniqueIdsMap?: boolean;
  119699. /**
  119700. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119701. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119702. */
  119703. useMaterialMeshMap?: boolean;
  119704. /**
  119705. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119707. */
  119708. useClonedMeshMap?: boolean;
  119709. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119710. virtual?: boolean;
  119711. }
  119712. /**
  119713. * Represents a scene to be rendered by the engine.
  119714. * @see https://doc.babylonjs.com/features/scene
  119715. */
  119716. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119717. /** The fog is deactivated */
  119718. static readonly FOGMODE_NONE: number;
  119719. /** The fog density is following an exponential function */
  119720. static readonly FOGMODE_EXP: number;
  119721. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119722. static readonly FOGMODE_EXP2: number;
  119723. /** The fog density is following a linear function. */
  119724. static readonly FOGMODE_LINEAR: number;
  119725. /**
  119726. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119728. */
  119729. static MinDeltaTime: number;
  119730. /**
  119731. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119733. */
  119734. static MaxDeltaTime: number;
  119735. /**
  119736. * Factory used to create the default material.
  119737. * @param name The name of the material to create
  119738. * @param scene The scene to create the material for
  119739. * @returns The default material
  119740. */
  119741. static DefaultMaterialFactory(scene: Scene): Material;
  119742. /**
  119743. * Factory used to create the a collision coordinator.
  119744. * @returns The collision coordinator
  119745. */
  119746. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119747. /** @hidden */
  119748. _inputManager: InputManager;
  119749. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119750. cameraToUseForPointers: Nullable<Camera>;
  119751. /** @hidden */
  119752. readonly _isScene: boolean;
  119753. /** @hidden */
  119754. _blockEntityCollection: boolean;
  119755. /**
  119756. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119757. */
  119758. autoClear: boolean;
  119759. /**
  119760. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119761. */
  119762. autoClearDepthAndStencil: boolean;
  119763. /**
  119764. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119765. */
  119766. clearColor: Color4;
  119767. /**
  119768. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119769. */
  119770. ambientColor: Color3;
  119771. /**
  119772. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119773. * It should only be one of the following (if not the default embedded one):
  119774. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119775. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119776. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119777. * The material properties need to be setup according to the type of texture in use.
  119778. */
  119779. environmentBRDFTexture: BaseTexture;
  119780. /**
  119781. * Texture used in all pbr material as the reflection texture.
  119782. * As in the majority of the scene they are the same (exception for multi room and so on),
  119783. * this is easier to reference from here than from all the materials.
  119784. */
  119785. get environmentTexture(): Nullable<BaseTexture>;
  119786. /**
  119787. * Texture used in all pbr material as the reflection texture.
  119788. * As in the majority of the scene they are the same (exception for multi room and so on),
  119789. * this is easier to set here than in all the materials.
  119790. */
  119791. set environmentTexture(value: Nullable<BaseTexture>);
  119792. /** @hidden */
  119793. protected _environmentIntensity: number;
  119794. /**
  119795. * Intensity of the environment in all pbr material.
  119796. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119797. * As in the majority of the scene they are the same (exception for multi room and so on),
  119798. * this is easier to reference from here than from all the materials.
  119799. */
  119800. get environmentIntensity(): number;
  119801. /**
  119802. * Intensity of the environment in all pbr material.
  119803. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119804. * As in the majority of the scene they are the same (exception for multi room and so on),
  119805. * this is easier to set here than in all the materials.
  119806. */
  119807. set environmentIntensity(value: number);
  119808. /** @hidden */
  119809. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119810. /**
  119811. * Default image processing configuration used either in the rendering
  119812. * Forward main pass or through the imageProcessingPostProcess if present.
  119813. * As in the majority of the scene they are the same (exception for multi camera),
  119814. * this is easier to reference from here than from all the materials and post process.
  119815. *
  119816. * No setter as we it is a shared configuration, you can set the values instead.
  119817. */
  119818. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119819. private _forceWireframe;
  119820. /**
  119821. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119822. */
  119823. set forceWireframe(value: boolean);
  119824. get forceWireframe(): boolean;
  119825. private _skipFrustumClipping;
  119826. /**
  119827. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119828. */
  119829. set skipFrustumClipping(value: boolean);
  119830. get skipFrustumClipping(): boolean;
  119831. private _forcePointsCloud;
  119832. /**
  119833. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119834. */
  119835. set forcePointsCloud(value: boolean);
  119836. get forcePointsCloud(): boolean;
  119837. /**
  119838. * Gets or sets the active clipplane 1
  119839. */
  119840. clipPlane: Nullable<Plane>;
  119841. /**
  119842. * Gets or sets the active clipplane 2
  119843. */
  119844. clipPlane2: Nullable<Plane>;
  119845. /**
  119846. * Gets or sets the active clipplane 3
  119847. */
  119848. clipPlane3: Nullable<Plane>;
  119849. /**
  119850. * Gets or sets the active clipplane 4
  119851. */
  119852. clipPlane4: Nullable<Plane>;
  119853. /**
  119854. * Gets or sets the active clipplane 5
  119855. */
  119856. clipPlane5: Nullable<Plane>;
  119857. /**
  119858. * Gets or sets the active clipplane 6
  119859. */
  119860. clipPlane6: Nullable<Plane>;
  119861. /**
  119862. * Gets or sets a boolean indicating if animations are enabled
  119863. */
  119864. animationsEnabled: boolean;
  119865. private _animationPropertiesOverride;
  119866. /**
  119867. * Gets or sets the animation properties override
  119868. */
  119869. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119870. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119871. /**
  119872. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119873. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119874. */
  119875. useConstantAnimationDeltaTime: boolean;
  119876. /**
  119877. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119878. * Please note that it requires to run a ray cast through the scene on every frame
  119879. */
  119880. constantlyUpdateMeshUnderPointer: boolean;
  119881. /**
  119882. * Defines the HTML cursor to use when hovering over interactive elements
  119883. */
  119884. hoverCursor: string;
  119885. /**
  119886. * Defines the HTML default cursor to use (empty by default)
  119887. */
  119888. defaultCursor: string;
  119889. /**
  119890. * Defines whether cursors are handled by the scene.
  119891. */
  119892. doNotHandleCursors: boolean;
  119893. /**
  119894. * This is used to call preventDefault() on pointer down
  119895. * in order to block unwanted artifacts like system double clicks
  119896. */
  119897. preventDefaultOnPointerDown: boolean;
  119898. /**
  119899. * This is used to call preventDefault() on pointer up
  119900. * in order to block unwanted artifacts like system double clicks
  119901. */
  119902. preventDefaultOnPointerUp: boolean;
  119903. /**
  119904. * Gets or sets user defined metadata
  119905. */
  119906. metadata: any;
  119907. /**
  119908. * For internal use only. Please do not use.
  119909. */
  119910. reservedDataStore: any;
  119911. /**
  119912. * Gets the name of the plugin used to load this scene (null by default)
  119913. */
  119914. loadingPluginName: string;
  119915. /**
  119916. * Use this array to add regular expressions used to disable offline support for specific urls
  119917. */
  119918. disableOfflineSupportExceptionRules: RegExp[];
  119919. /**
  119920. * An event triggered when the scene is disposed.
  119921. */
  119922. onDisposeObservable: Observable<Scene>;
  119923. private _onDisposeObserver;
  119924. /** Sets a function to be executed when this scene is disposed. */
  119925. set onDispose(callback: () => void);
  119926. /**
  119927. * An event triggered before rendering the scene (right after animations and physics)
  119928. */
  119929. onBeforeRenderObservable: Observable<Scene>;
  119930. private _onBeforeRenderObserver;
  119931. /** Sets a function to be executed before rendering this scene */
  119932. set beforeRender(callback: Nullable<() => void>);
  119933. /**
  119934. * An event triggered after rendering the scene
  119935. */
  119936. onAfterRenderObservable: Observable<Scene>;
  119937. /**
  119938. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119939. */
  119940. onAfterRenderCameraObservable: Observable<Camera>;
  119941. private _onAfterRenderObserver;
  119942. /** Sets a function to be executed after rendering this scene */
  119943. set afterRender(callback: Nullable<() => void>);
  119944. /**
  119945. * An event triggered before animating the scene
  119946. */
  119947. onBeforeAnimationsObservable: Observable<Scene>;
  119948. /**
  119949. * An event triggered after animations processing
  119950. */
  119951. onAfterAnimationsObservable: Observable<Scene>;
  119952. /**
  119953. * An event triggered before draw calls are ready to be sent
  119954. */
  119955. onBeforeDrawPhaseObservable: Observable<Scene>;
  119956. /**
  119957. * An event triggered after draw calls have been sent
  119958. */
  119959. onAfterDrawPhaseObservable: Observable<Scene>;
  119960. /**
  119961. * An event triggered when the scene is ready
  119962. */
  119963. onReadyObservable: Observable<Scene>;
  119964. /**
  119965. * An event triggered before rendering a camera
  119966. */
  119967. onBeforeCameraRenderObservable: Observable<Camera>;
  119968. private _onBeforeCameraRenderObserver;
  119969. /** Sets a function to be executed before rendering a camera*/
  119970. set beforeCameraRender(callback: () => void);
  119971. /**
  119972. * An event triggered after rendering a camera
  119973. */
  119974. onAfterCameraRenderObservable: Observable<Camera>;
  119975. private _onAfterCameraRenderObserver;
  119976. /** Sets a function to be executed after rendering a camera*/
  119977. set afterCameraRender(callback: () => void);
  119978. /**
  119979. * An event triggered when active meshes evaluation is about to start
  119980. */
  119981. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119982. /**
  119983. * An event triggered when active meshes evaluation is done
  119984. */
  119985. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119986. /**
  119987. * An event triggered when particles rendering is about to start
  119988. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119989. */
  119990. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119991. /**
  119992. * An event triggered when particles rendering is done
  119993. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119994. */
  119995. onAfterParticlesRenderingObservable: Observable<Scene>;
  119996. /**
  119997. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119998. */
  119999. onDataLoadedObservable: Observable<Scene>;
  120000. /**
  120001. * An event triggered when a camera is created
  120002. */
  120003. onNewCameraAddedObservable: Observable<Camera>;
  120004. /**
  120005. * An event triggered when a camera is removed
  120006. */
  120007. onCameraRemovedObservable: Observable<Camera>;
  120008. /**
  120009. * An event triggered when a light is created
  120010. */
  120011. onNewLightAddedObservable: Observable<Light>;
  120012. /**
  120013. * An event triggered when a light is removed
  120014. */
  120015. onLightRemovedObservable: Observable<Light>;
  120016. /**
  120017. * An event triggered when a geometry is created
  120018. */
  120019. onNewGeometryAddedObservable: Observable<Geometry>;
  120020. /**
  120021. * An event triggered when a geometry is removed
  120022. */
  120023. onGeometryRemovedObservable: Observable<Geometry>;
  120024. /**
  120025. * An event triggered when a transform node is created
  120026. */
  120027. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120028. /**
  120029. * An event triggered when a transform node is removed
  120030. */
  120031. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120032. /**
  120033. * An event triggered when a mesh is created
  120034. */
  120035. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120036. /**
  120037. * An event triggered when a mesh is removed
  120038. */
  120039. onMeshRemovedObservable: Observable<AbstractMesh>;
  120040. /**
  120041. * An event triggered when a skeleton is created
  120042. */
  120043. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120044. /**
  120045. * An event triggered when a skeleton is removed
  120046. */
  120047. onSkeletonRemovedObservable: Observable<Skeleton>;
  120048. /**
  120049. * An event triggered when a material is created
  120050. */
  120051. onNewMaterialAddedObservable: Observable<Material>;
  120052. /**
  120053. * An event triggered when a material is removed
  120054. */
  120055. onMaterialRemovedObservable: Observable<Material>;
  120056. /**
  120057. * An event triggered when a texture is created
  120058. */
  120059. onNewTextureAddedObservable: Observable<BaseTexture>;
  120060. /**
  120061. * An event triggered when a texture is removed
  120062. */
  120063. onTextureRemovedObservable: Observable<BaseTexture>;
  120064. /**
  120065. * An event triggered when render targets are about to be rendered
  120066. * Can happen multiple times per frame.
  120067. */
  120068. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120069. /**
  120070. * An event triggered when render targets were rendered.
  120071. * Can happen multiple times per frame.
  120072. */
  120073. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120074. /**
  120075. * An event triggered before calculating deterministic simulation step
  120076. */
  120077. onBeforeStepObservable: Observable<Scene>;
  120078. /**
  120079. * An event triggered after calculating deterministic simulation step
  120080. */
  120081. onAfterStepObservable: Observable<Scene>;
  120082. /**
  120083. * An event triggered when the activeCamera property is updated
  120084. */
  120085. onActiveCameraChanged: Observable<Scene>;
  120086. /**
  120087. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120088. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120089. * 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)
  120090. */
  120091. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120092. /**
  120093. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120094. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120095. * 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)
  120096. */
  120097. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120098. /**
  120099. * This Observable will when a mesh has been imported into the scene.
  120100. */
  120101. onMeshImportedObservable: Observable<AbstractMesh>;
  120102. /**
  120103. * This Observable will when an animation file has been imported into the scene.
  120104. */
  120105. onAnimationFileImportedObservable: Observable<Scene>;
  120106. /**
  120107. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120108. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120109. */
  120110. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120111. /** @hidden */
  120112. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120113. /**
  120114. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120115. */
  120116. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120117. /**
  120118. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120119. */
  120120. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120121. /**
  120122. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120123. */
  120124. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120125. /** Callback called when a pointer move is detected */
  120126. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120127. /** Callback called when a pointer down is detected */
  120128. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120129. /** Callback called when a pointer up is detected */
  120130. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120131. /** Callback called when a pointer pick is detected */
  120132. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120133. /**
  120134. * 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).
  120135. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120136. */
  120137. onPrePointerObservable: Observable<PointerInfoPre>;
  120138. /**
  120139. * Observable event triggered each time an input event is received from the rendering canvas
  120140. */
  120141. onPointerObservable: Observable<PointerInfo>;
  120142. /**
  120143. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120144. */
  120145. get unTranslatedPointer(): Vector2;
  120146. /**
  120147. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120148. */
  120149. static get DragMovementThreshold(): number;
  120150. static set DragMovementThreshold(value: number);
  120151. /**
  120152. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120153. */
  120154. static get LongPressDelay(): number;
  120155. static set LongPressDelay(value: number);
  120156. /**
  120157. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120158. */
  120159. static get DoubleClickDelay(): number;
  120160. static set DoubleClickDelay(value: number);
  120161. /** If you need to check double click without raising a single click at first click, enable this flag */
  120162. static get ExclusiveDoubleClickMode(): boolean;
  120163. static set ExclusiveDoubleClickMode(value: boolean);
  120164. /** @hidden */
  120165. _mirroredCameraPosition: Nullable<Vector3>;
  120166. /**
  120167. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120168. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120169. */
  120170. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120171. /**
  120172. * Observable event triggered each time an keyboard event is received from the hosting window
  120173. */
  120174. onKeyboardObservable: Observable<KeyboardInfo>;
  120175. private _useRightHandedSystem;
  120176. /**
  120177. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120178. */
  120179. set useRightHandedSystem(value: boolean);
  120180. get useRightHandedSystem(): boolean;
  120181. private _timeAccumulator;
  120182. private _currentStepId;
  120183. private _currentInternalStep;
  120184. /**
  120185. * Sets the step Id used by deterministic lock step
  120186. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120187. * @param newStepId defines the step Id
  120188. */
  120189. setStepId(newStepId: number): void;
  120190. /**
  120191. * Gets the step Id used by deterministic lock step
  120192. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120193. * @returns the step Id
  120194. */
  120195. getStepId(): number;
  120196. /**
  120197. * Gets the internal step used by deterministic lock step
  120198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120199. * @returns the internal step
  120200. */
  120201. getInternalStep(): number;
  120202. private _fogEnabled;
  120203. /**
  120204. * Gets or sets a boolean indicating if fog is enabled on this scene
  120205. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120206. * (Default is true)
  120207. */
  120208. set fogEnabled(value: boolean);
  120209. get fogEnabled(): boolean;
  120210. private _fogMode;
  120211. /**
  120212. * Gets or sets the fog mode to use
  120213. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120214. * | mode | value |
  120215. * | --- | --- |
  120216. * | FOGMODE_NONE | 0 |
  120217. * | FOGMODE_EXP | 1 |
  120218. * | FOGMODE_EXP2 | 2 |
  120219. * | FOGMODE_LINEAR | 3 |
  120220. */
  120221. set fogMode(value: number);
  120222. get fogMode(): number;
  120223. /**
  120224. * Gets or sets the fog color to use
  120225. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120226. * (Default is Color3(0.2, 0.2, 0.3))
  120227. */
  120228. fogColor: Color3;
  120229. /**
  120230. * Gets or sets the fog density to use
  120231. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120232. * (Default is 0.1)
  120233. */
  120234. fogDensity: number;
  120235. /**
  120236. * Gets or sets the fog start distance to use
  120237. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120238. * (Default is 0)
  120239. */
  120240. fogStart: number;
  120241. /**
  120242. * Gets or sets the fog end distance to use
  120243. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120244. * (Default is 1000)
  120245. */
  120246. fogEnd: number;
  120247. /**
  120248. * Flag indicating that the frame buffer binding is handled by another component
  120249. */
  120250. prePass: boolean;
  120251. private _shadowsEnabled;
  120252. /**
  120253. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120254. */
  120255. set shadowsEnabled(value: boolean);
  120256. get shadowsEnabled(): boolean;
  120257. private _lightsEnabled;
  120258. /**
  120259. * Gets or sets a boolean indicating if lights are enabled on this scene
  120260. */
  120261. set lightsEnabled(value: boolean);
  120262. get lightsEnabled(): boolean;
  120263. /** All of the active cameras added to this scene. */
  120264. activeCameras: Camera[];
  120265. /** @hidden */
  120266. _activeCamera: Nullable<Camera>;
  120267. /** Gets or sets the current active camera */
  120268. get activeCamera(): Nullable<Camera>;
  120269. set activeCamera(value: Nullable<Camera>);
  120270. private _defaultMaterial;
  120271. /** The default material used on meshes when no material is affected */
  120272. get defaultMaterial(): Material;
  120273. /** The default material used on meshes when no material is affected */
  120274. set defaultMaterial(value: Material);
  120275. private _texturesEnabled;
  120276. /**
  120277. * Gets or sets a boolean indicating if textures are enabled on this scene
  120278. */
  120279. set texturesEnabled(value: boolean);
  120280. get texturesEnabled(): boolean;
  120281. /**
  120282. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120283. */
  120284. physicsEnabled: boolean;
  120285. /**
  120286. * Gets or sets a boolean indicating if particles are enabled on this scene
  120287. */
  120288. particlesEnabled: boolean;
  120289. /**
  120290. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120291. */
  120292. spritesEnabled: boolean;
  120293. private _skeletonsEnabled;
  120294. /**
  120295. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120296. */
  120297. set skeletonsEnabled(value: boolean);
  120298. get skeletonsEnabled(): boolean;
  120299. /**
  120300. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120301. */
  120302. lensFlaresEnabled: boolean;
  120303. /**
  120304. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120305. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120306. */
  120307. collisionsEnabled: boolean;
  120308. private _collisionCoordinator;
  120309. /** @hidden */
  120310. get collisionCoordinator(): ICollisionCoordinator;
  120311. /**
  120312. * Defines the gravity applied to this scene (used only for collisions)
  120313. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120314. */
  120315. gravity: Vector3;
  120316. /**
  120317. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120318. */
  120319. postProcessesEnabled: boolean;
  120320. /**
  120321. * Gets the current postprocess manager
  120322. */
  120323. postProcessManager: PostProcessManager;
  120324. /**
  120325. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120326. */
  120327. renderTargetsEnabled: boolean;
  120328. /**
  120329. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120330. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120331. */
  120332. dumpNextRenderTargets: boolean;
  120333. /**
  120334. * The list of user defined render targets added to the scene
  120335. */
  120336. customRenderTargets: RenderTargetTexture[];
  120337. /**
  120338. * Defines if texture loading must be delayed
  120339. * If true, textures will only be loaded when they need to be rendered
  120340. */
  120341. useDelayedTextureLoading: boolean;
  120342. /**
  120343. * Gets the list of meshes imported to the scene through SceneLoader
  120344. */
  120345. importedMeshesFiles: String[];
  120346. /**
  120347. * Gets or sets a boolean indicating if probes are enabled on this scene
  120348. */
  120349. probesEnabled: boolean;
  120350. /**
  120351. * Gets or sets the current offline provider to use to store scene data
  120352. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120353. */
  120354. offlineProvider: IOfflineProvider;
  120355. /**
  120356. * Gets or sets the action manager associated with the scene
  120357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120358. */
  120359. actionManager: AbstractActionManager;
  120360. private _meshesForIntersections;
  120361. /**
  120362. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120363. */
  120364. proceduralTexturesEnabled: boolean;
  120365. private _engine;
  120366. private _totalVertices;
  120367. /** @hidden */
  120368. _activeIndices: PerfCounter;
  120369. /** @hidden */
  120370. _activeParticles: PerfCounter;
  120371. /** @hidden */
  120372. _activeBones: PerfCounter;
  120373. private _animationRatio;
  120374. /** @hidden */
  120375. _animationTimeLast: number;
  120376. /** @hidden */
  120377. _animationTime: number;
  120378. /**
  120379. * Gets or sets a general scale for animation speed
  120380. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120381. */
  120382. animationTimeScale: number;
  120383. /** @hidden */
  120384. _cachedMaterial: Nullable<Material>;
  120385. /** @hidden */
  120386. _cachedEffect: Nullable<Effect>;
  120387. /** @hidden */
  120388. _cachedVisibility: Nullable<number>;
  120389. private _renderId;
  120390. private _frameId;
  120391. private _executeWhenReadyTimeoutId;
  120392. private _intermediateRendering;
  120393. private _viewUpdateFlag;
  120394. private _projectionUpdateFlag;
  120395. /** @hidden */
  120396. _toBeDisposed: Nullable<IDisposable>[];
  120397. private _activeRequests;
  120398. /** @hidden */
  120399. _pendingData: any[];
  120400. private _isDisposed;
  120401. /**
  120402. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120403. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120404. */
  120405. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120406. private _activeMeshes;
  120407. private _processedMaterials;
  120408. private _renderTargets;
  120409. /** @hidden */
  120410. _activeParticleSystems: SmartArray<IParticleSystem>;
  120411. private _activeSkeletons;
  120412. private _softwareSkinnedMeshes;
  120413. private _renderingManager;
  120414. /** @hidden */
  120415. _activeAnimatables: Animatable[];
  120416. private _transformMatrix;
  120417. private _sceneUbo;
  120418. /** @hidden */
  120419. _viewMatrix: Matrix;
  120420. private _projectionMatrix;
  120421. /** @hidden */
  120422. _forcedViewPosition: Nullable<Vector3>;
  120423. /** @hidden */
  120424. _frustumPlanes: Plane[];
  120425. /**
  120426. * Gets the list of frustum planes (built from the active camera)
  120427. */
  120428. get frustumPlanes(): Plane[];
  120429. /**
  120430. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120431. * This is useful if there are more lights that the maximum simulteanous authorized
  120432. */
  120433. requireLightSorting: boolean;
  120434. /** @hidden */
  120435. readonly useMaterialMeshMap: boolean;
  120436. /** @hidden */
  120437. readonly useClonedMeshMap: boolean;
  120438. private _externalData;
  120439. private _uid;
  120440. /**
  120441. * @hidden
  120442. * Backing store of defined scene components.
  120443. */
  120444. _components: ISceneComponent[];
  120445. /**
  120446. * @hidden
  120447. * Backing store of defined scene components.
  120448. */
  120449. _serializableComponents: ISceneSerializableComponent[];
  120450. /**
  120451. * List of components to register on the next registration step.
  120452. */
  120453. private _transientComponents;
  120454. /**
  120455. * Registers the transient components if needed.
  120456. */
  120457. private _registerTransientComponents;
  120458. /**
  120459. * @hidden
  120460. * Add a component to the scene.
  120461. * Note that the ccomponent could be registered on th next frame if this is called after
  120462. * the register component stage.
  120463. * @param component Defines the component to add to the scene
  120464. */
  120465. _addComponent(component: ISceneComponent): void;
  120466. /**
  120467. * @hidden
  120468. * Gets a component from the scene.
  120469. * @param name defines the name of the component to retrieve
  120470. * @returns the component or null if not present
  120471. */
  120472. _getComponent(name: string): Nullable<ISceneComponent>;
  120473. /**
  120474. * @hidden
  120475. * Defines the actions happening before camera updates.
  120476. */
  120477. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120478. /**
  120479. * @hidden
  120480. * Defines the actions happening before clear the canvas.
  120481. */
  120482. _beforeClearStage: Stage<SimpleStageAction>;
  120483. /**
  120484. * @hidden
  120485. * Defines the actions when collecting render targets for the frame.
  120486. */
  120487. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120488. /**
  120489. * @hidden
  120490. * Defines the actions happening for one camera in the frame.
  120491. */
  120492. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120493. /**
  120494. * @hidden
  120495. * Defines the actions happening during the per mesh ready checks.
  120496. */
  120497. _isReadyForMeshStage: Stage<MeshStageAction>;
  120498. /**
  120499. * @hidden
  120500. * Defines the actions happening before evaluate active mesh checks.
  120501. */
  120502. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120503. /**
  120504. * @hidden
  120505. * Defines the actions happening during the evaluate sub mesh checks.
  120506. */
  120507. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120508. /**
  120509. * @hidden
  120510. * Defines the actions happening during the active mesh stage.
  120511. */
  120512. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120513. /**
  120514. * @hidden
  120515. * Defines the actions happening during the per camera render target step.
  120516. */
  120517. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120518. /**
  120519. * @hidden
  120520. * Defines the actions happening just before the active camera is drawing.
  120521. */
  120522. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120523. /**
  120524. * @hidden
  120525. * Defines the actions happening just before a render target is drawing.
  120526. */
  120527. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120528. /**
  120529. * @hidden
  120530. * Defines the actions happening just before a rendering group is drawing.
  120531. */
  120532. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120533. /**
  120534. * @hidden
  120535. * Defines the actions happening just before a mesh is drawing.
  120536. */
  120537. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120538. /**
  120539. * @hidden
  120540. * Defines the actions happening just after a mesh has been drawn.
  120541. */
  120542. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120543. /**
  120544. * @hidden
  120545. * Defines the actions happening just after a rendering group has been drawn.
  120546. */
  120547. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120548. /**
  120549. * @hidden
  120550. * Defines the actions happening just after the active camera has been drawn.
  120551. */
  120552. _afterCameraDrawStage: Stage<CameraStageAction>;
  120553. /**
  120554. * @hidden
  120555. * Defines the actions happening just after a render target has been drawn.
  120556. */
  120557. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120558. /**
  120559. * @hidden
  120560. * Defines the actions happening just after rendering all cameras and computing intersections.
  120561. */
  120562. _afterRenderStage: Stage<SimpleStageAction>;
  120563. /**
  120564. * @hidden
  120565. * Defines the actions happening when a pointer move event happens.
  120566. */
  120567. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120568. /**
  120569. * @hidden
  120570. * Defines the actions happening when a pointer down event happens.
  120571. */
  120572. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120573. /**
  120574. * @hidden
  120575. * Defines the actions happening when a pointer up event happens.
  120576. */
  120577. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120578. /**
  120579. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120580. */
  120581. private geometriesByUniqueId;
  120582. /**
  120583. * Creates a new Scene
  120584. * @param engine defines the engine to use to render this scene
  120585. * @param options defines the scene options
  120586. */
  120587. constructor(engine: Engine, options?: SceneOptions);
  120588. /**
  120589. * Gets a string identifying the name of the class
  120590. * @returns "Scene" string
  120591. */
  120592. getClassName(): string;
  120593. private _defaultMeshCandidates;
  120594. /**
  120595. * @hidden
  120596. */
  120597. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120598. private _defaultSubMeshCandidates;
  120599. /**
  120600. * @hidden
  120601. */
  120602. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120603. /**
  120604. * Sets the default candidate providers for the scene.
  120605. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120606. * and getCollidingSubMeshCandidates to their default function
  120607. */
  120608. setDefaultCandidateProviders(): void;
  120609. /**
  120610. * Gets the mesh that is currently under the pointer
  120611. */
  120612. get meshUnderPointer(): Nullable<AbstractMesh>;
  120613. /**
  120614. * Gets or sets the current on-screen X position of the pointer
  120615. */
  120616. get pointerX(): number;
  120617. set pointerX(value: number);
  120618. /**
  120619. * Gets or sets the current on-screen Y position of the pointer
  120620. */
  120621. get pointerY(): number;
  120622. set pointerY(value: number);
  120623. /**
  120624. * Gets the cached material (ie. the latest rendered one)
  120625. * @returns the cached material
  120626. */
  120627. getCachedMaterial(): Nullable<Material>;
  120628. /**
  120629. * Gets the cached effect (ie. the latest rendered one)
  120630. * @returns the cached effect
  120631. */
  120632. getCachedEffect(): Nullable<Effect>;
  120633. /**
  120634. * Gets the cached visibility state (ie. the latest rendered one)
  120635. * @returns the cached visibility state
  120636. */
  120637. getCachedVisibility(): Nullable<number>;
  120638. /**
  120639. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120640. * @param material defines the current material
  120641. * @param effect defines the current effect
  120642. * @param visibility defines the current visibility state
  120643. * @returns true if one parameter is not cached
  120644. */
  120645. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120646. /**
  120647. * Gets the engine associated with the scene
  120648. * @returns an Engine
  120649. */
  120650. getEngine(): Engine;
  120651. /**
  120652. * Gets the total number of vertices rendered per frame
  120653. * @returns the total number of vertices rendered per frame
  120654. */
  120655. getTotalVertices(): number;
  120656. /**
  120657. * Gets the performance counter for total vertices
  120658. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120659. */
  120660. get totalVerticesPerfCounter(): PerfCounter;
  120661. /**
  120662. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120663. * @returns the total number of active indices rendered per frame
  120664. */
  120665. getActiveIndices(): number;
  120666. /**
  120667. * Gets the performance counter for active indices
  120668. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120669. */
  120670. get totalActiveIndicesPerfCounter(): PerfCounter;
  120671. /**
  120672. * Gets the total number of active particles rendered per frame
  120673. * @returns the total number of active particles rendered per frame
  120674. */
  120675. getActiveParticles(): number;
  120676. /**
  120677. * Gets the performance counter for active particles
  120678. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120679. */
  120680. get activeParticlesPerfCounter(): PerfCounter;
  120681. /**
  120682. * Gets the total number of active bones rendered per frame
  120683. * @returns the total number of active bones rendered per frame
  120684. */
  120685. getActiveBones(): number;
  120686. /**
  120687. * Gets the performance counter for active bones
  120688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120689. */
  120690. get activeBonesPerfCounter(): PerfCounter;
  120691. /**
  120692. * Gets the array of active meshes
  120693. * @returns an array of AbstractMesh
  120694. */
  120695. getActiveMeshes(): SmartArray<AbstractMesh>;
  120696. /**
  120697. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120698. * @returns a number
  120699. */
  120700. getAnimationRatio(): number;
  120701. /**
  120702. * Gets an unique Id for the current render phase
  120703. * @returns a number
  120704. */
  120705. getRenderId(): number;
  120706. /**
  120707. * Gets an unique Id for the current frame
  120708. * @returns a number
  120709. */
  120710. getFrameId(): number;
  120711. /** Call this function if you want to manually increment the render Id*/
  120712. incrementRenderId(): void;
  120713. private _createUbo;
  120714. /**
  120715. * Use this method to simulate a pointer move on a mesh
  120716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120719. * @returns the current scene
  120720. */
  120721. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120722. /**
  120723. * Use this method to simulate a pointer down on a mesh
  120724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120727. * @returns the current scene
  120728. */
  120729. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120730. /**
  120731. * Use this method to simulate a pointer up on a mesh
  120732. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120733. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120734. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120735. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120736. * @returns the current scene
  120737. */
  120738. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120739. /**
  120740. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120741. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120742. * @returns true if the pointer was captured
  120743. */
  120744. isPointerCaptured(pointerId?: number): boolean;
  120745. /**
  120746. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120747. * @param attachUp defines if you want to attach events to pointerup
  120748. * @param attachDown defines if you want to attach events to pointerdown
  120749. * @param attachMove defines if you want to attach events to pointermove
  120750. */
  120751. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120752. /** Detaches all event handlers*/
  120753. detachControl(): void;
  120754. /**
  120755. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120756. * Delay loaded resources are not taking in account
  120757. * @return true if all required resources are ready
  120758. */
  120759. isReady(): boolean;
  120760. /** Resets all cached information relative to material (including effect and visibility) */
  120761. resetCachedMaterial(): void;
  120762. /**
  120763. * Registers a function to be called before every frame render
  120764. * @param func defines the function to register
  120765. */
  120766. registerBeforeRender(func: () => void): void;
  120767. /**
  120768. * Unregisters a function called before every frame render
  120769. * @param func defines the function to unregister
  120770. */
  120771. unregisterBeforeRender(func: () => void): void;
  120772. /**
  120773. * Registers a function to be called after every frame render
  120774. * @param func defines the function to register
  120775. */
  120776. registerAfterRender(func: () => void): void;
  120777. /**
  120778. * Unregisters a function called after every frame render
  120779. * @param func defines the function to unregister
  120780. */
  120781. unregisterAfterRender(func: () => void): void;
  120782. private _executeOnceBeforeRender;
  120783. /**
  120784. * The provided function will run before render once and will be disposed afterwards.
  120785. * A timeout delay can be provided so that the function will be executed in N ms.
  120786. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120787. * @param func The function to be executed.
  120788. * @param timeout optional delay in ms
  120789. */
  120790. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120791. /** @hidden */
  120792. _addPendingData(data: any): void;
  120793. /** @hidden */
  120794. _removePendingData(data: any): void;
  120795. /**
  120796. * Returns the number of items waiting to be loaded
  120797. * @returns the number of items waiting to be loaded
  120798. */
  120799. getWaitingItemsCount(): number;
  120800. /**
  120801. * Returns a boolean indicating if the scene is still loading data
  120802. */
  120803. get isLoading(): boolean;
  120804. /**
  120805. * Registers a function to be executed when the scene is ready
  120806. * @param {Function} func - the function to be executed
  120807. */
  120808. executeWhenReady(func: () => void): void;
  120809. /**
  120810. * Returns a promise that resolves when the scene is ready
  120811. * @returns A promise that resolves when the scene is ready
  120812. */
  120813. whenReadyAsync(): Promise<void>;
  120814. /** @hidden */
  120815. _checkIsReady(): void;
  120816. /**
  120817. * Gets all animatable attached to the scene
  120818. */
  120819. get animatables(): Animatable[];
  120820. /**
  120821. * Resets the last animation time frame.
  120822. * Useful to override when animations start running when loading a scene for the first time.
  120823. */
  120824. resetLastAnimationTimeFrame(): void;
  120825. /**
  120826. * Gets the current view matrix
  120827. * @returns a Matrix
  120828. */
  120829. getViewMatrix(): Matrix;
  120830. /**
  120831. * Gets the current projection matrix
  120832. * @returns a Matrix
  120833. */
  120834. getProjectionMatrix(): Matrix;
  120835. /**
  120836. * Gets the current transform matrix
  120837. * @returns a Matrix made of View * Projection
  120838. */
  120839. getTransformMatrix(): Matrix;
  120840. /**
  120841. * Sets the current transform matrix
  120842. * @param viewL defines the View matrix to use
  120843. * @param projectionL defines the Projection matrix to use
  120844. * @param viewR defines the right View matrix to use (if provided)
  120845. * @param projectionR defines the right Projection matrix to use (if provided)
  120846. */
  120847. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120848. /**
  120849. * Gets the uniform buffer used to store scene data
  120850. * @returns a UniformBuffer
  120851. */
  120852. getSceneUniformBuffer(): UniformBuffer;
  120853. /**
  120854. * Gets an unique (relatively to the current scene) Id
  120855. * @returns an unique number for the scene
  120856. */
  120857. getUniqueId(): number;
  120858. /**
  120859. * Add a mesh to the list of scene's meshes
  120860. * @param newMesh defines the mesh to add
  120861. * @param recursive if all child meshes should also be added to the scene
  120862. */
  120863. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120864. /**
  120865. * Remove a mesh for the list of scene's meshes
  120866. * @param toRemove defines the mesh to remove
  120867. * @param recursive if all child meshes should also be removed from the scene
  120868. * @returns the index where the mesh was in the mesh list
  120869. */
  120870. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120871. /**
  120872. * Add a transform node to the list of scene's transform nodes
  120873. * @param newTransformNode defines the transform node to add
  120874. */
  120875. addTransformNode(newTransformNode: TransformNode): void;
  120876. /**
  120877. * Remove a transform node for the list of scene's transform nodes
  120878. * @param toRemove defines the transform node to remove
  120879. * @returns the index where the transform node was in the transform node list
  120880. */
  120881. removeTransformNode(toRemove: TransformNode): number;
  120882. /**
  120883. * Remove a skeleton for the list of scene's skeletons
  120884. * @param toRemove defines the skeleton to remove
  120885. * @returns the index where the skeleton was in the skeleton list
  120886. */
  120887. removeSkeleton(toRemove: Skeleton): number;
  120888. /**
  120889. * Remove a morph target for the list of scene's morph targets
  120890. * @param toRemove defines the morph target to remove
  120891. * @returns the index where the morph target was in the morph target list
  120892. */
  120893. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120894. /**
  120895. * Remove a light for the list of scene's lights
  120896. * @param toRemove defines the light to remove
  120897. * @returns the index where the light was in the light list
  120898. */
  120899. removeLight(toRemove: Light): number;
  120900. /**
  120901. * Remove a camera for the list of scene's cameras
  120902. * @param toRemove defines the camera to remove
  120903. * @returns the index where the camera was in the camera list
  120904. */
  120905. removeCamera(toRemove: Camera): number;
  120906. /**
  120907. * Remove a particle system for the list of scene's particle systems
  120908. * @param toRemove defines the particle system to remove
  120909. * @returns the index where the particle system was in the particle system list
  120910. */
  120911. removeParticleSystem(toRemove: IParticleSystem): number;
  120912. /**
  120913. * Remove a animation for the list of scene's animations
  120914. * @param toRemove defines the animation to remove
  120915. * @returns the index where the animation was in the animation list
  120916. */
  120917. removeAnimation(toRemove: Animation): number;
  120918. /**
  120919. * Will stop the animation of the given target
  120920. * @param target - the target
  120921. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120922. * @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)
  120923. */
  120924. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120925. /**
  120926. * Removes the given animation group from this scene.
  120927. * @param toRemove The animation group to remove
  120928. * @returns The index of the removed animation group
  120929. */
  120930. removeAnimationGroup(toRemove: AnimationGroup): number;
  120931. /**
  120932. * Removes the given multi-material from this scene.
  120933. * @param toRemove The multi-material to remove
  120934. * @returns The index of the removed multi-material
  120935. */
  120936. removeMultiMaterial(toRemove: MultiMaterial): number;
  120937. /**
  120938. * Removes the given material from this scene.
  120939. * @param toRemove The material to remove
  120940. * @returns The index of the removed material
  120941. */
  120942. removeMaterial(toRemove: Material): number;
  120943. /**
  120944. * Removes the given action manager from this scene.
  120945. * @param toRemove The action manager to remove
  120946. * @returns The index of the removed action manager
  120947. */
  120948. removeActionManager(toRemove: AbstractActionManager): number;
  120949. /**
  120950. * Removes the given texture from this scene.
  120951. * @param toRemove The texture to remove
  120952. * @returns The index of the removed texture
  120953. */
  120954. removeTexture(toRemove: BaseTexture): number;
  120955. /**
  120956. * Adds the given light to this scene
  120957. * @param newLight The light to add
  120958. */
  120959. addLight(newLight: Light): void;
  120960. /**
  120961. * Sorts the list list based on light priorities
  120962. */
  120963. sortLightsByPriority(): void;
  120964. /**
  120965. * Adds the given camera to this scene
  120966. * @param newCamera The camera to add
  120967. */
  120968. addCamera(newCamera: Camera): void;
  120969. /**
  120970. * Adds the given skeleton to this scene
  120971. * @param newSkeleton The skeleton to add
  120972. */
  120973. addSkeleton(newSkeleton: Skeleton): void;
  120974. /**
  120975. * Adds the given particle system to this scene
  120976. * @param newParticleSystem The particle system to add
  120977. */
  120978. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120979. /**
  120980. * Adds the given animation to this scene
  120981. * @param newAnimation The animation to add
  120982. */
  120983. addAnimation(newAnimation: Animation): void;
  120984. /**
  120985. * Adds the given animation group to this scene.
  120986. * @param newAnimationGroup The animation group to add
  120987. */
  120988. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120989. /**
  120990. * Adds the given multi-material to this scene
  120991. * @param newMultiMaterial The multi-material to add
  120992. */
  120993. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120994. /**
  120995. * Adds the given material to this scene
  120996. * @param newMaterial The material to add
  120997. */
  120998. addMaterial(newMaterial: Material): void;
  120999. /**
  121000. * Adds the given morph target to this scene
  121001. * @param newMorphTargetManager The morph target to add
  121002. */
  121003. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121004. /**
  121005. * Adds the given geometry to this scene
  121006. * @param newGeometry The geometry to add
  121007. */
  121008. addGeometry(newGeometry: Geometry): void;
  121009. /**
  121010. * Adds the given action manager to this scene
  121011. * @param newActionManager The action manager to add
  121012. */
  121013. addActionManager(newActionManager: AbstractActionManager): void;
  121014. /**
  121015. * Adds the given texture to this scene.
  121016. * @param newTexture The texture to add
  121017. */
  121018. addTexture(newTexture: BaseTexture): void;
  121019. /**
  121020. * Switch active camera
  121021. * @param newCamera defines the new active camera
  121022. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121023. */
  121024. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121025. /**
  121026. * sets the active camera of the scene using its ID
  121027. * @param id defines the camera's ID
  121028. * @return the new active camera or null if none found.
  121029. */
  121030. setActiveCameraByID(id: string): Nullable<Camera>;
  121031. /**
  121032. * sets the active camera of the scene using its name
  121033. * @param name defines the camera's name
  121034. * @returns the new active camera or null if none found.
  121035. */
  121036. setActiveCameraByName(name: string): Nullable<Camera>;
  121037. /**
  121038. * get an animation group using its name
  121039. * @param name defines the material's name
  121040. * @return the animation group or null if none found.
  121041. */
  121042. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121043. /**
  121044. * Get a material using its unique id
  121045. * @param uniqueId defines the material's unique id
  121046. * @return the material or null if none found.
  121047. */
  121048. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121049. /**
  121050. * get a material using its id
  121051. * @param id defines the material's ID
  121052. * @return the material or null if none found.
  121053. */
  121054. getMaterialByID(id: string): Nullable<Material>;
  121055. /**
  121056. * Gets a the last added material using a given id
  121057. * @param id defines the material's ID
  121058. * @return the last material with the given id or null if none found.
  121059. */
  121060. getLastMaterialByID(id: string): Nullable<Material>;
  121061. /**
  121062. * Gets a material using its name
  121063. * @param name defines the material's name
  121064. * @return the material or null if none found.
  121065. */
  121066. getMaterialByName(name: string): Nullable<Material>;
  121067. /**
  121068. * Get a texture using its unique id
  121069. * @param uniqueId defines the texture's unique id
  121070. * @return the texture or null if none found.
  121071. */
  121072. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121073. /**
  121074. * Gets a camera using its id
  121075. * @param id defines the id to look for
  121076. * @returns the camera or null if not found
  121077. */
  121078. getCameraByID(id: string): Nullable<Camera>;
  121079. /**
  121080. * Gets a camera using its unique id
  121081. * @param uniqueId defines the unique id to look for
  121082. * @returns the camera or null if not found
  121083. */
  121084. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121085. /**
  121086. * Gets a camera using its name
  121087. * @param name defines the camera's name
  121088. * @return the camera or null if none found.
  121089. */
  121090. getCameraByName(name: string): Nullable<Camera>;
  121091. /**
  121092. * Gets a bone using its id
  121093. * @param id defines the bone's id
  121094. * @return the bone or null if not found
  121095. */
  121096. getBoneByID(id: string): Nullable<Bone>;
  121097. /**
  121098. * Gets a bone using its id
  121099. * @param name defines the bone's name
  121100. * @return the bone or null if not found
  121101. */
  121102. getBoneByName(name: string): Nullable<Bone>;
  121103. /**
  121104. * Gets a light node using its name
  121105. * @param name defines the the light's name
  121106. * @return the light or null if none found.
  121107. */
  121108. getLightByName(name: string): Nullable<Light>;
  121109. /**
  121110. * Gets a light node using its id
  121111. * @param id defines the light's id
  121112. * @return the light or null if none found.
  121113. */
  121114. getLightByID(id: string): Nullable<Light>;
  121115. /**
  121116. * Gets a light node using its scene-generated unique ID
  121117. * @param uniqueId defines the light's unique id
  121118. * @return the light or null if none found.
  121119. */
  121120. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121121. /**
  121122. * Gets a particle system by id
  121123. * @param id defines the particle system id
  121124. * @return the corresponding system or null if none found
  121125. */
  121126. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121127. /**
  121128. * Gets a geometry using its ID
  121129. * @param id defines the geometry's id
  121130. * @return the geometry or null if none found.
  121131. */
  121132. getGeometryByID(id: string): Nullable<Geometry>;
  121133. private _getGeometryByUniqueID;
  121134. /**
  121135. * Add a new geometry to this scene
  121136. * @param geometry defines the geometry to be added to the scene.
  121137. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121138. * @return a boolean defining if the geometry was added or not
  121139. */
  121140. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121141. /**
  121142. * Removes an existing geometry
  121143. * @param geometry defines the geometry to be removed from the scene
  121144. * @return a boolean defining if the geometry was removed or not
  121145. */
  121146. removeGeometry(geometry: Geometry): boolean;
  121147. /**
  121148. * Gets the list of geometries attached to the scene
  121149. * @returns an array of Geometry
  121150. */
  121151. getGeometries(): Geometry[];
  121152. /**
  121153. * Gets the first added mesh found of a given ID
  121154. * @param id defines the id to search for
  121155. * @return the mesh found or null if not found at all
  121156. */
  121157. getMeshByID(id: string): Nullable<AbstractMesh>;
  121158. /**
  121159. * Gets a list of meshes using their id
  121160. * @param id defines the id to search for
  121161. * @returns a list of meshes
  121162. */
  121163. getMeshesByID(id: string): Array<AbstractMesh>;
  121164. /**
  121165. * Gets the first added transform node found of a given ID
  121166. * @param id defines the id to search for
  121167. * @return the found transform node or null if not found at all.
  121168. */
  121169. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121170. /**
  121171. * Gets a transform node with its auto-generated unique id
  121172. * @param uniqueId efines the unique id to search for
  121173. * @return the found transform node or null if not found at all.
  121174. */
  121175. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121176. /**
  121177. * Gets a list of transform nodes using their id
  121178. * @param id defines the id to search for
  121179. * @returns a list of transform nodes
  121180. */
  121181. getTransformNodesByID(id: string): Array<TransformNode>;
  121182. /**
  121183. * Gets a mesh with its auto-generated unique id
  121184. * @param uniqueId defines the unique id to search for
  121185. * @return the found mesh or null if not found at all.
  121186. */
  121187. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121188. /**
  121189. * Gets a the last added mesh using a given id
  121190. * @param id defines the id to search for
  121191. * @return the found mesh or null if not found at all.
  121192. */
  121193. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121194. /**
  121195. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121196. * @param id defines the id to search for
  121197. * @return the found node or null if not found at all
  121198. */
  121199. getLastEntryByID(id: string): Nullable<Node>;
  121200. /**
  121201. * Gets a node (Mesh, Camera, Light) using a given id
  121202. * @param id defines the id to search for
  121203. * @return the found node or null if not found at all
  121204. */
  121205. getNodeByID(id: string): Nullable<Node>;
  121206. /**
  121207. * Gets a node (Mesh, Camera, Light) using a given name
  121208. * @param name defines the name to search for
  121209. * @return the found node or null if not found at all.
  121210. */
  121211. getNodeByName(name: string): Nullable<Node>;
  121212. /**
  121213. * Gets a mesh using a given name
  121214. * @param name defines the name to search for
  121215. * @return the found mesh or null if not found at all.
  121216. */
  121217. getMeshByName(name: string): Nullable<AbstractMesh>;
  121218. /**
  121219. * Gets a transform node using a given name
  121220. * @param name defines the name to search for
  121221. * @return the found transform node or null if not found at all.
  121222. */
  121223. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121224. /**
  121225. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121226. * @param id defines the id to search for
  121227. * @return the found skeleton or null if not found at all.
  121228. */
  121229. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121230. /**
  121231. * Gets a skeleton using a given auto generated unique id
  121232. * @param uniqueId defines the unique id to search for
  121233. * @return the found skeleton or null if not found at all.
  121234. */
  121235. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121236. /**
  121237. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121238. * @param id defines the id to search for
  121239. * @return the found skeleton or null if not found at all.
  121240. */
  121241. getSkeletonById(id: string): Nullable<Skeleton>;
  121242. /**
  121243. * Gets a skeleton using a given name
  121244. * @param name defines the name to search for
  121245. * @return the found skeleton or null if not found at all.
  121246. */
  121247. getSkeletonByName(name: string): Nullable<Skeleton>;
  121248. /**
  121249. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121250. * @param id defines the id to search for
  121251. * @return the found morph target manager or null if not found at all.
  121252. */
  121253. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121254. /**
  121255. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121256. * @param id defines the id to search for
  121257. * @return the found morph target or null if not found at all.
  121258. */
  121259. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121260. /**
  121261. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121262. * @param name defines the name to search for
  121263. * @return the found morph target or null if not found at all.
  121264. */
  121265. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121266. /**
  121267. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121268. * @param name defines the name to search for
  121269. * @return the found post process or null if not found at all.
  121270. */
  121271. getPostProcessByName(name: string): Nullable<PostProcess>;
  121272. /**
  121273. * Gets a boolean indicating if the given mesh is active
  121274. * @param mesh defines the mesh to look for
  121275. * @returns true if the mesh is in the active list
  121276. */
  121277. isActiveMesh(mesh: AbstractMesh): boolean;
  121278. /**
  121279. * Return a unique id as a string which can serve as an identifier for the scene
  121280. */
  121281. get uid(): string;
  121282. /**
  121283. * Add an externaly attached data from its key.
  121284. * This method call will fail and return false, if such key already exists.
  121285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121286. * @param key the unique key that identifies the data
  121287. * @param data the data object to associate to the key for this Engine instance
  121288. * @return true if no such key were already present and the data was added successfully, false otherwise
  121289. */
  121290. addExternalData<T>(key: string, data: T): boolean;
  121291. /**
  121292. * Get an externaly attached data from its key
  121293. * @param key the unique key that identifies the data
  121294. * @return the associated data, if present (can be null), or undefined if not present
  121295. */
  121296. getExternalData<T>(key: string): Nullable<T>;
  121297. /**
  121298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121299. * @param key the unique key that identifies the data
  121300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121301. * @return the associated data, can be null if the factory returned null.
  121302. */
  121303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121304. /**
  121305. * Remove an externaly attached data from the Engine instance
  121306. * @param key the unique key that identifies the data
  121307. * @return true if the data was successfully removed, false if it doesn't exist
  121308. */
  121309. removeExternalData(key: string): boolean;
  121310. private _evaluateSubMesh;
  121311. /**
  121312. * Clear the processed materials smart array preventing retention point in material dispose.
  121313. */
  121314. freeProcessedMaterials(): void;
  121315. private _preventFreeActiveMeshesAndRenderingGroups;
  121316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121318. * when disposing several meshes in a row or a hierarchy of meshes.
  121319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121320. */
  121321. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121322. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121323. /**
  121324. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121325. */
  121326. freeActiveMeshes(): void;
  121327. /**
  121328. * Clear the info related to rendering groups preventing retention points during dispose.
  121329. */
  121330. freeRenderingGroups(): void;
  121331. /** @hidden */
  121332. _isInIntermediateRendering(): boolean;
  121333. /**
  121334. * Lambda returning the list of potentially active meshes.
  121335. */
  121336. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121337. /**
  121338. * Lambda returning the list of potentially active sub meshes.
  121339. */
  121340. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121341. /**
  121342. * Lambda returning the list of potentially intersecting sub meshes.
  121343. */
  121344. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121345. /**
  121346. * Lambda returning the list of potentially colliding sub meshes.
  121347. */
  121348. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121349. private _activeMeshesFrozen;
  121350. private _skipEvaluateActiveMeshesCompletely;
  121351. /**
  121352. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121353. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121354. * @returns the current scene
  121355. */
  121356. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121357. /**
  121358. * Use this function to restart evaluating active meshes on every frame
  121359. * @returns the current scene
  121360. */
  121361. unfreezeActiveMeshes(): Scene;
  121362. private _evaluateActiveMeshes;
  121363. private _activeMesh;
  121364. /**
  121365. * Update the transform matrix to update from the current active camera
  121366. * @param force defines a boolean used to force the update even if cache is up to date
  121367. */
  121368. updateTransformMatrix(force?: boolean): void;
  121369. private _bindFrameBuffer;
  121370. /** @hidden */
  121371. _allowPostProcessClearColor: boolean;
  121372. /** @hidden */
  121373. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121374. private _processSubCameras;
  121375. private _checkIntersections;
  121376. /** @hidden */
  121377. _advancePhysicsEngineStep(step: number): void;
  121378. /**
  121379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121380. */
  121381. getDeterministicFrameTime: () => number;
  121382. /** @hidden */
  121383. _animate(): void;
  121384. /** Execute all animations (for a frame) */
  121385. animate(): void;
  121386. /**
  121387. * Render the scene
  121388. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121389. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121390. */
  121391. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121392. /**
  121393. * Freeze all materials
  121394. * A frozen material will not be updatable but should be faster to render
  121395. */
  121396. freezeMaterials(): void;
  121397. /**
  121398. * Unfreeze all materials
  121399. * A frozen material will not be updatable but should be faster to render
  121400. */
  121401. unfreezeMaterials(): void;
  121402. /**
  121403. * Releases all held ressources
  121404. */
  121405. dispose(): void;
  121406. /**
  121407. * Gets if the scene is already disposed
  121408. */
  121409. get isDisposed(): boolean;
  121410. /**
  121411. * Call this function to reduce memory footprint of the scene.
  121412. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121413. */
  121414. clearCachedVertexData(): void;
  121415. /**
  121416. * This function will remove the local cached buffer data from texture.
  121417. * It will save memory but will prevent the texture from being rebuilt
  121418. */
  121419. cleanCachedTextureBuffer(): void;
  121420. /**
  121421. * Get the world extend vectors with an optional filter
  121422. *
  121423. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121424. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121425. */
  121426. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121427. min: Vector3;
  121428. max: Vector3;
  121429. };
  121430. /**
  121431. * Creates a ray that can be used to pick in the scene
  121432. * @param x defines the x coordinate of the origin (on-screen)
  121433. * @param y defines the y coordinate of the origin (on-screen)
  121434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121435. * @param camera defines the camera to use for the picking
  121436. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121437. * @returns a Ray
  121438. */
  121439. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121440. /**
  121441. * Creates a ray that can be used to pick in the scene
  121442. * @param x defines the x coordinate of the origin (on-screen)
  121443. * @param y defines the y coordinate of the origin (on-screen)
  121444. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121445. * @param result defines the ray where to store the picking ray
  121446. * @param camera defines the camera to use for the picking
  121447. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121448. * @returns the current scene
  121449. */
  121450. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121451. /**
  121452. * Creates a ray that can be used to pick in the scene
  121453. * @param x defines the x coordinate of the origin (on-screen)
  121454. * @param y defines the y coordinate of the origin (on-screen)
  121455. * @param camera defines the camera to use for the picking
  121456. * @returns a Ray
  121457. */
  121458. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121459. /**
  121460. * Creates a ray that can be used to pick in the scene
  121461. * @param x defines the x coordinate of the origin (on-screen)
  121462. * @param y defines the y coordinate of the origin (on-screen)
  121463. * @param result defines the ray where to store the picking ray
  121464. * @param camera defines the camera to use for the picking
  121465. * @returns the current scene
  121466. */
  121467. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121468. /** Launch a ray to try to pick a mesh in the scene
  121469. * @param x position on screen
  121470. * @param y position on screen
  121471. * @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
  121472. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121473. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121475. * @returns a PickingInfo
  121476. */
  121477. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121478. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121479. * @param x position on screen
  121480. * @param y position on screen
  121481. * @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
  121482. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121483. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121484. * @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)
  121485. */
  121486. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121487. /** Use the given ray to pick a mesh in the scene
  121488. * @param ray The ray to use to pick meshes
  121489. * @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
  121490. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121492. * @returns a PickingInfo
  121493. */
  121494. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121495. /**
  121496. * Launch a ray to try to pick a mesh in the scene
  121497. * @param x X position on screen
  121498. * @param y Y position on screen
  121499. * @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
  121500. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121502. * @returns an array of PickingInfo
  121503. */
  121504. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121505. /**
  121506. * Launch a ray to try to pick a mesh in the scene
  121507. * @param ray Ray to use
  121508. * @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
  121509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121510. * @returns an array of PickingInfo
  121511. */
  121512. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121513. /**
  121514. * Force the value of meshUnderPointer
  121515. * @param mesh defines the mesh to use
  121516. * @param pointerId optional pointer id when using more than one pointer
  121517. */
  121518. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121519. /**
  121520. * Gets the mesh under the pointer
  121521. * @returns a Mesh or null if no mesh is under the pointer
  121522. */
  121523. getPointerOverMesh(): Nullable<AbstractMesh>;
  121524. /** @hidden */
  121525. _rebuildGeometries(): void;
  121526. /** @hidden */
  121527. _rebuildTextures(): void;
  121528. private _getByTags;
  121529. /**
  121530. * Get a list of meshes by tags
  121531. * @param tagsQuery defines the tags query to use
  121532. * @param forEach defines a predicate used to filter results
  121533. * @returns an array of Mesh
  121534. */
  121535. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121536. /**
  121537. * Get a list of cameras by tags
  121538. * @param tagsQuery defines the tags query to use
  121539. * @param forEach defines a predicate used to filter results
  121540. * @returns an array of Camera
  121541. */
  121542. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121543. /**
  121544. * Get a list of lights by tags
  121545. * @param tagsQuery defines the tags query to use
  121546. * @param forEach defines a predicate used to filter results
  121547. * @returns an array of Light
  121548. */
  121549. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121550. /**
  121551. * Get a list of materials by tags
  121552. * @param tagsQuery defines the tags query to use
  121553. * @param forEach defines a predicate used to filter results
  121554. * @returns an array of Material
  121555. */
  121556. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121557. /**
  121558. * Get a list of transform nodes by tags
  121559. * @param tagsQuery defines the tags query to use
  121560. * @param forEach defines a predicate used to filter results
  121561. * @returns an array of TransformNode
  121562. */
  121563. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121564. /**
  121565. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121566. * This allowed control for front to back rendering or reversly depending of the special needs.
  121567. *
  121568. * @param renderingGroupId The rendering group id corresponding to its index
  121569. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121570. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121571. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121572. */
  121573. 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;
  121574. /**
  121575. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121576. *
  121577. * @param renderingGroupId The rendering group id corresponding to its index
  121578. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121579. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121580. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121581. */
  121582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121583. /**
  121584. * Gets the current auto clear configuration for one rendering group of the rendering
  121585. * manager.
  121586. * @param index the rendering group index to get the information for
  121587. * @returns The auto clear setup for the requested rendering group
  121588. */
  121589. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121590. private _blockMaterialDirtyMechanism;
  121591. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121592. get blockMaterialDirtyMechanism(): boolean;
  121593. set blockMaterialDirtyMechanism(value: boolean);
  121594. /**
  121595. * Will flag all materials as dirty to trigger new shader compilation
  121596. * @param flag defines the flag used to specify which material part must be marked as dirty
  121597. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121598. */
  121599. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121600. /** @hidden */
  121601. _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;
  121602. /** @hidden */
  121603. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121604. /** @hidden */
  121605. _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;
  121606. /** @hidden */
  121607. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121608. /** @hidden */
  121609. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121610. /** @hidden */
  121611. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121612. }
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * Set of assets to keep when moving a scene into an asset container.
  121617. */
  121618. export class KeepAssets extends AbstractScene {
  121619. }
  121620. /**
  121621. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121622. */
  121623. export class InstantiatedEntries {
  121624. /**
  121625. * List of new root nodes (eg. nodes with no parent)
  121626. */
  121627. rootNodes: TransformNode[];
  121628. /**
  121629. * List of new skeletons
  121630. */
  121631. skeletons: Skeleton[];
  121632. /**
  121633. * List of new animation groups
  121634. */
  121635. animationGroups: AnimationGroup[];
  121636. }
  121637. /**
  121638. * Container with a set of assets that can be added or removed from a scene.
  121639. */
  121640. export class AssetContainer extends AbstractScene {
  121641. private _wasAddedToScene;
  121642. /**
  121643. * The scene the AssetContainer belongs to.
  121644. */
  121645. scene: Scene;
  121646. /**
  121647. * Instantiates an AssetContainer.
  121648. * @param scene The scene the AssetContainer belongs to.
  121649. */
  121650. constructor(scene: Scene);
  121651. /**
  121652. * Instantiate or clone all meshes and add the new ones to the scene.
  121653. * Skeletons and animation groups will all be cloned
  121654. * @param nameFunction defines an optional function used to get new names for clones
  121655. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121656. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121657. */
  121658. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121659. /**
  121660. * Adds all the assets from the container to the scene.
  121661. */
  121662. addAllToScene(): void;
  121663. /**
  121664. * Removes all the assets in the container from the scene
  121665. */
  121666. removeAllFromScene(): void;
  121667. /**
  121668. * Disposes all the assets in the container
  121669. */
  121670. dispose(): void;
  121671. private _moveAssets;
  121672. /**
  121673. * Removes all the assets contained in the scene and adds them to the container.
  121674. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121675. */
  121676. moveAllFromScene(keepAssets?: KeepAssets): void;
  121677. /**
  121678. * 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.
  121679. * @returns the root mesh
  121680. */
  121681. createRootMesh(): Mesh;
  121682. /**
  121683. * Merge animations (direct and animation groups) from this asset container into a scene
  121684. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121685. * @param animatables set of animatables to retarget to a node from the scene
  121686. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121687. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121688. */
  121689. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121690. }
  121691. }
  121692. declare module BABYLON {
  121693. /**
  121694. * Defines how the parser contract is defined.
  121695. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121696. */
  121697. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121698. /**
  121699. * Defines how the individual parser contract is defined.
  121700. * These parser can parse an individual asset
  121701. */
  121702. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121703. /**
  121704. * Base class of the scene acting as a container for the different elements composing a scene.
  121705. * This class is dynamically extended by the different components of the scene increasing
  121706. * flexibility and reducing coupling
  121707. */
  121708. export abstract class AbstractScene {
  121709. /**
  121710. * Stores the list of available parsers in the application.
  121711. */
  121712. private static _BabylonFileParsers;
  121713. /**
  121714. * Stores the list of available individual parsers in the application.
  121715. */
  121716. private static _IndividualBabylonFileParsers;
  121717. /**
  121718. * Adds a parser in the list of available ones
  121719. * @param name Defines the name of the parser
  121720. * @param parser Defines the parser to add
  121721. */
  121722. static AddParser(name: string, parser: BabylonFileParser): void;
  121723. /**
  121724. * Gets a general parser from the list of avaialble ones
  121725. * @param name Defines the name of the parser
  121726. * @returns the requested parser or null
  121727. */
  121728. static GetParser(name: string): Nullable<BabylonFileParser>;
  121729. /**
  121730. * Adds n individual parser in the list of available ones
  121731. * @param name Defines the name of the parser
  121732. * @param parser Defines the parser to add
  121733. */
  121734. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121735. /**
  121736. * Gets an individual parser from the list of avaialble ones
  121737. * @param name Defines the name of the parser
  121738. * @returns the requested parser or null
  121739. */
  121740. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121741. /**
  121742. * Parser json data and populate both a scene and its associated container object
  121743. * @param jsonData Defines the data to parse
  121744. * @param scene Defines the scene to parse the data for
  121745. * @param container Defines the container attached to the parsing sequence
  121746. * @param rootUrl Defines the root url of the data
  121747. */
  121748. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121749. /**
  121750. * Gets the list of root nodes (ie. nodes with no parent)
  121751. */
  121752. rootNodes: Node[];
  121753. /** All of the cameras added to this scene
  121754. * @see https://doc.babylonjs.com/babylon101/cameras
  121755. */
  121756. cameras: Camera[];
  121757. /**
  121758. * All of the lights added to this scene
  121759. * @see https://doc.babylonjs.com/babylon101/lights
  121760. */
  121761. lights: Light[];
  121762. /**
  121763. * All of the (abstract) meshes added to this scene
  121764. */
  121765. meshes: AbstractMesh[];
  121766. /**
  121767. * The list of skeletons added to the scene
  121768. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121769. */
  121770. skeletons: Skeleton[];
  121771. /**
  121772. * All of the particle systems added to this scene
  121773. * @see https://doc.babylonjs.com/babylon101/particles
  121774. */
  121775. particleSystems: IParticleSystem[];
  121776. /**
  121777. * Gets a list of Animations associated with the scene
  121778. */
  121779. animations: Animation[];
  121780. /**
  121781. * All of the animation groups added to this scene
  121782. * @see https://doc.babylonjs.com/how_to/group
  121783. */
  121784. animationGroups: AnimationGroup[];
  121785. /**
  121786. * All of the multi-materials added to this scene
  121787. * @see https://doc.babylonjs.com/how_to/multi_materials
  121788. */
  121789. multiMaterials: MultiMaterial[];
  121790. /**
  121791. * All of the materials added to this scene
  121792. * In the context of a Scene, it is not supposed to be modified manually.
  121793. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121794. * Note also that the order of the Material within the array is not significant and might change.
  121795. * @see https://doc.babylonjs.com/babylon101/materials
  121796. */
  121797. materials: Material[];
  121798. /**
  121799. * The list of morph target managers added to the scene
  121800. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121801. */
  121802. morphTargetManagers: MorphTargetManager[];
  121803. /**
  121804. * The list of geometries used in the scene.
  121805. */
  121806. geometries: Geometry[];
  121807. /**
  121808. * All of the tranform nodes added to this scene
  121809. * In the context of a Scene, it is not supposed to be modified manually.
  121810. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121811. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121812. * @see https://doc.babylonjs.com/how_to/transformnode
  121813. */
  121814. transformNodes: TransformNode[];
  121815. /**
  121816. * ActionManagers available on the scene.
  121817. */
  121818. actionManagers: AbstractActionManager[];
  121819. /**
  121820. * Textures to keep.
  121821. */
  121822. textures: BaseTexture[];
  121823. /** @hidden */
  121824. protected _environmentTexture: Nullable<BaseTexture>;
  121825. /**
  121826. * Texture used in all pbr material as the reflection texture.
  121827. * As in the majority of the scene they are the same (exception for multi room and so on),
  121828. * this is easier to reference from here than from all the materials.
  121829. */
  121830. get environmentTexture(): Nullable<BaseTexture>;
  121831. set environmentTexture(value: Nullable<BaseTexture>);
  121832. /**
  121833. * The list of postprocesses added to the scene
  121834. */
  121835. postProcesses: PostProcess[];
  121836. /**
  121837. * @returns all meshes, lights, cameras, transformNodes and bones
  121838. */
  121839. getNodes(): Array<Node>;
  121840. }
  121841. }
  121842. declare module BABYLON {
  121843. /**
  121844. * Interface used to define options for Sound class
  121845. */
  121846. export interface ISoundOptions {
  121847. /**
  121848. * Does the sound autoplay once loaded.
  121849. */
  121850. autoplay?: boolean;
  121851. /**
  121852. * Does the sound loop after it finishes playing once.
  121853. */
  121854. loop?: boolean;
  121855. /**
  121856. * Sound's volume
  121857. */
  121858. volume?: number;
  121859. /**
  121860. * Is it a spatial sound?
  121861. */
  121862. spatialSound?: boolean;
  121863. /**
  121864. * Maximum distance to hear that sound
  121865. */
  121866. maxDistance?: number;
  121867. /**
  121868. * Uses user defined attenuation function
  121869. */
  121870. useCustomAttenuation?: boolean;
  121871. /**
  121872. * Define the roll off factor of spatial sounds.
  121873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121874. */
  121875. rolloffFactor?: number;
  121876. /**
  121877. * Define the reference distance the sound should be heard perfectly.
  121878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121879. */
  121880. refDistance?: number;
  121881. /**
  121882. * Define the distance attenuation model the sound will follow.
  121883. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121884. */
  121885. distanceModel?: string;
  121886. /**
  121887. * Defines the playback speed (1 by default)
  121888. */
  121889. playbackRate?: number;
  121890. /**
  121891. * Defines if the sound is from a streaming source
  121892. */
  121893. streaming?: boolean;
  121894. /**
  121895. * Defines an optional length (in seconds) inside the sound file
  121896. */
  121897. length?: number;
  121898. /**
  121899. * Defines an optional offset (in seconds) inside the sound file
  121900. */
  121901. offset?: number;
  121902. /**
  121903. * If true, URLs will not be required to state the audio file codec to use.
  121904. */
  121905. skipCodecCheck?: boolean;
  121906. }
  121907. /**
  121908. * Defines a sound that can be played in the application.
  121909. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121911. */
  121912. export class Sound {
  121913. /**
  121914. * The name of the sound in the scene.
  121915. */
  121916. name: string;
  121917. /**
  121918. * Does the sound autoplay once loaded.
  121919. */
  121920. autoplay: boolean;
  121921. /**
  121922. * Does the sound loop after it finishes playing once.
  121923. */
  121924. loop: boolean;
  121925. /**
  121926. * Does the sound use a custom attenuation curve to simulate the falloff
  121927. * happening when the source gets further away from the camera.
  121928. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121929. */
  121930. useCustomAttenuation: boolean;
  121931. /**
  121932. * The sound track id this sound belongs to.
  121933. */
  121934. soundTrackId: number;
  121935. /**
  121936. * Is this sound currently played.
  121937. */
  121938. isPlaying: boolean;
  121939. /**
  121940. * Is this sound currently paused.
  121941. */
  121942. isPaused: boolean;
  121943. /**
  121944. * Does this sound enables spatial sound.
  121945. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121946. */
  121947. spatialSound: boolean;
  121948. /**
  121949. * Define the reference distance the sound should be heard perfectly.
  121950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121951. */
  121952. refDistance: number;
  121953. /**
  121954. * Define the roll off factor of spatial sounds.
  121955. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121956. */
  121957. rolloffFactor: number;
  121958. /**
  121959. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121961. */
  121962. maxDistance: number;
  121963. /**
  121964. * Define the distance attenuation model the sound will follow.
  121965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121966. */
  121967. distanceModel: string;
  121968. /**
  121969. * @hidden
  121970. * Back Compat
  121971. **/
  121972. onended: () => any;
  121973. /**
  121974. * Gets or sets an object used to store user defined information for the sound.
  121975. */
  121976. metadata: any;
  121977. /**
  121978. * Observable event when the current playing sound finishes.
  121979. */
  121980. onEndedObservable: Observable<Sound>;
  121981. private _panningModel;
  121982. private _playbackRate;
  121983. private _streaming;
  121984. private _startTime;
  121985. private _startOffset;
  121986. private _position;
  121987. /** @hidden */
  121988. _positionInEmitterSpace: boolean;
  121989. private _localDirection;
  121990. private _volume;
  121991. private _isReadyToPlay;
  121992. private _isDirectional;
  121993. private _readyToPlayCallback;
  121994. private _audioBuffer;
  121995. private _soundSource;
  121996. private _streamingSource;
  121997. private _soundPanner;
  121998. private _soundGain;
  121999. private _inputAudioNode;
  122000. private _outputAudioNode;
  122001. private _coneInnerAngle;
  122002. private _coneOuterAngle;
  122003. private _coneOuterGain;
  122004. private _scene;
  122005. private _connectedTransformNode;
  122006. private _customAttenuationFunction;
  122007. private _registerFunc;
  122008. private _isOutputConnected;
  122009. private _htmlAudioElement;
  122010. private _urlType;
  122011. private _length?;
  122012. private _offset?;
  122013. /** @hidden */
  122014. static _SceneComponentInitialization: (scene: Scene) => void;
  122015. /**
  122016. * Create a sound and attach it to a scene
  122017. * @param name Name of your sound
  122018. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122019. * @param scene defines the scene the sound belongs to
  122020. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122021. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122022. */
  122023. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122024. /**
  122025. * Release the sound and its associated resources
  122026. */
  122027. dispose(): void;
  122028. /**
  122029. * Gets if the sounds is ready to be played or not.
  122030. * @returns true if ready, otherwise false
  122031. */
  122032. isReady(): boolean;
  122033. private _soundLoaded;
  122034. /**
  122035. * Sets the data of the sound from an audiobuffer
  122036. * @param audioBuffer The audioBuffer containing the data
  122037. */
  122038. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122039. /**
  122040. * Updates the current sounds options such as maxdistance, loop...
  122041. * @param options A JSON object containing values named as the object properties
  122042. */
  122043. updateOptions(options: ISoundOptions): void;
  122044. private _createSpatialParameters;
  122045. private _updateSpatialParameters;
  122046. /**
  122047. * Switch the panning model to HRTF:
  122048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122050. */
  122051. switchPanningModelToHRTF(): void;
  122052. /**
  122053. * Switch the panning model to Equal Power:
  122054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122056. */
  122057. switchPanningModelToEqualPower(): void;
  122058. private _switchPanningModel;
  122059. /**
  122060. * Connect this sound to a sound track audio node like gain...
  122061. * @param soundTrackAudioNode the sound track audio node to connect to
  122062. */
  122063. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122064. /**
  122065. * Transform this sound into a directional source
  122066. * @param coneInnerAngle Size of the inner cone in degree
  122067. * @param coneOuterAngle Size of the outer cone in degree
  122068. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122069. */
  122070. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122071. /**
  122072. * Gets or sets the inner angle for the directional cone.
  122073. */
  122074. get directionalConeInnerAngle(): number;
  122075. /**
  122076. * Gets or sets the inner angle for the directional cone.
  122077. */
  122078. set directionalConeInnerAngle(value: number);
  122079. /**
  122080. * Gets or sets the outer angle for the directional cone.
  122081. */
  122082. get directionalConeOuterAngle(): number;
  122083. /**
  122084. * Gets or sets the outer angle for the directional cone.
  122085. */
  122086. set directionalConeOuterAngle(value: number);
  122087. /**
  122088. * Sets the position of the emitter if spatial sound is enabled
  122089. * @param newPosition Defines the new posisiton
  122090. */
  122091. setPosition(newPosition: Vector3): void;
  122092. /**
  122093. * Sets the local direction of the emitter if spatial sound is enabled
  122094. * @param newLocalDirection Defines the new local direction
  122095. */
  122096. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122097. private _updateDirection;
  122098. /** @hidden */
  122099. updateDistanceFromListener(): void;
  122100. /**
  122101. * Sets a new custom attenuation function for the sound.
  122102. * @param callback Defines the function used for the attenuation
  122103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122104. */
  122105. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122106. /**
  122107. * Play the sound
  122108. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122109. * @param offset (optional) Start the sound at a specific time in seconds
  122110. * @param length (optional) Sound duration (in seconds)
  122111. */
  122112. play(time?: number, offset?: number, length?: number): void;
  122113. private _onended;
  122114. /**
  122115. * Stop the sound
  122116. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122117. */
  122118. stop(time?: number): void;
  122119. /**
  122120. * Put the sound in pause
  122121. */
  122122. pause(): void;
  122123. /**
  122124. * Sets a dedicated volume for this sounds
  122125. * @param newVolume Define the new volume of the sound
  122126. * @param time Define time for gradual change to new volume
  122127. */
  122128. setVolume(newVolume: number, time?: number): void;
  122129. /**
  122130. * Set the sound play back rate
  122131. * @param newPlaybackRate Define the playback rate the sound should be played at
  122132. */
  122133. setPlaybackRate(newPlaybackRate: number): void;
  122134. /**
  122135. * Gets the volume of the sound.
  122136. * @returns the volume of the sound
  122137. */
  122138. getVolume(): number;
  122139. /**
  122140. * Attach the sound to a dedicated mesh
  122141. * @param transformNode The transform node to connect the sound with
  122142. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122143. */
  122144. attachToMesh(transformNode: TransformNode): void;
  122145. /**
  122146. * Detach the sound from the previously attached mesh
  122147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122148. */
  122149. detachFromMesh(): void;
  122150. private _onRegisterAfterWorldMatrixUpdate;
  122151. /**
  122152. * Clone the current sound in the scene.
  122153. * @returns the new sound clone
  122154. */
  122155. clone(): Nullable<Sound>;
  122156. /**
  122157. * Gets the current underlying audio buffer containing the data
  122158. * @returns the audio buffer
  122159. */
  122160. getAudioBuffer(): Nullable<AudioBuffer>;
  122161. /**
  122162. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122163. * @returns the source node
  122164. */
  122165. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122166. /**
  122167. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122168. * @returns the gain node
  122169. */
  122170. getSoundGain(): Nullable<GainNode>;
  122171. /**
  122172. * Serializes the Sound in a JSON representation
  122173. * @returns the JSON representation of the sound
  122174. */
  122175. serialize(): any;
  122176. /**
  122177. * Parse a JSON representation of a sound to innstantiate in a given scene
  122178. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122179. * @param scene Define the scene the new parsed sound should be created in
  122180. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122181. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122182. * @returns the newly parsed sound
  122183. */
  122184. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122185. }
  122186. }
  122187. declare module BABYLON {
  122188. /**
  122189. * This defines an action helpful to play a defined sound on a triggered action.
  122190. */
  122191. export class PlaySoundAction extends Action {
  122192. private _sound;
  122193. /**
  122194. * Instantiate the action
  122195. * @param triggerOptions defines the trigger options
  122196. * @param sound defines the sound to play
  122197. * @param condition defines the trigger related conditions
  122198. */
  122199. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122200. /** @hidden */
  122201. _prepare(): void;
  122202. /**
  122203. * Execute the action and play the sound.
  122204. */
  122205. execute(): void;
  122206. /**
  122207. * Serializes the actions and its related information.
  122208. * @param parent defines the object to serialize in
  122209. * @returns the serialized object
  122210. */
  122211. serialize(parent: any): any;
  122212. }
  122213. /**
  122214. * This defines an action helpful to stop a defined sound on a triggered action.
  122215. */
  122216. export class StopSoundAction extends Action {
  122217. private _sound;
  122218. /**
  122219. * Instantiate the action
  122220. * @param triggerOptions defines the trigger options
  122221. * @param sound defines the sound to stop
  122222. * @param condition defines the trigger related conditions
  122223. */
  122224. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122225. /** @hidden */
  122226. _prepare(): void;
  122227. /**
  122228. * Execute the action and stop the sound.
  122229. */
  122230. execute(): void;
  122231. /**
  122232. * Serializes the actions and its related information.
  122233. * @param parent defines the object to serialize in
  122234. * @returns the serialized object
  122235. */
  122236. serialize(parent: any): any;
  122237. }
  122238. }
  122239. declare module BABYLON {
  122240. /**
  122241. * This defines an action responsible to change the value of a property
  122242. * by interpolating between its current value and the newly set one once triggered.
  122243. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122244. */
  122245. export class InterpolateValueAction extends Action {
  122246. /**
  122247. * Defines the path of the property where the value should be interpolated
  122248. */
  122249. propertyPath: string;
  122250. /**
  122251. * Defines the target value at the end of the interpolation.
  122252. */
  122253. value: any;
  122254. /**
  122255. * Defines the time it will take for the property to interpolate to the value.
  122256. */
  122257. duration: number;
  122258. /**
  122259. * Defines if the other scene animations should be stopped when the action has been triggered
  122260. */
  122261. stopOtherAnimations?: boolean;
  122262. /**
  122263. * Defines a callback raised once the interpolation animation has been done.
  122264. */
  122265. onInterpolationDone?: () => void;
  122266. /**
  122267. * Observable triggered once the interpolation animation has been done.
  122268. */
  122269. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122270. private _target;
  122271. private _effectiveTarget;
  122272. private _property;
  122273. /**
  122274. * Instantiate the action
  122275. * @param triggerOptions defines the trigger options
  122276. * @param target defines the object containing the value to interpolate
  122277. * @param propertyPath defines the path to the property in the target object
  122278. * @param value defines the target value at the end of the interpolation
  122279. * @param duration deines the time it will take for the property to interpolate to the value.
  122280. * @param condition defines the trigger related conditions
  122281. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122282. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122283. */
  122284. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122285. /** @hidden */
  122286. _prepare(): void;
  122287. /**
  122288. * Execute the action starts the value interpolation.
  122289. */
  122290. execute(): void;
  122291. /**
  122292. * Serializes the actions and its related information.
  122293. * @param parent defines the object to serialize in
  122294. * @returns the serialized object
  122295. */
  122296. serialize(parent: any): any;
  122297. }
  122298. }
  122299. declare module BABYLON {
  122300. /**
  122301. * Options allowed during the creation of a sound track.
  122302. */
  122303. export interface ISoundTrackOptions {
  122304. /**
  122305. * The volume the sound track should take during creation
  122306. */
  122307. volume?: number;
  122308. /**
  122309. * Define if the sound track is the main sound track of the scene
  122310. */
  122311. mainTrack?: boolean;
  122312. }
  122313. /**
  122314. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122315. * It will be also used in a future release to apply effects on a specific track.
  122316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122317. */
  122318. export class SoundTrack {
  122319. /**
  122320. * The unique identifier of the sound track in the scene.
  122321. */
  122322. id: number;
  122323. /**
  122324. * The list of sounds included in the sound track.
  122325. */
  122326. soundCollection: Array<Sound>;
  122327. private _outputAudioNode;
  122328. private _scene;
  122329. private _connectedAnalyser;
  122330. private _options;
  122331. private _isInitialized;
  122332. /**
  122333. * Creates a new sound track.
  122334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122335. * @param scene Define the scene the sound track belongs to
  122336. * @param options
  122337. */
  122338. constructor(scene: Scene, options?: ISoundTrackOptions);
  122339. private _initializeSoundTrackAudioGraph;
  122340. /**
  122341. * Release the sound track and its associated resources
  122342. */
  122343. dispose(): void;
  122344. /**
  122345. * Adds a sound to this sound track
  122346. * @param sound define the cound to add
  122347. * @ignoreNaming
  122348. */
  122349. AddSound(sound: Sound): void;
  122350. /**
  122351. * Removes a sound to this sound track
  122352. * @param sound define the cound to remove
  122353. * @ignoreNaming
  122354. */
  122355. RemoveSound(sound: Sound): void;
  122356. /**
  122357. * Set a global volume for the full sound track.
  122358. * @param newVolume Define the new volume of the sound track
  122359. */
  122360. setVolume(newVolume: number): void;
  122361. /**
  122362. * Switch the panning model to HRTF:
  122363. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122364. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122365. */
  122366. switchPanningModelToHRTF(): void;
  122367. /**
  122368. * Switch the panning model to Equal Power:
  122369. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122371. */
  122372. switchPanningModelToEqualPower(): void;
  122373. /**
  122374. * Connect the sound track to an audio analyser allowing some amazing
  122375. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122377. * @param analyser The analyser to connect to the engine
  122378. */
  122379. connectToAnalyser(analyser: Analyser): void;
  122380. }
  122381. }
  122382. declare module BABYLON {
  122383. interface AbstractScene {
  122384. /**
  122385. * The list of sounds used in the scene.
  122386. */
  122387. sounds: Nullable<Array<Sound>>;
  122388. }
  122389. interface Scene {
  122390. /**
  122391. * @hidden
  122392. * Backing field
  122393. */
  122394. _mainSoundTrack: SoundTrack;
  122395. /**
  122396. * The main sound track played by the scene.
  122397. * It cotains your primary collection of sounds.
  122398. */
  122399. mainSoundTrack: SoundTrack;
  122400. /**
  122401. * The list of sound tracks added to the scene
  122402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122403. */
  122404. soundTracks: Nullable<Array<SoundTrack>>;
  122405. /**
  122406. * Gets a sound using a given name
  122407. * @param name defines the name to search for
  122408. * @return the found sound or null if not found at all.
  122409. */
  122410. getSoundByName(name: string): Nullable<Sound>;
  122411. /**
  122412. * Gets or sets if audio support is enabled
  122413. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122414. */
  122415. audioEnabled: boolean;
  122416. /**
  122417. * Gets or sets if audio will be output to headphones
  122418. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122419. */
  122420. headphone: boolean;
  122421. /**
  122422. * Gets or sets custom audio listener position provider
  122423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122424. */
  122425. audioListenerPositionProvider: Nullable<() => Vector3>;
  122426. /**
  122427. * Gets or sets a refresh rate when using 3D audio positioning
  122428. */
  122429. audioPositioningRefreshRate: number;
  122430. }
  122431. /**
  122432. * Defines the sound scene component responsible to manage any sounds
  122433. * in a given scene.
  122434. */
  122435. export class AudioSceneComponent implements ISceneSerializableComponent {
  122436. private static _CameraDirectionLH;
  122437. private static _CameraDirectionRH;
  122438. /**
  122439. * The component name helpfull to identify the component in the list of scene components.
  122440. */
  122441. readonly name: string;
  122442. /**
  122443. * The scene the component belongs to.
  122444. */
  122445. scene: Scene;
  122446. private _audioEnabled;
  122447. /**
  122448. * Gets whether audio is enabled or not.
  122449. * Please use related enable/disable method to switch state.
  122450. */
  122451. get audioEnabled(): boolean;
  122452. private _headphone;
  122453. /**
  122454. * Gets whether audio is outputing to headphone or not.
  122455. * Please use the according Switch methods to change output.
  122456. */
  122457. get headphone(): boolean;
  122458. /**
  122459. * Gets or sets a refresh rate when using 3D audio positioning
  122460. */
  122461. audioPositioningRefreshRate: number;
  122462. private _audioListenerPositionProvider;
  122463. /**
  122464. * Gets the current audio listener position provider
  122465. */
  122466. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122467. /**
  122468. * Sets a custom listener position for all sounds in the scene
  122469. * By default, this is the position of the first active camera
  122470. */
  122471. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122472. /**
  122473. * Creates a new instance of the component for the given scene
  122474. * @param scene Defines the scene to register the component in
  122475. */
  122476. constructor(scene: Scene);
  122477. /**
  122478. * Registers the component in a given scene
  122479. */
  122480. register(): void;
  122481. /**
  122482. * Rebuilds the elements related to this component in case of
  122483. * context lost for instance.
  122484. */
  122485. rebuild(): void;
  122486. /**
  122487. * Serializes the component data to the specified json object
  122488. * @param serializationObject The object to serialize to
  122489. */
  122490. serialize(serializationObject: any): void;
  122491. /**
  122492. * Adds all the elements from the container to the scene
  122493. * @param container the container holding the elements
  122494. */
  122495. addFromContainer(container: AbstractScene): void;
  122496. /**
  122497. * Removes all the elements in the container from the scene
  122498. * @param container contains the elements to remove
  122499. * @param dispose if the removed element should be disposed (default: false)
  122500. */
  122501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122502. /**
  122503. * Disposes the component and the associated ressources.
  122504. */
  122505. dispose(): void;
  122506. /**
  122507. * Disables audio in the associated scene.
  122508. */
  122509. disableAudio(): void;
  122510. /**
  122511. * Enables audio in the associated scene.
  122512. */
  122513. enableAudio(): void;
  122514. /**
  122515. * Switch audio to headphone output.
  122516. */
  122517. switchAudioModeForHeadphones(): void;
  122518. /**
  122519. * Switch audio to normal speakers.
  122520. */
  122521. switchAudioModeForNormalSpeakers(): void;
  122522. private _cachedCameraDirection;
  122523. private _cachedCameraPosition;
  122524. private _lastCheck;
  122525. private _afterRender;
  122526. }
  122527. }
  122528. declare module BABYLON {
  122529. /**
  122530. * Wraps one or more Sound objects and selects one with random weight for playback.
  122531. */
  122532. export class WeightedSound {
  122533. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122534. loop: boolean;
  122535. private _coneInnerAngle;
  122536. private _coneOuterAngle;
  122537. private _volume;
  122538. /** A Sound is currently playing. */
  122539. isPlaying: boolean;
  122540. /** A Sound is currently paused. */
  122541. isPaused: boolean;
  122542. private _sounds;
  122543. private _weights;
  122544. private _currentIndex?;
  122545. /**
  122546. * Creates a new WeightedSound from the list of sounds given.
  122547. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122548. * @param sounds Array of Sounds that will be selected from.
  122549. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122550. */
  122551. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122552. /**
  122553. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122554. */
  122555. get directionalConeInnerAngle(): number;
  122556. /**
  122557. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122558. */
  122559. set directionalConeInnerAngle(value: number);
  122560. /**
  122561. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122562. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122563. */
  122564. get directionalConeOuterAngle(): number;
  122565. /**
  122566. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122567. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122568. */
  122569. set directionalConeOuterAngle(value: number);
  122570. /**
  122571. * Playback volume.
  122572. */
  122573. get volume(): number;
  122574. /**
  122575. * Playback volume.
  122576. */
  122577. set volume(value: number);
  122578. private _onended;
  122579. /**
  122580. * Suspend playback
  122581. */
  122582. pause(): void;
  122583. /**
  122584. * Stop playback
  122585. */
  122586. stop(): void;
  122587. /**
  122588. * Start playback.
  122589. * @param startOffset Position the clip head at a specific time in seconds.
  122590. */
  122591. play(startOffset?: number): void;
  122592. }
  122593. }
  122594. declare module BABYLON {
  122595. /**
  122596. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122597. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122598. */
  122599. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122600. /**
  122601. * Gets the name of the behavior.
  122602. */
  122603. get name(): string;
  122604. /**
  122605. * The easing function used by animations
  122606. */
  122607. static EasingFunction: BackEase;
  122608. /**
  122609. * The easing mode used by animations
  122610. */
  122611. static EasingMode: number;
  122612. /**
  122613. * The duration of the animation, in milliseconds
  122614. */
  122615. transitionDuration: number;
  122616. /**
  122617. * Length of the distance animated by the transition when lower radius is reached
  122618. */
  122619. lowerRadiusTransitionRange: number;
  122620. /**
  122621. * Length of the distance animated by the transition when upper radius is reached
  122622. */
  122623. upperRadiusTransitionRange: number;
  122624. private _autoTransitionRange;
  122625. /**
  122626. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122627. */
  122628. get autoTransitionRange(): boolean;
  122629. /**
  122630. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122631. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122632. */
  122633. set autoTransitionRange(value: boolean);
  122634. private _attachedCamera;
  122635. private _onAfterCheckInputsObserver;
  122636. private _onMeshTargetChangedObserver;
  122637. /**
  122638. * Initializes the behavior.
  122639. */
  122640. init(): void;
  122641. /**
  122642. * Attaches the behavior to its arc rotate camera.
  122643. * @param camera Defines the camera to attach the behavior to
  122644. */
  122645. attach(camera: ArcRotateCamera): void;
  122646. /**
  122647. * Detaches the behavior from its current arc rotate camera.
  122648. */
  122649. detach(): void;
  122650. private _radiusIsAnimating;
  122651. private _radiusBounceTransition;
  122652. private _animatables;
  122653. private _cachedWheelPrecision;
  122654. /**
  122655. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122656. * @param radiusLimit The limit to check against.
  122657. * @return Bool to indicate if at limit.
  122658. */
  122659. private _isRadiusAtLimit;
  122660. /**
  122661. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122662. * @param radiusDelta The delta by which to animate to. Can be negative.
  122663. */
  122664. private _applyBoundRadiusAnimation;
  122665. /**
  122666. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122667. */
  122668. protected _clearAnimationLocks(): void;
  122669. /**
  122670. * Stops and removes all animations that have been applied to the camera
  122671. */
  122672. stopAllAnimations(): void;
  122673. }
  122674. }
  122675. declare module BABYLON {
  122676. /**
  122677. * 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.
  122678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122679. */
  122680. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122681. /**
  122682. * Gets the name of the behavior.
  122683. */
  122684. get name(): string;
  122685. private _mode;
  122686. private _radiusScale;
  122687. private _positionScale;
  122688. private _defaultElevation;
  122689. private _elevationReturnTime;
  122690. private _elevationReturnWaitTime;
  122691. private _zoomStopsAnimation;
  122692. private _framingTime;
  122693. /**
  122694. * The easing function used by animations
  122695. */
  122696. static EasingFunction: ExponentialEase;
  122697. /**
  122698. * The easing mode used by animations
  122699. */
  122700. static EasingMode: number;
  122701. /**
  122702. * Sets the current mode used by the behavior
  122703. */
  122704. set mode(mode: number);
  122705. /**
  122706. * Gets current mode used by the behavior.
  122707. */
  122708. get mode(): number;
  122709. /**
  122710. * Sets the scale applied to the radius (1 by default)
  122711. */
  122712. set radiusScale(radius: number);
  122713. /**
  122714. * Gets the scale applied to the radius
  122715. */
  122716. get radiusScale(): number;
  122717. /**
  122718. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122719. */
  122720. set positionScale(scale: number);
  122721. /**
  122722. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122723. */
  122724. get positionScale(): number;
  122725. /**
  122726. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122727. * behaviour is triggered, in radians.
  122728. */
  122729. set defaultElevation(elevation: number);
  122730. /**
  122731. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122732. * behaviour is triggered, in radians.
  122733. */
  122734. get defaultElevation(): number;
  122735. /**
  122736. * Sets the time (in milliseconds) taken to return to the default beta position.
  122737. * Negative value indicates camera should not return to default.
  122738. */
  122739. set elevationReturnTime(speed: number);
  122740. /**
  122741. * Gets the time (in milliseconds) taken to return to the default beta position.
  122742. * Negative value indicates camera should not return to default.
  122743. */
  122744. get elevationReturnTime(): number;
  122745. /**
  122746. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122747. */
  122748. set elevationReturnWaitTime(time: number);
  122749. /**
  122750. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122751. */
  122752. get elevationReturnWaitTime(): number;
  122753. /**
  122754. * Sets the flag that indicates if user zooming should stop animation.
  122755. */
  122756. set zoomStopsAnimation(flag: boolean);
  122757. /**
  122758. * Gets the flag that indicates if user zooming should stop animation.
  122759. */
  122760. get zoomStopsAnimation(): boolean;
  122761. /**
  122762. * Sets the transition time when framing the mesh, in milliseconds
  122763. */
  122764. set framingTime(time: number);
  122765. /**
  122766. * Gets the transition time when framing the mesh, in milliseconds
  122767. */
  122768. get framingTime(): number;
  122769. /**
  122770. * Define if the behavior should automatically change the configured
  122771. * camera limits and sensibilities.
  122772. */
  122773. autoCorrectCameraLimitsAndSensibility: boolean;
  122774. private _onPrePointerObservableObserver;
  122775. private _onAfterCheckInputsObserver;
  122776. private _onMeshTargetChangedObserver;
  122777. private _attachedCamera;
  122778. private _isPointerDown;
  122779. private _lastInteractionTime;
  122780. /**
  122781. * Initializes the behavior.
  122782. */
  122783. init(): void;
  122784. /**
  122785. * Attaches the behavior to its arc rotate camera.
  122786. * @param camera Defines the camera to attach the behavior to
  122787. */
  122788. attach(camera: ArcRotateCamera): void;
  122789. /**
  122790. * Detaches the behavior from its current arc rotate camera.
  122791. */
  122792. detach(): void;
  122793. private _animatables;
  122794. private _betaIsAnimating;
  122795. private _betaTransition;
  122796. private _radiusTransition;
  122797. private _vectorTransition;
  122798. /**
  122799. * Targets the given mesh and updates zoom level accordingly.
  122800. * @param mesh The mesh to target.
  122801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122803. */
  122804. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122805. /**
  122806. * Targets the given mesh with its children and updates zoom level accordingly.
  122807. * @param mesh The mesh to target.
  122808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122810. */
  122811. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122812. /**
  122813. * Targets the given meshes with their children and updates zoom level accordingly.
  122814. * @param meshes The mesh to target.
  122815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122817. */
  122818. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122819. /**
  122820. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122821. * @param minimumWorld Determines the smaller position of the bounding box extend
  122822. * @param maximumWorld Determines the bigger position of the bounding box extend
  122823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122825. */
  122826. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122827. /**
  122828. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122829. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122830. * frustum width.
  122831. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122832. * to fully enclose the mesh in the viewing frustum.
  122833. */
  122834. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122835. /**
  122836. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122837. * is automatically returned to its default position (expected to be above ground plane).
  122838. */
  122839. private _maintainCameraAboveGround;
  122840. /**
  122841. * Returns the frustum slope based on the canvas ratio and camera FOV
  122842. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122843. */
  122844. private _getFrustumSlope;
  122845. /**
  122846. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122847. */
  122848. private _clearAnimationLocks;
  122849. /**
  122850. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122851. */
  122852. private _applyUserInteraction;
  122853. /**
  122854. * Stops and removes all animations that have been applied to the camera
  122855. */
  122856. stopAllAnimations(): void;
  122857. /**
  122858. * Gets a value indicating if the user is moving the camera
  122859. */
  122860. get isUserIsMoving(): boolean;
  122861. /**
  122862. * The camera can move all the way towards the mesh.
  122863. */
  122864. static IgnoreBoundsSizeMode: number;
  122865. /**
  122866. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122867. */
  122868. static FitFrustumSidesMode: number;
  122869. }
  122870. }
  122871. declare module BABYLON {
  122872. /**
  122873. * Base class for Camera Pointer Inputs.
  122874. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122875. * for example usage.
  122876. */
  122877. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122878. /**
  122879. * Defines the camera the input is attached to.
  122880. */
  122881. abstract camera: Camera;
  122882. /**
  122883. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122884. */
  122885. protected _altKey: boolean;
  122886. protected _ctrlKey: boolean;
  122887. protected _metaKey: boolean;
  122888. protected _shiftKey: boolean;
  122889. /**
  122890. * Which mouse buttons were pressed at time of last mouse event.
  122891. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122892. */
  122893. protected _buttonsPressed: number;
  122894. /**
  122895. * Defines the buttons associated with the input to handle camera move.
  122896. */
  122897. buttons: number[];
  122898. /**
  122899. * Attach the input controls to a specific dom element to get the input from.
  122900. * @param element Defines the element the controls should be listened from
  122901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122902. */
  122903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122904. /**
  122905. * Detach the current controls from the specified dom element.
  122906. * @param element Defines the element to stop listening the inputs from
  122907. */
  122908. detachControl(element: Nullable<HTMLElement>): void;
  122909. /**
  122910. * Gets the class name of the current input.
  122911. * @returns the class name
  122912. */
  122913. getClassName(): string;
  122914. /**
  122915. * Get the friendly name associated with the input class.
  122916. * @returns the input friendly name
  122917. */
  122918. getSimpleName(): string;
  122919. /**
  122920. * Called on pointer POINTERDOUBLETAP event.
  122921. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122922. */
  122923. protected onDoubleTap(type: string): void;
  122924. /**
  122925. * Called on pointer POINTERMOVE event if only a single touch is active.
  122926. * Override this method to provide functionality.
  122927. */
  122928. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122929. /**
  122930. * Called on pointer POINTERMOVE event if multiple touches are active.
  122931. * Override this method to provide functionality.
  122932. */
  122933. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122934. /**
  122935. * Called on JS contextmenu event.
  122936. * Override this method to provide functionality.
  122937. */
  122938. protected onContextMenu(evt: PointerEvent): void;
  122939. /**
  122940. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122941. * press.
  122942. * Override this method to provide functionality.
  122943. */
  122944. protected onButtonDown(evt: PointerEvent): void;
  122945. /**
  122946. * Called each time a new POINTERUP event occurs. Ie, for each button
  122947. * release.
  122948. * Override this method to provide functionality.
  122949. */
  122950. protected onButtonUp(evt: PointerEvent): void;
  122951. /**
  122952. * Called when window becomes inactive.
  122953. * Override this method to provide functionality.
  122954. */
  122955. protected onLostFocus(): void;
  122956. private _pointerInput;
  122957. private _observer;
  122958. private _onLostFocus;
  122959. private pointA;
  122960. private pointB;
  122961. }
  122962. }
  122963. declare module BABYLON {
  122964. /**
  122965. * Manage the pointers inputs to control an arc rotate camera.
  122966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122967. */
  122968. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122969. /**
  122970. * Defines the camera the input is attached to.
  122971. */
  122972. camera: ArcRotateCamera;
  122973. /**
  122974. * Gets the class name of the current input.
  122975. * @returns the class name
  122976. */
  122977. getClassName(): string;
  122978. /**
  122979. * Defines the buttons associated with the input to handle camera move.
  122980. */
  122981. buttons: number[];
  122982. /**
  122983. * Defines the pointer angular sensibility along the X axis or how fast is
  122984. * the camera rotating.
  122985. */
  122986. angularSensibilityX: number;
  122987. /**
  122988. * Defines the pointer angular sensibility along the Y axis or how fast is
  122989. * the camera rotating.
  122990. */
  122991. angularSensibilityY: number;
  122992. /**
  122993. * Defines the pointer pinch precision or how fast is the camera zooming.
  122994. */
  122995. pinchPrecision: number;
  122996. /**
  122997. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122998. * from 0.
  122999. * It defines the percentage of current camera.radius to use as delta when
  123000. * pinch zoom is used.
  123001. */
  123002. pinchDeltaPercentage: number;
  123003. /**
  123004. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123005. * that any object in the plane at the camera's target point will scale
  123006. * perfectly with finger motion.
  123007. * Overrides pinchDeltaPercentage and pinchPrecision.
  123008. */
  123009. useNaturalPinchZoom: boolean;
  123010. /**
  123011. * Defines the pointer panning sensibility or how fast is the camera moving.
  123012. */
  123013. panningSensibility: number;
  123014. /**
  123015. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123016. */
  123017. multiTouchPanning: boolean;
  123018. /**
  123019. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123020. * zoom (pinch) through multitouch.
  123021. */
  123022. multiTouchPanAndZoom: boolean;
  123023. /**
  123024. * Revers pinch action direction.
  123025. */
  123026. pinchInwards: boolean;
  123027. private _isPanClick;
  123028. private _twoFingerActivityCount;
  123029. private _isPinching;
  123030. /**
  123031. * Called on pointer POINTERMOVE event if only a single touch is active.
  123032. */
  123033. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123034. /**
  123035. * Called on pointer POINTERDOUBLETAP event.
  123036. */
  123037. protected onDoubleTap(type: string): void;
  123038. /**
  123039. * Called on pointer POINTERMOVE event if multiple touches are active.
  123040. */
  123041. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123042. /**
  123043. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123044. * press.
  123045. */
  123046. protected onButtonDown(evt: PointerEvent): void;
  123047. /**
  123048. * Called each time a new POINTERUP event occurs. Ie, for each button
  123049. * release.
  123050. */
  123051. protected onButtonUp(evt: PointerEvent): void;
  123052. /**
  123053. * Called when window becomes inactive.
  123054. */
  123055. protected onLostFocus(): void;
  123056. }
  123057. }
  123058. declare module BABYLON {
  123059. /**
  123060. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123061. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123062. */
  123063. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123064. /**
  123065. * Defines the camera the input is attached to.
  123066. */
  123067. camera: ArcRotateCamera;
  123068. /**
  123069. * Defines the list of key codes associated with the up action (increase alpha)
  123070. */
  123071. keysUp: number[];
  123072. /**
  123073. * Defines the list of key codes associated with the down action (decrease alpha)
  123074. */
  123075. keysDown: number[];
  123076. /**
  123077. * Defines the list of key codes associated with the left action (increase beta)
  123078. */
  123079. keysLeft: number[];
  123080. /**
  123081. * Defines the list of key codes associated with the right action (decrease beta)
  123082. */
  123083. keysRight: number[];
  123084. /**
  123085. * Defines the list of key codes associated with the reset action.
  123086. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123087. */
  123088. keysReset: number[];
  123089. /**
  123090. * Defines the panning sensibility of the inputs.
  123091. * (How fast is the camera panning)
  123092. */
  123093. panningSensibility: number;
  123094. /**
  123095. * Defines the zooming sensibility of the inputs.
  123096. * (How fast is the camera zooming)
  123097. */
  123098. zoomingSensibility: number;
  123099. /**
  123100. * Defines whether maintaining the alt key down switch the movement mode from
  123101. * orientation to zoom.
  123102. */
  123103. useAltToZoom: boolean;
  123104. /**
  123105. * Rotation speed of the camera
  123106. */
  123107. angularSpeed: number;
  123108. private _keys;
  123109. private _ctrlPressed;
  123110. private _altPressed;
  123111. private _onCanvasBlurObserver;
  123112. private _onKeyboardObserver;
  123113. private _engine;
  123114. private _scene;
  123115. /**
  123116. * Attach the input controls to a specific dom element to get the input from.
  123117. * @param element Defines the element the controls should be listened from
  123118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123119. */
  123120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123121. /**
  123122. * Detach the current controls from the specified dom element.
  123123. * @param element Defines the element to stop listening the inputs from
  123124. */
  123125. detachControl(element: Nullable<HTMLElement>): void;
  123126. /**
  123127. * Update the current camera state depending on the inputs that have been used this frame.
  123128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123129. */
  123130. checkInputs(): void;
  123131. /**
  123132. * Gets the class name of the current intput.
  123133. * @returns the class name
  123134. */
  123135. getClassName(): string;
  123136. /**
  123137. * Get the friendly name associated with the input class.
  123138. * @returns the input friendly name
  123139. */
  123140. getSimpleName(): string;
  123141. }
  123142. }
  123143. declare module BABYLON {
  123144. /**
  123145. * Manage the mouse wheel inputs to control an arc rotate camera.
  123146. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123147. */
  123148. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123149. /**
  123150. * Defines the camera the input is attached to.
  123151. */
  123152. camera: ArcRotateCamera;
  123153. /**
  123154. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123155. */
  123156. wheelPrecision: number;
  123157. /**
  123158. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123159. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123160. */
  123161. wheelDeltaPercentage: number;
  123162. private _wheel;
  123163. private _observer;
  123164. private computeDeltaFromMouseWheelLegacyEvent;
  123165. /**
  123166. * Attach the input controls to a specific dom element to get the input from.
  123167. * @param element Defines the element the controls should be listened from
  123168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123169. */
  123170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123171. /**
  123172. * Detach the current controls from the specified dom element.
  123173. * @param element Defines the element to stop listening the inputs from
  123174. */
  123175. detachControl(element: Nullable<HTMLElement>): void;
  123176. /**
  123177. * Gets the class name of the current intput.
  123178. * @returns the class name
  123179. */
  123180. getClassName(): string;
  123181. /**
  123182. * Get the friendly name associated with the input class.
  123183. * @returns the input friendly name
  123184. */
  123185. getSimpleName(): string;
  123186. }
  123187. }
  123188. declare module BABYLON {
  123189. /**
  123190. * Default Inputs manager for the ArcRotateCamera.
  123191. * It groups all the default supported inputs for ease of use.
  123192. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123193. */
  123194. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123195. /**
  123196. * Instantiates a new ArcRotateCameraInputsManager.
  123197. * @param camera Defines the camera the inputs belong to
  123198. */
  123199. constructor(camera: ArcRotateCamera);
  123200. /**
  123201. * Add mouse wheel input support to the input manager.
  123202. * @returns the current input manager
  123203. */
  123204. addMouseWheel(): ArcRotateCameraInputsManager;
  123205. /**
  123206. * Add pointers input support to the input manager.
  123207. * @returns the current input manager
  123208. */
  123209. addPointers(): ArcRotateCameraInputsManager;
  123210. /**
  123211. * Add keyboard input support to the input manager.
  123212. * @returns the current input manager
  123213. */
  123214. addKeyboard(): ArcRotateCameraInputsManager;
  123215. }
  123216. }
  123217. declare module BABYLON {
  123218. /**
  123219. * This represents an orbital type of camera.
  123220. *
  123221. * 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.
  123222. * 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.
  123223. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123224. */
  123225. export class ArcRotateCamera extends TargetCamera {
  123226. /**
  123227. * Defines the rotation angle of the camera along the longitudinal axis.
  123228. */
  123229. alpha: number;
  123230. /**
  123231. * Defines the rotation angle of the camera along the latitudinal axis.
  123232. */
  123233. beta: number;
  123234. /**
  123235. * Defines the radius of the camera from it s target point.
  123236. */
  123237. radius: number;
  123238. protected _target: Vector3;
  123239. protected _targetHost: Nullable<AbstractMesh>;
  123240. /**
  123241. * Defines the target point of the camera.
  123242. * The camera looks towards it form the radius distance.
  123243. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123244. */
  123245. get target(): Vector3;
  123246. set target(value: Vector3);
  123247. /**
  123248. * Define the current local position of the camera in the scene
  123249. */
  123250. get position(): Vector3;
  123251. set position(newPosition: Vector3);
  123252. protected _upToYMatrix: Matrix;
  123253. protected _YToUpMatrix: Matrix;
  123254. /**
  123255. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123256. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123257. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123258. */
  123259. set upVector(vec: Vector3);
  123260. get upVector(): Vector3;
  123261. /**
  123262. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123263. */
  123264. setMatUp(): void;
  123265. /**
  123266. * Current inertia value on the longitudinal axis.
  123267. * The bigger this number the longer it will take for the camera to stop.
  123268. */
  123269. inertialAlphaOffset: number;
  123270. /**
  123271. * Current inertia value on the latitudinal axis.
  123272. * The bigger this number the longer it will take for the camera to stop.
  123273. */
  123274. inertialBetaOffset: number;
  123275. /**
  123276. * Current inertia value on the radius axis.
  123277. * The bigger this number the longer it will take for the camera to stop.
  123278. */
  123279. inertialRadiusOffset: number;
  123280. /**
  123281. * Minimum allowed angle on the longitudinal axis.
  123282. * This can help limiting how the Camera is able to move in the scene.
  123283. */
  123284. lowerAlphaLimit: Nullable<number>;
  123285. /**
  123286. * Maximum allowed angle on the longitudinal axis.
  123287. * This can help limiting how the Camera is able to move in the scene.
  123288. */
  123289. upperAlphaLimit: Nullable<number>;
  123290. /**
  123291. * Minimum allowed angle on the latitudinal axis.
  123292. * This can help limiting how the Camera is able to move in the scene.
  123293. */
  123294. lowerBetaLimit: number;
  123295. /**
  123296. * Maximum allowed angle on the latitudinal axis.
  123297. * This can help limiting how the Camera is able to move in the scene.
  123298. */
  123299. upperBetaLimit: number;
  123300. /**
  123301. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123302. * This can help limiting how the Camera is able to move in the scene.
  123303. */
  123304. lowerRadiusLimit: Nullable<number>;
  123305. /**
  123306. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123307. * This can help limiting how the Camera is able to move in the scene.
  123308. */
  123309. upperRadiusLimit: Nullable<number>;
  123310. /**
  123311. * Defines the current inertia value used during panning of the camera along the X axis.
  123312. */
  123313. inertialPanningX: number;
  123314. /**
  123315. * Defines the current inertia value used during panning of the camera along the Y axis.
  123316. */
  123317. inertialPanningY: number;
  123318. /**
  123319. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123320. * Basically if your fingers moves away from more than this distance you will be considered
  123321. * in pinch mode.
  123322. */
  123323. pinchToPanMaxDistance: number;
  123324. /**
  123325. * Defines the maximum distance the camera can pan.
  123326. * This could help keeping the cammera always in your scene.
  123327. */
  123328. panningDistanceLimit: Nullable<number>;
  123329. /**
  123330. * Defines the target of the camera before paning.
  123331. */
  123332. panningOriginTarget: Vector3;
  123333. /**
  123334. * Defines the value of the inertia used during panning.
  123335. * 0 would mean stop inertia and one would mean no decelleration at all.
  123336. */
  123337. panningInertia: number;
  123338. /**
  123339. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123340. */
  123341. get angularSensibilityX(): number;
  123342. set angularSensibilityX(value: number);
  123343. /**
  123344. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123345. */
  123346. get angularSensibilityY(): number;
  123347. set angularSensibilityY(value: number);
  123348. /**
  123349. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123350. */
  123351. get pinchPrecision(): number;
  123352. set pinchPrecision(value: number);
  123353. /**
  123354. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123355. * It will be used instead of pinchDeltaPrecision if different from 0.
  123356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123357. */
  123358. get pinchDeltaPercentage(): number;
  123359. set pinchDeltaPercentage(value: number);
  123360. /**
  123361. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123362. * and pinch delta percentage.
  123363. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123364. * that any object in the plane at the camera's target point will scale
  123365. * perfectly with finger motion.
  123366. */
  123367. get useNaturalPinchZoom(): boolean;
  123368. set useNaturalPinchZoom(value: boolean);
  123369. /**
  123370. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123371. */
  123372. get panningSensibility(): number;
  123373. set panningSensibility(value: number);
  123374. /**
  123375. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123376. */
  123377. get keysUp(): number[];
  123378. set keysUp(value: number[]);
  123379. /**
  123380. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123381. */
  123382. get keysDown(): number[];
  123383. set keysDown(value: number[]);
  123384. /**
  123385. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123386. */
  123387. get keysLeft(): number[];
  123388. set keysLeft(value: number[]);
  123389. /**
  123390. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123391. */
  123392. get keysRight(): number[];
  123393. set keysRight(value: number[]);
  123394. /**
  123395. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123396. */
  123397. get wheelPrecision(): number;
  123398. set wheelPrecision(value: number);
  123399. /**
  123400. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123401. * It will be used instead of pinchDeltaPrecision if different from 0.
  123402. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123403. */
  123404. get wheelDeltaPercentage(): number;
  123405. set wheelDeltaPercentage(value: number);
  123406. /**
  123407. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123408. */
  123409. zoomOnFactor: number;
  123410. /**
  123411. * Defines a screen offset for the camera position.
  123412. */
  123413. targetScreenOffset: Vector2;
  123414. /**
  123415. * Allows the camera to be completely reversed.
  123416. * If false the camera can not arrive upside down.
  123417. */
  123418. allowUpsideDown: boolean;
  123419. /**
  123420. * Define if double tap/click is used to restore the previously saved state of the camera.
  123421. */
  123422. useInputToRestoreState: boolean;
  123423. /** @hidden */
  123424. _viewMatrix: Matrix;
  123425. /** @hidden */
  123426. _useCtrlForPanning: boolean;
  123427. /** @hidden */
  123428. _panningMouseButton: number;
  123429. /**
  123430. * Defines the input associated to the camera.
  123431. */
  123432. inputs: ArcRotateCameraInputsManager;
  123433. /** @hidden */
  123434. _reset: () => void;
  123435. /**
  123436. * Defines the allowed panning axis.
  123437. */
  123438. panningAxis: Vector3;
  123439. protected _localDirection: Vector3;
  123440. protected _transformedDirection: Vector3;
  123441. private _bouncingBehavior;
  123442. /**
  123443. * Gets the bouncing behavior of the camera if it has been enabled.
  123444. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123445. */
  123446. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123447. /**
  123448. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123449. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123450. */
  123451. get useBouncingBehavior(): boolean;
  123452. set useBouncingBehavior(value: boolean);
  123453. private _framingBehavior;
  123454. /**
  123455. * Gets the framing behavior of the camera if it has been enabled.
  123456. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123457. */
  123458. get framingBehavior(): Nullable<FramingBehavior>;
  123459. /**
  123460. * Defines if the framing behavior of the camera is enabled on the camera.
  123461. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123462. */
  123463. get useFramingBehavior(): boolean;
  123464. set useFramingBehavior(value: boolean);
  123465. private _autoRotationBehavior;
  123466. /**
  123467. * Gets the auto rotation behavior of the camera if it has been enabled.
  123468. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123469. */
  123470. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123471. /**
  123472. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123473. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123474. */
  123475. get useAutoRotationBehavior(): boolean;
  123476. set useAutoRotationBehavior(value: boolean);
  123477. /**
  123478. * Observable triggered when the mesh target has been changed on the camera.
  123479. */
  123480. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123481. /**
  123482. * Event raised when the camera is colliding with a mesh.
  123483. */
  123484. onCollide: (collidedMesh: AbstractMesh) => void;
  123485. /**
  123486. * Defines whether the camera should check collision with the objects oh the scene.
  123487. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123488. */
  123489. checkCollisions: boolean;
  123490. /**
  123491. * Defines the collision radius of the camera.
  123492. * This simulates a sphere around the camera.
  123493. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123494. */
  123495. collisionRadius: Vector3;
  123496. protected _collider: Collider;
  123497. protected _previousPosition: Vector3;
  123498. protected _collisionVelocity: Vector3;
  123499. protected _newPosition: Vector3;
  123500. protected _previousAlpha: number;
  123501. protected _previousBeta: number;
  123502. protected _previousRadius: number;
  123503. protected _collisionTriggered: boolean;
  123504. protected _targetBoundingCenter: Nullable<Vector3>;
  123505. private _computationVector;
  123506. /**
  123507. * Instantiates a new ArcRotateCamera in a given scene
  123508. * @param name Defines the name of the camera
  123509. * @param alpha Defines the camera rotation along the logitudinal axis
  123510. * @param beta Defines the camera rotation along the latitudinal axis
  123511. * @param radius Defines the camera distance from its target
  123512. * @param target Defines the camera target
  123513. * @param scene Defines the scene the camera belongs to
  123514. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123515. */
  123516. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123517. /** @hidden */
  123518. _initCache(): void;
  123519. /** @hidden */
  123520. _updateCache(ignoreParentClass?: boolean): void;
  123521. protected _getTargetPosition(): Vector3;
  123522. private _storedAlpha;
  123523. private _storedBeta;
  123524. private _storedRadius;
  123525. private _storedTarget;
  123526. private _storedTargetScreenOffset;
  123527. /**
  123528. * Stores the current state of the camera (alpha, beta, radius and target)
  123529. * @returns the camera itself
  123530. */
  123531. storeState(): Camera;
  123532. /**
  123533. * @hidden
  123534. * Restored camera state. You must call storeState() first
  123535. */
  123536. _restoreStateValues(): boolean;
  123537. /** @hidden */
  123538. _isSynchronizedViewMatrix(): boolean;
  123539. /**
  123540. * Attached controls to the current camera.
  123541. * @param element Defines the element the controls should be listened from
  123542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123543. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123544. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123545. */
  123546. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123547. /**
  123548. * Detach the current controls from the camera.
  123549. * The camera will stop reacting to inputs.
  123550. * @param element Defines the element to stop listening the inputs from
  123551. */
  123552. detachControl(element: HTMLElement): void;
  123553. /** @hidden */
  123554. _checkInputs(): void;
  123555. protected _checkLimits(): void;
  123556. /**
  123557. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123558. */
  123559. rebuildAnglesAndRadius(): void;
  123560. /**
  123561. * Use a position to define the current camera related information like alpha, beta and radius
  123562. * @param position Defines the position to set the camera at
  123563. */
  123564. setPosition(position: Vector3): void;
  123565. /**
  123566. * Defines the target the camera should look at.
  123567. * This will automatically adapt alpha beta and radius to fit within the new target.
  123568. * @param target Defines the new target as a Vector or a mesh
  123569. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123570. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123571. */
  123572. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123573. /** @hidden */
  123574. _getViewMatrix(): Matrix;
  123575. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123576. /**
  123577. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123578. * @param meshes Defines the mesh to zoom on
  123579. * @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)
  123580. */
  123581. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123582. /**
  123583. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123584. * The target will be changed but the radius
  123585. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123586. * @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)
  123587. */
  123588. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123589. min: Vector3;
  123590. max: Vector3;
  123591. distance: number;
  123592. }, doNotUpdateMaxZ?: boolean): void;
  123593. /**
  123594. * @override
  123595. * Override Camera.createRigCamera
  123596. */
  123597. createRigCamera(name: string, cameraIndex: number): Camera;
  123598. /**
  123599. * @hidden
  123600. * @override
  123601. * Override Camera._updateRigCameras
  123602. */
  123603. _updateRigCameras(): void;
  123604. /**
  123605. * Destroy the camera and release the current resources hold by it.
  123606. */
  123607. dispose(): void;
  123608. /**
  123609. * Gets the current object class name.
  123610. * @return the class name
  123611. */
  123612. getClassName(): string;
  123613. }
  123614. }
  123615. declare module BABYLON {
  123616. /**
  123617. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123618. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123619. */
  123620. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123621. /**
  123622. * Gets the name of the behavior.
  123623. */
  123624. get name(): string;
  123625. private _zoomStopsAnimation;
  123626. private _idleRotationSpeed;
  123627. private _idleRotationWaitTime;
  123628. private _idleRotationSpinupTime;
  123629. /**
  123630. * Sets the flag that indicates if user zooming should stop animation.
  123631. */
  123632. set zoomStopsAnimation(flag: boolean);
  123633. /**
  123634. * Gets the flag that indicates if user zooming should stop animation.
  123635. */
  123636. get zoomStopsAnimation(): boolean;
  123637. /**
  123638. * Sets the default speed at which the camera rotates around the model.
  123639. */
  123640. set idleRotationSpeed(speed: number);
  123641. /**
  123642. * Gets the default speed at which the camera rotates around the model.
  123643. */
  123644. get idleRotationSpeed(): number;
  123645. /**
  123646. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123647. */
  123648. set idleRotationWaitTime(time: number);
  123649. /**
  123650. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123651. */
  123652. get idleRotationWaitTime(): number;
  123653. /**
  123654. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123655. */
  123656. set idleRotationSpinupTime(time: number);
  123657. /**
  123658. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123659. */
  123660. get idleRotationSpinupTime(): number;
  123661. /**
  123662. * Gets a value indicating if the camera is currently rotating because of this behavior
  123663. */
  123664. get rotationInProgress(): boolean;
  123665. private _onPrePointerObservableObserver;
  123666. private _onAfterCheckInputsObserver;
  123667. private _attachedCamera;
  123668. private _isPointerDown;
  123669. private _lastFrameTime;
  123670. private _lastInteractionTime;
  123671. private _cameraRotationSpeed;
  123672. /**
  123673. * Initializes the behavior.
  123674. */
  123675. init(): void;
  123676. /**
  123677. * Attaches the behavior to its arc rotate camera.
  123678. * @param camera Defines the camera to attach the behavior to
  123679. */
  123680. attach(camera: ArcRotateCamera): void;
  123681. /**
  123682. * Detaches the behavior from its current arc rotate camera.
  123683. */
  123684. detach(): void;
  123685. /**
  123686. * Returns true if user is scrolling.
  123687. * @return true if user is scrolling.
  123688. */
  123689. private _userIsZooming;
  123690. private _lastFrameRadius;
  123691. private _shouldAnimationStopForInteraction;
  123692. /**
  123693. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123694. */
  123695. private _applyUserInteraction;
  123696. private _userIsMoving;
  123697. }
  123698. }
  123699. declare module BABYLON {
  123700. /**
  123701. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123702. */
  123703. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123704. private ui;
  123705. /**
  123706. * The name of the behavior
  123707. */
  123708. name: string;
  123709. /**
  123710. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123711. */
  123712. distanceAwayFromFace: number;
  123713. /**
  123714. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123715. */
  123716. distanceAwayFromBottomOfFace: number;
  123717. private _faceVectors;
  123718. private _target;
  123719. private _scene;
  123720. private _onRenderObserver;
  123721. private _tmpMatrix;
  123722. private _tmpVector;
  123723. /**
  123724. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123725. * @param ui The transform node that should be attched to the mesh
  123726. */
  123727. constructor(ui: TransformNode);
  123728. /**
  123729. * Initializes the behavior
  123730. */
  123731. init(): void;
  123732. private _closestFace;
  123733. private _zeroVector;
  123734. private _lookAtTmpMatrix;
  123735. private _lookAtToRef;
  123736. /**
  123737. * Attaches the AttachToBoxBehavior to the passed in mesh
  123738. * @param target The mesh that the specified node will be attached to
  123739. */
  123740. attach(target: Mesh): void;
  123741. /**
  123742. * Detaches the behavior from the mesh
  123743. */
  123744. detach(): void;
  123745. }
  123746. }
  123747. declare module BABYLON {
  123748. /**
  123749. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123750. */
  123751. export class FadeInOutBehavior implements Behavior<Mesh> {
  123752. /**
  123753. * Time in milliseconds to delay before fading in (Default: 0)
  123754. */
  123755. delay: number;
  123756. /**
  123757. * Time in milliseconds for the mesh to fade in (Default: 300)
  123758. */
  123759. fadeInTime: number;
  123760. private _millisecondsPerFrame;
  123761. private _hovered;
  123762. private _hoverValue;
  123763. private _ownerNode;
  123764. /**
  123765. * Instatiates the FadeInOutBehavior
  123766. */
  123767. constructor();
  123768. /**
  123769. * The name of the behavior
  123770. */
  123771. get name(): string;
  123772. /**
  123773. * Initializes the behavior
  123774. */
  123775. init(): void;
  123776. /**
  123777. * Attaches the fade behavior on the passed in mesh
  123778. * @param ownerNode The mesh that will be faded in/out once attached
  123779. */
  123780. attach(ownerNode: Mesh): void;
  123781. /**
  123782. * Detaches the behavior from the mesh
  123783. */
  123784. detach(): void;
  123785. /**
  123786. * Triggers the mesh to begin fading in or out
  123787. * @param value if the object should fade in or out (true to fade in)
  123788. */
  123789. fadeIn(value: boolean): void;
  123790. private _update;
  123791. private _setAllVisibility;
  123792. }
  123793. }
  123794. declare module BABYLON {
  123795. /**
  123796. * Class containing a set of static utilities functions for managing Pivots
  123797. * @hidden
  123798. */
  123799. export class PivotTools {
  123800. private static _PivotCached;
  123801. private static _OldPivotPoint;
  123802. private static _PivotTranslation;
  123803. private static _PivotTmpVector;
  123804. private static _PivotPostMultiplyPivotMatrix;
  123805. /** @hidden */
  123806. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123807. /** @hidden */
  123808. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123809. }
  123810. }
  123811. declare module BABYLON {
  123812. /**
  123813. * Class containing static functions to help procedurally build meshes
  123814. */
  123815. export class PlaneBuilder {
  123816. /**
  123817. * Creates a plane mesh
  123818. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123819. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123820. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123824. * @param name defines the name of the mesh
  123825. * @param options defines the options used to create the mesh
  123826. * @param scene defines the hosting scene
  123827. * @returns the plane mesh
  123828. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123829. */
  123830. static CreatePlane(name: string, options: {
  123831. size?: number;
  123832. width?: number;
  123833. height?: number;
  123834. sideOrientation?: number;
  123835. frontUVs?: Vector4;
  123836. backUVs?: Vector4;
  123837. updatable?: boolean;
  123838. sourcePlane?: Plane;
  123839. }, scene?: Nullable<Scene>): Mesh;
  123840. }
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123845. */
  123846. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123847. private static _AnyMouseID;
  123848. /**
  123849. * Abstract mesh the behavior is set on
  123850. */
  123851. attachedNode: AbstractMesh;
  123852. private _dragPlane;
  123853. private _scene;
  123854. private _pointerObserver;
  123855. private _beforeRenderObserver;
  123856. private static _planeScene;
  123857. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123858. /**
  123859. * 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)
  123860. */
  123861. maxDragAngle: number;
  123862. /**
  123863. * @hidden
  123864. */
  123865. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123866. /**
  123867. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123868. */
  123869. currentDraggingPointerID: number;
  123870. /**
  123871. * The last position where the pointer hit the drag plane in world space
  123872. */
  123873. lastDragPosition: Vector3;
  123874. /**
  123875. * If the behavior is currently in a dragging state
  123876. */
  123877. dragging: boolean;
  123878. /**
  123879. * 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)
  123880. */
  123881. dragDeltaRatio: number;
  123882. /**
  123883. * If the drag plane orientation should be updated during the dragging (Default: true)
  123884. */
  123885. updateDragPlane: boolean;
  123886. private _debugMode;
  123887. private _moving;
  123888. /**
  123889. * Fires each time the attached mesh is dragged with the pointer
  123890. * * delta between last drag position and current drag position in world space
  123891. * * dragDistance along the drag axis
  123892. * * dragPlaneNormal normal of the current drag plane used during the drag
  123893. * * dragPlanePoint in world space where the drag intersects the drag plane
  123894. */
  123895. onDragObservable: Observable<{
  123896. delta: Vector3;
  123897. dragPlanePoint: Vector3;
  123898. dragPlaneNormal: Vector3;
  123899. dragDistance: number;
  123900. pointerId: number;
  123901. }>;
  123902. /**
  123903. * Fires each time a drag begins (eg. mouse down on mesh)
  123904. */
  123905. onDragStartObservable: Observable<{
  123906. dragPlanePoint: Vector3;
  123907. pointerId: number;
  123908. }>;
  123909. /**
  123910. * Fires each time a drag ends (eg. mouse release after drag)
  123911. */
  123912. onDragEndObservable: Observable<{
  123913. dragPlanePoint: Vector3;
  123914. pointerId: number;
  123915. }>;
  123916. /**
  123917. * If the attached mesh should be moved when dragged
  123918. */
  123919. moveAttached: boolean;
  123920. /**
  123921. * If the drag behavior will react to drag events (Default: true)
  123922. */
  123923. enabled: boolean;
  123924. /**
  123925. * If pointer events should start and release the drag (Default: true)
  123926. */
  123927. startAndReleaseDragOnPointerEvents: boolean;
  123928. /**
  123929. * If camera controls should be detached during the drag
  123930. */
  123931. detachCameraControls: boolean;
  123932. /**
  123933. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123934. */
  123935. useObjectOrientationForDragging: boolean;
  123936. private _options;
  123937. /**
  123938. * Gets the options used by the behavior
  123939. */
  123940. get options(): {
  123941. dragAxis?: Vector3;
  123942. dragPlaneNormal?: Vector3;
  123943. };
  123944. /**
  123945. * Sets the options used by the behavior
  123946. */
  123947. set options(options: {
  123948. dragAxis?: Vector3;
  123949. dragPlaneNormal?: Vector3;
  123950. });
  123951. /**
  123952. * Creates a pointer drag behavior that can be attached to a mesh
  123953. * @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)
  123954. */
  123955. constructor(options?: {
  123956. dragAxis?: Vector3;
  123957. dragPlaneNormal?: Vector3;
  123958. });
  123959. /**
  123960. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123961. */
  123962. validateDrag: (targetPosition: Vector3) => boolean;
  123963. /**
  123964. * The name of the behavior
  123965. */
  123966. get name(): string;
  123967. /**
  123968. * Initializes the behavior
  123969. */
  123970. init(): void;
  123971. private _tmpVector;
  123972. private _alternatePickedPoint;
  123973. private _worldDragAxis;
  123974. private _targetPosition;
  123975. private _attachedElement;
  123976. /**
  123977. * Attaches the drag behavior the passed in mesh
  123978. * @param ownerNode The mesh that will be dragged around once attached
  123979. * @param predicate Predicate to use for pick filtering
  123980. */
  123981. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123982. /**
  123983. * Force relase the drag action by code.
  123984. */
  123985. releaseDrag(): void;
  123986. private _startDragRay;
  123987. private _lastPointerRay;
  123988. /**
  123989. * Simulates the start of a pointer drag event on the behavior
  123990. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123991. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123992. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123993. */
  123994. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123995. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123996. private _dragDelta;
  123997. protected _moveDrag(ray: Ray): void;
  123998. private _pickWithRayOnDragPlane;
  123999. private _pointA;
  124000. private _pointC;
  124001. private _localAxis;
  124002. private _lookAt;
  124003. private _updateDragPlanePosition;
  124004. /**
  124005. * Detaches the behavior from the mesh
  124006. */
  124007. detach(): void;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /**
  124012. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124013. */
  124014. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124015. private _dragBehaviorA;
  124016. private _dragBehaviorB;
  124017. private _startDistance;
  124018. private _initialScale;
  124019. private _targetScale;
  124020. private _ownerNode;
  124021. private _sceneRenderObserver;
  124022. /**
  124023. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124024. */
  124025. constructor();
  124026. /**
  124027. * The name of the behavior
  124028. */
  124029. get name(): string;
  124030. /**
  124031. * Initializes the behavior
  124032. */
  124033. init(): void;
  124034. private _getCurrentDistance;
  124035. /**
  124036. * Attaches the scale behavior the passed in mesh
  124037. * @param ownerNode The mesh that will be scaled around once attached
  124038. */
  124039. attach(ownerNode: Mesh): void;
  124040. /**
  124041. * Detaches the behavior from the mesh
  124042. */
  124043. detach(): void;
  124044. }
  124045. }
  124046. declare module BABYLON {
  124047. /**
  124048. * 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
  124049. */
  124050. export class SixDofDragBehavior implements Behavior<Mesh> {
  124051. private static _virtualScene;
  124052. private _ownerNode;
  124053. private _sceneRenderObserver;
  124054. private _scene;
  124055. private _targetPosition;
  124056. private _virtualOriginMesh;
  124057. private _virtualDragMesh;
  124058. private _pointerObserver;
  124059. private _moving;
  124060. private _startingOrientation;
  124061. private _attachedElement;
  124062. /**
  124063. * 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)
  124064. */
  124065. private zDragFactor;
  124066. /**
  124067. * If the object should rotate to face the drag origin
  124068. */
  124069. rotateDraggedObject: boolean;
  124070. /**
  124071. * If the behavior is currently in a dragging state
  124072. */
  124073. dragging: boolean;
  124074. /**
  124075. * 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)
  124076. */
  124077. dragDeltaRatio: number;
  124078. /**
  124079. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124080. */
  124081. currentDraggingPointerID: number;
  124082. /**
  124083. * If camera controls should be detached during the drag
  124084. */
  124085. detachCameraControls: boolean;
  124086. /**
  124087. * Fires each time a drag starts
  124088. */
  124089. onDragStartObservable: Observable<{}>;
  124090. /**
  124091. * Fires each time a drag ends (eg. mouse release after drag)
  124092. */
  124093. onDragEndObservable: Observable<{}>;
  124094. /**
  124095. * 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
  124096. */
  124097. constructor();
  124098. /**
  124099. * The name of the behavior
  124100. */
  124101. get name(): string;
  124102. /**
  124103. * Initializes the behavior
  124104. */
  124105. init(): void;
  124106. /**
  124107. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124108. */
  124109. private get _pointerCamera();
  124110. /**
  124111. * Attaches the scale behavior the passed in mesh
  124112. * @param ownerNode The mesh that will be scaled around once attached
  124113. */
  124114. attach(ownerNode: Mesh): void;
  124115. /**
  124116. * Detaches the behavior from the mesh
  124117. */
  124118. detach(): void;
  124119. }
  124120. }
  124121. declare module BABYLON {
  124122. /**
  124123. * Class used to apply inverse kinematics to bones
  124124. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124125. */
  124126. export class BoneIKController {
  124127. private static _tmpVecs;
  124128. private static _tmpQuat;
  124129. private static _tmpMats;
  124130. /**
  124131. * Gets or sets the target mesh
  124132. */
  124133. targetMesh: AbstractMesh;
  124134. /** Gets or sets the mesh used as pole */
  124135. poleTargetMesh: AbstractMesh;
  124136. /**
  124137. * Gets or sets the bone used as pole
  124138. */
  124139. poleTargetBone: Nullable<Bone>;
  124140. /**
  124141. * Gets or sets the target position
  124142. */
  124143. targetPosition: Vector3;
  124144. /**
  124145. * Gets or sets the pole target position
  124146. */
  124147. poleTargetPosition: Vector3;
  124148. /**
  124149. * Gets or sets the pole target local offset
  124150. */
  124151. poleTargetLocalOffset: Vector3;
  124152. /**
  124153. * Gets or sets the pole angle
  124154. */
  124155. poleAngle: number;
  124156. /**
  124157. * Gets or sets the mesh associated with the controller
  124158. */
  124159. mesh: AbstractMesh;
  124160. /**
  124161. * 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)
  124162. */
  124163. slerpAmount: number;
  124164. private _bone1Quat;
  124165. private _bone1Mat;
  124166. private _bone2Ang;
  124167. private _bone1;
  124168. private _bone2;
  124169. private _bone1Length;
  124170. private _bone2Length;
  124171. private _maxAngle;
  124172. private _maxReach;
  124173. private _rightHandedSystem;
  124174. private _bendAxis;
  124175. private _slerping;
  124176. private _adjustRoll;
  124177. /**
  124178. * Gets or sets maximum allowed angle
  124179. */
  124180. get maxAngle(): number;
  124181. set maxAngle(value: number);
  124182. /**
  124183. * Creates a new BoneIKController
  124184. * @param mesh defines the mesh to control
  124185. * @param bone defines the bone to control
  124186. * @param options defines options to set up the controller
  124187. */
  124188. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124189. targetMesh?: AbstractMesh;
  124190. poleTargetMesh?: AbstractMesh;
  124191. poleTargetBone?: Bone;
  124192. poleTargetLocalOffset?: Vector3;
  124193. poleAngle?: number;
  124194. bendAxis?: Vector3;
  124195. maxAngle?: number;
  124196. slerpAmount?: number;
  124197. });
  124198. private _setMaxAngle;
  124199. /**
  124200. * Force the controller to update the bones
  124201. */
  124202. update(): void;
  124203. }
  124204. }
  124205. declare module BABYLON {
  124206. /**
  124207. * Class used to make a bone look toward a point in space
  124208. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124209. */
  124210. export class BoneLookController {
  124211. private static _tmpVecs;
  124212. private static _tmpQuat;
  124213. private static _tmpMats;
  124214. /**
  124215. * The target Vector3 that the bone will look at
  124216. */
  124217. target: Vector3;
  124218. /**
  124219. * The mesh that the bone is attached to
  124220. */
  124221. mesh: AbstractMesh;
  124222. /**
  124223. * The bone that will be looking to the target
  124224. */
  124225. bone: Bone;
  124226. /**
  124227. * The up axis of the coordinate system that is used when the bone is rotated
  124228. */
  124229. upAxis: Vector3;
  124230. /**
  124231. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124232. */
  124233. upAxisSpace: Space;
  124234. /**
  124235. * Used to make an adjustment to the yaw of the bone
  124236. */
  124237. adjustYaw: number;
  124238. /**
  124239. * Used to make an adjustment to the pitch of the bone
  124240. */
  124241. adjustPitch: number;
  124242. /**
  124243. * Used to make an adjustment to the roll of the bone
  124244. */
  124245. adjustRoll: number;
  124246. /**
  124247. * 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)
  124248. */
  124249. slerpAmount: number;
  124250. private _minYaw;
  124251. private _maxYaw;
  124252. private _minPitch;
  124253. private _maxPitch;
  124254. private _minYawSin;
  124255. private _minYawCos;
  124256. private _maxYawSin;
  124257. private _maxYawCos;
  124258. private _midYawConstraint;
  124259. private _minPitchTan;
  124260. private _maxPitchTan;
  124261. private _boneQuat;
  124262. private _slerping;
  124263. private _transformYawPitch;
  124264. private _transformYawPitchInv;
  124265. private _firstFrameSkipped;
  124266. private _yawRange;
  124267. private _fowardAxis;
  124268. /**
  124269. * Gets or sets the minimum yaw angle that the bone can look to
  124270. */
  124271. get minYaw(): number;
  124272. set minYaw(value: number);
  124273. /**
  124274. * Gets or sets the maximum yaw angle that the bone can look to
  124275. */
  124276. get maxYaw(): number;
  124277. set maxYaw(value: number);
  124278. /**
  124279. * Gets or sets the minimum pitch angle that the bone can look to
  124280. */
  124281. get minPitch(): number;
  124282. set minPitch(value: number);
  124283. /**
  124284. * Gets or sets the maximum pitch angle that the bone can look to
  124285. */
  124286. get maxPitch(): number;
  124287. set maxPitch(value: number);
  124288. /**
  124289. * Create a BoneLookController
  124290. * @param mesh the mesh that the bone belongs to
  124291. * @param bone the bone that will be looking to the target
  124292. * @param target the target Vector3 to look at
  124293. * @param options optional settings:
  124294. * * maxYaw: the maximum angle the bone will yaw to
  124295. * * minYaw: the minimum angle the bone will yaw to
  124296. * * maxPitch: the maximum angle the bone will pitch to
  124297. * * minPitch: the minimum angle the bone will yaw to
  124298. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124299. * * upAxis: the up axis of the coordinate system
  124300. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124301. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124302. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124303. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124304. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124305. * * adjustRoll: used to make an adjustment to the roll of the bone
  124306. **/
  124307. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124308. maxYaw?: number;
  124309. minYaw?: number;
  124310. maxPitch?: number;
  124311. minPitch?: number;
  124312. slerpAmount?: number;
  124313. upAxis?: Vector3;
  124314. upAxisSpace?: Space;
  124315. yawAxis?: Vector3;
  124316. pitchAxis?: Vector3;
  124317. adjustYaw?: number;
  124318. adjustPitch?: number;
  124319. adjustRoll?: number;
  124320. });
  124321. /**
  124322. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124323. */
  124324. update(): void;
  124325. private _getAngleDiff;
  124326. private _getAngleBetween;
  124327. private _isAngleBetween;
  124328. }
  124329. }
  124330. declare module BABYLON {
  124331. /**
  124332. * Manage the gamepad inputs to control an arc rotate camera.
  124333. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124334. */
  124335. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124336. /**
  124337. * Defines the camera the input is attached to.
  124338. */
  124339. camera: ArcRotateCamera;
  124340. /**
  124341. * Defines the gamepad the input is gathering event from.
  124342. */
  124343. gamepad: Nullable<Gamepad>;
  124344. /**
  124345. * Defines the gamepad rotation sensiblity.
  124346. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124347. */
  124348. gamepadRotationSensibility: number;
  124349. /**
  124350. * Defines the gamepad move sensiblity.
  124351. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124352. */
  124353. gamepadMoveSensibility: number;
  124354. private _yAxisScale;
  124355. /**
  124356. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124357. */
  124358. get invertYAxis(): boolean;
  124359. set invertYAxis(value: boolean);
  124360. private _onGamepadConnectedObserver;
  124361. private _onGamepadDisconnectedObserver;
  124362. /**
  124363. * Attach the input controls to a specific dom element to get the input from.
  124364. * @param element Defines the element the controls should be listened from
  124365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124366. */
  124367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124368. /**
  124369. * Detach the current controls from the specified dom element.
  124370. * @param element Defines the element to stop listening the inputs from
  124371. */
  124372. detachControl(element: Nullable<HTMLElement>): void;
  124373. /**
  124374. * Update the current camera state depending on the inputs that have been used this frame.
  124375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124376. */
  124377. checkInputs(): void;
  124378. /**
  124379. * Gets the class name of the current intput.
  124380. * @returns the class name
  124381. */
  124382. getClassName(): string;
  124383. /**
  124384. * Get the friendly name associated with the input class.
  124385. * @returns the input friendly name
  124386. */
  124387. getSimpleName(): string;
  124388. }
  124389. }
  124390. declare module BABYLON {
  124391. interface ArcRotateCameraInputsManager {
  124392. /**
  124393. * Add orientation input support to the input manager.
  124394. * @returns the current input manager
  124395. */
  124396. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124397. }
  124398. /**
  124399. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124401. */
  124402. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124403. /**
  124404. * Defines the camera the input is attached to.
  124405. */
  124406. camera: ArcRotateCamera;
  124407. /**
  124408. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124409. */
  124410. alphaCorrection: number;
  124411. /**
  124412. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124413. */
  124414. gammaCorrection: number;
  124415. private _alpha;
  124416. private _gamma;
  124417. private _dirty;
  124418. private _deviceOrientationHandler;
  124419. /**
  124420. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124421. */
  124422. constructor();
  124423. /**
  124424. * Attach the input controls to a specific dom element to get the input from.
  124425. * @param element Defines the element the controls should be listened from
  124426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124427. */
  124428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124429. /** @hidden */
  124430. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124431. /**
  124432. * Update the current camera state depending on the inputs that have been used this frame.
  124433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124434. */
  124435. checkInputs(): void;
  124436. /**
  124437. * Detach the current controls from the specified dom element.
  124438. * @param element Defines the element to stop listening the inputs from
  124439. */
  124440. detachControl(element: Nullable<HTMLElement>): void;
  124441. /**
  124442. * Gets the class name of the current intput.
  124443. * @returns the class name
  124444. */
  124445. getClassName(): string;
  124446. /**
  124447. * Get the friendly name associated with the input class.
  124448. * @returns the input friendly name
  124449. */
  124450. getSimpleName(): string;
  124451. }
  124452. }
  124453. declare module BABYLON {
  124454. /**
  124455. * Listen to mouse events to control the camera.
  124456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124457. */
  124458. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124459. /**
  124460. * Defines the camera the input is attached to.
  124461. */
  124462. camera: FlyCamera;
  124463. /**
  124464. * Defines if touch is enabled. (Default is true.)
  124465. */
  124466. touchEnabled: boolean;
  124467. /**
  124468. * Defines the buttons associated with the input to handle camera rotation.
  124469. */
  124470. buttons: number[];
  124471. /**
  124472. * Assign buttons for Yaw control.
  124473. */
  124474. buttonsYaw: number[];
  124475. /**
  124476. * Assign buttons for Pitch control.
  124477. */
  124478. buttonsPitch: number[];
  124479. /**
  124480. * Assign buttons for Roll control.
  124481. */
  124482. buttonsRoll: number[];
  124483. /**
  124484. * Detect if any button is being pressed while mouse is moved.
  124485. * -1 = Mouse locked.
  124486. * 0 = Left button.
  124487. * 1 = Middle Button.
  124488. * 2 = Right Button.
  124489. */
  124490. activeButton: number;
  124491. /**
  124492. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124493. * Higher values reduce its sensitivity.
  124494. */
  124495. angularSensibility: number;
  124496. private _mousemoveCallback;
  124497. private _observer;
  124498. private _rollObserver;
  124499. private previousPosition;
  124500. private noPreventDefault;
  124501. private element;
  124502. /**
  124503. * Listen to mouse events to control the camera.
  124504. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124505. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124506. */
  124507. constructor(touchEnabled?: boolean);
  124508. /**
  124509. * Attach the mouse control to the HTML DOM element.
  124510. * @param element Defines the element that listens to the input events.
  124511. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124512. */
  124513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124514. /**
  124515. * Detach the current controls from the specified dom element.
  124516. * @param element Defines the element to stop listening the inputs from
  124517. */
  124518. detachControl(element: Nullable<HTMLElement>): void;
  124519. /**
  124520. * Gets the class name of the current input.
  124521. * @returns the class name.
  124522. */
  124523. getClassName(): string;
  124524. /**
  124525. * Get the friendly name associated with the input class.
  124526. * @returns the input's friendly name.
  124527. */
  124528. getSimpleName(): string;
  124529. private _pointerInput;
  124530. private _onMouseMove;
  124531. /**
  124532. * Rotate camera by mouse offset.
  124533. */
  124534. private rotateCamera;
  124535. }
  124536. }
  124537. declare module BABYLON {
  124538. /**
  124539. * Default Inputs manager for the FlyCamera.
  124540. * It groups all the default supported inputs for ease of use.
  124541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124542. */
  124543. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124544. /**
  124545. * Instantiates a new FlyCameraInputsManager.
  124546. * @param camera Defines the camera the inputs belong to.
  124547. */
  124548. constructor(camera: FlyCamera);
  124549. /**
  124550. * Add keyboard input support to the input manager.
  124551. * @returns the new FlyCameraKeyboardMoveInput().
  124552. */
  124553. addKeyboard(): FlyCameraInputsManager;
  124554. /**
  124555. * Add mouse input support to the input manager.
  124556. * @param touchEnabled Enable touch screen support.
  124557. * @returns the new FlyCameraMouseInput().
  124558. */
  124559. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124560. }
  124561. }
  124562. declare module BABYLON {
  124563. /**
  124564. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124565. * such as in a 3D Space Shooter or a Flight Simulator.
  124566. */
  124567. export class FlyCamera extends TargetCamera {
  124568. /**
  124569. * Define the collision ellipsoid of the camera.
  124570. * This is helpful for simulating a camera body, like a player's body.
  124571. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124572. */
  124573. ellipsoid: Vector3;
  124574. /**
  124575. * Define an offset for the position of the ellipsoid around the camera.
  124576. * This can be helpful if the camera is attached away from the player's body center,
  124577. * such as at its head.
  124578. */
  124579. ellipsoidOffset: Vector3;
  124580. /**
  124581. * Enable or disable collisions of the camera with the rest of the scene objects.
  124582. */
  124583. checkCollisions: boolean;
  124584. /**
  124585. * Enable or disable gravity on the camera.
  124586. */
  124587. applyGravity: boolean;
  124588. /**
  124589. * Define the current direction the camera is moving to.
  124590. */
  124591. cameraDirection: Vector3;
  124592. /**
  124593. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124594. * This overrides and empties cameraRotation.
  124595. */
  124596. rotationQuaternion: Quaternion;
  124597. /**
  124598. * Track Roll to maintain the wanted Rolling when looking around.
  124599. */
  124600. _trackRoll: number;
  124601. /**
  124602. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124603. */
  124604. rollCorrect: number;
  124605. /**
  124606. * Mimic a banked turn, Rolling the camera when Yawing.
  124607. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124608. */
  124609. bankedTurn: boolean;
  124610. /**
  124611. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124612. */
  124613. bankedTurnLimit: number;
  124614. /**
  124615. * Value of 0 disables the banked Roll.
  124616. * Value of 1 is equal to the Yaw angle in radians.
  124617. */
  124618. bankedTurnMultiplier: number;
  124619. /**
  124620. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124621. */
  124622. inputs: FlyCameraInputsManager;
  124623. /**
  124624. * Gets the input sensibility for mouse input.
  124625. * Higher values reduce sensitivity.
  124626. */
  124627. get angularSensibility(): number;
  124628. /**
  124629. * Sets the input sensibility for a mouse input.
  124630. * Higher values reduce sensitivity.
  124631. */
  124632. set angularSensibility(value: number);
  124633. /**
  124634. * Get the keys for camera movement forward.
  124635. */
  124636. get keysForward(): number[];
  124637. /**
  124638. * Set the keys for camera movement forward.
  124639. */
  124640. set keysForward(value: number[]);
  124641. /**
  124642. * Get the keys for camera movement backward.
  124643. */
  124644. get keysBackward(): number[];
  124645. set keysBackward(value: number[]);
  124646. /**
  124647. * Get the keys for camera movement up.
  124648. */
  124649. get keysUp(): number[];
  124650. /**
  124651. * Set the keys for camera movement up.
  124652. */
  124653. set keysUp(value: number[]);
  124654. /**
  124655. * Get the keys for camera movement down.
  124656. */
  124657. get keysDown(): number[];
  124658. /**
  124659. * Set the keys for camera movement down.
  124660. */
  124661. set keysDown(value: number[]);
  124662. /**
  124663. * Get the keys for camera movement left.
  124664. */
  124665. get keysLeft(): number[];
  124666. /**
  124667. * Set the keys for camera movement left.
  124668. */
  124669. set keysLeft(value: number[]);
  124670. /**
  124671. * Set the keys for camera movement right.
  124672. */
  124673. get keysRight(): number[];
  124674. /**
  124675. * Set the keys for camera movement right.
  124676. */
  124677. set keysRight(value: number[]);
  124678. /**
  124679. * Event raised when the camera collides with a mesh in the scene.
  124680. */
  124681. onCollide: (collidedMesh: AbstractMesh) => void;
  124682. private _collider;
  124683. private _needMoveForGravity;
  124684. private _oldPosition;
  124685. private _diffPosition;
  124686. private _newPosition;
  124687. /** @hidden */
  124688. _localDirection: Vector3;
  124689. /** @hidden */
  124690. _transformedDirection: Vector3;
  124691. /**
  124692. * Instantiates a FlyCamera.
  124693. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124694. * such as in a 3D Space Shooter or a Flight Simulator.
  124695. * @param name Define the name of the camera in the scene.
  124696. * @param position Define the starting position of the camera in the scene.
  124697. * @param scene Define the scene the camera belongs to.
  124698. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124699. */
  124700. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124701. /**
  124702. * Attach a control to the HTML DOM element.
  124703. * @param element Defines the element that listens to the input events.
  124704. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124705. */
  124706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124707. /**
  124708. * Detach a control from the HTML DOM element.
  124709. * The camera will stop reacting to that input.
  124710. * @param element Defines the element that listens to the input events.
  124711. */
  124712. detachControl(element: HTMLElement): void;
  124713. private _collisionMask;
  124714. /**
  124715. * Get the mask that the camera ignores in collision events.
  124716. */
  124717. get collisionMask(): number;
  124718. /**
  124719. * Set the mask that the camera ignores in collision events.
  124720. */
  124721. set collisionMask(mask: number);
  124722. /** @hidden */
  124723. _collideWithWorld(displacement: Vector3): void;
  124724. /** @hidden */
  124725. private _onCollisionPositionChange;
  124726. /** @hidden */
  124727. _checkInputs(): void;
  124728. /** @hidden */
  124729. _decideIfNeedsToMove(): boolean;
  124730. /** @hidden */
  124731. _updatePosition(): void;
  124732. /**
  124733. * Restore the Roll to its target value at the rate specified.
  124734. * @param rate - Higher means slower restoring.
  124735. * @hidden
  124736. */
  124737. restoreRoll(rate: number): void;
  124738. /**
  124739. * Destroy the camera and release the current resources held by it.
  124740. */
  124741. dispose(): void;
  124742. /**
  124743. * Get the current object class name.
  124744. * @returns the class name.
  124745. */
  124746. getClassName(): string;
  124747. }
  124748. }
  124749. declare module BABYLON {
  124750. /**
  124751. * Listen to keyboard events to control the camera.
  124752. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124753. */
  124754. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124755. /**
  124756. * Defines the camera the input is attached to.
  124757. */
  124758. camera: FlyCamera;
  124759. /**
  124760. * The list of keyboard keys used to control the forward move of the camera.
  124761. */
  124762. keysForward: number[];
  124763. /**
  124764. * The list of keyboard keys used to control the backward move of the camera.
  124765. */
  124766. keysBackward: number[];
  124767. /**
  124768. * The list of keyboard keys used to control the forward move of the camera.
  124769. */
  124770. keysUp: number[];
  124771. /**
  124772. * The list of keyboard keys used to control the backward move of the camera.
  124773. */
  124774. keysDown: number[];
  124775. /**
  124776. * The list of keyboard keys used to control the right strafe move of the camera.
  124777. */
  124778. keysRight: number[];
  124779. /**
  124780. * The list of keyboard keys used to control the left strafe move of the camera.
  124781. */
  124782. keysLeft: number[];
  124783. private _keys;
  124784. private _onCanvasBlurObserver;
  124785. private _onKeyboardObserver;
  124786. private _engine;
  124787. private _scene;
  124788. /**
  124789. * Attach the input controls to a specific dom element to get the input from.
  124790. * @param element Defines the element the controls should be listened from
  124791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124792. */
  124793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124794. /**
  124795. * Detach the current controls from the specified dom element.
  124796. * @param element Defines the element to stop listening the inputs from
  124797. */
  124798. detachControl(element: Nullable<HTMLElement>): void;
  124799. /**
  124800. * Gets the class name of the current intput.
  124801. * @returns the class name
  124802. */
  124803. getClassName(): string;
  124804. /** @hidden */
  124805. _onLostFocus(e: FocusEvent): void;
  124806. /**
  124807. * Get the friendly name associated with the input class.
  124808. * @returns the input friendly name
  124809. */
  124810. getSimpleName(): string;
  124811. /**
  124812. * Update the current camera state depending on the inputs that have been used this frame.
  124813. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124814. */
  124815. checkInputs(): void;
  124816. }
  124817. }
  124818. declare module BABYLON {
  124819. /**
  124820. * Manage the mouse wheel inputs to control a follow camera.
  124821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124822. */
  124823. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124824. /**
  124825. * Defines the camera the input is attached to.
  124826. */
  124827. camera: FollowCamera;
  124828. /**
  124829. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124830. */
  124831. axisControlRadius: boolean;
  124832. /**
  124833. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124834. */
  124835. axisControlHeight: boolean;
  124836. /**
  124837. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124838. */
  124839. axisControlRotation: boolean;
  124840. /**
  124841. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124842. * relation to mouseWheel events.
  124843. */
  124844. wheelPrecision: number;
  124845. /**
  124846. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124847. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124848. */
  124849. wheelDeltaPercentage: number;
  124850. private _wheel;
  124851. private _observer;
  124852. /**
  124853. * Attach the input controls to a specific dom element to get the input from.
  124854. * @param element Defines the element the controls should be listened from
  124855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124856. */
  124857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124858. /**
  124859. * Detach the current controls from the specified dom element.
  124860. * @param element Defines the element to stop listening the inputs from
  124861. */
  124862. detachControl(element: Nullable<HTMLElement>): void;
  124863. /**
  124864. * Gets the class name of the current intput.
  124865. * @returns the class name
  124866. */
  124867. getClassName(): string;
  124868. /**
  124869. * Get the friendly name associated with the input class.
  124870. * @returns the input friendly name
  124871. */
  124872. getSimpleName(): string;
  124873. }
  124874. }
  124875. declare module BABYLON {
  124876. /**
  124877. * Manage the pointers inputs to control an follow camera.
  124878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124879. */
  124880. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124881. /**
  124882. * Defines the camera the input is attached to.
  124883. */
  124884. camera: FollowCamera;
  124885. /**
  124886. * Gets the class name of the current input.
  124887. * @returns the class name
  124888. */
  124889. getClassName(): string;
  124890. /**
  124891. * Defines the pointer angular sensibility along the X axis or how fast is
  124892. * the camera rotating.
  124893. * A negative number will reverse the axis direction.
  124894. */
  124895. angularSensibilityX: number;
  124896. /**
  124897. * Defines the pointer angular sensibility along the Y axis or how fast is
  124898. * the camera rotating.
  124899. * A negative number will reverse the axis direction.
  124900. */
  124901. angularSensibilityY: number;
  124902. /**
  124903. * Defines the pointer pinch precision or how fast is the camera zooming.
  124904. * A negative number will reverse the axis direction.
  124905. */
  124906. pinchPrecision: number;
  124907. /**
  124908. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124909. * from 0.
  124910. * It defines the percentage of current camera.radius to use as delta when
  124911. * pinch zoom is used.
  124912. */
  124913. pinchDeltaPercentage: number;
  124914. /**
  124915. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124916. */
  124917. axisXControlRadius: boolean;
  124918. /**
  124919. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124920. */
  124921. axisXControlHeight: boolean;
  124922. /**
  124923. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124924. */
  124925. axisXControlRotation: boolean;
  124926. /**
  124927. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124928. */
  124929. axisYControlRadius: boolean;
  124930. /**
  124931. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124932. */
  124933. axisYControlHeight: boolean;
  124934. /**
  124935. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124936. */
  124937. axisYControlRotation: boolean;
  124938. /**
  124939. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124940. */
  124941. axisPinchControlRadius: boolean;
  124942. /**
  124943. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124944. */
  124945. axisPinchControlHeight: boolean;
  124946. /**
  124947. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124948. */
  124949. axisPinchControlRotation: boolean;
  124950. /**
  124951. * Log error messages if basic misconfiguration has occurred.
  124952. */
  124953. warningEnable: boolean;
  124954. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124955. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124956. private _warningCounter;
  124957. private _warning;
  124958. }
  124959. }
  124960. declare module BABYLON {
  124961. /**
  124962. * Default Inputs manager for the FollowCamera.
  124963. * It groups all the default supported inputs for ease of use.
  124964. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124965. */
  124966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124967. /**
  124968. * Instantiates a new FollowCameraInputsManager.
  124969. * @param camera Defines the camera the inputs belong to
  124970. */
  124971. constructor(camera: FollowCamera);
  124972. /**
  124973. * Add keyboard input support to the input manager.
  124974. * @returns the current input manager
  124975. */
  124976. addKeyboard(): FollowCameraInputsManager;
  124977. /**
  124978. * Add mouse wheel input support to the input manager.
  124979. * @returns the current input manager
  124980. */
  124981. addMouseWheel(): FollowCameraInputsManager;
  124982. /**
  124983. * Add pointers input support to the input manager.
  124984. * @returns the current input manager
  124985. */
  124986. addPointers(): FollowCameraInputsManager;
  124987. /**
  124988. * Add orientation input support to the input manager.
  124989. * @returns the current input manager
  124990. */
  124991. addVRDeviceOrientation(): FollowCameraInputsManager;
  124992. }
  124993. }
  124994. declare module BABYLON {
  124995. /**
  124996. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124997. * an arc rotate version arcFollowCamera are available.
  124998. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124999. */
  125000. export class FollowCamera extends TargetCamera {
  125001. /**
  125002. * Distance the follow camera should follow an object at
  125003. */
  125004. radius: number;
  125005. /**
  125006. * Minimum allowed distance of the camera to the axis of rotation
  125007. * (The camera can not get closer).
  125008. * This can help limiting how the Camera is able to move in the scene.
  125009. */
  125010. lowerRadiusLimit: Nullable<number>;
  125011. /**
  125012. * Maximum allowed distance of the camera to the axis of rotation
  125013. * (The camera can not get further).
  125014. * This can help limiting how the Camera is able to move in the scene.
  125015. */
  125016. upperRadiusLimit: Nullable<number>;
  125017. /**
  125018. * Define a rotation offset between the camera and the object it follows
  125019. */
  125020. rotationOffset: number;
  125021. /**
  125022. * Minimum allowed angle to camera position relative to target object.
  125023. * This can help limiting how the Camera is able to move in the scene.
  125024. */
  125025. lowerRotationOffsetLimit: Nullable<number>;
  125026. /**
  125027. * Maximum allowed angle to camera position relative to target object.
  125028. * This can help limiting how the Camera is able to move in the scene.
  125029. */
  125030. upperRotationOffsetLimit: Nullable<number>;
  125031. /**
  125032. * Define a height offset between the camera and the object it follows.
  125033. * It can help following an object from the top (like a car chaing a plane)
  125034. */
  125035. heightOffset: number;
  125036. /**
  125037. * Minimum allowed height of camera position relative to target object.
  125038. * This can help limiting how the Camera is able to move in the scene.
  125039. */
  125040. lowerHeightOffsetLimit: Nullable<number>;
  125041. /**
  125042. * Maximum allowed height of camera position relative to target object.
  125043. * This can help limiting how the Camera is able to move in the scene.
  125044. */
  125045. upperHeightOffsetLimit: Nullable<number>;
  125046. /**
  125047. * Define how fast the camera can accelerate to follow it s target.
  125048. */
  125049. cameraAcceleration: number;
  125050. /**
  125051. * Define the speed limit of the camera following an object.
  125052. */
  125053. maxCameraSpeed: number;
  125054. /**
  125055. * Define the target of the camera.
  125056. */
  125057. lockedTarget: Nullable<AbstractMesh>;
  125058. /**
  125059. * Defines the input associated with the camera.
  125060. */
  125061. inputs: FollowCameraInputsManager;
  125062. /**
  125063. * Instantiates the follow camera.
  125064. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125065. * @param name Define the name of the camera in the scene
  125066. * @param position Define the position of the camera
  125067. * @param scene Define the scene the camera belong to
  125068. * @param lockedTarget Define the target of the camera
  125069. */
  125070. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125071. private _follow;
  125072. /**
  125073. * Attached controls to the current camera.
  125074. * @param element Defines the element the controls should be listened from
  125075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125076. */
  125077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125078. /**
  125079. * Detach the current controls from the camera.
  125080. * The camera will stop reacting to inputs.
  125081. * @param element Defines the element to stop listening the inputs from
  125082. */
  125083. detachControl(element: HTMLElement): void;
  125084. /** @hidden */
  125085. _checkInputs(): void;
  125086. private _checkLimits;
  125087. /**
  125088. * Gets the camera class name.
  125089. * @returns the class name
  125090. */
  125091. getClassName(): string;
  125092. }
  125093. /**
  125094. * Arc Rotate version of the follow camera.
  125095. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125096. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125097. */
  125098. export class ArcFollowCamera extends TargetCamera {
  125099. /** The longitudinal angle of the camera */
  125100. alpha: number;
  125101. /** The latitudinal angle of the camera */
  125102. beta: number;
  125103. /** The radius of the camera from its target */
  125104. radius: number;
  125105. private _cartesianCoordinates;
  125106. /** Define the camera target (the mesh it should follow) */
  125107. private _meshTarget;
  125108. /**
  125109. * Instantiates a new ArcFollowCamera
  125110. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125111. * @param name Define the name of the camera
  125112. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125113. * @param beta Define the rotation angle of the camera around the elevation axis
  125114. * @param radius Define the radius of the camera from its target point
  125115. * @param target Define the target of the camera
  125116. * @param scene Define the scene the camera belongs to
  125117. */
  125118. constructor(name: string,
  125119. /** The longitudinal angle of the camera */
  125120. alpha: number,
  125121. /** The latitudinal angle of the camera */
  125122. beta: number,
  125123. /** The radius of the camera from its target */
  125124. radius: number,
  125125. /** Define the camera target (the mesh it should follow) */
  125126. target: Nullable<AbstractMesh>, scene: Scene);
  125127. private _follow;
  125128. /** @hidden */
  125129. _checkInputs(): void;
  125130. /**
  125131. * Returns the class name of the object.
  125132. * It is mostly used internally for serialization purposes.
  125133. */
  125134. getClassName(): string;
  125135. }
  125136. }
  125137. declare module BABYLON {
  125138. /**
  125139. * Manage the keyboard inputs to control the movement of a follow camera.
  125140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125141. */
  125142. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125143. /**
  125144. * Defines the camera the input is attached to.
  125145. */
  125146. camera: FollowCamera;
  125147. /**
  125148. * Defines the list of key codes associated with the up action (increase heightOffset)
  125149. */
  125150. keysHeightOffsetIncr: number[];
  125151. /**
  125152. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125153. */
  125154. keysHeightOffsetDecr: number[];
  125155. /**
  125156. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125157. */
  125158. keysHeightOffsetModifierAlt: boolean;
  125159. /**
  125160. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125161. */
  125162. keysHeightOffsetModifierCtrl: boolean;
  125163. /**
  125164. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125165. */
  125166. keysHeightOffsetModifierShift: boolean;
  125167. /**
  125168. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125169. */
  125170. keysRotationOffsetIncr: number[];
  125171. /**
  125172. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125173. */
  125174. keysRotationOffsetDecr: number[];
  125175. /**
  125176. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125177. */
  125178. keysRotationOffsetModifierAlt: boolean;
  125179. /**
  125180. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125181. */
  125182. keysRotationOffsetModifierCtrl: boolean;
  125183. /**
  125184. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125185. */
  125186. keysRotationOffsetModifierShift: boolean;
  125187. /**
  125188. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125189. */
  125190. keysRadiusIncr: number[];
  125191. /**
  125192. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125193. */
  125194. keysRadiusDecr: number[];
  125195. /**
  125196. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125197. */
  125198. keysRadiusModifierAlt: boolean;
  125199. /**
  125200. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125201. */
  125202. keysRadiusModifierCtrl: boolean;
  125203. /**
  125204. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125205. */
  125206. keysRadiusModifierShift: boolean;
  125207. /**
  125208. * Defines the rate of change of heightOffset.
  125209. */
  125210. heightSensibility: number;
  125211. /**
  125212. * Defines the rate of change of rotationOffset.
  125213. */
  125214. rotationSensibility: number;
  125215. /**
  125216. * Defines the rate of change of radius.
  125217. */
  125218. radiusSensibility: number;
  125219. private _keys;
  125220. private _ctrlPressed;
  125221. private _altPressed;
  125222. private _shiftPressed;
  125223. private _onCanvasBlurObserver;
  125224. private _onKeyboardObserver;
  125225. private _engine;
  125226. private _scene;
  125227. /**
  125228. * Attach the input controls to a specific dom element to get the input from.
  125229. * @param element Defines the element the controls should be listened from
  125230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125231. */
  125232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125233. /**
  125234. * Detach the current controls from the specified dom element.
  125235. * @param element Defines the element to stop listening the inputs from
  125236. */
  125237. detachControl(element: Nullable<HTMLElement>): void;
  125238. /**
  125239. * Update the current camera state depending on the inputs that have been used this frame.
  125240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125241. */
  125242. checkInputs(): void;
  125243. /**
  125244. * Gets the class name of the current input.
  125245. * @returns the class name
  125246. */
  125247. getClassName(): string;
  125248. /**
  125249. * Get the friendly name associated with the input class.
  125250. * @returns the input friendly name
  125251. */
  125252. getSimpleName(): string;
  125253. /**
  125254. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125255. * allow modification of the heightOffset value.
  125256. */
  125257. private _modifierHeightOffset;
  125258. /**
  125259. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125260. * allow modification of the rotationOffset value.
  125261. */
  125262. private _modifierRotationOffset;
  125263. /**
  125264. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125265. * allow modification of the radius value.
  125266. */
  125267. private _modifierRadius;
  125268. }
  125269. }
  125270. declare module BABYLON {
  125271. interface FreeCameraInputsManager {
  125272. /**
  125273. * @hidden
  125274. */
  125275. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125276. /**
  125277. * Add orientation input support to the input manager.
  125278. * @returns the current input manager
  125279. */
  125280. addDeviceOrientation(): FreeCameraInputsManager;
  125281. }
  125282. /**
  125283. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125284. * Screen rotation is taken into account.
  125285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125286. */
  125287. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125288. private _camera;
  125289. private _screenOrientationAngle;
  125290. private _constantTranform;
  125291. private _screenQuaternion;
  125292. private _alpha;
  125293. private _beta;
  125294. private _gamma;
  125295. /**
  125296. * Can be used to detect if a device orientation sensor is available on a device
  125297. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125298. * @returns a promise that will resolve on orientation change
  125299. */
  125300. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125301. /**
  125302. * @hidden
  125303. */
  125304. _onDeviceOrientationChangedObservable: Observable<void>;
  125305. /**
  125306. * Instantiates a new input
  125307. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125308. */
  125309. constructor();
  125310. /**
  125311. * Define the camera controlled by the input.
  125312. */
  125313. get camera(): FreeCamera;
  125314. set camera(camera: FreeCamera);
  125315. /**
  125316. * Attach the input controls to a specific dom element to get the input from.
  125317. * @param element Defines the element the controls should be listened from
  125318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125319. */
  125320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125321. private _orientationChanged;
  125322. private _deviceOrientation;
  125323. /**
  125324. * Detach the current controls from the specified dom element.
  125325. * @param element Defines the element to stop listening the inputs from
  125326. */
  125327. detachControl(element: Nullable<HTMLElement>): void;
  125328. /**
  125329. * Update the current camera state depending on the inputs that have been used this frame.
  125330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125331. */
  125332. checkInputs(): void;
  125333. /**
  125334. * Gets the class name of the current intput.
  125335. * @returns the class name
  125336. */
  125337. getClassName(): string;
  125338. /**
  125339. * Get the friendly name associated with the input class.
  125340. * @returns the input friendly name
  125341. */
  125342. getSimpleName(): string;
  125343. }
  125344. }
  125345. declare module BABYLON {
  125346. /**
  125347. * Manage the gamepad inputs to control a free camera.
  125348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125349. */
  125350. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125351. /**
  125352. * Define the camera the input is attached to.
  125353. */
  125354. camera: FreeCamera;
  125355. /**
  125356. * Define the Gamepad controlling the input
  125357. */
  125358. gamepad: Nullable<Gamepad>;
  125359. /**
  125360. * Defines the gamepad rotation sensiblity.
  125361. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125362. */
  125363. gamepadAngularSensibility: number;
  125364. /**
  125365. * Defines the gamepad move sensiblity.
  125366. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125367. */
  125368. gamepadMoveSensibility: number;
  125369. private _yAxisScale;
  125370. /**
  125371. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125372. */
  125373. get invertYAxis(): boolean;
  125374. set invertYAxis(value: boolean);
  125375. private _onGamepadConnectedObserver;
  125376. private _onGamepadDisconnectedObserver;
  125377. private _cameraTransform;
  125378. private _deltaTransform;
  125379. private _vector3;
  125380. private _vector2;
  125381. /**
  125382. * Attach the input controls to a specific dom element to get the input from.
  125383. * @param element Defines the element the controls should be listened from
  125384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125385. */
  125386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125387. /**
  125388. * Detach the current controls from the specified dom element.
  125389. * @param element Defines the element to stop listening the inputs from
  125390. */
  125391. detachControl(element: Nullable<HTMLElement>): void;
  125392. /**
  125393. * Update the current camera state depending on the inputs that have been used this frame.
  125394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125395. */
  125396. checkInputs(): void;
  125397. /**
  125398. * Gets the class name of the current intput.
  125399. * @returns the class name
  125400. */
  125401. getClassName(): string;
  125402. /**
  125403. * Get the friendly name associated with the input class.
  125404. * @returns the input friendly name
  125405. */
  125406. getSimpleName(): string;
  125407. }
  125408. }
  125409. declare module BABYLON {
  125410. /**
  125411. * Defines the potential axis of a Joystick
  125412. */
  125413. export enum JoystickAxis {
  125414. /** X axis */
  125415. X = 0,
  125416. /** Y axis */
  125417. Y = 1,
  125418. /** Z axis */
  125419. Z = 2
  125420. }
  125421. /**
  125422. * Represents the different customization options available
  125423. * for VirtualJoystick
  125424. */
  125425. interface VirtualJoystickCustomizations {
  125426. /**
  125427. * Size of the joystick's puck
  125428. */
  125429. puckSize: number;
  125430. /**
  125431. * Size of the joystick's container
  125432. */
  125433. containerSize: number;
  125434. /**
  125435. * Color of the joystick && puck
  125436. */
  125437. color: string;
  125438. /**
  125439. * Image URL for the joystick's puck
  125440. */
  125441. puckImage?: string;
  125442. /**
  125443. * Image URL for the joystick's container
  125444. */
  125445. containerImage?: string;
  125446. /**
  125447. * Defines the unmoving position of the joystick container
  125448. */
  125449. position?: {
  125450. x: number;
  125451. y: number;
  125452. };
  125453. /**
  125454. * Defines whether or not the joystick container is always visible
  125455. */
  125456. alwaysVisible: boolean;
  125457. /**
  125458. * Defines whether or not to limit the movement of the puck to the joystick's container
  125459. */
  125460. limitToContainer: boolean;
  125461. }
  125462. /**
  125463. * Class used to define virtual joystick (used in touch mode)
  125464. */
  125465. export class VirtualJoystick {
  125466. /**
  125467. * Gets or sets a boolean indicating that left and right values must be inverted
  125468. */
  125469. reverseLeftRight: boolean;
  125470. /**
  125471. * Gets or sets a boolean indicating that up and down values must be inverted
  125472. */
  125473. reverseUpDown: boolean;
  125474. /**
  125475. * Gets the offset value for the position (ie. the change of the position value)
  125476. */
  125477. deltaPosition: Vector3;
  125478. /**
  125479. * Gets a boolean indicating if the virtual joystick was pressed
  125480. */
  125481. pressed: boolean;
  125482. /**
  125483. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125484. */
  125485. static Canvas: Nullable<HTMLCanvasElement>;
  125486. /**
  125487. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125488. */
  125489. limitToContainer: boolean;
  125490. private static _globalJoystickIndex;
  125491. private static _alwaysVisibleSticks;
  125492. private static vjCanvasContext;
  125493. private static vjCanvasWidth;
  125494. private static vjCanvasHeight;
  125495. private static halfWidth;
  125496. private static _GetDefaultOptions;
  125497. private _action;
  125498. private _axisTargetedByLeftAndRight;
  125499. private _axisTargetedByUpAndDown;
  125500. private _joystickSensibility;
  125501. private _inversedSensibility;
  125502. private _joystickPointerID;
  125503. private _joystickColor;
  125504. private _joystickPointerPos;
  125505. private _joystickPreviousPointerPos;
  125506. private _joystickPointerStartPos;
  125507. private _deltaJoystickVector;
  125508. private _leftJoystick;
  125509. private _touches;
  125510. private _joystickPosition;
  125511. private _alwaysVisible;
  125512. private _puckImage;
  125513. private _containerImage;
  125514. private _joystickPuckSize;
  125515. private _joystickContainerSize;
  125516. private _clearPuckSize;
  125517. private _clearContainerSize;
  125518. private _clearPuckSizeOffset;
  125519. private _clearContainerSizeOffset;
  125520. private _onPointerDownHandlerRef;
  125521. private _onPointerMoveHandlerRef;
  125522. private _onPointerUpHandlerRef;
  125523. private _onResize;
  125524. /**
  125525. * Creates a new virtual joystick
  125526. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125527. * @param customizations Defines the options we want to customize the VirtualJoystick
  125528. */
  125529. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125530. /**
  125531. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125532. * @param newJoystickSensibility defines the new sensibility
  125533. */
  125534. setJoystickSensibility(newJoystickSensibility: number): void;
  125535. private _onPointerDown;
  125536. private _onPointerMove;
  125537. private _onPointerUp;
  125538. /**
  125539. * Change the color of the virtual joystick
  125540. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125541. */
  125542. setJoystickColor(newColor: string): void;
  125543. /**
  125544. * Size of the joystick's container
  125545. */
  125546. set containerSize(newSize: number);
  125547. get containerSize(): number;
  125548. /**
  125549. * Size of the joystick's puck
  125550. */
  125551. set puckSize(newSize: number);
  125552. get puckSize(): number;
  125553. /**
  125554. * Clears the set position of the joystick
  125555. */
  125556. clearPosition(): void;
  125557. /**
  125558. * Defines whether or not the joystick container is always visible
  125559. */
  125560. set alwaysVisible(value: boolean);
  125561. get alwaysVisible(): boolean;
  125562. /**
  125563. * Sets the constant position of the Joystick container
  125564. * @param x X axis coordinate
  125565. * @param y Y axis coordinate
  125566. */
  125567. setPosition(x: number, y: number): void;
  125568. /**
  125569. * Defines a callback to call when the joystick is touched
  125570. * @param action defines the callback
  125571. */
  125572. setActionOnTouch(action: () => any): void;
  125573. /**
  125574. * Defines which axis you'd like to control for left & right
  125575. * @param axis defines the axis to use
  125576. */
  125577. setAxisForLeftRight(axis: JoystickAxis): void;
  125578. /**
  125579. * Defines which axis you'd like to control for up & down
  125580. * @param axis defines the axis to use
  125581. */
  125582. setAxisForUpDown(axis: JoystickAxis): void;
  125583. /**
  125584. * Clears the canvas from the previous puck / container draw
  125585. */
  125586. private _clearPreviousDraw;
  125587. /**
  125588. * Loads `urlPath` to be used for the container's image
  125589. * @param urlPath defines the urlPath of an image to use
  125590. */
  125591. setContainerImage(urlPath: string): void;
  125592. /**
  125593. * Loads `urlPath` to be used for the puck's image
  125594. * @param urlPath defines the urlPath of an image to use
  125595. */
  125596. setPuckImage(urlPath: string): void;
  125597. /**
  125598. * Draws the Virtual Joystick's container
  125599. */
  125600. private _drawContainer;
  125601. /**
  125602. * Draws the Virtual Joystick's puck
  125603. */
  125604. private _drawPuck;
  125605. private _drawVirtualJoystick;
  125606. /**
  125607. * Release internal HTML canvas
  125608. */
  125609. releaseCanvas(): void;
  125610. }
  125611. }
  125612. declare module BABYLON {
  125613. interface FreeCameraInputsManager {
  125614. /**
  125615. * Add virtual joystick input support to the input manager.
  125616. * @returns the current input manager
  125617. */
  125618. addVirtualJoystick(): FreeCameraInputsManager;
  125619. }
  125620. /**
  125621. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125623. */
  125624. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125625. /**
  125626. * Defines the camera the input is attached to.
  125627. */
  125628. camera: FreeCamera;
  125629. private _leftjoystick;
  125630. private _rightjoystick;
  125631. /**
  125632. * Gets the left stick of the virtual joystick.
  125633. * @returns The virtual Joystick
  125634. */
  125635. getLeftJoystick(): VirtualJoystick;
  125636. /**
  125637. * Gets the right stick of the virtual joystick.
  125638. * @returns The virtual Joystick
  125639. */
  125640. getRightJoystick(): VirtualJoystick;
  125641. /**
  125642. * Update the current camera state depending on the inputs that have been used this frame.
  125643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125644. */
  125645. checkInputs(): void;
  125646. /**
  125647. * Attach the input controls to a specific dom element to get the input from.
  125648. * @param element Defines the element the controls should be listened from
  125649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125650. */
  125651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125652. /**
  125653. * Detach the current controls from the specified dom element.
  125654. * @param element Defines the element to stop listening the inputs from
  125655. */
  125656. detachControl(element: Nullable<HTMLElement>): void;
  125657. /**
  125658. * Gets the class name of the current intput.
  125659. * @returns the class name
  125660. */
  125661. getClassName(): string;
  125662. /**
  125663. * Get the friendly name associated with the input class.
  125664. * @returns the input friendly name
  125665. */
  125666. getSimpleName(): string;
  125667. }
  125668. }
  125669. declare module BABYLON {
  125670. /**
  125671. * This represents a FPS type of camera controlled by touch.
  125672. * This is like a universal camera minus the Gamepad controls.
  125673. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125674. */
  125675. export class TouchCamera extends FreeCamera {
  125676. /**
  125677. * Defines the touch sensibility for rotation.
  125678. * The higher the faster.
  125679. */
  125680. get touchAngularSensibility(): number;
  125681. set touchAngularSensibility(value: number);
  125682. /**
  125683. * Defines the touch sensibility for move.
  125684. * The higher the faster.
  125685. */
  125686. get touchMoveSensibility(): number;
  125687. set touchMoveSensibility(value: number);
  125688. /**
  125689. * Instantiates a new touch camera.
  125690. * This represents a FPS type of camera controlled by touch.
  125691. * This is like a universal camera minus the Gamepad controls.
  125692. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125693. * @param name Define the name of the camera in the scene
  125694. * @param position Define the start position of the camera in the scene
  125695. * @param scene Define the scene the camera belongs to
  125696. */
  125697. constructor(name: string, position: Vector3, scene: Scene);
  125698. /**
  125699. * Gets the current object class name.
  125700. * @return the class name
  125701. */
  125702. getClassName(): string;
  125703. /** @hidden */
  125704. _setupInputs(): void;
  125705. }
  125706. }
  125707. declare module BABYLON {
  125708. /**
  125709. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125710. * being tilted forward or back and left or right.
  125711. */
  125712. export class DeviceOrientationCamera extends FreeCamera {
  125713. private _initialQuaternion;
  125714. private _quaternionCache;
  125715. private _tmpDragQuaternion;
  125716. private _disablePointerInputWhenUsingDeviceOrientation;
  125717. /**
  125718. * Creates a new device orientation camera
  125719. * @param name The name of the camera
  125720. * @param position The start position camera
  125721. * @param scene The scene the camera belongs to
  125722. */
  125723. constructor(name: string, position: Vector3, scene: Scene);
  125724. /**
  125725. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125726. */
  125727. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125728. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125729. private _dragFactor;
  125730. /**
  125731. * Enabled turning on the y axis when the orientation sensor is active
  125732. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125733. */
  125734. enableHorizontalDragging(dragFactor?: number): void;
  125735. /**
  125736. * Gets the current instance class name ("DeviceOrientationCamera").
  125737. * This helps avoiding instanceof at run time.
  125738. * @returns the class name
  125739. */
  125740. getClassName(): string;
  125741. /**
  125742. * @hidden
  125743. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125744. */
  125745. _checkInputs(): void;
  125746. /**
  125747. * Reset the camera to its default orientation on the specified axis only.
  125748. * @param axis The axis to reset
  125749. */
  125750. resetToCurrentRotation(axis?: Axis): void;
  125751. }
  125752. }
  125753. declare module BABYLON {
  125754. /**
  125755. * Defines supported buttons for XBox360 compatible gamepads
  125756. */
  125757. export enum Xbox360Button {
  125758. /** A */
  125759. A = 0,
  125760. /** B */
  125761. B = 1,
  125762. /** X */
  125763. X = 2,
  125764. /** Y */
  125765. Y = 3,
  125766. /** Left button */
  125767. LB = 4,
  125768. /** Right button */
  125769. RB = 5,
  125770. /** Back */
  125771. Back = 8,
  125772. /** Start */
  125773. Start = 9,
  125774. /** Left stick */
  125775. LeftStick = 10,
  125776. /** Right stick */
  125777. RightStick = 11
  125778. }
  125779. /** Defines values for XBox360 DPad */
  125780. export enum Xbox360Dpad {
  125781. /** Up */
  125782. Up = 12,
  125783. /** Down */
  125784. Down = 13,
  125785. /** Left */
  125786. Left = 14,
  125787. /** Right */
  125788. Right = 15
  125789. }
  125790. /**
  125791. * Defines a XBox360 gamepad
  125792. */
  125793. export class Xbox360Pad extends Gamepad {
  125794. private _leftTrigger;
  125795. private _rightTrigger;
  125796. private _onlefttriggerchanged;
  125797. private _onrighttriggerchanged;
  125798. private _onbuttondown;
  125799. private _onbuttonup;
  125800. private _ondpaddown;
  125801. private _ondpadup;
  125802. /** Observable raised when a button is pressed */
  125803. onButtonDownObservable: Observable<Xbox360Button>;
  125804. /** Observable raised when a button is released */
  125805. onButtonUpObservable: Observable<Xbox360Button>;
  125806. /** Observable raised when a pad is pressed */
  125807. onPadDownObservable: Observable<Xbox360Dpad>;
  125808. /** Observable raised when a pad is released */
  125809. onPadUpObservable: Observable<Xbox360Dpad>;
  125810. private _buttonA;
  125811. private _buttonB;
  125812. private _buttonX;
  125813. private _buttonY;
  125814. private _buttonBack;
  125815. private _buttonStart;
  125816. private _buttonLB;
  125817. private _buttonRB;
  125818. private _buttonLeftStick;
  125819. private _buttonRightStick;
  125820. private _dPadUp;
  125821. private _dPadDown;
  125822. private _dPadLeft;
  125823. private _dPadRight;
  125824. private _isXboxOnePad;
  125825. /**
  125826. * Creates a new XBox360 gamepad object
  125827. * @param id defines the id of this gamepad
  125828. * @param index defines its index
  125829. * @param gamepad defines the internal HTML gamepad object
  125830. * @param xboxOne defines if it is a XBox One gamepad
  125831. */
  125832. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125833. /**
  125834. * Defines the callback to call when left trigger is pressed
  125835. * @param callback defines the callback to use
  125836. */
  125837. onlefttriggerchanged(callback: (value: number) => void): void;
  125838. /**
  125839. * Defines the callback to call when right trigger is pressed
  125840. * @param callback defines the callback to use
  125841. */
  125842. onrighttriggerchanged(callback: (value: number) => void): void;
  125843. /**
  125844. * Gets the left trigger value
  125845. */
  125846. get leftTrigger(): number;
  125847. /**
  125848. * Sets the left trigger value
  125849. */
  125850. set leftTrigger(newValue: number);
  125851. /**
  125852. * Gets the right trigger value
  125853. */
  125854. get rightTrigger(): number;
  125855. /**
  125856. * Sets the right trigger value
  125857. */
  125858. set rightTrigger(newValue: number);
  125859. /**
  125860. * Defines the callback to call when a button is pressed
  125861. * @param callback defines the callback to use
  125862. */
  125863. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125864. /**
  125865. * Defines the callback to call when a button is released
  125866. * @param callback defines the callback to use
  125867. */
  125868. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125869. /**
  125870. * Defines the callback to call when a pad is pressed
  125871. * @param callback defines the callback to use
  125872. */
  125873. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125874. /**
  125875. * Defines the callback to call when a pad is released
  125876. * @param callback defines the callback to use
  125877. */
  125878. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125879. private _setButtonValue;
  125880. private _setDPadValue;
  125881. /**
  125882. * Gets the value of the `A` button
  125883. */
  125884. get buttonA(): number;
  125885. /**
  125886. * Sets the value of the `A` button
  125887. */
  125888. set buttonA(value: number);
  125889. /**
  125890. * Gets the value of the `B` button
  125891. */
  125892. get buttonB(): number;
  125893. /**
  125894. * Sets the value of the `B` button
  125895. */
  125896. set buttonB(value: number);
  125897. /**
  125898. * Gets the value of the `X` button
  125899. */
  125900. get buttonX(): number;
  125901. /**
  125902. * Sets the value of the `X` button
  125903. */
  125904. set buttonX(value: number);
  125905. /**
  125906. * Gets the value of the `Y` button
  125907. */
  125908. get buttonY(): number;
  125909. /**
  125910. * Sets the value of the `Y` button
  125911. */
  125912. set buttonY(value: number);
  125913. /**
  125914. * Gets the value of the `Start` button
  125915. */
  125916. get buttonStart(): number;
  125917. /**
  125918. * Sets the value of the `Start` button
  125919. */
  125920. set buttonStart(value: number);
  125921. /**
  125922. * Gets the value of the `Back` button
  125923. */
  125924. get buttonBack(): number;
  125925. /**
  125926. * Sets the value of the `Back` button
  125927. */
  125928. set buttonBack(value: number);
  125929. /**
  125930. * Gets the value of the `Left` button
  125931. */
  125932. get buttonLB(): number;
  125933. /**
  125934. * Sets the value of the `Left` button
  125935. */
  125936. set buttonLB(value: number);
  125937. /**
  125938. * Gets the value of the `Right` button
  125939. */
  125940. get buttonRB(): number;
  125941. /**
  125942. * Sets the value of the `Right` button
  125943. */
  125944. set buttonRB(value: number);
  125945. /**
  125946. * Gets the value of the Left joystick
  125947. */
  125948. get buttonLeftStick(): number;
  125949. /**
  125950. * Sets the value of the Left joystick
  125951. */
  125952. set buttonLeftStick(value: number);
  125953. /**
  125954. * Gets the value of the Right joystick
  125955. */
  125956. get buttonRightStick(): number;
  125957. /**
  125958. * Sets the value of the Right joystick
  125959. */
  125960. set buttonRightStick(value: number);
  125961. /**
  125962. * Gets the value of D-pad up
  125963. */
  125964. get dPadUp(): number;
  125965. /**
  125966. * Sets the value of D-pad up
  125967. */
  125968. set dPadUp(value: number);
  125969. /**
  125970. * Gets the value of D-pad down
  125971. */
  125972. get dPadDown(): number;
  125973. /**
  125974. * Sets the value of D-pad down
  125975. */
  125976. set dPadDown(value: number);
  125977. /**
  125978. * Gets the value of D-pad left
  125979. */
  125980. get dPadLeft(): number;
  125981. /**
  125982. * Sets the value of D-pad left
  125983. */
  125984. set dPadLeft(value: number);
  125985. /**
  125986. * Gets the value of D-pad right
  125987. */
  125988. get dPadRight(): number;
  125989. /**
  125990. * Sets the value of D-pad right
  125991. */
  125992. set dPadRight(value: number);
  125993. /**
  125994. * Force the gamepad to synchronize with device values
  125995. */
  125996. update(): void;
  125997. /**
  125998. * Disposes the gamepad
  125999. */
  126000. dispose(): void;
  126001. }
  126002. }
  126003. declare module BABYLON {
  126004. /**
  126005. * Defines supported buttons for DualShock compatible gamepads
  126006. */
  126007. export enum DualShockButton {
  126008. /** Cross */
  126009. Cross = 0,
  126010. /** Circle */
  126011. Circle = 1,
  126012. /** Square */
  126013. Square = 2,
  126014. /** Triangle */
  126015. Triangle = 3,
  126016. /** L1 */
  126017. L1 = 4,
  126018. /** R1 */
  126019. R1 = 5,
  126020. /** Share */
  126021. Share = 8,
  126022. /** Options */
  126023. Options = 9,
  126024. /** Left stick */
  126025. LeftStick = 10,
  126026. /** Right stick */
  126027. RightStick = 11
  126028. }
  126029. /** Defines values for DualShock DPad */
  126030. export enum DualShockDpad {
  126031. /** Up */
  126032. Up = 12,
  126033. /** Down */
  126034. Down = 13,
  126035. /** Left */
  126036. Left = 14,
  126037. /** Right */
  126038. Right = 15
  126039. }
  126040. /**
  126041. * Defines a DualShock gamepad
  126042. */
  126043. export class DualShockPad extends Gamepad {
  126044. private _leftTrigger;
  126045. private _rightTrigger;
  126046. private _onlefttriggerchanged;
  126047. private _onrighttriggerchanged;
  126048. private _onbuttondown;
  126049. private _onbuttonup;
  126050. private _ondpaddown;
  126051. private _ondpadup;
  126052. /** Observable raised when a button is pressed */
  126053. onButtonDownObservable: Observable<DualShockButton>;
  126054. /** Observable raised when a button is released */
  126055. onButtonUpObservable: Observable<DualShockButton>;
  126056. /** Observable raised when a pad is pressed */
  126057. onPadDownObservable: Observable<DualShockDpad>;
  126058. /** Observable raised when a pad is released */
  126059. onPadUpObservable: Observable<DualShockDpad>;
  126060. private _buttonCross;
  126061. private _buttonCircle;
  126062. private _buttonSquare;
  126063. private _buttonTriangle;
  126064. private _buttonShare;
  126065. private _buttonOptions;
  126066. private _buttonL1;
  126067. private _buttonR1;
  126068. private _buttonLeftStick;
  126069. private _buttonRightStick;
  126070. private _dPadUp;
  126071. private _dPadDown;
  126072. private _dPadLeft;
  126073. private _dPadRight;
  126074. /**
  126075. * Creates a new DualShock gamepad object
  126076. * @param id defines the id of this gamepad
  126077. * @param index defines its index
  126078. * @param gamepad defines the internal HTML gamepad object
  126079. */
  126080. constructor(id: string, index: number, gamepad: any);
  126081. /**
  126082. * Defines the callback to call when left trigger is pressed
  126083. * @param callback defines the callback to use
  126084. */
  126085. onlefttriggerchanged(callback: (value: number) => void): void;
  126086. /**
  126087. * Defines the callback to call when right trigger is pressed
  126088. * @param callback defines the callback to use
  126089. */
  126090. onrighttriggerchanged(callback: (value: number) => void): void;
  126091. /**
  126092. * Gets the left trigger value
  126093. */
  126094. get leftTrigger(): number;
  126095. /**
  126096. * Sets the left trigger value
  126097. */
  126098. set leftTrigger(newValue: number);
  126099. /**
  126100. * Gets the right trigger value
  126101. */
  126102. get rightTrigger(): number;
  126103. /**
  126104. * Sets the right trigger value
  126105. */
  126106. set rightTrigger(newValue: number);
  126107. /**
  126108. * Defines the callback to call when a button is pressed
  126109. * @param callback defines the callback to use
  126110. */
  126111. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126112. /**
  126113. * Defines the callback to call when a button is released
  126114. * @param callback defines the callback to use
  126115. */
  126116. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126117. /**
  126118. * Defines the callback to call when a pad is pressed
  126119. * @param callback defines the callback to use
  126120. */
  126121. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126122. /**
  126123. * Defines the callback to call when a pad is released
  126124. * @param callback defines the callback to use
  126125. */
  126126. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126127. private _setButtonValue;
  126128. private _setDPadValue;
  126129. /**
  126130. * Gets the value of the `Cross` button
  126131. */
  126132. get buttonCross(): number;
  126133. /**
  126134. * Sets the value of the `Cross` button
  126135. */
  126136. set buttonCross(value: number);
  126137. /**
  126138. * Gets the value of the `Circle` button
  126139. */
  126140. get buttonCircle(): number;
  126141. /**
  126142. * Sets the value of the `Circle` button
  126143. */
  126144. set buttonCircle(value: number);
  126145. /**
  126146. * Gets the value of the `Square` button
  126147. */
  126148. get buttonSquare(): number;
  126149. /**
  126150. * Sets the value of the `Square` button
  126151. */
  126152. set buttonSquare(value: number);
  126153. /**
  126154. * Gets the value of the `Triangle` button
  126155. */
  126156. get buttonTriangle(): number;
  126157. /**
  126158. * Sets the value of the `Triangle` button
  126159. */
  126160. set buttonTriangle(value: number);
  126161. /**
  126162. * Gets the value of the `Options` button
  126163. */
  126164. get buttonOptions(): number;
  126165. /**
  126166. * Sets the value of the `Options` button
  126167. */
  126168. set buttonOptions(value: number);
  126169. /**
  126170. * Gets the value of the `Share` button
  126171. */
  126172. get buttonShare(): number;
  126173. /**
  126174. * Sets the value of the `Share` button
  126175. */
  126176. set buttonShare(value: number);
  126177. /**
  126178. * Gets the value of the `L1` button
  126179. */
  126180. get buttonL1(): number;
  126181. /**
  126182. * Sets the value of the `L1` button
  126183. */
  126184. set buttonL1(value: number);
  126185. /**
  126186. * Gets the value of the `R1` button
  126187. */
  126188. get buttonR1(): number;
  126189. /**
  126190. * Sets the value of the `R1` button
  126191. */
  126192. set buttonR1(value: number);
  126193. /**
  126194. * Gets the value of the Left joystick
  126195. */
  126196. get buttonLeftStick(): number;
  126197. /**
  126198. * Sets the value of the Left joystick
  126199. */
  126200. set buttonLeftStick(value: number);
  126201. /**
  126202. * Gets the value of the Right joystick
  126203. */
  126204. get buttonRightStick(): number;
  126205. /**
  126206. * Sets the value of the Right joystick
  126207. */
  126208. set buttonRightStick(value: number);
  126209. /**
  126210. * Gets the value of D-pad up
  126211. */
  126212. get dPadUp(): number;
  126213. /**
  126214. * Sets the value of D-pad up
  126215. */
  126216. set dPadUp(value: number);
  126217. /**
  126218. * Gets the value of D-pad down
  126219. */
  126220. get dPadDown(): number;
  126221. /**
  126222. * Sets the value of D-pad down
  126223. */
  126224. set dPadDown(value: number);
  126225. /**
  126226. * Gets the value of D-pad left
  126227. */
  126228. get dPadLeft(): number;
  126229. /**
  126230. * Sets the value of D-pad left
  126231. */
  126232. set dPadLeft(value: number);
  126233. /**
  126234. * Gets the value of D-pad right
  126235. */
  126236. get dPadRight(): number;
  126237. /**
  126238. * Sets the value of D-pad right
  126239. */
  126240. set dPadRight(value: number);
  126241. /**
  126242. * Force the gamepad to synchronize with device values
  126243. */
  126244. update(): void;
  126245. /**
  126246. * Disposes the gamepad
  126247. */
  126248. dispose(): void;
  126249. }
  126250. }
  126251. declare module BABYLON {
  126252. /**
  126253. * Manager for handling gamepads
  126254. */
  126255. export class GamepadManager {
  126256. private _scene?;
  126257. private _babylonGamepads;
  126258. private _oneGamepadConnected;
  126259. /** @hidden */
  126260. _isMonitoring: boolean;
  126261. private _gamepadEventSupported;
  126262. private _gamepadSupport?;
  126263. /**
  126264. * observable to be triggered when the gamepad controller has been connected
  126265. */
  126266. onGamepadConnectedObservable: Observable<Gamepad>;
  126267. /**
  126268. * observable to be triggered when the gamepad controller has been disconnected
  126269. */
  126270. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126271. private _onGamepadConnectedEvent;
  126272. private _onGamepadDisconnectedEvent;
  126273. /**
  126274. * Initializes the gamepad manager
  126275. * @param _scene BabylonJS scene
  126276. */
  126277. constructor(_scene?: Scene | undefined);
  126278. /**
  126279. * The gamepads in the game pad manager
  126280. */
  126281. get gamepads(): Gamepad[];
  126282. /**
  126283. * Get the gamepad controllers based on type
  126284. * @param type The type of gamepad controller
  126285. * @returns Nullable gamepad
  126286. */
  126287. getGamepadByType(type?: number): Nullable<Gamepad>;
  126288. /**
  126289. * Disposes the gamepad manager
  126290. */
  126291. dispose(): void;
  126292. private _addNewGamepad;
  126293. private _startMonitoringGamepads;
  126294. private _stopMonitoringGamepads;
  126295. /** @hidden */
  126296. _checkGamepadsStatus(): void;
  126297. private _updateGamepadObjects;
  126298. }
  126299. }
  126300. declare module BABYLON {
  126301. interface Scene {
  126302. /** @hidden */
  126303. _gamepadManager: Nullable<GamepadManager>;
  126304. /**
  126305. * Gets the gamepad manager associated with the scene
  126306. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126307. */
  126308. gamepadManager: GamepadManager;
  126309. }
  126310. /**
  126311. * Interface representing a free camera inputs manager
  126312. */
  126313. interface FreeCameraInputsManager {
  126314. /**
  126315. * Adds gamepad input support to the FreeCameraInputsManager.
  126316. * @returns the FreeCameraInputsManager
  126317. */
  126318. addGamepad(): FreeCameraInputsManager;
  126319. }
  126320. /**
  126321. * Interface representing an arc rotate camera inputs manager
  126322. */
  126323. interface ArcRotateCameraInputsManager {
  126324. /**
  126325. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126326. * @returns the camera inputs manager
  126327. */
  126328. addGamepad(): ArcRotateCameraInputsManager;
  126329. }
  126330. /**
  126331. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126332. */
  126333. export class GamepadSystemSceneComponent implements ISceneComponent {
  126334. /**
  126335. * The component name helpfull to identify the component in the list of scene components.
  126336. */
  126337. readonly name: string;
  126338. /**
  126339. * The scene the component belongs to.
  126340. */
  126341. scene: Scene;
  126342. /**
  126343. * Creates a new instance of the component for the given scene
  126344. * @param scene Defines the scene to register the component in
  126345. */
  126346. constructor(scene: Scene);
  126347. /**
  126348. * Registers the component in a given scene
  126349. */
  126350. register(): void;
  126351. /**
  126352. * Rebuilds the elements related to this component in case of
  126353. * context lost for instance.
  126354. */
  126355. rebuild(): void;
  126356. /**
  126357. * Disposes the component and the associated ressources
  126358. */
  126359. dispose(): void;
  126360. private _beforeCameraUpdate;
  126361. }
  126362. }
  126363. declare module BABYLON {
  126364. /**
  126365. * 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,
  126366. * which still works and will still be found in many Playgrounds.
  126367. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126368. */
  126369. export class UniversalCamera extends TouchCamera {
  126370. /**
  126371. * Defines the gamepad rotation sensiblity.
  126372. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126373. */
  126374. get gamepadAngularSensibility(): number;
  126375. set gamepadAngularSensibility(value: number);
  126376. /**
  126377. * Defines the gamepad move sensiblity.
  126378. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126379. */
  126380. get gamepadMoveSensibility(): number;
  126381. set gamepadMoveSensibility(value: number);
  126382. /**
  126383. * 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,
  126384. * which still works and will still be found in many Playgrounds.
  126385. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126386. * @param name Define the name of the camera in the scene
  126387. * @param position Define the start position of the camera in the scene
  126388. * @param scene Define the scene the camera belongs to
  126389. */
  126390. constructor(name: string, position: Vector3, scene: Scene);
  126391. /**
  126392. * Gets the current object class name.
  126393. * @return the class name
  126394. */
  126395. getClassName(): string;
  126396. }
  126397. }
  126398. declare module BABYLON {
  126399. /**
  126400. * This represents a FPS type of camera. This is only here for back compat purpose.
  126401. * Please use the UniversalCamera instead as both are identical.
  126402. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126403. */
  126404. export class GamepadCamera extends UniversalCamera {
  126405. /**
  126406. * Instantiates a new Gamepad Camera
  126407. * This represents a FPS type of camera. This is only here for back compat purpose.
  126408. * Please use the UniversalCamera instead as both are identical.
  126409. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126410. * @param name Define the name of the camera in the scene
  126411. * @param position Define the start position of the camera in the scene
  126412. * @param scene Define the scene the camera belongs to
  126413. */
  126414. constructor(name: string, position: Vector3, scene: Scene);
  126415. /**
  126416. * Gets the current object class name.
  126417. * @return the class name
  126418. */
  126419. getClassName(): string;
  126420. }
  126421. }
  126422. declare module BABYLON {
  126423. /** @hidden */
  126424. export var passPixelShader: {
  126425. name: string;
  126426. shader: string;
  126427. };
  126428. }
  126429. declare module BABYLON {
  126430. /** @hidden */
  126431. export var passCubePixelShader: {
  126432. name: string;
  126433. shader: string;
  126434. };
  126435. }
  126436. declare module BABYLON {
  126437. /**
  126438. * PassPostProcess which produces an output the same as it's input
  126439. */
  126440. export class PassPostProcess extends PostProcess {
  126441. /**
  126442. * Gets a string identifying the name of the class
  126443. * @returns "PassPostProcess" string
  126444. */
  126445. getClassName(): string;
  126446. /**
  126447. * Creates the PassPostProcess
  126448. * @param name The name of the effect.
  126449. * @param options The required width/height ratio to downsize to before computing the render pass.
  126450. * @param camera The camera to apply the render pass to.
  126451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126452. * @param engine The engine which the post process will be applied. (default: current engine)
  126453. * @param reusable If the post process can be reused on the same frame. (default: false)
  126454. * @param textureType The type of texture to be used when performing the post processing.
  126455. * @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)
  126456. */
  126457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126458. /** @hidden */
  126459. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126460. }
  126461. /**
  126462. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126463. */
  126464. export class PassCubePostProcess extends PostProcess {
  126465. private _face;
  126466. /**
  126467. * Gets or sets the cube face to display.
  126468. * * 0 is +X
  126469. * * 1 is -X
  126470. * * 2 is +Y
  126471. * * 3 is -Y
  126472. * * 4 is +Z
  126473. * * 5 is -Z
  126474. */
  126475. get face(): number;
  126476. set face(value: number);
  126477. /**
  126478. * Gets a string identifying the name of the class
  126479. * @returns "PassCubePostProcess" string
  126480. */
  126481. getClassName(): string;
  126482. /**
  126483. * Creates the PassCubePostProcess
  126484. * @param name The name of the effect.
  126485. * @param options The required width/height ratio to downsize to before computing the render pass.
  126486. * @param camera The camera to apply the render pass to.
  126487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126488. * @param engine The engine which the post process will be applied. (default: current engine)
  126489. * @param reusable If the post process can be reused on the same frame. (default: false)
  126490. * @param textureType The type of texture to be used when performing the post processing.
  126491. * @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)
  126492. */
  126493. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126494. /** @hidden */
  126495. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126496. }
  126497. }
  126498. declare module BABYLON {
  126499. /** @hidden */
  126500. export var anaglyphPixelShader: {
  126501. name: string;
  126502. shader: string;
  126503. };
  126504. }
  126505. declare module BABYLON {
  126506. /**
  126507. * Postprocess used to generate anaglyphic rendering
  126508. */
  126509. export class AnaglyphPostProcess extends PostProcess {
  126510. private _passedProcess;
  126511. /**
  126512. * Gets a string identifying the name of the class
  126513. * @returns "AnaglyphPostProcess" string
  126514. */
  126515. getClassName(): string;
  126516. /**
  126517. * Creates a new AnaglyphPostProcess
  126518. * @param name defines postprocess name
  126519. * @param options defines creation options or target ratio scale
  126520. * @param rigCameras defines cameras using this postprocess
  126521. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126522. * @param engine defines hosting engine
  126523. * @param reusable defines if the postprocess will be reused multiple times per frame
  126524. */
  126525. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126526. }
  126527. }
  126528. declare module BABYLON {
  126529. /**
  126530. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126531. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126532. */
  126533. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126534. /**
  126535. * Creates a new AnaglyphArcRotateCamera
  126536. * @param name defines camera name
  126537. * @param alpha defines alpha angle (in radians)
  126538. * @param beta defines beta angle (in radians)
  126539. * @param radius defines radius
  126540. * @param target defines camera target
  126541. * @param interaxialDistance defines distance between each color axis
  126542. * @param scene defines the hosting scene
  126543. */
  126544. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126545. /**
  126546. * Gets camera class name
  126547. * @returns AnaglyphArcRotateCamera
  126548. */
  126549. getClassName(): string;
  126550. }
  126551. }
  126552. declare module BABYLON {
  126553. /**
  126554. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126555. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126556. */
  126557. export class AnaglyphFreeCamera extends FreeCamera {
  126558. /**
  126559. * Creates a new AnaglyphFreeCamera
  126560. * @param name defines camera name
  126561. * @param position defines initial position
  126562. * @param interaxialDistance defines distance between each color axis
  126563. * @param scene defines the hosting scene
  126564. */
  126565. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126566. /**
  126567. * Gets camera class name
  126568. * @returns AnaglyphFreeCamera
  126569. */
  126570. getClassName(): string;
  126571. }
  126572. }
  126573. declare module BABYLON {
  126574. /**
  126575. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126576. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126577. */
  126578. export class AnaglyphGamepadCamera extends GamepadCamera {
  126579. /**
  126580. * Creates a new AnaglyphGamepadCamera
  126581. * @param name defines camera name
  126582. * @param position defines initial position
  126583. * @param interaxialDistance defines distance between each color axis
  126584. * @param scene defines the hosting scene
  126585. */
  126586. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126587. /**
  126588. * Gets camera class name
  126589. * @returns AnaglyphGamepadCamera
  126590. */
  126591. getClassName(): string;
  126592. }
  126593. }
  126594. declare module BABYLON {
  126595. /**
  126596. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126597. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126598. */
  126599. export class AnaglyphUniversalCamera extends UniversalCamera {
  126600. /**
  126601. * Creates a new AnaglyphUniversalCamera
  126602. * @param name defines camera name
  126603. * @param position defines initial position
  126604. * @param interaxialDistance defines distance between each color axis
  126605. * @param scene defines the hosting scene
  126606. */
  126607. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126608. /**
  126609. * Gets camera class name
  126610. * @returns AnaglyphUniversalCamera
  126611. */
  126612. getClassName(): string;
  126613. }
  126614. }
  126615. declare module BABYLON {
  126616. /**
  126617. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126618. * @see https://doc.babylonjs.com/features/cameras
  126619. */
  126620. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126621. /**
  126622. * Creates a new StereoscopicArcRotateCamera
  126623. * @param name defines camera name
  126624. * @param alpha defines alpha angle (in radians)
  126625. * @param beta defines beta angle (in radians)
  126626. * @param radius defines radius
  126627. * @param target defines camera target
  126628. * @param interaxialDistance defines distance between each color axis
  126629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126630. * @param scene defines the hosting scene
  126631. */
  126632. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126633. /**
  126634. * Gets camera class name
  126635. * @returns StereoscopicArcRotateCamera
  126636. */
  126637. getClassName(): string;
  126638. }
  126639. }
  126640. declare module BABYLON {
  126641. /**
  126642. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126643. * @see https://doc.babylonjs.com/features/cameras
  126644. */
  126645. export class StereoscopicFreeCamera extends FreeCamera {
  126646. /**
  126647. * Creates a new StereoscopicFreeCamera
  126648. * @param name defines camera name
  126649. * @param position defines initial position
  126650. * @param interaxialDistance defines distance between each color axis
  126651. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126652. * @param scene defines the hosting scene
  126653. */
  126654. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126655. /**
  126656. * Gets camera class name
  126657. * @returns StereoscopicFreeCamera
  126658. */
  126659. getClassName(): string;
  126660. }
  126661. }
  126662. declare module BABYLON {
  126663. /**
  126664. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126665. * @see https://doc.babylonjs.com/features/cameras
  126666. */
  126667. export class StereoscopicGamepadCamera extends GamepadCamera {
  126668. /**
  126669. * Creates a new StereoscopicGamepadCamera
  126670. * @param name defines camera name
  126671. * @param position defines initial position
  126672. * @param interaxialDistance defines distance between each color axis
  126673. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126674. * @param scene defines the hosting scene
  126675. */
  126676. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126677. /**
  126678. * Gets camera class name
  126679. * @returns StereoscopicGamepadCamera
  126680. */
  126681. getClassName(): string;
  126682. }
  126683. }
  126684. declare module BABYLON {
  126685. /**
  126686. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126687. * @see https://doc.babylonjs.com/features/cameras
  126688. */
  126689. export class StereoscopicUniversalCamera extends UniversalCamera {
  126690. /**
  126691. * Creates a new StereoscopicUniversalCamera
  126692. * @param name defines camera name
  126693. * @param position defines initial position
  126694. * @param interaxialDistance defines distance between each color axis
  126695. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126696. * @param scene defines the hosting scene
  126697. */
  126698. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126699. /**
  126700. * Gets camera class name
  126701. * @returns StereoscopicUniversalCamera
  126702. */
  126703. getClassName(): string;
  126704. }
  126705. }
  126706. declare module BABYLON {
  126707. /**
  126708. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126709. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126710. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126711. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126712. */
  126713. export class VirtualJoysticksCamera extends FreeCamera {
  126714. /**
  126715. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126716. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126717. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126718. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126719. * @param name Define the name of the camera in the scene
  126720. * @param position Define the start position of the camera in the scene
  126721. * @param scene Define the scene the camera belongs to
  126722. */
  126723. constructor(name: string, position: Vector3, scene: Scene);
  126724. /**
  126725. * Gets the current object class name.
  126726. * @return the class name
  126727. */
  126728. getClassName(): string;
  126729. }
  126730. }
  126731. declare module BABYLON {
  126732. /**
  126733. * This represents all the required metrics to create a VR camera.
  126734. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126735. */
  126736. export class VRCameraMetrics {
  126737. /**
  126738. * Define the horizontal resolution off the screen.
  126739. */
  126740. hResolution: number;
  126741. /**
  126742. * Define the vertical resolution off the screen.
  126743. */
  126744. vResolution: number;
  126745. /**
  126746. * Define the horizontal screen size.
  126747. */
  126748. hScreenSize: number;
  126749. /**
  126750. * Define the vertical screen size.
  126751. */
  126752. vScreenSize: number;
  126753. /**
  126754. * Define the vertical screen center position.
  126755. */
  126756. vScreenCenter: number;
  126757. /**
  126758. * Define the distance of the eyes to the screen.
  126759. */
  126760. eyeToScreenDistance: number;
  126761. /**
  126762. * Define the distance between both lenses
  126763. */
  126764. lensSeparationDistance: number;
  126765. /**
  126766. * Define the distance between both viewer's eyes.
  126767. */
  126768. interpupillaryDistance: number;
  126769. /**
  126770. * Define the distortion factor of the VR postprocess.
  126771. * Please, touch with care.
  126772. */
  126773. distortionK: number[];
  126774. /**
  126775. * Define the chromatic aberration correction factors for the VR post process.
  126776. */
  126777. chromaAbCorrection: number[];
  126778. /**
  126779. * Define the scale factor of the post process.
  126780. * The smaller the better but the slower.
  126781. */
  126782. postProcessScaleFactor: number;
  126783. /**
  126784. * Define an offset for the lens center.
  126785. */
  126786. lensCenterOffset: number;
  126787. /**
  126788. * Define if the current vr camera should compensate the distortion of the lense or not.
  126789. */
  126790. compensateDistortion: boolean;
  126791. /**
  126792. * Defines if multiview should be enabled when rendering (Default: false)
  126793. */
  126794. multiviewEnabled: boolean;
  126795. /**
  126796. * Gets the rendering aspect ratio based on the provided resolutions.
  126797. */
  126798. get aspectRatio(): number;
  126799. /**
  126800. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126801. */
  126802. get aspectRatioFov(): number;
  126803. /**
  126804. * @hidden
  126805. */
  126806. get leftHMatrix(): Matrix;
  126807. /**
  126808. * @hidden
  126809. */
  126810. get rightHMatrix(): Matrix;
  126811. /**
  126812. * @hidden
  126813. */
  126814. get leftPreViewMatrix(): Matrix;
  126815. /**
  126816. * @hidden
  126817. */
  126818. get rightPreViewMatrix(): Matrix;
  126819. /**
  126820. * Get the default VRMetrics based on the most generic setup.
  126821. * @returns the default vr metrics
  126822. */
  126823. static GetDefault(): VRCameraMetrics;
  126824. }
  126825. }
  126826. declare module BABYLON {
  126827. /** @hidden */
  126828. export var vrDistortionCorrectionPixelShader: {
  126829. name: string;
  126830. shader: string;
  126831. };
  126832. }
  126833. declare module BABYLON {
  126834. /**
  126835. * VRDistortionCorrectionPostProcess used for mobile VR
  126836. */
  126837. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126838. private _isRightEye;
  126839. private _distortionFactors;
  126840. private _postProcessScaleFactor;
  126841. private _lensCenterOffset;
  126842. private _scaleIn;
  126843. private _scaleFactor;
  126844. private _lensCenter;
  126845. /**
  126846. * Gets a string identifying the name of the class
  126847. * @returns "VRDistortionCorrectionPostProcess" string
  126848. */
  126849. getClassName(): string;
  126850. /**
  126851. * Initializes the VRDistortionCorrectionPostProcess
  126852. * @param name The name of the effect.
  126853. * @param camera The camera to apply the render pass to.
  126854. * @param isRightEye If this is for the right eye distortion
  126855. * @param vrMetrics All the required metrics for the VR camera
  126856. */
  126857. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126858. }
  126859. }
  126860. declare module BABYLON {
  126861. /**
  126862. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126863. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126864. */
  126865. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126866. /**
  126867. * Creates a new VRDeviceOrientationArcRotateCamera
  126868. * @param name defines camera name
  126869. * @param alpha defines the camera rotation along the logitudinal axis
  126870. * @param beta defines the camera rotation along the latitudinal axis
  126871. * @param radius defines the camera distance from its target
  126872. * @param target defines the camera target
  126873. * @param scene defines the scene the camera belongs to
  126874. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126875. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126876. */
  126877. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126878. /**
  126879. * Gets camera class name
  126880. * @returns VRDeviceOrientationArcRotateCamera
  126881. */
  126882. getClassName(): string;
  126883. }
  126884. }
  126885. declare module BABYLON {
  126886. /**
  126887. * Camera used to simulate VR rendering (based on FreeCamera)
  126888. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126889. */
  126890. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126891. /**
  126892. * Creates a new VRDeviceOrientationFreeCamera
  126893. * @param name defines camera name
  126894. * @param position defines the start position of the camera
  126895. * @param scene defines the scene the camera belongs to
  126896. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126897. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126898. */
  126899. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126900. /**
  126901. * Gets camera class name
  126902. * @returns VRDeviceOrientationFreeCamera
  126903. */
  126904. getClassName(): string;
  126905. }
  126906. }
  126907. declare module BABYLON {
  126908. /**
  126909. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126910. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126911. */
  126912. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126913. /**
  126914. * Creates a new VRDeviceOrientationGamepadCamera
  126915. * @param name defines camera name
  126916. * @param position defines the start position of the camera
  126917. * @param scene defines the scene the camera belongs to
  126918. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126919. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126920. */
  126921. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126922. /**
  126923. * Gets camera class name
  126924. * @returns VRDeviceOrientationGamepadCamera
  126925. */
  126926. getClassName(): string;
  126927. }
  126928. }
  126929. declare module BABYLON {
  126930. /**
  126931. * A class extending Texture allowing drawing on a texture
  126932. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126933. */
  126934. export class DynamicTexture extends Texture {
  126935. private _generateMipMaps;
  126936. private _canvas;
  126937. private _context;
  126938. /**
  126939. * Creates a DynamicTexture
  126940. * @param name defines the name of the texture
  126941. * @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
  126942. * @param scene defines the scene where you want the texture
  126943. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126944. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126945. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126946. */
  126947. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126948. /**
  126949. * Get the current class name of the texture useful for serialization or dynamic coding.
  126950. * @returns "DynamicTexture"
  126951. */
  126952. getClassName(): string;
  126953. /**
  126954. * Gets the current state of canRescale
  126955. */
  126956. get canRescale(): boolean;
  126957. private _recreate;
  126958. /**
  126959. * Scales the texture
  126960. * @param ratio the scale factor to apply to both width and height
  126961. */
  126962. scale(ratio: number): void;
  126963. /**
  126964. * Resizes the texture
  126965. * @param width the new width
  126966. * @param height the new height
  126967. */
  126968. scaleTo(width: number, height: number): void;
  126969. /**
  126970. * Gets the context of the canvas used by the texture
  126971. * @returns the canvas context of the dynamic texture
  126972. */
  126973. getContext(): CanvasRenderingContext2D;
  126974. /**
  126975. * Clears the texture
  126976. */
  126977. clear(): void;
  126978. /**
  126979. * Updates the texture
  126980. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126981. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126982. */
  126983. update(invertY?: boolean, premulAlpha?: boolean): void;
  126984. /**
  126985. * Draws text onto the texture
  126986. * @param text defines the text to be drawn
  126987. * @param x defines the placement of the text from the left
  126988. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126989. * @param font defines the font to be used with font-style, font-size, font-name
  126990. * @param color defines the color used for the text
  126991. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126992. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126993. * @param update defines whether texture is immediately update (default is true)
  126994. */
  126995. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126996. /**
  126997. * Clones the texture
  126998. * @returns the clone of the texture.
  126999. */
  127000. clone(): DynamicTexture;
  127001. /**
  127002. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127003. * @returns a serialized dynamic texture object
  127004. */
  127005. serialize(): any;
  127006. private _IsCanvasElement;
  127007. /** @hidden */
  127008. _rebuild(): void;
  127009. }
  127010. }
  127011. declare module BABYLON {
  127012. /**
  127013. * Class containing static functions to help procedurally build meshes
  127014. */
  127015. export class GroundBuilder {
  127016. /**
  127017. * Creates a ground mesh
  127018. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127019. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127021. * @param name defines the name of the mesh
  127022. * @param options defines the options used to create the mesh
  127023. * @param scene defines the hosting scene
  127024. * @returns the ground mesh
  127025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127026. */
  127027. static CreateGround(name: string, options: {
  127028. width?: number;
  127029. height?: number;
  127030. subdivisions?: number;
  127031. subdivisionsX?: number;
  127032. subdivisionsY?: number;
  127033. updatable?: boolean;
  127034. }, scene: any): Mesh;
  127035. /**
  127036. * Creates a tiled ground mesh
  127037. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127038. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127039. * * 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
  127040. * * 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
  127041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127042. * @param name defines the name of the mesh
  127043. * @param options defines the options used to create the mesh
  127044. * @param scene defines the hosting scene
  127045. * @returns the tiled ground mesh
  127046. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127047. */
  127048. static CreateTiledGround(name: string, options: {
  127049. xmin: number;
  127050. zmin: number;
  127051. xmax: number;
  127052. zmax: number;
  127053. subdivisions?: {
  127054. w: number;
  127055. h: number;
  127056. };
  127057. precision?: {
  127058. w: number;
  127059. h: number;
  127060. };
  127061. updatable?: boolean;
  127062. }, scene?: Nullable<Scene>): Mesh;
  127063. /**
  127064. * Creates a ground mesh from a height map
  127065. * * The parameter `url` sets the URL of the height map image resource.
  127066. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127067. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127068. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127069. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127070. * * 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.
  127071. * * 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).
  127072. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127074. * @param name defines the name of the mesh
  127075. * @param url defines the url to the height map
  127076. * @param options defines the options used to create the mesh
  127077. * @param scene defines the hosting scene
  127078. * @returns the ground mesh
  127079. * @see https://doc.babylonjs.com/babylon101/height_map
  127080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127081. */
  127082. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127083. width?: number;
  127084. height?: number;
  127085. subdivisions?: number;
  127086. minHeight?: number;
  127087. maxHeight?: number;
  127088. colorFilter?: Color3;
  127089. alphaFilter?: number;
  127090. updatable?: boolean;
  127091. onReady?: (mesh: GroundMesh) => void;
  127092. }, scene?: Nullable<Scene>): GroundMesh;
  127093. }
  127094. }
  127095. declare module BABYLON {
  127096. /**
  127097. * Class containing static functions to help procedurally build meshes
  127098. */
  127099. export class TorusBuilder {
  127100. /**
  127101. * Creates a torus mesh
  127102. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127103. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127104. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127108. * @param name defines the name of the mesh
  127109. * @param options defines the options used to create the mesh
  127110. * @param scene defines the hosting scene
  127111. * @returns the torus mesh
  127112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127113. */
  127114. static CreateTorus(name: string, options: {
  127115. diameter?: number;
  127116. thickness?: number;
  127117. tessellation?: number;
  127118. updatable?: boolean;
  127119. sideOrientation?: number;
  127120. frontUVs?: Vector4;
  127121. backUVs?: Vector4;
  127122. }, scene: any): Mesh;
  127123. }
  127124. }
  127125. declare module BABYLON {
  127126. /**
  127127. * Class containing static functions to help procedurally build meshes
  127128. */
  127129. export class CylinderBuilder {
  127130. /**
  127131. * Creates a cylinder or a cone mesh
  127132. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127133. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127134. * * 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.
  127135. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127136. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127137. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127138. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127139. * * 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).
  127140. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127141. * * 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).
  127142. * * 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
  127143. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127144. * * 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
  127145. * * 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.
  127146. * * If `enclose` is false, a ring surface is one element.
  127147. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127148. * * 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
  127149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127152. * @param name defines the name of the mesh
  127153. * @param options defines the options used to create the mesh
  127154. * @param scene defines the hosting scene
  127155. * @returns the cylinder mesh
  127156. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127157. */
  127158. static CreateCylinder(name: string, options: {
  127159. height?: number;
  127160. diameterTop?: number;
  127161. diameterBottom?: number;
  127162. diameter?: number;
  127163. tessellation?: number;
  127164. subdivisions?: number;
  127165. arc?: number;
  127166. faceColors?: Color4[];
  127167. faceUV?: Vector4[];
  127168. updatable?: boolean;
  127169. hasRings?: boolean;
  127170. enclose?: boolean;
  127171. cap?: number;
  127172. sideOrientation?: number;
  127173. frontUVs?: Vector4;
  127174. backUVs?: Vector4;
  127175. }, scene: any): Mesh;
  127176. }
  127177. }
  127178. declare module BABYLON {
  127179. /**
  127180. * States of the webXR experience
  127181. */
  127182. export enum WebXRState {
  127183. /**
  127184. * Transitioning to being in XR mode
  127185. */
  127186. ENTERING_XR = 0,
  127187. /**
  127188. * Transitioning to non XR mode
  127189. */
  127190. EXITING_XR = 1,
  127191. /**
  127192. * In XR mode and presenting
  127193. */
  127194. IN_XR = 2,
  127195. /**
  127196. * Not entered XR mode
  127197. */
  127198. NOT_IN_XR = 3
  127199. }
  127200. /**
  127201. * Abstraction of the XR render target
  127202. */
  127203. export interface WebXRRenderTarget extends IDisposable {
  127204. /**
  127205. * xrpresent context of the canvas which can be used to display/mirror xr content
  127206. */
  127207. canvasContext: WebGLRenderingContext;
  127208. /**
  127209. * xr layer for the canvas
  127210. */
  127211. xrLayer: Nullable<XRWebGLLayer>;
  127212. /**
  127213. * Initializes the xr layer for the session
  127214. * @param xrSession xr session
  127215. * @returns a promise that will resolve once the XR Layer has been created
  127216. */
  127217. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127218. }
  127219. }
  127220. declare module BABYLON {
  127221. /**
  127222. * COnfiguration object for WebXR output canvas
  127223. */
  127224. export class WebXRManagedOutputCanvasOptions {
  127225. /**
  127226. * An optional canvas in case you wish to create it yourself and provide it here.
  127227. * If not provided, a new canvas will be created
  127228. */
  127229. canvasElement?: HTMLCanvasElement;
  127230. /**
  127231. * Options for this XR Layer output
  127232. */
  127233. canvasOptions?: XRWebGLLayerOptions;
  127234. /**
  127235. * CSS styling for a newly created canvas (if not provided)
  127236. */
  127237. newCanvasCssStyle?: string;
  127238. /**
  127239. * Get the default values of the configuration object
  127240. * @param engine defines the engine to use (can be null)
  127241. * @returns default values of this configuration object
  127242. */
  127243. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127244. }
  127245. /**
  127246. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127247. */
  127248. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127249. private _options;
  127250. private _canvas;
  127251. private _engine;
  127252. private _originalCanvasSize;
  127253. /**
  127254. * Rendering context of the canvas which can be used to display/mirror xr content
  127255. */
  127256. canvasContext: WebGLRenderingContext;
  127257. /**
  127258. * xr layer for the canvas
  127259. */
  127260. xrLayer: Nullable<XRWebGLLayer>;
  127261. /**
  127262. * Obseervers registered here will be triggered when the xr layer was initialized
  127263. */
  127264. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127265. /**
  127266. * Initializes the canvas to be added/removed upon entering/exiting xr
  127267. * @param _xrSessionManager The XR Session manager
  127268. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127269. */
  127270. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127271. /**
  127272. * Disposes of the object
  127273. */
  127274. dispose(): void;
  127275. /**
  127276. * Initializes the xr layer for the session
  127277. * @param xrSession xr session
  127278. * @returns a promise that will resolve once the XR Layer has been created
  127279. */
  127280. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127281. private _addCanvas;
  127282. private _removeCanvas;
  127283. private _setCanvasSize;
  127284. private _setManagedOutputCanvas;
  127285. }
  127286. }
  127287. declare module BABYLON {
  127288. /**
  127289. * Manages an XRSession to work with Babylon's engine
  127290. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127291. */
  127292. export class WebXRSessionManager implements IDisposable {
  127293. /** The scene which the session should be created for */
  127294. scene: Scene;
  127295. private _referenceSpace;
  127296. private _rttProvider;
  127297. private _sessionEnded;
  127298. private _xrNavigator;
  127299. private baseLayer;
  127300. /**
  127301. * The base reference space from which the session started. good if you want to reset your
  127302. * reference space
  127303. */
  127304. baseReferenceSpace: XRReferenceSpace;
  127305. /**
  127306. * Current XR frame
  127307. */
  127308. currentFrame: Nullable<XRFrame>;
  127309. /** WebXR timestamp updated every frame */
  127310. currentTimestamp: number;
  127311. /**
  127312. * Used just in case of a failure to initialize an immersive session.
  127313. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127314. */
  127315. defaultHeightCompensation: number;
  127316. /**
  127317. * Fires every time a new xrFrame arrives which can be used to update the camera
  127318. */
  127319. onXRFrameObservable: Observable<XRFrame>;
  127320. /**
  127321. * Fires when the reference space changed
  127322. */
  127323. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127324. /**
  127325. * Fires when the xr session is ended either by the device or manually done
  127326. */
  127327. onXRSessionEnded: Observable<any>;
  127328. /**
  127329. * Fires when the xr session is ended either by the device or manually done
  127330. */
  127331. onXRSessionInit: Observable<XRSession>;
  127332. /**
  127333. * Underlying xr session
  127334. */
  127335. session: XRSession;
  127336. /**
  127337. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127338. * or get the offset the player is currently at.
  127339. */
  127340. viewerReferenceSpace: XRReferenceSpace;
  127341. /**
  127342. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127343. * @param scene The scene which the session should be created for
  127344. */
  127345. constructor(
  127346. /** The scene which the session should be created for */
  127347. scene: Scene);
  127348. /**
  127349. * The current reference space used in this session. This reference space can constantly change!
  127350. * It is mainly used to offset the camera's position.
  127351. */
  127352. get referenceSpace(): XRReferenceSpace;
  127353. /**
  127354. * Set a new reference space and triggers the observable
  127355. */
  127356. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127357. /**
  127358. * Disposes of the session manager
  127359. */
  127360. dispose(): void;
  127361. /**
  127362. * Stops the xrSession and restores the render loop
  127363. * @returns Promise which resolves after it exits XR
  127364. */
  127365. exitXRAsync(): Promise<void>;
  127366. /**
  127367. * Gets the correct render target texture to be rendered this frame for this eye
  127368. * @param eye the eye for which to get the render target
  127369. * @returns the render target for the specified eye
  127370. */
  127371. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127372. /**
  127373. * Creates a WebXRRenderTarget object for the XR session
  127374. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127375. * @param options optional options to provide when creating a new render target
  127376. * @returns a WebXR render target to which the session can render
  127377. */
  127378. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127379. /**
  127380. * Initializes the manager
  127381. * After initialization enterXR can be called to start an XR session
  127382. * @returns Promise which resolves after it is initialized
  127383. */
  127384. initializeAsync(): Promise<void>;
  127385. /**
  127386. * Initializes an xr session
  127387. * @param xrSessionMode mode to initialize
  127388. * @param xrSessionInit defines optional and required values to pass to the session builder
  127389. * @returns a promise which will resolve once the session has been initialized
  127390. */
  127391. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127392. /**
  127393. * Checks if a session would be supported for the creation options specified
  127394. * @param sessionMode session mode to check if supported eg. immersive-vr
  127395. * @returns A Promise that resolves to true if supported and false if not
  127396. */
  127397. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127398. /**
  127399. * Resets the reference space to the one started the session
  127400. */
  127401. resetReferenceSpace(): void;
  127402. /**
  127403. * Starts rendering to the xr layer
  127404. */
  127405. runXRRenderLoop(): void;
  127406. /**
  127407. * Sets the reference space on the xr session
  127408. * @param referenceSpaceType space to set
  127409. * @returns a promise that will resolve once the reference space has been set
  127410. */
  127411. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127412. /**
  127413. * Updates the render state of the session
  127414. * @param state state to set
  127415. * @returns a promise that resolves once the render state has been updated
  127416. */
  127417. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127418. /**
  127419. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127420. * @param sessionMode defines the session to test
  127421. * @returns a promise with boolean as final value
  127422. */
  127423. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127424. private _createRenderTargetTexture;
  127425. }
  127426. }
  127427. declare module BABYLON {
  127428. /**
  127429. * WebXR Camera which holds the views for the xrSession
  127430. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127431. */
  127432. export class WebXRCamera extends FreeCamera {
  127433. private _xrSessionManager;
  127434. private _firstFrame;
  127435. private _referenceQuaternion;
  127436. private _referencedPosition;
  127437. private _xrInvPositionCache;
  127438. private _xrInvQuaternionCache;
  127439. /**
  127440. * Observable raised before camera teleportation
  127441. */
  127442. onBeforeCameraTeleport: Observable<Vector3>;
  127443. /**
  127444. * Observable raised after camera teleportation
  127445. */
  127446. onAfterCameraTeleport: Observable<Vector3>;
  127447. /**
  127448. * Should position compensation execute on first frame.
  127449. * This is used when copying the position from a native (non XR) camera
  127450. */
  127451. compensateOnFirstFrame: boolean;
  127452. /**
  127453. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127454. * @param name the name of the camera
  127455. * @param scene the scene to add the camera to
  127456. * @param _xrSessionManager a constructed xr session manager
  127457. */
  127458. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127459. /**
  127460. * Return the user's height, unrelated to the current ground.
  127461. * This will be the y position of this camera, when ground level is 0.
  127462. */
  127463. get realWorldHeight(): number;
  127464. /** @hidden */
  127465. _updateForDualEyeDebugging(): void;
  127466. /**
  127467. * Sets this camera's transformation based on a non-vr camera
  127468. * @param otherCamera the non-vr camera to copy the transformation from
  127469. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127470. */
  127471. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127472. /**
  127473. * Gets the current instance class name ("WebXRCamera").
  127474. * @returns the class name
  127475. */
  127476. getClassName(): string;
  127477. private _rotate180;
  127478. private _updateFromXRSession;
  127479. private _updateNumberOfRigCameras;
  127480. private _updateReferenceSpace;
  127481. private _updateReferenceSpaceOffset;
  127482. }
  127483. }
  127484. declare module BABYLON {
  127485. /**
  127486. * Defining the interface required for a (webxr) feature
  127487. */
  127488. export interface IWebXRFeature extends IDisposable {
  127489. /**
  127490. * Is this feature attached
  127491. */
  127492. attached: boolean;
  127493. /**
  127494. * Should auto-attach be disabled?
  127495. */
  127496. disableAutoAttach: boolean;
  127497. /**
  127498. * Attach the feature to the session
  127499. * Will usually be called by the features manager
  127500. *
  127501. * @param force should attachment be forced (even when already attached)
  127502. * @returns true if successful.
  127503. */
  127504. attach(force?: boolean): boolean;
  127505. /**
  127506. * Detach the feature from the session
  127507. * Will usually be called by the features manager
  127508. *
  127509. * @returns true if successful.
  127510. */
  127511. detach(): boolean;
  127512. /**
  127513. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127514. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127515. *
  127516. * @returns whether or not the feature is compatible in this environment
  127517. */
  127518. isCompatible(): boolean;
  127519. /**
  127520. * Was this feature disposed;
  127521. */
  127522. isDisposed: boolean;
  127523. /**
  127524. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127525. */
  127526. xrNativeFeatureName?: string;
  127527. /**
  127528. * A list of (Babylon WebXR) features this feature depends on
  127529. */
  127530. dependsOn?: string[];
  127531. }
  127532. /**
  127533. * A list of the currently available features without referencing them
  127534. */
  127535. export class WebXRFeatureName {
  127536. /**
  127537. * The name of the anchor system feature
  127538. */
  127539. static readonly ANCHOR_SYSTEM: string;
  127540. /**
  127541. * The name of the background remover feature
  127542. */
  127543. static readonly BACKGROUND_REMOVER: string;
  127544. /**
  127545. * The name of the hit test feature
  127546. */
  127547. static readonly HIT_TEST: string;
  127548. /**
  127549. * physics impostors for xr controllers feature
  127550. */
  127551. static readonly PHYSICS_CONTROLLERS: string;
  127552. /**
  127553. * The name of the plane detection feature
  127554. */
  127555. static readonly PLANE_DETECTION: string;
  127556. /**
  127557. * The name of the pointer selection feature
  127558. */
  127559. static readonly POINTER_SELECTION: string;
  127560. /**
  127561. * The name of the teleportation feature
  127562. */
  127563. static readonly TELEPORTATION: string;
  127564. /**
  127565. * The name of the feature points feature.
  127566. */
  127567. static readonly FEATURE_POINTS: string;
  127568. /**
  127569. * The name of the hand tracking feature.
  127570. */
  127571. static readonly HAND_TRACKING: string;
  127572. }
  127573. /**
  127574. * Defining the constructor of a feature. Used to register the modules.
  127575. */
  127576. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127577. /**
  127578. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127579. * It is mainly used in AR sessions.
  127580. *
  127581. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127582. */
  127583. export class WebXRFeaturesManager implements IDisposable {
  127584. private _xrSessionManager;
  127585. private static readonly _AvailableFeatures;
  127586. private _features;
  127587. /**
  127588. * constructs a new features manages.
  127589. *
  127590. * @param _xrSessionManager an instance of WebXRSessionManager
  127591. */
  127592. constructor(_xrSessionManager: WebXRSessionManager);
  127593. /**
  127594. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127595. * Mainly used internally.
  127596. *
  127597. * @param featureName the name of the feature to register
  127598. * @param constructorFunction the function used to construct the module
  127599. * @param version the (babylon) version of the module
  127600. * @param stable is that a stable version of this module
  127601. */
  127602. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127603. /**
  127604. * Returns a constructor of a specific feature.
  127605. *
  127606. * @param featureName the name of the feature to construct
  127607. * @param version the version of the feature to load
  127608. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127609. * @param options optional options provided to the module.
  127610. * @returns a function that, when called, will return a new instance of this feature
  127611. */
  127612. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127613. /**
  127614. * Can be used to return the list of features currently registered
  127615. *
  127616. * @returns an Array of available features
  127617. */
  127618. static GetAvailableFeatures(): string[];
  127619. /**
  127620. * Gets the versions available for a specific feature
  127621. * @param featureName the name of the feature
  127622. * @returns an array with the available versions
  127623. */
  127624. static GetAvailableVersions(featureName: string): string[];
  127625. /**
  127626. * Return the latest unstable version of this feature
  127627. * @param featureName the name of the feature to search
  127628. * @returns the version number. if not found will return -1
  127629. */
  127630. static GetLatestVersionOfFeature(featureName: string): number;
  127631. /**
  127632. * Return the latest stable version of this feature
  127633. * @param featureName the name of the feature to search
  127634. * @returns the version number. if not found will return -1
  127635. */
  127636. static GetStableVersionOfFeature(featureName: string): number;
  127637. /**
  127638. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127639. * Can be used during a session to start a feature
  127640. * @param featureName the name of feature to attach
  127641. */
  127642. attachFeature(featureName: string): void;
  127643. /**
  127644. * Can be used inside a session or when the session ends to detach a specific feature
  127645. * @param featureName the name of the feature to detach
  127646. */
  127647. detachFeature(featureName: string): void;
  127648. /**
  127649. * Used to disable an already-enabled feature
  127650. * The feature will be disposed and will be recreated once enabled.
  127651. * @param featureName the feature to disable
  127652. * @returns true if disable was successful
  127653. */
  127654. disableFeature(featureName: string | {
  127655. Name: string;
  127656. }): boolean;
  127657. /**
  127658. * dispose this features manager
  127659. */
  127660. dispose(): void;
  127661. /**
  127662. * 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.
  127663. * 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.
  127664. *
  127665. * @param featureName the name of the feature to load or the class of the feature
  127666. * @param version optional version to load. if not provided the latest version will be enabled
  127667. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127668. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127669. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127670. * @returns a new constructed feature or throws an error if feature not found.
  127671. */
  127672. enableFeature(featureName: string | {
  127673. Name: string;
  127674. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127675. /**
  127676. * get the implementation of an enabled feature.
  127677. * @param featureName the name of the feature to load
  127678. * @returns the feature class, if found
  127679. */
  127680. getEnabledFeature(featureName: string): IWebXRFeature;
  127681. /**
  127682. * Get the list of enabled features
  127683. * @returns an array of enabled features
  127684. */
  127685. getEnabledFeatures(): string[];
  127686. /**
  127687. * This function will exten the session creation configuration object with enabled features.
  127688. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127689. * according to the defined "required" variable, provided during enableFeature call
  127690. * @param xrSessionInit the xr Session init object to extend
  127691. *
  127692. * @returns an extended XRSessionInit object
  127693. */
  127694. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127695. }
  127696. }
  127697. declare module BABYLON {
  127698. /**
  127699. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127700. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127701. */
  127702. export class WebXRExperienceHelper implements IDisposable {
  127703. private scene;
  127704. private _nonVRCamera;
  127705. private _originalSceneAutoClear;
  127706. private _supported;
  127707. /**
  127708. * Camera used to render xr content
  127709. */
  127710. camera: WebXRCamera;
  127711. /** A features manager for this xr session */
  127712. featuresManager: WebXRFeaturesManager;
  127713. /**
  127714. * Observers registered here will be triggered after the camera's initial transformation is set
  127715. * This can be used to set a different ground level or an extra rotation.
  127716. *
  127717. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127718. * to the position set after this observable is done executing.
  127719. */
  127720. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127721. /**
  127722. * Fires when the state of the experience helper has changed
  127723. */
  127724. onStateChangedObservable: Observable<WebXRState>;
  127725. /** Session manager used to keep track of xr session */
  127726. sessionManager: WebXRSessionManager;
  127727. /**
  127728. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127729. */
  127730. state: WebXRState;
  127731. /**
  127732. * Creates a WebXRExperienceHelper
  127733. * @param scene The scene the helper should be created in
  127734. */
  127735. private constructor();
  127736. /**
  127737. * Creates the experience helper
  127738. * @param scene the scene to attach the experience helper to
  127739. * @returns a promise for the experience helper
  127740. */
  127741. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127742. /**
  127743. * Disposes of the experience helper
  127744. */
  127745. dispose(): void;
  127746. /**
  127747. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127748. * @param sessionMode options for the XR session
  127749. * @param referenceSpaceType frame of reference of the XR session
  127750. * @param renderTarget the output canvas that will be used to enter XR mode
  127751. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127752. * @returns promise that resolves after xr mode has entered
  127753. */
  127754. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127755. /**
  127756. * Exits XR mode and returns the scene to its original state
  127757. * @returns promise that resolves after xr mode has exited
  127758. */
  127759. exitXRAsync(): Promise<void>;
  127760. private _nonXRToXRCamera;
  127761. private _setState;
  127762. }
  127763. }
  127764. declare module BABYLON {
  127765. /**
  127766. * X-Y values for axes in WebXR
  127767. */
  127768. export interface IWebXRMotionControllerAxesValue {
  127769. /**
  127770. * The value of the x axis
  127771. */
  127772. x: number;
  127773. /**
  127774. * The value of the y-axis
  127775. */
  127776. y: number;
  127777. }
  127778. /**
  127779. * changed / previous values for the values of this component
  127780. */
  127781. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127782. /**
  127783. * current (this frame) value
  127784. */
  127785. current: T;
  127786. /**
  127787. * previous (last change) value
  127788. */
  127789. previous: T;
  127790. }
  127791. /**
  127792. * Represents changes in the component between current frame and last values recorded
  127793. */
  127794. export interface IWebXRMotionControllerComponentChanges {
  127795. /**
  127796. * will be populated with previous and current values if axes changed
  127797. */
  127798. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127799. /**
  127800. * will be populated with previous and current values if pressed changed
  127801. */
  127802. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127803. /**
  127804. * will be populated with previous and current values if touched changed
  127805. */
  127806. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127807. /**
  127808. * will be populated with previous and current values if value changed
  127809. */
  127810. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127811. }
  127812. /**
  127813. * This class represents a single component (for example button or thumbstick) of a motion controller
  127814. */
  127815. export class WebXRControllerComponent implements IDisposable {
  127816. /**
  127817. * the id of this component
  127818. */
  127819. id: string;
  127820. /**
  127821. * the type of the component
  127822. */
  127823. type: MotionControllerComponentType;
  127824. private _buttonIndex;
  127825. private _axesIndices;
  127826. private _axes;
  127827. private _changes;
  127828. private _currentValue;
  127829. private _hasChanges;
  127830. private _pressed;
  127831. private _touched;
  127832. /**
  127833. * button component type
  127834. */
  127835. static BUTTON_TYPE: MotionControllerComponentType;
  127836. /**
  127837. * squeeze component type
  127838. */
  127839. static SQUEEZE_TYPE: MotionControllerComponentType;
  127840. /**
  127841. * Thumbstick component type
  127842. */
  127843. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127844. /**
  127845. * Touchpad component type
  127846. */
  127847. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127848. /**
  127849. * trigger component type
  127850. */
  127851. static TRIGGER_TYPE: MotionControllerComponentType;
  127852. /**
  127853. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127854. * the axes data changes
  127855. */
  127856. onAxisValueChangedObservable: Observable<{
  127857. x: number;
  127858. y: number;
  127859. }>;
  127860. /**
  127861. * Observers registered here will be triggered when the state of a button changes
  127862. * State change is either pressed / touched / value
  127863. */
  127864. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127865. /**
  127866. * Creates a new component for a motion controller.
  127867. * It is created by the motion controller itself
  127868. *
  127869. * @param id the id of this component
  127870. * @param type the type of the component
  127871. * @param _buttonIndex index in the buttons array of the gamepad
  127872. * @param _axesIndices indices of the values in the axes array of the gamepad
  127873. */
  127874. constructor(
  127875. /**
  127876. * the id of this component
  127877. */
  127878. id: string,
  127879. /**
  127880. * the type of the component
  127881. */
  127882. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127883. /**
  127884. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127885. */
  127886. get axes(): IWebXRMotionControllerAxesValue;
  127887. /**
  127888. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127889. */
  127890. get changes(): IWebXRMotionControllerComponentChanges;
  127891. /**
  127892. * Return whether or not the component changed the last frame
  127893. */
  127894. get hasChanges(): boolean;
  127895. /**
  127896. * is the button currently pressed
  127897. */
  127898. get pressed(): boolean;
  127899. /**
  127900. * is the button currently touched
  127901. */
  127902. get touched(): boolean;
  127903. /**
  127904. * Get the current value of this component
  127905. */
  127906. get value(): number;
  127907. /**
  127908. * Dispose this component
  127909. */
  127910. dispose(): void;
  127911. /**
  127912. * Are there axes correlating to this component
  127913. * @return true is axes data is available
  127914. */
  127915. isAxes(): boolean;
  127916. /**
  127917. * Is this component a button (hence - pressable)
  127918. * @returns true if can be pressed
  127919. */
  127920. isButton(): boolean;
  127921. /**
  127922. * update this component using the gamepad object it is in. Called on every frame
  127923. * @param nativeController the native gamepad controller object
  127924. */
  127925. update(nativeController: IMinimalMotionControllerObject): void;
  127926. }
  127927. }
  127928. declare module BABYLON {
  127929. /**
  127930. * Interface used to represent data loading progression
  127931. */
  127932. export interface ISceneLoaderProgressEvent {
  127933. /**
  127934. * Defines if data length to load can be evaluated
  127935. */
  127936. readonly lengthComputable: boolean;
  127937. /**
  127938. * Defines the loaded data length
  127939. */
  127940. readonly loaded: number;
  127941. /**
  127942. * Defines the data length to load
  127943. */
  127944. readonly total: number;
  127945. }
  127946. /**
  127947. * Interface used by SceneLoader plugins to define supported file extensions
  127948. */
  127949. export interface ISceneLoaderPluginExtensions {
  127950. /**
  127951. * Defines the list of supported extensions
  127952. */
  127953. [extension: string]: {
  127954. isBinary: boolean;
  127955. };
  127956. }
  127957. /**
  127958. * Interface used by SceneLoader plugin factory
  127959. */
  127960. export interface ISceneLoaderPluginFactory {
  127961. /**
  127962. * Defines the name of the factory
  127963. */
  127964. name: string;
  127965. /**
  127966. * Function called to create a new plugin
  127967. * @return the new plugin
  127968. */
  127969. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127970. /**
  127971. * The callback that returns true if the data can be directly loaded.
  127972. * @param data string containing the file data
  127973. * @returns if the data can be loaded directly
  127974. */
  127975. canDirectLoad?(data: string): boolean;
  127976. }
  127977. /**
  127978. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127979. */
  127980. export interface ISceneLoaderPluginBase {
  127981. /**
  127982. * The friendly name of this plugin.
  127983. */
  127984. name: string;
  127985. /**
  127986. * The file extensions supported by this plugin.
  127987. */
  127988. extensions: string | ISceneLoaderPluginExtensions;
  127989. /**
  127990. * The callback called when loading from a url.
  127991. * @param scene scene loading this url
  127992. * @param url url to load
  127993. * @param onSuccess callback called when the file successfully loads
  127994. * @param onProgress callback called while file is loading (if the server supports this mode)
  127995. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127996. * @param onError callback called when the file fails to load
  127997. * @returns a file request object
  127998. */
  127999. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128000. /**
  128001. * The callback called when loading from a file object.
  128002. * @param scene scene loading this file
  128003. * @param file defines the file to load
  128004. * @param onSuccess defines the callback to call when data is loaded
  128005. * @param onProgress defines the callback to call during loading process
  128006. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128007. * @param onError defines the callback to call when an error occurs
  128008. * @returns a file request object
  128009. */
  128010. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128011. /**
  128012. * The callback that returns true if the data can be directly loaded.
  128013. * @param data string containing the file data
  128014. * @returns if the data can be loaded directly
  128015. */
  128016. canDirectLoad?(data: string): boolean;
  128017. /**
  128018. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128019. * @param scene scene loading this data
  128020. * @param data string containing the data
  128021. * @returns data to pass to the plugin
  128022. */
  128023. directLoad?(scene: Scene, data: string): any;
  128024. /**
  128025. * The callback that allows custom handling of the root url based on the response url.
  128026. * @param rootUrl the original root url
  128027. * @param responseURL the response url if available
  128028. * @returns the new root url
  128029. */
  128030. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128031. }
  128032. /**
  128033. * Interface used to define a SceneLoader plugin
  128034. */
  128035. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128036. /**
  128037. * Import meshes into a scene.
  128038. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128039. * @param scene The scene to import into
  128040. * @param data The data to import
  128041. * @param rootUrl The root url for scene and resources
  128042. * @param meshes The meshes array to import into
  128043. * @param particleSystems The particle systems array to import into
  128044. * @param skeletons The skeletons array to import into
  128045. * @param onError The callback when import fails
  128046. * @returns True if successful or false otherwise
  128047. */
  128048. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128049. /**
  128050. * Load into a scene.
  128051. * @param scene The scene to load into
  128052. * @param data The data to import
  128053. * @param rootUrl The root url for scene and resources
  128054. * @param onError The callback when import fails
  128055. * @returns True if successful or false otherwise
  128056. */
  128057. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128058. /**
  128059. * Load into an asset container.
  128060. * @param scene The scene to load into
  128061. * @param data The data to import
  128062. * @param rootUrl The root url for scene and resources
  128063. * @param onError The callback when import fails
  128064. * @returns The loaded asset container
  128065. */
  128066. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128067. }
  128068. /**
  128069. * Interface used to define an async SceneLoader plugin
  128070. */
  128071. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128072. /**
  128073. * Import meshes into a scene.
  128074. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128075. * @param scene The scene to import into
  128076. * @param data The data to import
  128077. * @param rootUrl The root url for scene and resources
  128078. * @param onProgress The callback when the load progresses
  128079. * @param fileName Defines the name of the file to load
  128080. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128081. */
  128082. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128083. meshes: AbstractMesh[];
  128084. particleSystems: IParticleSystem[];
  128085. skeletons: Skeleton[];
  128086. animationGroups: AnimationGroup[];
  128087. }>;
  128088. /**
  128089. * Load into a scene.
  128090. * @param scene The scene to load into
  128091. * @param data The data to import
  128092. * @param rootUrl The root url for scene and resources
  128093. * @param onProgress The callback when the load progresses
  128094. * @param fileName Defines the name of the file to load
  128095. * @returns Nothing
  128096. */
  128097. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128098. /**
  128099. * Load into an asset container.
  128100. * @param scene The scene to load into
  128101. * @param data The data to import
  128102. * @param rootUrl The root url for scene and resources
  128103. * @param onProgress The callback when the load progresses
  128104. * @param fileName Defines the name of the file to load
  128105. * @returns The loaded asset container
  128106. */
  128107. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128108. }
  128109. /**
  128110. * Mode that determines how to handle old animation groups before loading new ones.
  128111. */
  128112. export enum SceneLoaderAnimationGroupLoadingMode {
  128113. /**
  128114. * Reset all old animations to initial state then dispose them.
  128115. */
  128116. Clean = 0,
  128117. /**
  128118. * Stop all old animations.
  128119. */
  128120. Stop = 1,
  128121. /**
  128122. * Restart old animations from first frame.
  128123. */
  128124. Sync = 2,
  128125. /**
  128126. * Old animations remains untouched.
  128127. */
  128128. NoSync = 3
  128129. }
  128130. /**
  128131. * Defines a plugin registered by the SceneLoader
  128132. */
  128133. interface IRegisteredPlugin {
  128134. /**
  128135. * Defines the plugin to use
  128136. */
  128137. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128138. /**
  128139. * Defines if the plugin supports binary data
  128140. */
  128141. isBinary: boolean;
  128142. }
  128143. /**
  128144. * Class used to load scene from various file formats using registered plugins
  128145. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128146. */
  128147. export class SceneLoader {
  128148. /**
  128149. * No logging while loading
  128150. */
  128151. static readonly NO_LOGGING: number;
  128152. /**
  128153. * Minimal logging while loading
  128154. */
  128155. static readonly MINIMAL_LOGGING: number;
  128156. /**
  128157. * Summary logging while loading
  128158. */
  128159. static readonly SUMMARY_LOGGING: number;
  128160. /**
  128161. * Detailled logging while loading
  128162. */
  128163. static readonly DETAILED_LOGGING: number;
  128164. /**
  128165. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128166. */
  128167. static get ForceFullSceneLoadingForIncremental(): boolean;
  128168. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128169. /**
  128170. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128171. */
  128172. static get ShowLoadingScreen(): boolean;
  128173. static set ShowLoadingScreen(value: boolean);
  128174. /**
  128175. * Defines the current logging level (while loading the scene)
  128176. * @ignorenaming
  128177. */
  128178. static get loggingLevel(): number;
  128179. static set loggingLevel(value: number);
  128180. /**
  128181. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128182. */
  128183. static get CleanBoneMatrixWeights(): boolean;
  128184. static set CleanBoneMatrixWeights(value: boolean);
  128185. /**
  128186. * Event raised when a plugin is used to load a scene
  128187. */
  128188. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128189. private static _registeredPlugins;
  128190. private static _showingLoadingScreen;
  128191. /**
  128192. * Gets the default plugin (used to load Babylon files)
  128193. * @returns the .babylon plugin
  128194. */
  128195. static GetDefaultPlugin(): IRegisteredPlugin;
  128196. private static _GetPluginForExtension;
  128197. private static _GetPluginForDirectLoad;
  128198. private static _GetPluginForFilename;
  128199. private static _GetDirectLoad;
  128200. private static _LoadData;
  128201. private static _GetFileInfo;
  128202. /**
  128203. * Gets a plugin that can load the given extension
  128204. * @param extension defines the extension to load
  128205. * @returns a plugin or null if none works
  128206. */
  128207. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128208. /**
  128209. * Gets a boolean indicating that the given extension can be loaded
  128210. * @param extension defines the extension to load
  128211. * @returns true if the extension is supported
  128212. */
  128213. static IsPluginForExtensionAvailable(extension: string): boolean;
  128214. /**
  128215. * Adds a new plugin to the list of registered plugins
  128216. * @param plugin defines the plugin to add
  128217. */
  128218. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128219. /**
  128220. * Import meshes into a scene
  128221. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128222. * @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)
  128223. * @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)
  128224. * @param scene the instance of BABYLON.Scene to append to
  128225. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128226. * @param onProgress a callback with a progress event for each file being loaded
  128227. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128228. * @param pluginExtension the extension used to determine the plugin
  128229. * @returns The loaded plugin
  128230. */
  128231. 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>;
  128232. /**
  128233. * Import meshes into a scene
  128234. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128235. * @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)
  128236. * @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)
  128237. * @param scene the instance of BABYLON.Scene to append to
  128238. * @param onProgress a callback with a progress event for each file being loaded
  128239. * @param pluginExtension the extension used to determine the plugin
  128240. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128241. */
  128242. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128243. meshes: AbstractMesh[];
  128244. particleSystems: IParticleSystem[];
  128245. skeletons: Skeleton[];
  128246. animationGroups: AnimationGroup[];
  128247. }>;
  128248. /**
  128249. * Load a scene
  128250. * @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)
  128251. * @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)
  128252. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128253. * @param onSuccess a callback with the scene when import succeeds
  128254. * @param onProgress a callback with a progress event for each file being loaded
  128255. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128256. * @param pluginExtension the extension used to determine the plugin
  128257. * @returns The loaded plugin
  128258. */
  128259. 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>;
  128260. /**
  128261. * Load a scene
  128262. * @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)
  128263. * @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)
  128264. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128265. * @param onProgress a callback with a progress event for each file being loaded
  128266. * @param pluginExtension the extension used to determine the plugin
  128267. * @returns The loaded scene
  128268. */
  128269. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128270. /**
  128271. * Append a scene
  128272. * @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)
  128273. * @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)
  128274. * @param scene is the instance of BABYLON.Scene to append to
  128275. * @param onSuccess a callback with the scene when import succeeds
  128276. * @param onProgress a callback with a progress event for each file being loaded
  128277. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128278. * @param pluginExtension the extension used to determine the plugin
  128279. * @returns The loaded plugin
  128280. */
  128281. 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>;
  128282. /**
  128283. * Append a scene
  128284. * @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)
  128285. * @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)
  128286. * @param scene is the instance of BABYLON.Scene to append to
  128287. * @param onProgress a callback with a progress event for each file being loaded
  128288. * @param pluginExtension the extension used to determine the plugin
  128289. * @returns The given scene
  128290. */
  128291. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128292. /**
  128293. * Load a scene into an asset container
  128294. * @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)
  128295. * @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)
  128296. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128297. * @param onSuccess a callback with the scene when import succeeds
  128298. * @param onProgress a callback with a progress event for each file being loaded
  128299. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128300. * @param pluginExtension the extension used to determine the plugin
  128301. * @returns The loaded plugin
  128302. */
  128303. 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>;
  128304. /**
  128305. * Load a scene into an asset container
  128306. * @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)
  128307. * @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)
  128308. * @param scene is the instance of Scene to append to
  128309. * @param onProgress a callback with a progress event for each file being loaded
  128310. * @param pluginExtension the extension used to determine the plugin
  128311. * @returns The loaded asset container
  128312. */
  128313. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128314. /**
  128315. * Import animations from a file into a scene
  128316. * @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)
  128317. * @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)
  128318. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128319. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128320. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128321. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128322. * @param onSuccess a callback with the scene when import succeeds
  128323. * @param onProgress a callback with a progress event for each file being loaded
  128324. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128325. * @param pluginExtension the extension used to determine the plugin
  128326. */
  128327. 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;
  128328. /**
  128329. * Import animations from a file into a scene
  128330. * @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)
  128331. * @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)
  128332. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128333. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128334. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128335. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128336. * @param onSuccess a callback with the scene when import succeeds
  128337. * @param onProgress a callback with a progress event for each file being loaded
  128338. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128339. * @param pluginExtension the extension used to determine the plugin
  128340. * @returns the updated scene with imported animations
  128341. */
  128342. 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>;
  128343. }
  128344. }
  128345. declare module BABYLON {
  128346. /**
  128347. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128348. */
  128349. export type MotionControllerHandedness = "none" | "left" | "right";
  128350. /**
  128351. * The type of components available in motion controllers.
  128352. * This is not the name of the component.
  128353. */
  128354. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128355. /**
  128356. * The state of a controller component
  128357. */
  128358. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128359. /**
  128360. * The schema of motion controller layout.
  128361. * No object will be initialized using this interface
  128362. * This is used just to define the profile.
  128363. */
  128364. export interface IMotionControllerLayout {
  128365. /**
  128366. * Path to load the assets. Usually relative to the base path
  128367. */
  128368. assetPath: string;
  128369. /**
  128370. * Available components (unsorted)
  128371. */
  128372. components: {
  128373. /**
  128374. * A map of component Ids
  128375. */
  128376. [componentId: string]: {
  128377. /**
  128378. * The type of input the component outputs
  128379. */
  128380. type: MotionControllerComponentType;
  128381. /**
  128382. * The indices of this component in the gamepad object
  128383. */
  128384. gamepadIndices: {
  128385. /**
  128386. * Index of button
  128387. */
  128388. button?: number;
  128389. /**
  128390. * If available, index of x-axis
  128391. */
  128392. xAxis?: number;
  128393. /**
  128394. * If available, index of y-axis
  128395. */
  128396. yAxis?: number;
  128397. };
  128398. /**
  128399. * The mesh's root node name
  128400. */
  128401. rootNodeName: string;
  128402. /**
  128403. * Animation definitions for this model
  128404. */
  128405. visualResponses: {
  128406. [stateKey: string]: {
  128407. /**
  128408. * What property will be animated
  128409. */
  128410. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128411. /**
  128412. * What states influence this visual response
  128413. */
  128414. states: MotionControllerComponentStateType[];
  128415. /**
  128416. * Type of animation - movement or visibility
  128417. */
  128418. valueNodeProperty: "transform" | "visibility";
  128419. /**
  128420. * Base node name to move. Its position will be calculated according to the min and max nodes
  128421. */
  128422. valueNodeName?: string;
  128423. /**
  128424. * Minimum movement node
  128425. */
  128426. minNodeName?: string;
  128427. /**
  128428. * Max movement node
  128429. */
  128430. maxNodeName?: string;
  128431. };
  128432. };
  128433. /**
  128434. * If touch enabled, what is the name of node to display user feedback
  128435. */
  128436. touchPointNodeName?: string;
  128437. };
  128438. };
  128439. /**
  128440. * Is it xr standard mapping or not
  128441. */
  128442. gamepadMapping: "" | "xr-standard";
  128443. /**
  128444. * Base root node of this entire model
  128445. */
  128446. rootNodeName: string;
  128447. /**
  128448. * Defines the main button component id
  128449. */
  128450. selectComponentId: string;
  128451. }
  128452. /**
  128453. * A definition for the layout map in the input profile
  128454. */
  128455. export interface IMotionControllerLayoutMap {
  128456. /**
  128457. * Layouts with handedness type as a key
  128458. */
  128459. [handedness: string]: IMotionControllerLayout;
  128460. }
  128461. /**
  128462. * The XR Input profile schema
  128463. * Profiles can be found here:
  128464. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128465. */
  128466. export interface IMotionControllerProfile {
  128467. /**
  128468. * fallback profiles for this profileId
  128469. */
  128470. fallbackProfileIds: string[];
  128471. /**
  128472. * The layout map, with handedness as key
  128473. */
  128474. layouts: IMotionControllerLayoutMap;
  128475. /**
  128476. * The id of this profile
  128477. * correlates to the profile(s) in the xrInput.profiles array
  128478. */
  128479. profileId: string;
  128480. }
  128481. /**
  128482. * A helper-interface for the 3 meshes needed for controller button animation
  128483. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128484. */
  128485. export interface IMotionControllerButtonMeshMap {
  128486. /**
  128487. * the mesh that defines the pressed value mesh position.
  128488. * This is used to find the max-position of this button
  128489. */
  128490. pressedMesh: AbstractMesh;
  128491. /**
  128492. * the mesh that defines the unpressed value mesh position.
  128493. * This is used to find the min (or initial) position of this button
  128494. */
  128495. unpressedMesh: AbstractMesh;
  128496. /**
  128497. * The mesh that will be changed when value changes
  128498. */
  128499. valueMesh: AbstractMesh;
  128500. }
  128501. /**
  128502. * A helper-interface for the 3 meshes needed for controller axis animation.
  128503. * This will be expanded when touchpad animations are fully supported
  128504. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128505. */
  128506. export interface IMotionControllerMeshMap {
  128507. /**
  128508. * the mesh that defines the maximum value mesh position.
  128509. */
  128510. maxMesh?: AbstractMesh;
  128511. /**
  128512. * the mesh that defines the minimum value mesh position.
  128513. */
  128514. minMesh?: AbstractMesh;
  128515. /**
  128516. * The mesh that will be changed when axis value changes
  128517. */
  128518. valueMesh?: AbstractMesh;
  128519. }
  128520. /**
  128521. * The elements needed for change-detection of the gamepad objects in motion controllers
  128522. */
  128523. export interface IMinimalMotionControllerObject {
  128524. /**
  128525. * Available axes of this controller
  128526. */
  128527. axes: number[];
  128528. /**
  128529. * An array of available buttons
  128530. */
  128531. buttons: Array<{
  128532. /**
  128533. * Value of the button/trigger
  128534. */
  128535. value: number;
  128536. /**
  128537. * If the button/trigger is currently touched
  128538. */
  128539. touched: boolean;
  128540. /**
  128541. * If the button/trigger is currently pressed
  128542. */
  128543. pressed: boolean;
  128544. }>;
  128545. /**
  128546. * EXPERIMENTAL haptic support.
  128547. */
  128548. hapticActuators?: Array<{
  128549. pulse: (value: number, duration: number) => Promise<boolean>;
  128550. }>;
  128551. }
  128552. /**
  128553. * An Abstract Motion controller
  128554. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128555. * Each component has an observable to check for changes in value and state
  128556. */
  128557. export abstract class WebXRAbstractMotionController implements IDisposable {
  128558. protected scene: Scene;
  128559. protected layout: IMotionControllerLayout;
  128560. /**
  128561. * The gamepad object correlating to this controller
  128562. */
  128563. gamepadObject: IMinimalMotionControllerObject;
  128564. /**
  128565. * handedness (left/right/none) of this controller
  128566. */
  128567. handedness: MotionControllerHandedness;
  128568. private _initComponent;
  128569. private _modelReady;
  128570. /**
  128571. * A map of components (WebXRControllerComponent) in this motion controller
  128572. * Components have a ComponentType and can also have both button and axis definitions
  128573. */
  128574. readonly components: {
  128575. [id: string]: WebXRControllerComponent;
  128576. };
  128577. /**
  128578. * Disable the model's animation. Can be set at any time.
  128579. */
  128580. disableAnimation: boolean;
  128581. /**
  128582. * Observers registered here will be triggered when the model of this controller is done loading
  128583. */
  128584. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128585. /**
  128586. * The profile id of this motion controller
  128587. */
  128588. abstract profileId: string;
  128589. /**
  128590. * The root mesh of the model. It is null if the model was not yet initialized
  128591. */
  128592. rootMesh: Nullable<AbstractMesh>;
  128593. /**
  128594. * constructs a new abstract motion controller
  128595. * @param scene the scene to which the model of the controller will be added
  128596. * @param layout The profile layout to load
  128597. * @param gamepadObject The gamepad object correlating to this controller
  128598. * @param handedness handedness (left/right/none) of this controller
  128599. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128600. */
  128601. constructor(scene: Scene, layout: IMotionControllerLayout,
  128602. /**
  128603. * The gamepad object correlating to this controller
  128604. */
  128605. gamepadObject: IMinimalMotionControllerObject,
  128606. /**
  128607. * handedness (left/right/none) of this controller
  128608. */
  128609. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128610. /**
  128611. * Dispose this controller, the model mesh and all its components
  128612. */
  128613. dispose(): void;
  128614. /**
  128615. * Returns all components of specific type
  128616. * @param type the type to search for
  128617. * @return an array of components with this type
  128618. */
  128619. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128620. /**
  128621. * get a component based an its component id as defined in layout.components
  128622. * @param id the id of the component
  128623. * @returns the component correlates to the id or undefined if not found
  128624. */
  128625. getComponent(id: string): WebXRControllerComponent;
  128626. /**
  128627. * Get the list of components available in this motion controller
  128628. * @returns an array of strings correlating to available components
  128629. */
  128630. getComponentIds(): string[];
  128631. /**
  128632. * Get the first component of specific type
  128633. * @param type type of component to find
  128634. * @return a controller component or null if not found
  128635. */
  128636. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128637. /**
  128638. * Get the main (Select) component of this controller as defined in the layout
  128639. * @returns the main component of this controller
  128640. */
  128641. getMainComponent(): WebXRControllerComponent;
  128642. /**
  128643. * Loads the model correlating to this controller
  128644. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128645. * @returns A promise fulfilled with the result of the model loading
  128646. */
  128647. loadModel(): Promise<boolean>;
  128648. /**
  128649. * Update this model using the current XRFrame
  128650. * @param xrFrame the current xr frame to use and update the model
  128651. */
  128652. updateFromXRFrame(xrFrame: XRFrame): void;
  128653. /**
  128654. * Backwards compatibility due to a deeply-integrated typo
  128655. */
  128656. get handness(): XREye;
  128657. /**
  128658. * Pulse (vibrate) this controller
  128659. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128660. * Consecutive calls to this function will cancel the last pulse call
  128661. *
  128662. * @param value the strength of the pulse in 0.0...1.0 range
  128663. * @param duration Duration of the pulse in milliseconds
  128664. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128665. * @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
  128666. */
  128667. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128668. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128669. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128670. /**
  128671. * Moves the axis on the controller mesh based on its current state
  128672. * @param axis the index of the axis
  128673. * @param axisValue the value of the axis which determines the meshes new position
  128674. * @hidden
  128675. */
  128676. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128677. /**
  128678. * Update the model itself with the current frame data
  128679. * @param xrFrame the frame to use for updating the model mesh
  128680. */
  128681. protected updateModel(xrFrame: XRFrame): void;
  128682. /**
  128683. * Get the filename and path for this controller's model
  128684. * @returns a map of filename and path
  128685. */
  128686. protected abstract _getFilenameAndPath(): {
  128687. filename: string;
  128688. path: string;
  128689. };
  128690. /**
  128691. * This function is called before the mesh is loaded. It checks for loading constraints.
  128692. * For example, this function can check if the GLB loader is available
  128693. * If this function returns false, the generic controller will be loaded instead
  128694. * @returns Is the client ready to load the mesh
  128695. */
  128696. protected abstract _getModelLoadingConstraints(): boolean;
  128697. /**
  128698. * This function will be called after the model was successfully loaded and can be used
  128699. * for mesh transformations before it is available for the user
  128700. * @param meshes the loaded meshes
  128701. */
  128702. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128703. /**
  128704. * Set the root mesh for this controller. Important for the WebXR controller class
  128705. * @param meshes the loaded meshes
  128706. */
  128707. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128708. /**
  128709. * A function executed each frame that updates the mesh (if needed)
  128710. * @param xrFrame the current xrFrame
  128711. */
  128712. protected abstract _updateModel(xrFrame: XRFrame): void;
  128713. private _getGenericFilenameAndPath;
  128714. private _getGenericParentMesh;
  128715. }
  128716. }
  128717. declare module BABYLON {
  128718. /**
  128719. * A generic trigger-only motion controller for WebXR
  128720. */
  128721. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128722. /**
  128723. * Static version of the profile id of this controller
  128724. */
  128725. static ProfileId: string;
  128726. profileId: string;
  128727. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128728. protected _getFilenameAndPath(): {
  128729. filename: string;
  128730. path: string;
  128731. };
  128732. protected _getModelLoadingConstraints(): boolean;
  128733. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128734. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128735. protected _updateModel(): void;
  128736. }
  128737. }
  128738. declare module BABYLON {
  128739. /**
  128740. * Class containing static functions to help procedurally build meshes
  128741. */
  128742. export class SphereBuilder {
  128743. /**
  128744. * Creates a sphere mesh
  128745. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128746. * * 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`)
  128747. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128748. * * 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
  128749. * * 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)
  128750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128753. * @param name defines the name of the mesh
  128754. * @param options defines the options used to create the mesh
  128755. * @param scene defines the hosting scene
  128756. * @returns the sphere mesh
  128757. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128758. */
  128759. static CreateSphere(name: string, options: {
  128760. segments?: number;
  128761. diameter?: number;
  128762. diameterX?: number;
  128763. diameterY?: number;
  128764. diameterZ?: number;
  128765. arc?: number;
  128766. slice?: number;
  128767. sideOrientation?: number;
  128768. frontUVs?: Vector4;
  128769. backUVs?: Vector4;
  128770. updatable?: boolean;
  128771. }, scene?: Nullable<Scene>): Mesh;
  128772. }
  128773. }
  128774. declare module BABYLON {
  128775. /**
  128776. * A profiled motion controller has its profile loaded from an online repository.
  128777. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128778. */
  128779. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128780. private _repositoryUrl;
  128781. private _buttonMeshMapping;
  128782. private _touchDots;
  128783. /**
  128784. * The profile ID of this controller. Will be populated when the controller initializes.
  128785. */
  128786. profileId: string;
  128787. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128788. dispose(): void;
  128789. protected _getFilenameAndPath(): {
  128790. filename: string;
  128791. path: string;
  128792. };
  128793. protected _getModelLoadingConstraints(): boolean;
  128794. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128795. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128796. protected _updateModel(_xrFrame: XRFrame): void;
  128797. }
  128798. }
  128799. declare module BABYLON {
  128800. /**
  128801. * A construction function type to create a new controller based on an xrInput object
  128802. */
  128803. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128804. /**
  128805. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128806. *
  128807. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128808. * it should be replaced with auto-loaded controllers.
  128809. *
  128810. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128811. */
  128812. export class WebXRMotionControllerManager {
  128813. private static _AvailableControllers;
  128814. private static _Fallbacks;
  128815. private static _ProfileLoadingPromises;
  128816. private static _ProfilesList;
  128817. /**
  128818. * The base URL of the online controller repository. Can be changed at any time.
  128819. */
  128820. static BaseRepositoryUrl: string;
  128821. /**
  128822. * Which repository gets priority - local or online
  128823. */
  128824. static PrioritizeOnlineRepository: boolean;
  128825. /**
  128826. * Use the online repository, or use only locally-defined controllers
  128827. */
  128828. static UseOnlineRepository: boolean;
  128829. /**
  128830. * Clear the cache used for profile loading and reload when requested again
  128831. */
  128832. static ClearProfilesCache(): void;
  128833. /**
  128834. * Register the default fallbacks.
  128835. * This function is called automatically when this file is imported.
  128836. */
  128837. static DefaultFallbacks(): void;
  128838. /**
  128839. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128840. * @param profileId the profile to which a fallback needs to be found
  128841. * @return an array with corresponding fallback profiles
  128842. */
  128843. static FindFallbackWithProfileId(profileId: string): string[];
  128844. /**
  128845. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128846. * The order of search:
  128847. *
  128848. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128849. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128850. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128851. * 4) return the generic trigger controller if none were found
  128852. *
  128853. * @param xrInput the xrInput to which a new controller is initialized
  128854. * @param scene the scene to which the model will be added
  128855. * @param forceProfile force a certain profile for this controller
  128856. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128857. */
  128858. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128859. /**
  128860. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128861. *
  128862. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128863. *
  128864. * @param type the profile type to register
  128865. * @param constructFunction the function to be called when loading this profile
  128866. */
  128867. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128868. /**
  128869. * Register a fallback to a specific profile.
  128870. * @param profileId the profileId that will receive the fallbacks
  128871. * @param fallbacks A list of fallback profiles
  128872. */
  128873. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128874. /**
  128875. * Will update the list of profiles available in the repository
  128876. * @return a promise that resolves to a map of profiles available online
  128877. */
  128878. static UpdateProfilesList(): Promise<{
  128879. [profile: string]: string;
  128880. }>;
  128881. private static _LoadProfileFromRepository;
  128882. private static _LoadProfilesFromAvailableControllers;
  128883. }
  128884. }
  128885. declare module BABYLON {
  128886. /**
  128887. * Configuration options for the WebXR controller creation
  128888. */
  128889. export interface IWebXRControllerOptions {
  128890. /**
  128891. * Should the controller mesh be animated when a user interacts with it
  128892. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128893. */
  128894. disableMotionControllerAnimation?: boolean;
  128895. /**
  128896. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128897. */
  128898. doNotLoadControllerMesh?: boolean;
  128899. /**
  128900. * Force a specific controller type for this controller.
  128901. * This can be used when creating your own profile or when testing different controllers
  128902. */
  128903. forceControllerProfile?: string;
  128904. /**
  128905. * Defines a rendering group ID for meshes that will be loaded.
  128906. * This is for the default controllers only.
  128907. */
  128908. renderingGroupId?: number;
  128909. }
  128910. /**
  128911. * Represents an XR controller
  128912. */
  128913. export class WebXRInputSource {
  128914. private _scene;
  128915. /** The underlying input source for the controller */
  128916. inputSource: XRInputSource;
  128917. private _options;
  128918. private _tmpVector;
  128919. private _uniqueId;
  128920. private _disposed;
  128921. /**
  128922. * 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
  128923. */
  128924. grip?: AbstractMesh;
  128925. /**
  128926. * If available, this is the gamepad object related to this controller.
  128927. * Using this object it is possible to get click events and trackpad changes of the
  128928. * webxr controller that is currently being used.
  128929. */
  128930. motionController?: WebXRAbstractMotionController;
  128931. /**
  128932. * Event that fires when the controller is removed/disposed.
  128933. * The object provided as event data is this controller, after associated assets were disposed.
  128934. * uniqueId is still available.
  128935. */
  128936. onDisposeObservable: Observable<WebXRInputSource>;
  128937. /**
  128938. * Will be triggered when the mesh associated with the motion controller is done loading.
  128939. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128940. * A shortened version of controller -> motion controller -> on mesh loaded.
  128941. */
  128942. onMeshLoadedObservable: Observable<AbstractMesh>;
  128943. /**
  128944. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128945. */
  128946. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128947. /**
  128948. * Pointer which can be used to select objects or attach a visible laser to
  128949. */
  128950. pointer: AbstractMesh;
  128951. /**
  128952. * Creates the input source object
  128953. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128954. * @param _scene the scene which the controller should be associated to
  128955. * @param inputSource the underlying input source for the controller
  128956. * @param _options options for this controller creation
  128957. */
  128958. constructor(_scene: Scene,
  128959. /** The underlying input source for the controller */
  128960. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128961. /**
  128962. * Get this controllers unique id
  128963. */
  128964. get uniqueId(): string;
  128965. /**
  128966. * Disposes of the object
  128967. */
  128968. dispose(): void;
  128969. /**
  128970. * Gets a world space ray coming from the pointer or grip
  128971. * @param result the resulting ray
  128972. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128973. */
  128974. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128975. /**
  128976. * Updates the controller pose based on the given XRFrame
  128977. * @param xrFrame xr frame to update the pose with
  128978. * @param referenceSpace reference space to use
  128979. */
  128980. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128981. }
  128982. }
  128983. declare module BABYLON {
  128984. /**
  128985. * The schema for initialization options of the XR Input class
  128986. */
  128987. export interface IWebXRInputOptions {
  128988. /**
  128989. * If set to true no model will be automatically loaded
  128990. */
  128991. doNotLoadControllerMeshes?: boolean;
  128992. /**
  128993. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128994. * If not found, the xr input profile data will be used.
  128995. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128996. */
  128997. forceInputProfile?: string;
  128998. /**
  128999. * Do not send a request to the controller repository to load the profile.
  129000. *
  129001. * Instead, use the controllers available in babylon itself.
  129002. */
  129003. disableOnlineControllerRepository?: boolean;
  129004. /**
  129005. * A custom URL for the controllers repository
  129006. */
  129007. customControllersRepositoryURL?: string;
  129008. /**
  129009. * Should the controller model's components not move according to the user input
  129010. */
  129011. disableControllerAnimation?: boolean;
  129012. /**
  129013. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129014. */
  129015. controllerOptions?: IWebXRControllerOptions;
  129016. }
  129017. /**
  129018. * XR input used to track XR inputs such as controllers/rays
  129019. */
  129020. export class WebXRInput implements IDisposable {
  129021. /**
  129022. * the xr session manager for this session
  129023. */
  129024. xrSessionManager: WebXRSessionManager;
  129025. /**
  129026. * the WebXR camera for this session. Mainly used for teleportation
  129027. */
  129028. xrCamera: WebXRCamera;
  129029. private readonly options;
  129030. /**
  129031. * XR controllers being tracked
  129032. */
  129033. controllers: Array<WebXRInputSource>;
  129034. private _frameObserver;
  129035. private _sessionEndedObserver;
  129036. private _sessionInitObserver;
  129037. /**
  129038. * Event when a controller has been connected/added
  129039. */
  129040. onControllerAddedObservable: Observable<WebXRInputSource>;
  129041. /**
  129042. * Event when a controller has been removed/disconnected
  129043. */
  129044. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129045. /**
  129046. * Initializes the WebXRInput
  129047. * @param xrSessionManager the xr session manager for this session
  129048. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129049. * @param options = initialization options for this xr input
  129050. */
  129051. constructor(
  129052. /**
  129053. * the xr session manager for this session
  129054. */
  129055. xrSessionManager: WebXRSessionManager,
  129056. /**
  129057. * the WebXR camera for this session. Mainly used for teleportation
  129058. */
  129059. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129060. private _onInputSourcesChange;
  129061. private _addAndRemoveControllers;
  129062. /**
  129063. * Disposes of the object
  129064. */
  129065. dispose(): void;
  129066. }
  129067. }
  129068. declare module BABYLON {
  129069. /**
  129070. * This is the base class for all WebXR features.
  129071. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129072. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129073. */
  129074. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129075. protected _xrSessionManager: WebXRSessionManager;
  129076. private _attached;
  129077. private _removeOnDetach;
  129078. /**
  129079. * Is this feature disposed?
  129080. */
  129081. isDisposed: boolean;
  129082. /**
  129083. * Should auto-attach be disabled?
  129084. */
  129085. disableAutoAttach: boolean;
  129086. /**
  129087. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129088. */
  129089. xrNativeFeatureName: string;
  129090. /**
  129091. * Construct a new (abstract) WebXR feature
  129092. * @param _xrSessionManager the xr session manager for this feature
  129093. */
  129094. constructor(_xrSessionManager: WebXRSessionManager);
  129095. /**
  129096. * Is this feature attached
  129097. */
  129098. get attached(): boolean;
  129099. /**
  129100. * attach this feature
  129101. *
  129102. * @param force should attachment be forced (even when already attached)
  129103. * @returns true if successful, false is failed or already attached
  129104. */
  129105. attach(force?: boolean): boolean;
  129106. /**
  129107. * detach this feature.
  129108. *
  129109. * @returns true if successful, false if failed or already detached
  129110. */
  129111. detach(): boolean;
  129112. /**
  129113. * Dispose this feature and all of the resources attached
  129114. */
  129115. dispose(): void;
  129116. /**
  129117. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129118. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129119. *
  129120. * @returns whether or not the feature is compatible in this environment
  129121. */
  129122. isCompatible(): boolean;
  129123. /**
  129124. * This is used to register callbacks that will automatically be removed when detach is called.
  129125. * @param observable the observable to which the observer will be attached
  129126. * @param callback the callback to register
  129127. */
  129128. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129129. /**
  129130. * Code in this function will be executed on each xrFrame received from the browser.
  129131. * This function will not execute after the feature is detached.
  129132. * @param _xrFrame the current frame
  129133. */
  129134. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129135. }
  129136. }
  129137. declare module BABYLON {
  129138. /**
  129139. * Renders a layer on top of an existing scene
  129140. */
  129141. export class UtilityLayerRenderer implements IDisposable {
  129142. /** the original scene that will be rendered on top of */
  129143. originalScene: Scene;
  129144. private _pointerCaptures;
  129145. private _lastPointerEvents;
  129146. private static _DefaultUtilityLayer;
  129147. private static _DefaultKeepDepthUtilityLayer;
  129148. private _sharedGizmoLight;
  129149. private _renderCamera;
  129150. /**
  129151. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129152. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129153. * @returns the camera that is used when rendering the utility layer
  129154. */
  129155. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129156. /**
  129157. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129158. * @param cam the camera that should be used when rendering the utility layer
  129159. */
  129160. setRenderCamera(cam: Nullable<Camera>): void;
  129161. /**
  129162. * @hidden
  129163. * Light which used by gizmos to get light shading
  129164. */
  129165. _getSharedGizmoLight(): HemisphericLight;
  129166. /**
  129167. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129168. */
  129169. pickUtilitySceneFirst: boolean;
  129170. /**
  129171. * 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)
  129172. */
  129173. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129174. /**
  129175. * 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)
  129176. */
  129177. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129178. /**
  129179. * The scene that is rendered on top of the original scene
  129180. */
  129181. utilityLayerScene: Scene;
  129182. /**
  129183. * If the utility layer should automatically be rendered on top of existing scene
  129184. */
  129185. shouldRender: boolean;
  129186. /**
  129187. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129188. */
  129189. onlyCheckPointerDownEvents: boolean;
  129190. /**
  129191. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129192. */
  129193. processAllEvents: boolean;
  129194. /**
  129195. * Observable raised when the pointer move from the utility layer scene to the main scene
  129196. */
  129197. onPointerOutObservable: Observable<number>;
  129198. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129199. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129200. private _afterRenderObserver;
  129201. private _sceneDisposeObserver;
  129202. private _originalPointerObserver;
  129203. /**
  129204. * Instantiates a UtilityLayerRenderer
  129205. * @param originalScene the original scene that will be rendered on top of
  129206. * @param handleEvents boolean indicating if the utility layer should handle events
  129207. */
  129208. constructor(
  129209. /** the original scene that will be rendered on top of */
  129210. originalScene: Scene, handleEvents?: boolean);
  129211. private _notifyObservers;
  129212. /**
  129213. * Renders the utility layers scene on top of the original scene
  129214. */
  129215. render(): void;
  129216. /**
  129217. * Disposes of the renderer
  129218. */
  129219. dispose(): void;
  129220. private _updateCamera;
  129221. }
  129222. }
  129223. declare module BABYLON {
  129224. /**
  129225. * Options interface for the pointer selection module
  129226. */
  129227. export interface IWebXRControllerPointerSelectionOptions {
  129228. /**
  129229. * if provided, this scene will be used to render meshes.
  129230. */
  129231. customUtilityLayerScene?: Scene;
  129232. /**
  129233. * 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)
  129234. * If not disabled, the last picked point will be used to execute a pointer up event
  129235. * If disabled, pointer up event will be triggered right after the pointer down event.
  129236. * Used in screen and gaze target ray mode only
  129237. */
  129238. disablePointerUpOnTouchOut: boolean;
  129239. /**
  129240. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129241. */
  129242. forceGazeMode: boolean;
  129243. /**
  129244. * 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
  129245. * to start a new countdown to the pointer down event.
  129246. * Defaults to 1.
  129247. */
  129248. gazeModePointerMovedFactor?: number;
  129249. /**
  129250. * Different button type to use instead of the main component
  129251. */
  129252. overrideButtonId?: string;
  129253. /**
  129254. * use this rendering group id for the meshes (optional)
  129255. */
  129256. renderingGroupId?: number;
  129257. /**
  129258. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129259. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129260. * 3000 means 3 seconds between pointing at something and selecting it
  129261. */
  129262. timeToSelect?: number;
  129263. /**
  129264. * Should meshes created here be added to a utility layer or the main scene
  129265. */
  129266. useUtilityLayer?: boolean;
  129267. /**
  129268. * Optional WebXR camera to be used for gaze selection
  129269. */
  129270. gazeCamera?: WebXRCamera;
  129271. /**
  129272. * the xr input to use with this pointer selection
  129273. */
  129274. xrInput: WebXRInput;
  129275. }
  129276. /**
  129277. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129278. */
  129279. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129280. private readonly _options;
  129281. private static _idCounter;
  129282. private _attachController;
  129283. private _controllers;
  129284. private _scene;
  129285. private _tmpVectorForPickCompare;
  129286. /**
  129287. * The module's name
  129288. */
  129289. static readonly Name: string;
  129290. /**
  129291. * The (Babylon) version of this module.
  129292. * This is an integer representing the implementation version.
  129293. * This number does not correspond to the WebXR specs version
  129294. */
  129295. static readonly Version: number;
  129296. /**
  129297. * Disable lighting on the laser pointer (so it will always be visible)
  129298. */
  129299. disablePointerLighting: boolean;
  129300. /**
  129301. * Disable lighting on the selection mesh (so it will always be visible)
  129302. */
  129303. disableSelectionMeshLighting: boolean;
  129304. /**
  129305. * Should the laser pointer be displayed
  129306. */
  129307. displayLaserPointer: boolean;
  129308. /**
  129309. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129310. */
  129311. displaySelectionMesh: boolean;
  129312. /**
  129313. * This color will be set to the laser pointer when selection is triggered
  129314. */
  129315. laserPointerPickedColor: Color3;
  129316. /**
  129317. * Default color of the laser pointer
  129318. */
  129319. laserPointerDefaultColor: Color3;
  129320. /**
  129321. * default color of the selection ring
  129322. */
  129323. selectionMeshDefaultColor: Color3;
  129324. /**
  129325. * This color will be applied to the selection ring when selection is triggered
  129326. */
  129327. selectionMeshPickedColor: Color3;
  129328. /**
  129329. * Optional filter to be used for ray selection. This predicate shares behavior with
  129330. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129331. */
  129332. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129333. /**
  129334. * constructs a new background remover module
  129335. * @param _xrSessionManager the session manager for this module
  129336. * @param _options read-only options to be used in this module
  129337. */
  129338. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129339. /**
  129340. * attach this feature
  129341. * Will usually be called by the features manager
  129342. *
  129343. * @returns true if successful.
  129344. */
  129345. attach(): boolean;
  129346. /**
  129347. * detach this feature.
  129348. * Will usually be called by the features manager
  129349. *
  129350. * @returns true if successful.
  129351. */
  129352. detach(): boolean;
  129353. /**
  129354. * Will get the mesh under a specific pointer.
  129355. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129356. * @param controllerId the controllerId to check
  129357. * @returns The mesh under pointer or null if no mesh is under the pointer
  129358. */
  129359. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129360. /**
  129361. * Get the xr controller that correlates to the pointer id in the pointer event
  129362. *
  129363. * @param id the pointer id to search for
  129364. * @returns the controller that correlates to this id or null if not found
  129365. */
  129366. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129367. protected _onXRFrame(_xrFrame: XRFrame): void;
  129368. private _attachGazeMode;
  129369. private _attachScreenRayMode;
  129370. private _attachTrackedPointerRayMode;
  129371. private _convertNormalToDirectionOfRay;
  129372. private _detachController;
  129373. private _generateNewMeshPair;
  129374. private _pickingMoved;
  129375. private _updatePointerDistance;
  129376. /** @hidden */
  129377. get lasterPointerDefaultColor(): Color3;
  129378. }
  129379. }
  129380. declare module BABYLON {
  129381. /**
  129382. * Button which can be used to enter a different mode of XR
  129383. */
  129384. export class WebXREnterExitUIButton {
  129385. /** button element */
  129386. element: HTMLElement;
  129387. /** XR initialization options for the button */
  129388. sessionMode: XRSessionMode;
  129389. /** Reference space type */
  129390. referenceSpaceType: XRReferenceSpaceType;
  129391. /**
  129392. * Creates a WebXREnterExitUIButton
  129393. * @param element button element
  129394. * @param sessionMode XR initialization session mode
  129395. * @param referenceSpaceType the type of reference space to be used
  129396. */
  129397. constructor(
  129398. /** button element */
  129399. element: HTMLElement,
  129400. /** XR initialization options for the button */
  129401. sessionMode: XRSessionMode,
  129402. /** Reference space type */
  129403. referenceSpaceType: XRReferenceSpaceType);
  129404. /**
  129405. * Extendable function which can be used to update the button's visuals when the state changes
  129406. * @param activeButton the current active button in the UI
  129407. */
  129408. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129409. }
  129410. /**
  129411. * Options to create the webXR UI
  129412. */
  129413. export class WebXREnterExitUIOptions {
  129414. /**
  129415. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129416. */
  129417. customButtons?: Array<WebXREnterExitUIButton>;
  129418. /**
  129419. * A reference space type to use when creating the default button.
  129420. * Default is local-floor
  129421. */
  129422. referenceSpaceType?: XRReferenceSpaceType;
  129423. /**
  129424. * Context to enter xr with
  129425. */
  129426. renderTarget?: Nullable<WebXRRenderTarget>;
  129427. /**
  129428. * A session mode to use when creating the default button.
  129429. * Default is immersive-vr
  129430. */
  129431. sessionMode?: XRSessionMode;
  129432. /**
  129433. * A list of optional features to init the session with
  129434. */
  129435. optionalFeatures?: string[];
  129436. /**
  129437. * A list of optional features to init the session with
  129438. */
  129439. requiredFeatures?: string[];
  129440. }
  129441. /**
  129442. * UI to allow the user to enter/exit XR mode
  129443. */
  129444. export class WebXREnterExitUI implements IDisposable {
  129445. private scene;
  129446. /** version of the options passed to this UI */
  129447. options: WebXREnterExitUIOptions;
  129448. private _activeButton;
  129449. private _buttons;
  129450. /**
  129451. * The HTML Div Element to which buttons are added.
  129452. */
  129453. readonly overlay: HTMLDivElement;
  129454. /**
  129455. * Fired every time the active button is changed.
  129456. *
  129457. * When xr is entered via a button that launches xr that button will be the callback parameter
  129458. *
  129459. * When exiting xr the callback parameter will be null)
  129460. */
  129461. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129462. /**
  129463. *
  129464. * @param scene babylon scene object to use
  129465. * @param options (read-only) version of the options passed to this UI
  129466. */
  129467. private constructor();
  129468. /**
  129469. * Creates UI to allow the user to enter/exit XR mode
  129470. * @param scene the scene to add the ui to
  129471. * @param helper the xr experience helper to enter/exit xr with
  129472. * @param options options to configure the UI
  129473. * @returns the created ui
  129474. */
  129475. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129476. /**
  129477. * Disposes of the XR UI component
  129478. */
  129479. dispose(): void;
  129480. private _updateButtons;
  129481. }
  129482. }
  129483. declare module BABYLON {
  129484. /**
  129485. * Class containing static functions to help procedurally build meshes
  129486. */
  129487. export class LinesBuilder {
  129488. /**
  129489. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129490. * * 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
  129491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129492. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129493. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129494. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129495. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129496. * * 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
  129497. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129500. * @param name defines the name of the new line system
  129501. * @param options defines the options used to create the line system
  129502. * @param scene defines the hosting scene
  129503. * @returns a new line system mesh
  129504. */
  129505. static CreateLineSystem(name: string, options: {
  129506. lines: Vector3[][];
  129507. updatable?: boolean;
  129508. instance?: Nullable<LinesMesh>;
  129509. colors?: Nullable<Color4[][]>;
  129510. useVertexAlpha?: boolean;
  129511. }, scene: Nullable<Scene>): LinesMesh;
  129512. /**
  129513. * Creates a line mesh
  129514. * 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
  129515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129516. * * The parameter `points` is an array successive Vector3
  129517. * * 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
  129518. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129519. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129520. * * When updating an instance, remember that only point positions can change, not the number of points
  129521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129523. * @param name defines the name of the new line system
  129524. * @param options defines the options used to create the line system
  129525. * @param scene defines the hosting scene
  129526. * @returns a new line mesh
  129527. */
  129528. static CreateLines(name: string, options: {
  129529. points: Vector3[];
  129530. updatable?: boolean;
  129531. instance?: Nullable<LinesMesh>;
  129532. colors?: Color4[];
  129533. useVertexAlpha?: boolean;
  129534. }, scene?: Nullable<Scene>): LinesMesh;
  129535. /**
  129536. * Creates a dashed line mesh
  129537. * * 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
  129538. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129539. * * The parameter `points` is an array successive Vector3
  129540. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129541. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129542. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129543. * * 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
  129544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129545. * * When updating an instance, remember that only point positions can change, not the number of points
  129546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129547. * @param name defines the name of the mesh
  129548. * @param options defines the options used to create the mesh
  129549. * @param scene defines the hosting scene
  129550. * @returns the dashed line mesh
  129551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129552. */
  129553. static CreateDashedLines(name: string, options: {
  129554. points: Vector3[];
  129555. dashSize?: number;
  129556. gapSize?: number;
  129557. dashNb?: number;
  129558. updatable?: boolean;
  129559. instance?: LinesMesh;
  129560. useVertexAlpha?: boolean;
  129561. }, scene?: Nullable<Scene>): LinesMesh;
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * Construction options for a timer
  129567. */
  129568. export interface ITimerOptions<T> {
  129569. /**
  129570. * Time-to-end
  129571. */
  129572. timeout: number;
  129573. /**
  129574. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129575. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129576. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129577. */
  129578. contextObservable: Observable<T>;
  129579. /**
  129580. * Optional parameters when adding an observer to the observable
  129581. */
  129582. observableParameters?: {
  129583. mask?: number;
  129584. insertFirst?: boolean;
  129585. scope?: any;
  129586. };
  129587. /**
  129588. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129589. */
  129590. breakCondition?: (data?: ITimerData<T>) => boolean;
  129591. /**
  129592. * Will be triggered when the time condition has met
  129593. */
  129594. onEnded?: (data: ITimerData<any>) => void;
  129595. /**
  129596. * Will be triggered when the break condition has met (prematurely ended)
  129597. */
  129598. onAborted?: (data: ITimerData<any>) => void;
  129599. /**
  129600. * Optional function to execute on each tick (or count)
  129601. */
  129602. onTick?: (data: ITimerData<any>) => void;
  129603. }
  129604. /**
  129605. * An interface defining the data sent by the timer
  129606. */
  129607. export interface ITimerData<T> {
  129608. /**
  129609. * When did it start
  129610. */
  129611. startTime: number;
  129612. /**
  129613. * Time now
  129614. */
  129615. currentTime: number;
  129616. /**
  129617. * Time passed since started
  129618. */
  129619. deltaTime: number;
  129620. /**
  129621. * How much is completed, in [0.0...1.0].
  129622. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129623. */
  129624. completeRate: number;
  129625. /**
  129626. * What the registered observable sent in the last count
  129627. */
  129628. payload: T;
  129629. }
  129630. /**
  129631. * The current state of the timer
  129632. */
  129633. export enum TimerState {
  129634. /**
  129635. * Timer initialized, not yet started
  129636. */
  129637. INIT = 0,
  129638. /**
  129639. * Timer started and counting
  129640. */
  129641. STARTED = 1,
  129642. /**
  129643. * Timer ended (whether aborted or time reached)
  129644. */
  129645. ENDED = 2
  129646. }
  129647. /**
  129648. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129649. *
  129650. * @param options options with which to initialize this timer
  129651. */
  129652. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129653. /**
  129654. * An advanced implementation of a timer class
  129655. */
  129656. export class AdvancedTimer<T = any> implements IDisposable {
  129657. /**
  129658. * Will notify each time the timer calculates the remaining time
  129659. */
  129660. onEachCountObservable: Observable<ITimerData<T>>;
  129661. /**
  129662. * Will trigger when the timer was aborted due to the break condition
  129663. */
  129664. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129665. /**
  129666. * Will trigger when the timer ended successfully
  129667. */
  129668. onTimerEndedObservable: Observable<ITimerData<T>>;
  129669. /**
  129670. * Will trigger when the timer state has changed
  129671. */
  129672. onStateChangedObservable: Observable<TimerState>;
  129673. private _observer;
  129674. private _contextObservable;
  129675. private _observableParameters;
  129676. private _startTime;
  129677. private _timer;
  129678. private _state;
  129679. private _breakCondition;
  129680. private _timeToEnd;
  129681. private _breakOnNextTick;
  129682. /**
  129683. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129684. * @param options construction options for this advanced timer
  129685. */
  129686. constructor(options: ITimerOptions<T>);
  129687. /**
  129688. * set a breaking condition for this timer. Default is to never break during count
  129689. * @param predicate the new break condition. Returns true to break, false otherwise
  129690. */
  129691. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129692. /**
  129693. * Reset ALL associated observables in this advanced timer
  129694. */
  129695. clearObservables(): void;
  129696. /**
  129697. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129698. *
  129699. * @param timeToEnd how much time to measure until timer ended
  129700. */
  129701. start(timeToEnd?: number): void;
  129702. /**
  129703. * Will force a stop on the next tick.
  129704. */
  129705. stop(): void;
  129706. /**
  129707. * Dispose this timer, clearing all resources
  129708. */
  129709. dispose(): void;
  129710. private _setState;
  129711. private _tick;
  129712. private _stop;
  129713. }
  129714. }
  129715. declare module BABYLON {
  129716. /**
  129717. * The options container for the teleportation module
  129718. */
  129719. export interface IWebXRTeleportationOptions {
  129720. /**
  129721. * if provided, this scene will be used to render meshes.
  129722. */
  129723. customUtilityLayerScene?: Scene;
  129724. /**
  129725. * Values to configure the default target mesh
  129726. */
  129727. defaultTargetMeshOptions?: {
  129728. /**
  129729. * Fill color of the teleportation area
  129730. */
  129731. teleportationFillColor?: string;
  129732. /**
  129733. * Border color for the teleportation area
  129734. */
  129735. teleportationBorderColor?: string;
  129736. /**
  129737. * Disable the mesh's animation sequence
  129738. */
  129739. disableAnimation?: boolean;
  129740. /**
  129741. * Disable lighting on the material or the ring and arrow
  129742. */
  129743. disableLighting?: boolean;
  129744. /**
  129745. * Override the default material of the torus and arrow
  129746. */
  129747. torusArrowMaterial?: Material;
  129748. };
  129749. /**
  129750. * A list of meshes to use as floor meshes.
  129751. * Meshes can be added and removed after initializing the feature using the
  129752. * addFloorMesh and removeFloorMesh functions
  129753. * If empty, rotation will still work
  129754. */
  129755. floorMeshes?: AbstractMesh[];
  129756. /**
  129757. * use this rendering group id for the meshes (optional)
  129758. */
  129759. renderingGroupId?: number;
  129760. /**
  129761. * Should teleportation move only to snap points
  129762. */
  129763. snapPointsOnly?: boolean;
  129764. /**
  129765. * An array of points to which the teleportation will snap to.
  129766. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129767. */
  129768. snapPositions?: Vector3[];
  129769. /**
  129770. * How close should the teleportation ray be in order to snap to position.
  129771. * Default to 0.8 units (meters)
  129772. */
  129773. snapToPositionRadius?: number;
  129774. /**
  129775. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129776. * If you want to support rotation, make sure your mesh has a direction indicator.
  129777. *
  129778. * When left untouched, the default mesh will be initialized.
  129779. */
  129780. teleportationTargetMesh?: AbstractMesh;
  129781. /**
  129782. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129783. */
  129784. timeToTeleport?: number;
  129785. /**
  129786. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129787. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129788. */
  129789. useMainComponentOnly?: boolean;
  129790. /**
  129791. * Should meshes created here be added to a utility layer or the main scene
  129792. */
  129793. useUtilityLayer?: boolean;
  129794. /**
  129795. * Babylon XR Input class for controller
  129796. */
  129797. xrInput: WebXRInput;
  129798. /**
  129799. * Meshes that the teleportation ray cannot go through
  129800. */
  129801. pickBlockerMeshes?: AbstractMesh[];
  129802. }
  129803. /**
  129804. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129805. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129806. * the input of the attached controllers.
  129807. */
  129808. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129809. private _options;
  129810. private _controllers;
  129811. private _currentTeleportationControllerId;
  129812. private _floorMeshes;
  129813. private _quadraticBezierCurve;
  129814. private _selectionFeature;
  129815. private _snapToPositions;
  129816. private _snappedToPoint;
  129817. private _teleportationRingMaterial?;
  129818. private _tmpRay;
  129819. private _tmpVector;
  129820. private _tmpQuaternion;
  129821. /**
  129822. * The module's name
  129823. */
  129824. static readonly Name: string;
  129825. /**
  129826. * The (Babylon) version of this module.
  129827. * This is an integer representing the implementation version.
  129828. * This number does not correspond to the webxr specs version
  129829. */
  129830. static readonly Version: number;
  129831. /**
  129832. * Is movement backwards enabled
  129833. */
  129834. backwardsMovementEnabled: boolean;
  129835. /**
  129836. * Distance to travel when moving backwards
  129837. */
  129838. backwardsTeleportationDistance: number;
  129839. /**
  129840. * The distance from the user to the inspection point in the direction of the controller
  129841. * A higher number will allow the user to move further
  129842. * defaults to 5 (meters, in xr units)
  129843. */
  129844. parabolicCheckRadius: number;
  129845. /**
  129846. * Should the module support parabolic ray on top of direct ray
  129847. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129848. * Very helpful when moving between floors / different heights
  129849. */
  129850. parabolicRayEnabled: boolean;
  129851. /**
  129852. * How much rotation should be applied when rotating right and left
  129853. */
  129854. rotationAngle: number;
  129855. /**
  129856. * Is rotation enabled when moving forward?
  129857. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129858. */
  129859. rotationEnabled: boolean;
  129860. /**
  129861. * constructs a new anchor system
  129862. * @param _xrSessionManager an instance of WebXRSessionManager
  129863. * @param _options configuration object for this feature
  129864. */
  129865. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129866. /**
  129867. * Get the snapPointsOnly flag
  129868. */
  129869. get snapPointsOnly(): boolean;
  129870. /**
  129871. * Sets the snapPointsOnly flag
  129872. * @param snapToPoints should teleportation be exclusively to snap points
  129873. */
  129874. set snapPointsOnly(snapToPoints: boolean);
  129875. /**
  129876. * Add a new mesh to the floor meshes array
  129877. * @param mesh the mesh to use as floor mesh
  129878. */
  129879. addFloorMesh(mesh: AbstractMesh): void;
  129880. /**
  129881. * Add a new snap-to point to fix teleportation to this position
  129882. * @param newSnapPoint The new Snap-To point
  129883. */
  129884. addSnapPoint(newSnapPoint: Vector3): void;
  129885. attach(): boolean;
  129886. detach(): boolean;
  129887. dispose(): void;
  129888. /**
  129889. * Remove a mesh from the floor meshes array
  129890. * @param mesh the mesh to remove
  129891. */
  129892. removeFloorMesh(mesh: AbstractMesh): void;
  129893. /**
  129894. * Remove a mesh from the floor meshes array using its name
  129895. * @param name the mesh name to remove
  129896. */
  129897. removeFloorMeshByName(name: string): void;
  129898. /**
  129899. * 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
  129900. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129901. * @returns was the point found and removed or not
  129902. */
  129903. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129904. /**
  129905. * This function sets a selection feature that will be disabled when
  129906. * the forward ray is shown and will be reattached when hidden.
  129907. * This is used to remove the selection rays when moving.
  129908. * @param selectionFeature the feature to disable when forward movement is enabled
  129909. */
  129910. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129911. protected _onXRFrame(_xrFrame: XRFrame): void;
  129912. private _attachController;
  129913. private _createDefaultTargetMesh;
  129914. private _detachController;
  129915. private _findClosestSnapPointWithRadius;
  129916. private _setTargetMeshPosition;
  129917. private _setTargetMeshVisibility;
  129918. private _showParabolicPath;
  129919. private _teleportForward;
  129920. }
  129921. }
  129922. declare module BABYLON {
  129923. /**
  129924. * Options for the default xr helper
  129925. */
  129926. export class WebXRDefaultExperienceOptions {
  129927. /**
  129928. * Enable or disable default UI to enter XR
  129929. */
  129930. disableDefaultUI?: boolean;
  129931. /**
  129932. * Should teleportation not initialize. defaults to false.
  129933. */
  129934. disableTeleportation?: boolean;
  129935. /**
  129936. * Floor meshes that will be used for teleport
  129937. */
  129938. floorMeshes?: Array<AbstractMesh>;
  129939. /**
  129940. * If set to true, the first frame will not be used to reset position
  129941. * The first frame is mainly used when copying transformation from the old camera
  129942. * Mainly used in AR
  129943. */
  129944. ignoreNativeCameraTransformation?: boolean;
  129945. /**
  129946. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129947. */
  129948. inputOptions?: IWebXRInputOptions;
  129949. /**
  129950. * optional configuration for the output canvas
  129951. */
  129952. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129953. /**
  129954. * optional UI options. This can be used among other to change session mode and reference space type
  129955. */
  129956. uiOptions?: WebXREnterExitUIOptions;
  129957. /**
  129958. * When loading teleportation and pointer select, use stable versions instead of latest.
  129959. */
  129960. useStablePlugins?: boolean;
  129961. /**
  129962. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129963. */
  129964. renderingGroupId?: number;
  129965. /**
  129966. * A list of optional features to init the session with
  129967. * If set to true, all features we support will be added
  129968. */
  129969. optionalFeatures?: boolean | string[];
  129970. }
  129971. /**
  129972. * Default experience which provides a similar setup to the previous webVRExperience
  129973. */
  129974. export class WebXRDefaultExperience {
  129975. /**
  129976. * Base experience
  129977. */
  129978. baseExperience: WebXRExperienceHelper;
  129979. /**
  129980. * Enables ui for entering/exiting xr
  129981. */
  129982. enterExitUI: WebXREnterExitUI;
  129983. /**
  129984. * Input experience extension
  129985. */
  129986. input: WebXRInput;
  129987. /**
  129988. * Enables laser pointer and selection
  129989. */
  129990. pointerSelection: WebXRControllerPointerSelection;
  129991. /**
  129992. * Default target xr should render to
  129993. */
  129994. renderTarget: WebXRRenderTarget;
  129995. /**
  129996. * Enables teleportation
  129997. */
  129998. teleportation: WebXRMotionControllerTeleportation;
  129999. private constructor();
  130000. /**
  130001. * Creates the default xr experience
  130002. * @param scene scene
  130003. * @param options options for basic configuration
  130004. * @returns resulting WebXRDefaultExperience
  130005. */
  130006. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130007. /**
  130008. * DIsposes of the experience helper
  130009. */
  130010. dispose(): void;
  130011. }
  130012. }
  130013. declare module BABYLON {
  130014. /**
  130015. * Options to modify the vr teleportation behavior.
  130016. */
  130017. export interface VRTeleportationOptions {
  130018. /**
  130019. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130020. */
  130021. floorMeshName?: string;
  130022. /**
  130023. * A list of meshes to be used as the teleportation floor. (default: empty)
  130024. */
  130025. floorMeshes?: Mesh[];
  130026. /**
  130027. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130028. */
  130029. teleportationMode?: number;
  130030. /**
  130031. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130032. */
  130033. teleportationTime?: number;
  130034. /**
  130035. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130036. */
  130037. teleportationSpeed?: number;
  130038. /**
  130039. * The easing function used in the animation or null for Linear. (default CircleEase)
  130040. */
  130041. easingFunction?: EasingFunction;
  130042. }
  130043. /**
  130044. * Options to modify the vr experience helper's behavior.
  130045. */
  130046. export interface VRExperienceHelperOptions extends WebVROptions {
  130047. /**
  130048. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130049. */
  130050. createDeviceOrientationCamera?: boolean;
  130051. /**
  130052. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130053. */
  130054. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130055. /**
  130056. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130057. */
  130058. laserToggle?: boolean;
  130059. /**
  130060. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130061. */
  130062. floorMeshes?: Mesh[];
  130063. /**
  130064. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130065. */
  130066. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130067. /**
  130068. * Defines if WebXR should be used instead of WebVR (if available)
  130069. */
  130070. useXR?: boolean;
  130071. }
  130072. /**
  130073. * Event containing information after VR has been entered
  130074. */
  130075. export class OnAfterEnteringVRObservableEvent {
  130076. /**
  130077. * If entering vr was successful
  130078. */
  130079. success: boolean;
  130080. }
  130081. /**
  130082. * Helps to quickly add VR support to an existing scene.
  130083. * See https://doc.babylonjs.com/how_to/webvr_helper
  130084. */
  130085. export class VRExperienceHelper {
  130086. /** Options to modify the vr experience helper's behavior. */
  130087. webVROptions: VRExperienceHelperOptions;
  130088. private _scene;
  130089. private _position;
  130090. private _btnVR;
  130091. private _btnVRDisplayed;
  130092. private _webVRsupported;
  130093. private _webVRready;
  130094. private _webVRrequesting;
  130095. private _webVRpresenting;
  130096. private _hasEnteredVR;
  130097. private _fullscreenVRpresenting;
  130098. private _inputElement;
  130099. private _webVRCamera;
  130100. private _vrDeviceOrientationCamera;
  130101. private _deviceOrientationCamera;
  130102. private _existingCamera;
  130103. private _onKeyDown;
  130104. private _onVrDisplayPresentChange;
  130105. private _onVRDisplayChanged;
  130106. private _onVRRequestPresentStart;
  130107. private _onVRRequestPresentComplete;
  130108. /**
  130109. * 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)
  130110. */
  130111. enableGazeEvenWhenNoPointerLock: boolean;
  130112. /**
  130113. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130114. */
  130115. exitVROnDoubleTap: boolean;
  130116. /**
  130117. * Observable raised right before entering VR.
  130118. */
  130119. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130120. /**
  130121. * Observable raised when entering VR has completed.
  130122. */
  130123. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130124. /**
  130125. * Observable raised when exiting VR.
  130126. */
  130127. onExitingVRObservable: Observable<VRExperienceHelper>;
  130128. /**
  130129. * Observable raised when controller mesh is loaded.
  130130. */
  130131. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130132. /** Return this.onEnteringVRObservable
  130133. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130134. */
  130135. get onEnteringVR(): Observable<VRExperienceHelper>;
  130136. /** Return this.onExitingVRObservable
  130137. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130138. */
  130139. get onExitingVR(): Observable<VRExperienceHelper>;
  130140. /** Return this.onControllerMeshLoadedObservable
  130141. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130142. */
  130143. get onControllerMeshLoaded(): Observable<WebVRController>;
  130144. private _rayLength;
  130145. private _useCustomVRButton;
  130146. private _teleportationRequested;
  130147. private _teleportActive;
  130148. private _floorMeshName;
  130149. private _floorMeshesCollection;
  130150. private _teleportationMode;
  130151. private _teleportationTime;
  130152. private _teleportationSpeed;
  130153. private _teleportationEasing;
  130154. private _rotationAllowed;
  130155. private _teleportBackwardsVector;
  130156. private _teleportationTarget;
  130157. private _isDefaultTeleportationTarget;
  130158. private _postProcessMove;
  130159. private _teleportationFillColor;
  130160. private _teleportationBorderColor;
  130161. private _rotationAngle;
  130162. private _haloCenter;
  130163. private _cameraGazer;
  130164. private _padSensibilityUp;
  130165. private _padSensibilityDown;
  130166. private _leftController;
  130167. private _rightController;
  130168. private _gazeColor;
  130169. private _laserColor;
  130170. private _pickedLaserColor;
  130171. private _pickedGazeColor;
  130172. /**
  130173. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130174. */
  130175. onNewMeshSelected: Observable<AbstractMesh>;
  130176. /**
  130177. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130178. * This observable will provide the mesh and the controller used to select the mesh
  130179. */
  130180. onMeshSelectedWithController: Observable<{
  130181. mesh: AbstractMesh;
  130182. controller: WebVRController;
  130183. }>;
  130184. /**
  130185. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130186. */
  130187. onNewMeshPicked: Observable<PickingInfo>;
  130188. private _circleEase;
  130189. /**
  130190. * Observable raised before camera teleportation
  130191. */
  130192. onBeforeCameraTeleport: Observable<Vector3>;
  130193. /**
  130194. * Observable raised after camera teleportation
  130195. */
  130196. onAfterCameraTeleport: Observable<Vector3>;
  130197. /**
  130198. * Observable raised when current selected mesh gets unselected
  130199. */
  130200. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130201. private _raySelectionPredicate;
  130202. /**
  130203. * To be optionaly changed by user to define custom ray selection
  130204. */
  130205. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130206. /**
  130207. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130208. */
  130209. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130210. /**
  130211. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130212. */
  130213. teleportationEnabled: boolean;
  130214. private _defaultHeight;
  130215. private _teleportationInitialized;
  130216. private _interactionsEnabled;
  130217. private _interactionsRequested;
  130218. private _displayGaze;
  130219. private _displayLaserPointer;
  130220. /**
  130221. * The mesh used to display where the user is going to teleport.
  130222. */
  130223. get teleportationTarget(): Mesh;
  130224. /**
  130225. * Sets the mesh to be used to display where the user is going to teleport.
  130226. */
  130227. set teleportationTarget(value: Mesh);
  130228. /**
  130229. * 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
  130230. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130231. * See https://doc.babylonjs.com/resources/baking_transformations
  130232. */
  130233. get gazeTrackerMesh(): Mesh;
  130234. set gazeTrackerMesh(value: Mesh);
  130235. /**
  130236. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130237. */
  130238. updateGazeTrackerScale: boolean;
  130239. /**
  130240. * If the gaze trackers color should be updated when selecting meshes
  130241. */
  130242. updateGazeTrackerColor: boolean;
  130243. /**
  130244. * If the controller laser color should be updated when selecting meshes
  130245. */
  130246. updateControllerLaserColor: boolean;
  130247. /**
  130248. * The gaze tracking mesh corresponding to the left controller
  130249. */
  130250. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130251. /**
  130252. * The gaze tracking mesh corresponding to the right controller
  130253. */
  130254. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130255. /**
  130256. * If the ray of the gaze should be displayed.
  130257. */
  130258. get displayGaze(): boolean;
  130259. /**
  130260. * Sets if the ray of the gaze should be displayed.
  130261. */
  130262. set displayGaze(value: boolean);
  130263. /**
  130264. * If the ray of the LaserPointer should be displayed.
  130265. */
  130266. get displayLaserPointer(): boolean;
  130267. /**
  130268. * Sets if the ray of the LaserPointer should be displayed.
  130269. */
  130270. set displayLaserPointer(value: boolean);
  130271. /**
  130272. * The deviceOrientationCamera used as the camera when not in VR.
  130273. */
  130274. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130275. /**
  130276. * Based on the current WebVR support, returns the current VR camera used.
  130277. */
  130278. get currentVRCamera(): Nullable<Camera>;
  130279. /**
  130280. * The webVRCamera which is used when in VR.
  130281. */
  130282. get webVRCamera(): WebVRFreeCamera;
  130283. /**
  130284. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130285. */
  130286. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130287. /**
  130288. * The html button that is used to trigger entering into VR.
  130289. */
  130290. get vrButton(): Nullable<HTMLButtonElement>;
  130291. private get _teleportationRequestInitiated();
  130292. /**
  130293. * Defines whether or not Pointer lock should be requested when switching to
  130294. * full screen.
  130295. */
  130296. requestPointerLockOnFullScreen: boolean;
  130297. /**
  130298. * If asking to force XR, this will be populated with the default xr experience
  130299. */
  130300. xr: WebXRDefaultExperience;
  130301. /**
  130302. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130303. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130304. */
  130305. xrTestDone: boolean;
  130306. /**
  130307. * Instantiates a VRExperienceHelper.
  130308. * Helps to quickly add VR support to an existing scene.
  130309. * @param scene The scene the VRExperienceHelper belongs to.
  130310. * @param webVROptions Options to modify the vr experience helper's behavior.
  130311. */
  130312. constructor(scene: Scene,
  130313. /** Options to modify the vr experience helper's behavior. */
  130314. webVROptions?: VRExperienceHelperOptions);
  130315. private completeVRInit;
  130316. private _onDefaultMeshLoaded;
  130317. private _onResize;
  130318. private _onFullscreenChange;
  130319. /**
  130320. * Gets a value indicating if we are currently in VR mode.
  130321. */
  130322. get isInVRMode(): boolean;
  130323. private onVrDisplayPresentChange;
  130324. private onVRDisplayChanged;
  130325. private moveButtonToBottomRight;
  130326. private displayVRButton;
  130327. private updateButtonVisibility;
  130328. private _cachedAngularSensibility;
  130329. /**
  130330. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130331. * Otherwise, will use the fullscreen API.
  130332. */
  130333. enterVR(): void;
  130334. /**
  130335. * Attempt to exit VR, or fullscreen.
  130336. */
  130337. exitVR(): void;
  130338. /**
  130339. * The position of the vr experience helper.
  130340. */
  130341. get position(): Vector3;
  130342. /**
  130343. * Sets the position of the vr experience helper.
  130344. */
  130345. set position(value: Vector3);
  130346. /**
  130347. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130348. */
  130349. enableInteractions(): void;
  130350. private get _noControllerIsActive();
  130351. private beforeRender;
  130352. private _isTeleportationFloor;
  130353. /**
  130354. * Adds a floor mesh to be used for teleportation.
  130355. * @param floorMesh the mesh to be used for teleportation.
  130356. */
  130357. addFloorMesh(floorMesh: Mesh): void;
  130358. /**
  130359. * Removes a floor mesh from being used for teleportation.
  130360. * @param floorMesh the mesh to be removed.
  130361. */
  130362. removeFloorMesh(floorMesh: Mesh): void;
  130363. /**
  130364. * Enables interactions and teleportation using the VR controllers and gaze.
  130365. * @param vrTeleportationOptions options to modify teleportation behavior.
  130366. */
  130367. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130368. private _onNewGamepadConnected;
  130369. private _tryEnableInteractionOnController;
  130370. private _onNewGamepadDisconnected;
  130371. private _enableInteractionOnController;
  130372. private _checkTeleportWithRay;
  130373. private _checkRotate;
  130374. private _checkTeleportBackwards;
  130375. private _enableTeleportationOnController;
  130376. private _createTeleportationCircles;
  130377. private _displayTeleportationTarget;
  130378. private _hideTeleportationTarget;
  130379. private _rotateCamera;
  130380. private _moveTeleportationSelectorTo;
  130381. private _workingVector;
  130382. private _workingQuaternion;
  130383. private _workingMatrix;
  130384. /**
  130385. * Time Constant Teleportation Mode
  130386. */
  130387. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130388. /**
  130389. * Speed Constant Teleportation Mode
  130390. */
  130391. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130392. /**
  130393. * Teleports the users feet to the desired location
  130394. * @param location The location where the user's feet should be placed
  130395. */
  130396. teleportCamera(location: Vector3): void;
  130397. private _convertNormalToDirectionOfRay;
  130398. private _castRayAndSelectObject;
  130399. private _notifySelectedMeshUnselected;
  130400. /**
  130401. * Permanently set new colors for the laser pointer
  130402. * @param color the new laser color
  130403. * @param pickedColor the new laser color when picked mesh detected
  130404. */
  130405. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130406. /**
  130407. * Set lighting enabled / disabled on the laser pointer of both controllers
  130408. * @param enabled should the lighting be enabled on the laser pointer
  130409. */
  130410. setLaserLightingState(enabled?: boolean): void;
  130411. /**
  130412. * Permanently set new colors for the gaze pointer
  130413. * @param color the new gaze color
  130414. * @param pickedColor the new gaze color when picked mesh detected
  130415. */
  130416. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130417. /**
  130418. * Sets the color of the laser ray from the vr controllers.
  130419. * @param color new color for the ray.
  130420. */
  130421. changeLaserColor(color: Color3): void;
  130422. /**
  130423. * Sets the color of the ray from the vr headsets gaze.
  130424. * @param color new color for the ray.
  130425. */
  130426. changeGazeColor(color: Color3): void;
  130427. /**
  130428. * Exits VR and disposes of the vr experience helper
  130429. */
  130430. dispose(): void;
  130431. /**
  130432. * Gets the name of the VRExperienceHelper class
  130433. * @returns "VRExperienceHelper"
  130434. */
  130435. getClassName(): string;
  130436. }
  130437. }
  130438. declare module BABYLON {
  130439. /**
  130440. * Contains an array of blocks representing the octree
  130441. */
  130442. export interface IOctreeContainer<T> {
  130443. /**
  130444. * Blocks within the octree
  130445. */
  130446. blocks: Array<OctreeBlock<T>>;
  130447. }
  130448. /**
  130449. * Class used to store a cell in an octree
  130450. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130451. */
  130452. export class OctreeBlock<T> {
  130453. /**
  130454. * Gets the content of the current block
  130455. */
  130456. entries: T[];
  130457. /**
  130458. * Gets the list of block children
  130459. */
  130460. blocks: Array<OctreeBlock<T>>;
  130461. private _depth;
  130462. private _maxDepth;
  130463. private _capacity;
  130464. private _minPoint;
  130465. private _maxPoint;
  130466. private _boundingVectors;
  130467. private _creationFunc;
  130468. /**
  130469. * Creates a new block
  130470. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130471. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130472. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130473. * @param depth defines the current depth of this block in the octree
  130474. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130475. * @param creationFunc defines a callback to call when an element is added to the block
  130476. */
  130477. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130478. /**
  130479. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130480. */
  130481. get capacity(): number;
  130482. /**
  130483. * Gets the minimum vector (in world space) of the block's bounding box
  130484. */
  130485. get minPoint(): Vector3;
  130486. /**
  130487. * Gets the maximum vector (in world space) of the block's bounding box
  130488. */
  130489. get maxPoint(): Vector3;
  130490. /**
  130491. * Add a new element to this block
  130492. * @param entry defines the element to add
  130493. */
  130494. addEntry(entry: T): void;
  130495. /**
  130496. * Remove an element from this block
  130497. * @param entry defines the element to remove
  130498. */
  130499. removeEntry(entry: T): void;
  130500. /**
  130501. * Add an array of elements to this block
  130502. * @param entries defines the array of elements to add
  130503. */
  130504. addEntries(entries: T[]): void;
  130505. /**
  130506. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130507. * @param frustumPlanes defines the frustum planes to test
  130508. * @param selection defines the array to store current content if selection is positive
  130509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130510. */
  130511. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130512. /**
  130513. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130514. * @param sphereCenter defines the bounding sphere center
  130515. * @param sphereRadius defines the bounding sphere radius
  130516. * @param selection defines the array to store current content if selection is positive
  130517. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130518. */
  130519. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130520. /**
  130521. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130522. * @param ray defines the ray to test with
  130523. * @param selection defines the array to store current content if selection is positive
  130524. */
  130525. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130526. /**
  130527. * Subdivide the content into child blocks (this block will then be empty)
  130528. */
  130529. createInnerBlocks(): void;
  130530. /**
  130531. * @hidden
  130532. */
  130533. 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;
  130534. }
  130535. }
  130536. declare module BABYLON {
  130537. /**
  130538. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130540. */
  130541. export class Octree<T> {
  130542. /** 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.) */
  130543. maxDepth: number;
  130544. /**
  130545. * Blocks within the octree containing objects
  130546. */
  130547. blocks: Array<OctreeBlock<T>>;
  130548. /**
  130549. * Content stored in the octree
  130550. */
  130551. dynamicContent: T[];
  130552. private _maxBlockCapacity;
  130553. private _selectionContent;
  130554. private _creationFunc;
  130555. /**
  130556. * Creates a octree
  130557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130558. * @param creationFunc function to be used to instatiate the octree
  130559. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130560. * @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.)
  130561. */
  130562. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130563. /** 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.) */
  130564. maxDepth?: number);
  130565. /**
  130566. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130567. * @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);
  130568. * @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);
  130569. * @param entries meshes to be added to the octree blocks
  130570. */
  130571. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130572. /**
  130573. * Adds a mesh to the octree
  130574. * @param entry Mesh to add to the octree
  130575. */
  130576. addMesh(entry: T): void;
  130577. /**
  130578. * Remove an element from the octree
  130579. * @param entry defines the element to remove
  130580. */
  130581. removeMesh(entry: T): void;
  130582. /**
  130583. * Selects an array of meshes within the frustum
  130584. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130585. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130586. * @returns array of meshes within the frustum
  130587. */
  130588. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130589. /**
  130590. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130591. * @param sphereCenter defines the bounding sphere center
  130592. * @param sphereRadius defines the bounding sphere radius
  130593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130594. * @returns an array of objects that intersect the sphere
  130595. */
  130596. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130597. /**
  130598. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130599. * @param ray defines the ray to test with
  130600. * @returns array of intersected objects
  130601. */
  130602. intersectsRay(ray: Ray): SmartArray<T>;
  130603. /**
  130604. * Adds a mesh into the octree block if it intersects the block
  130605. */
  130606. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130607. /**
  130608. * Adds a submesh into the octree block if it intersects the block
  130609. */
  130610. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130611. }
  130612. }
  130613. declare module BABYLON {
  130614. interface Scene {
  130615. /**
  130616. * @hidden
  130617. * Backing Filed
  130618. */
  130619. _selectionOctree: Octree<AbstractMesh>;
  130620. /**
  130621. * Gets the octree used to boost mesh selection (picking)
  130622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130623. */
  130624. selectionOctree: Octree<AbstractMesh>;
  130625. /**
  130626. * Creates or updates the octree used to boost selection (picking)
  130627. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130628. * @param maxCapacity defines the maximum capacity per leaf
  130629. * @param maxDepth defines the maximum depth of the octree
  130630. * @returns an octree of AbstractMesh
  130631. */
  130632. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130633. }
  130634. interface AbstractMesh {
  130635. /**
  130636. * @hidden
  130637. * Backing Field
  130638. */
  130639. _submeshesOctree: Octree<SubMesh>;
  130640. /**
  130641. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130642. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130643. * @param maxCapacity defines the maximum size of each block (64 by default)
  130644. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130645. * @returns the new octree
  130646. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130647. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130648. */
  130649. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130650. }
  130651. /**
  130652. * Defines the octree scene component responsible to manage any octrees
  130653. * in a given scene.
  130654. */
  130655. export class OctreeSceneComponent {
  130656. /**
  130657. * The component name help to identify the component in the list of scene components.
  130658. */
  130659. readonly name: string;
  130660. /**
  130661. * The scene the component belongs to.
  130662. */
  130663. scene: Scene;
  130664. /**
  130665. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130666. */
  130667. readonly checksIsEnabled: boolean;
  130668. /**
  130669. * Creates a new instance of the component for the given scene
  130670. * @param scene Defines the scene to register the component in
  130671. */
  130672. constructor(scene: Scene);
  130673. /**
  130674. * Registers the component in a given scene
  130675. */
  130676. register(): void;
  130677. /**
  130678. * Return the list of active meshes
  130679. * @returns the list of active meshes
  130680. */
  130681. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130682. /**
  130683. * Return the list of active sub meshes
  130684. * @param mesh The mesh to get the candidates sub meshes from
  130685. * @returns the list of active sub meshes
  130686. */
  130687. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130688. private _tempRay;
  130689. /**
  130690. * Return the list of sub meshes intersecting with a given local ray
  130691. * @param mesh defines the mesh to find the submesh for
  130692. * @param localRay defines the ray in local space
  130693. * @returns the list of intersecting sub meshes
  130694. */
  130695. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130696. /**
  130697. * Return the list of sub meshes colliding with a collider
  130698. * @param mesh defines the mesh to find the submesh for
  130699. * @param collider defines the collider to evaluate the collision against
  130700. * @returns the list of colliding sub meshes
  130701. */
  130702. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130703. /**
  130704. * Rebuilds the elements related to this component in case of
  130705. * context lost for instance.
  130706. */
  130707. rebuild(): void;
  130708. /**
  130709. * Disposes the component and the associated ressources.
  130710. */
  130711. dispose(): void;
  130712. }
  130713. }
  130714. declare module BABYLON {
  130715. /**
  130716. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130717. */
  130718. export class Gizmo implements IDisposable {
  130719. /** The utility layer the gizmo will be added to */
  130720. gizmoLayer: UtilityLayerRenderer;
  130721. /**
  130722. * The root mesh of the gizmo
  130723. */
  130724. _rootMesh: Mesh;
  130725. private _attachedMesh;
  130726. private _attachedNode;
  130727. /**
  130728. * Ratio for the scale of the gizmo (Default: 1)
  130729. */
  130730. protected _scaleRatio: number;
  130731. /**
  130732. * boolean updated by pointermove when a gizmo mesh is hovered
  130733. */
  130734. protected _isHovered: boolean;
  130735. /**
  130736. * Ratio for the scale of the gizmo (Default: 1)
  130737. */
  130738. set scaleRatio(value: number);
  130739. get scaleRatio(): number;
  130740. /**
  130741. * True when the mouse pointer is hovered a gizmo mesh
  130742. */
  130743. get isHovered(): boolean;
  130744. /**
  130745. * If a custom mesh has been set (Default: false)
  130746. */
  130747. protected _customMeshSet: boolean;
  130748. /**
  130749. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130750. * * When set, interactions will be enabled
  130751. */
  130752. get attachedMesh(): Nullable<AbstractMesh>;
  130753. set attachedMesh(value: Nullable<AbstractMesh>);
  130754. /**
  130755. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130756. * * When set, interactions will be enabled
  130757. */
  130758. get attachedNode(): Nullable<Node>;
  130759. set attachedNode(value: Nullable<Node>);
  130760. /**
  130761. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130762. * @param mesh The mesh to replace the default mesh of the gizmo
  130763. */
  130764. setCustomMesh(mesh: Mesh): void;
  130765. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130766. /**
  130767. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130768. */
  130769. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130770. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130771. /**
  130772. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130773. */
  130774. updateGizmoPositionToMatchAttachedMesh: boolean;
  130775. /**
  130776. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130777. */
  130778. updateScale: boolean;
  130779. protected _interactionsEnabled: boolean;
  130780. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130781. private _beforeRenderObserver;
  130782. private _tempQuaternion;
  130783. private _tempVector;
  130784. private _tempVector2;
  130785. private _tempMatrix1;
  130786. private _tempMatrix2;
  130787. private _rightHandtoLeftHandMatrix;
  130788. /**
  130789. * Creates a gizmo
  130790. * @param gizmoLayer The utility layer the gizmo will be added to
  130791. */
  130792. constructor(
  130793. /** The utility layer the gizmo will be added to */
  130794. gizmoLayer?: UtilityLayerRenderer);
  130795. /**
  130796. * Updates the gizmo to match the attached mesh's position/rotation
  130797. */
  130798. protected _update(): void;
  130799. /**
  130800. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130801. * @param value Node, TransformNode or mesh
  130802. */
  130803. protected _matrixChanged(): void;
  130804. /**
  130805. * Disposes of the gizmo
  130806. */
  130807. dispose(): void;
  130808. }
  130809. }
  130810. declare module BABYLON {
  130811. /**
  130812. * Single plane drag gizmo
  130813. */
  130814. export class PlaneDragGizmo extends Gizmo {
  130815. /**
  130816. * Drag behavior responsible for the gizmos dragging interactions
  130817. */
  130818. dragBehavior: PointerDragBehavior;
  130819. private _pointerObserver;
  130820. /**
  130821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130822. */
  130823. snapDistance: number;
  130824. /**
  130825. * Event that fires each time the gizmo snaps to a new location.
  130826. * * snapDistance is the the change in distance
  130827. */
  130828. onSnapObservable: Observable<{
  130829. snapDistance: number;
  130830. }>;
  130831. private _plane;
  130832. private _coloredMaterial;
  130833. private _hoverMaterial;
  130834. private _isEnabled;
  130835. private _parent;
  130836. /** @hidden */
  130837. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130838. /** @hidden */
  130839. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130840. /**
  130841. * Creates a PlaneDragGizmo
  130842. * @param gizmoLayer The utility layer the gizmo will be added to
  130843. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130844. * @param color The color of the gizmo
  130845. */
  130846. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130847. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130848. /**
  130849. * If the gizmo is enabled
  130850. */
  130851. set isEnabled(value: boolean);
  130852. get isEnabled(): boolean;
  130853. /**
  130854. * Disposes of the gizmo
  130855. */
  130856. dispose(): void;
  130857. }
  130858. }
  130859. declare module BABYLON {
  130860. /**
  130861. * Gizmo that enables dragging a mesh along 3 axis
  130862. */
  130863. export class PositionGizmo extends Gizmo {
  130864. /**
  130865. * Internal gizmo used for interactions on the x axis
  130866. */
  130867. xGizmo: AxisDragGizmo;
  130868. /**
  130869. * Internal gizmo used for interactions on the y axis
  130870. */
  130871. yGizmo: AxisDragGizmo;
  130872. /**
  130873. * Internal gizmo used for interactions on the z axis
  130874. */
  130875. zGizmo: AxisDragGizmo;
  130876. /**
  130877. * Internal gizmo used for interactions on the yz plane
  130878. */
  130879. xPlaneGizmo: PlaneDragGizmo;
  130880. /**
  130881. * Internal gizmo used for interactions on the xz plane
  130882. */
  130883. yPlaneGizmo: PlaneDragGizmo;
  130884. /**
  130885. * Internal gizmo used for interactions on the xy plane
  130886. */
  130887. zPlaneGizmo: PlaneDragGizmo;
  130888. /**
  130889. * private variables
  130890. */
  130891. private _meshAttached;
  130892. private _nodeAttached;
  130893. private _snapDistance;
  130894. /** Fires an event when any of it's sub gizmos are dragged */
  130895. onDragStartObservable: Observable<unknown>;
  130896. /** Fires an event when any of it's sub gizmos are released from dragging */
  130897. onDragEndObservable: Observable<unknown>;
  130898. /**
  130899. * If set to true, planar drag is enabled
  130900. */
  130901. private _planarGizmoEnabled;
  130902. get attachedMesh(): Nullable<AbstractMesh>;
  130903. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130904. get attachedNode(): Nullable<Node>;
  130905. set attachedNode(node: Nullable<Node>);
  130906. /**
  130907. * True when the mouse pointer is hovering a gizmo mesh
  130908. */
  130909. get isHovered(): boolean;
  130910. /**
  130911. * Creates a PositionGizmo
  130912. * @param gizmoLayer The utility layer the gizmo will be added to
  130913. @param thickness display gizmo axis thickness
  130914. */
  130915. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130916. /**
  130917. * If the planar drag gizmo is enabled
  130918. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130919. */
  130920. set planarGizmoEnabled(value: boolean);
  130921. get planarGizmoEnabled(): boolean;
  130922. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130923. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130924. /**
  130925. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130926. */
  130927. set snapDistance(value: number);
  130928. get snapDistance(): number;
  130929. /**
  130930. * Ratio for the scale of the gizmo (Default: 1)
  130931. */
  130932. set scaleRatio(value: number);
  130933. get scaleRatio(): number;
  130934. /**
  130935. * Disposes of the gizmo
  130936. */
  130937. dispose(): void;
  130938. /**
  130939. * CustomMeshes are not supported by this gizmo
  130940. * @param mesh The mesh to replace the default mesh of the gizmo
  130941. */
  130942. setCustomMesh(mesh: Mesh): void;
  130943. }
  130944. }
  130945. declare module BABYLON {
  130946. /**
  130947. * Single axis drag gizmo
  130948. */
  130949. export class AxisDragGizmo extends Gizmo {
  130950. /**
  130951. * Drag behavior responsible for the gizmos dragging interactions
  130952. */
  130953. dragBehavior: PointerDragBehavior;
  130954. private _pointerObserver;
  130955. /**
  130956. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130957. */
  130958. snapDistance: number;
  130959. /**
  130960. * Event that fires each time the gizmo snaps to a new location.
  130961. * * snapDistance is the the change in distance
  130962. */
  130963. onSnapObservable: Observable<{
  130964. snapDistance: number;
  130965. }>;
  130966. private _isEnabled;
  130967. private _parent;
  130968. private _arrow;
  130969. private _coloredMaterial;
  130970. private _hoverMaterial;
  130971. /** @hidden */
  130972. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130973. /** @hidden */
  130974. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130975. /**
  130976. * Creates an AxisDragGizmo
  130977. * @param gizmoLayer The utility layer the gizmo will be added to
  130978. * @param dragAxis The axis which the gizmo will be able to drag on
  130979. * @param color The color of the gizmo
  130980. * @param thickness display gizmo axis thickness
  130981. */
  130982. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130983. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130984. /**
  130985. * If the gizmo is enabled
  130986. */
  130987. set isEnabled(value: boolean);
  130988. get isEnabled(): boolean;
  130989. /**
  130990. * Disposes of the gizmo
  130991. */
  130992. dispose(): void;
  130993. }
  130994. }
  130995. declare module BABYLON.Debug {
  130996. /**
  130997. * The Axes viewer will show 3 axes in a specific point in space
  130998. */
  130999. export class AxesViewer {
  131000. private _xAxis;
  131001. private _yAxis;
  131002. private _zAxis;
  131003. private _scaleLinesFactor;
  131004. private _instanced;
  131005. /**
  131006. * Gets the hosting scene
  131007. */
  131008. scene: Nullable<Scene>;
  131009. /**
  131010. * Gets or sets a number used to scale line length
  131011. */
  131012. scaleLines: number;
  131013. /** Gets the node hierarchy used to render x-axis */
  131014. get xAxis(): TransformNode;
  131015. /** Gets the node hierarchy used to render y-axis */
  131016. get yAxis(): TransformNode;
  131017. /** Gets the node hierarchy used to render z-axis */
  131018. get zAxis(): TransformNode;
  131019. /**
  131020. * Creates a new AxesViewer
  131021. * @param scene defines the hosting scene
  131022. * @param scaleLines defines a number used to scale line length (1 by default)
  131023. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131024. * @param xAxis defines the node hierarchy used to render the x-axis
  131025. * @param yAxis defines the node hierarchy used to render the y-axis
  131026. * @param zAxis defines the node hierarchy used to render the z-axis
  131027. */
  131028. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131029. /**
  131030. * Force the viewer to update
  131031. * @param position defines the position of the viewer
  131032. * @param xaxis defines the x axis of the viewer
  131033. * @param yaxis defines the y axis of the viewer
  131034. * @param zaxis defines the z axis of the viewer
  131035. */
  131036. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131037. /**
  131038. * Creates an instance of this axes viewer.
  131039. * @returns a new axes viewer with instanced meshes
  131040. */
  131041. createInstance(): AxesViewer;
  131042. /** Releases resources */
  131043. dispose(): void;
  131044. private static _SetRenderingGroupId;
  131045. }
  131046. }
  131047. declare module BABYLON.Debug {
  131048. /**
  131049. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131050. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131051. */
  131052. export class BoneAxesViewer extends AxesViewer {
  131053. /**
  131054. * Gets or sets the target mesh where to display the axes viewer
  131055. */
  131056. mesh: Nullable<Mesh>;
  131057. /**
  131058. * Gets or sets the target bone where to display the axes viewer
  131059. */
  131060. bone: Nullable<Bone>;
  131061. /** Gets current position */
  131062. pos: Vector3;
  131063. /** Gets direction of X axis */
  131064. xaxis: Vector3;
  131065. /** Gets direction of Y axis */
  131066. yaxis: Vector3;
  131067. /** Gets direction of Z axis */
  131068. zaxis: Vector3;
  131069. /**
  131070. * Creates a new BoneAxesViewer
  131071. * @param scene defines the hosting scene
  131072. * @param bone defines the target bone
  131073. * @param mesh defines the target mesh
  131074. * @param scaleLines defines a scaling factor for line length (1 by default)
  131075. */
  131076. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131077. /**
  131078. * Force the viewer to update
  131079. */
  131080. update(): void;
  131081. /** Releases resources */
  131082. dispose(): void;
  131083. }
  131084. }
  131085. declare module BABYLON {
  131086. /**
  131087. * Interface used to define scene explorer extensibility option
  131088. */
  131089. export interface IExplorerExtensibilityOption {
  131090. /**
  131091. * Define the option label
  131092. */
  131093. label: string;
  131094. /**
  131095. * Defines the action to execute on click
  131096. */
  131097. action: (entity: any) => void;
  131098. }
  131099. /**
  131100. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131101. */
  131102. export interface IExplorerExtensibilityGroup {
  131103. /**
  131104. * Defines a predicate to test if a given type mut be extended
  131105. */
  131106. predicate: (entity: any) => boolean;
  131107. /**
  131108. * Gets the list of options added to a type
  131109. */
  131110. entries: IExplorerExtensibilityOption[];
  131111. }
  131112. /**
  131113. * Interface used to define the options to use to create the Inspector
  131114. */
  131115. export interface IInspectorOptions {
  131116. /**
  131117. * Display in overlay mode (default: false)
  131118. */
  131119. overlay?: boolean;
  131120. /**
  131121. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131122. */
  131123. globalRoot?: HTMLElement;
  131124. /**
  131125. * Display the Scene explorer
  131126. */
  131127. showExplorer?: boolean;
  131128. /**
  131129. * Display the property inspector
  131130. */
  131131. showInspector?: boolean;
  131132. /**
  131133. * Display in embed mode (both panes on the right)
  131134. */
  131135. embedMode?: boolean;
  131136. /**
  131137. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131138. */
  131139. handleResize?: boolean;
  131140. /**
  131141. * Allow the panes to popup (default: true)
  131142. */
  131143. enablePopup?: boolean;
  131144. /**
  131145. * Allow the panes to be closed by users (default: true)
  131146. */
  131147. enableClose?: boolean;
  131148. /**
  131149. * Optional list of extensibility entries
  131150. */
  131151. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131152. /**
  131153. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131154. */
  131155. inspectorURL?: string;
  131156. /**
  131157. * Optional initial tab (default to DebugLayerTab.Properties)
  131158. */
  131159. initialTab?: DebugLayerTab;
  131160. }
  131161. interface Scene {
  131162. /**
  131163. * @hidden
  131164. * Backing field
  131165. */
  131166. _debugLayer: DebugLayer;
  131167. /**
  131168. * Gets the debug layer (aka Inspector) associated with the scene
  131169. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131170. */
  131171. debugLayer: DebugLayer;
  131172. }
  131173. /**
  131174. * Enum of inspector action tab
  131175. */
  131176. export enum DebugLayerTab {
  131177. /**
  131178. * Properties tag (default)
  131179. */
  131180. Properties = 0,
  131181. /**
  131182. * Debug tab
  131183. */
  131184. Debug = 1,
  131185. /**
  131186. * Statistics tab
  131187. */
  131188. Statistics = 2,
  131189. /**
  131190. * Tools tab
  131191. */
  131192. Tools = 3,
  131193. /**
  131194. * Settings tab
  131195. */
  131196. Settings = 4
  131197. }
  131198. /**
  131199. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131200. * what is happening in your scene
  131201. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131202. */
  131203. export class DebugLayer {
  131204. /**
  131205. * Define the url to get the inspector script from.
  131206. * By default it uses the babylonjs CDN.
  131207. * @ignoreNaming
  131208. */
  131209. static InspectorURL: string;
  131210. private _scene;
  131211. private BJSINSPECTOR;
  131212. private _onPropertyChangedObservable?;
  131213. /**
  131214. * Observable triggered when a property is changed through the inspector.
  131215. */
  131216. get onPropertyChangedObservable(): any;
  131217. /**
  131218. * Instantiates a new debug layer.
  131219. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131220. * what is happening in your scene
  131221. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131222. * @param scene Defines the scene to inspect
  131223. */
  131224. constructor(scene: Scene);
  131225. /** Creates the inspector window. */
  131226. private _createInspector;
  131227. /**
  131228. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131229. * @param entity defines the entity to select
  131230. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131231. */
  131232. select(entity: any, lineContainerTitles?: string | string[]): void;
  131233. /** Get the inspector from bundle or global */
  131234. private _getGlobalInspector;
  131235. /**
  131236. * Get if the inspector is visible or not.
  131237. * @returns true if visible otherwise, false
  131238. */
  131239. isVisible(): boolean;
  131240. /**
  131241. * Hide the inspector and close its window.
  131242. */
  131243. hide(): void;
  131244. /**
  131245. * Update the scene in the inspector
  131246. */
  131247. setAsActiveScene(): void;
  131248. /**
  131249. * Launch the debugLayer.
  131250. * @param config Define the configuration of the inspector
  131251. * @return a promise fulfilled when the debug layer is visible
  131252. */
  131253. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131254. }
  131255. }
  131256. declare module BABYLON {
  131257. /**
  131258. * Class containing static functions to help procedurally build meshes
  131259. */
  131260. export class BoxBuilder {
  131261. /**
  131262. * Creates a box mesh
  131263. * * The parameter `size` sets the size (float) of each box side (default 1)
  131264. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131265. * * 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)
  131266. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131270. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131271. * @param name defines the name of the mesh
  131272. * @param options defines the options used to create the mesh
  131273. * @param scene defines the hosting scene
  131274. * @returns the box mesh
  131275. */
  131276. static CreateBox(name: string, options: {
  131277. size?: number;
  131278. width?: number;
  131279. height?: number;
  131280. depth?: number;
  131281. faceUV?: Vector4[];
  131282. faceColors?: Color4[];
  131283. sideOrientation?: number;
  131284. frontUVs?: Vector4;
  131285. backUVs?: Vector4;
  131286. wrap?: boolean;
  131287. topBaseAt?: number;
  131288. bottomBaseAt?: number;
  131289. updatable?: boolean;
  131290. }, scene?: Nullable<Scene>): Mesh;
  131291. }
  131292. }
  131293. declare module BABYLON.Debug {
  131294. /**
  131295. * Used to show the physics impostor around the specific mesh
  131296. */
  131297. export class PhysicsViewer {
  131298. /** @hidden */
  131299. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131300. /** @hidden */
  131301. protected _meshes: Array<Nullable<AbstractMesh>>;
  131302. /** @hidden */
  131303. protected _scene: Nullable<Scene>;
  131304. /** @hidden */
  131305. protected _numMeshes: number;
  131306. /** @hidden */
  131307. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131308. private _renderFunction;
  131309. private _utilityLayer;
  131310. private _debugBoxMesh;
  131311. private _debugSphereMesh;
  131312. private _debugCylinderMesh;
  131313. private _debugMaterial;
  131314. private _debugMeshMeshes;
  131315. /**
  131316. * Creates a new PhysicsViewer
  131317. * @param scene defines the hosting scene
  131318. */
  131319. constructor(scene: Scene);
  131320. /** @hidden */
  131321. protected _updateDebugMeshes(): void;
  131322. /**
  131323. * Renders a specified physic impostor
  131324. * @param impostor defines the impostor to render
  131325. * @param targetMesh defines the mesh represented by the impostor
  131326. * @returns the new debug mesh used to render the impostor
  131327. */
  131328. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131329. /**
  131330. * Hides a specified physic impostor
  131331. * @param impostor defines the impostor to hide
  131332. */
  131333. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131334. private _getDebugMaterial;
  131335. private _getDebugBoxMesh;
  131336. private _getDebugSphereMesh;
  131337. private _getDebugCylinderMesh;
  131338. private _getDebugMeshMesh;
  131339. private _getDebugMesh;
  131340. /** Releases all resources */
  131341. dispose(): void;
  131342. }
  131343. }
  131344. declare module BABYLON {
  131345. /**
  131346. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131347. * in order to better appreciate the issue one might have.
  131348. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131349. */
  131350. export class RayHelper {
  131351. /**
  131352. * Defines the ray we are currently tryin to visualize.
  131353. */
  131354. ray: Nullable<Ray>;
  131355. private _renderPoints;
  131356. private _renderLine;
  131357. private _renderFunction;
  131358. private _scene;
  131359. private _onAfterRenderObserver;
  131360. private _onAfterStepObserver;
  131361. private _attachedToMesh;
  131362. private _meshSpaceDirection;
  131363. private _meshSpaceOrigin;
  131364. /**
  131365. * Helper function to create a colored helper in a scene in one line.
  131366. * @param ray Defines the ray we are currently tryin to visualize
  131367. * @param scene Defines the scene the ray is used in
  131368. * @param color Defines the color we want to see the ray in
  131369. * @returns The newly created ray helper.
  131370. */
  131371. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131372. /**
  131373. * Instantiate a new ray helper.
  131374. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131375. * in order to better appreciate the issue one might have.
  131376. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131377. * @param ray Defines the ray we are currently tryin to visualize
  131378. */
  131379. constructor(ray: Ray);
  131380. /**
  131381. * Shows the ray we are willing to debug.
  131382. * @param scene Defines the scene the ray needs to be rendered in
  131383. * @param color Defines the color the ray needs to be rendered in
  131384. */
  131385. show(scene: Scene, color?: Color3): void;
  131386. /**
  131387. * Hides the ray we are debugging.
  131388. */
  131389. hide(): void;
  131390. private _render;
  131391. /**
  131392. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131393. * @param mesh Defines the mesh we want the helper attached to
  131394. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131395. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131396. * @param length Defines the length of the ray
  131397. */
  131398. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131399. /**
  131400. * Detach the ray helper from the mesh it has previously been attached to.
  131401. */
  131402. detachFromMesh(): void;
  131403. private _updateToMesh;
  131404. /**
  131405. * Dispose the helper and release its associated resources.
  131406. */
  131407. dispose(): void;
  131408. }
  131409. }
  131410. declare module BABYLON {
  131411. /**
  131412. * Defines the options associated with the creation of a SkeletonViewer.
  131413. */
  131414. export interface ISkeletonViewerOptions {
  131415. /** Should the system pause animations before building the Viewer? */
  131416. pauseAnimations: boolean;
  131417. /** Should the system return the skeleton to rest before building? */
  131418. returnToRest: boolean;
  131419. /** public Display Mode of the Viewer */
  131420. displayMode: number;
  131421. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131422. displayOptions: ISkeletonViewerDisplayOptions;
  131423. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131424. computeBonesUsingShaders: boolean;
  131425. /** Flag ignore non weighted bones */
  131426. useAllBones: boolean;
  131427. }
  131428. /**
  131429. * Defines how to display the various bone meshes for the viewer.
  131430. */
  131431. export interface ISkeletonViewerDisplayOptions {
  131432. /** How far down to start tapering the bone spurs */
  131433. midStep?: number;
  131434. /** How big is the midStep? */
  131435. midStepFactor?: number;
  131436. /** Base for the Sphere Size */
  131437. sphereBaseSize?: number;
  131438. /** The ratio of the sphere to the longest bone in units */
  131439. sphereScaleUnit?: number;
  131440. /** Ratio for the Sphere Size */
  131441. sphereFactor?: number;
  131442. /** Whether to show local axes or not */
  131443. showLocalAxes?: boolean;
  131444. /** Length of each local axis */
  131445. localAxesSize?: number;
  131446. }
  131447. /**
  131448. * Defines the constructor options for the BoneWeight Shader.
  131449. */
  131450. export interface IBoneWeightShaderOptions {
  131451. /** Skeleton to Map */
  131452. skeleton: Skeleton;
  131453. /** Colors for Uninfluenced bones */
  131454. colorBase?: Color3;
  131455. /** Colors for 0.0-0.25 Weight bones */
  131456. colorZero?: Color3;
  131457. /** Color for 0.25-0.5 Weight Influence */
  131458. colorQuarter?: Color3;
  131459. /** Color for 0.5-0.75 Weight Influence */
  131460. colorHalf?: Color3;
  131461. /** Color for 0.75-1 Weight Influence */
  131462. colorFull?: Color3;
  131463. /** Color for Zero Weight Influence */
  131464. targetBoneIndex?: number;
  131465. }
  131466. /**
  131467. * Simple structure of the gradient steps for the Color Map.
  131468. */
  131469. export interface ISkeletonMapShaderColorMapKnot {
  131470. /** Color of the Knot */
  131471. color: Color3;
  131472. /** Location of the Knot */
  131473. location: number;
  131474. }
  131475. /**
  131476. * Defines the constructor options for the SkeletonMap Shader.
  131477. */
  131478. export interface ISkeletonMapShaderOptions {
  131479. /** Skeleton to Map */
  131480. skeleton: Skeleton;
  131481. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131482. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131483. }
  131484. }
  131485. declare module BABYLON {
  131486. /**
  131487. * Class containing static functions to help procedurally build meshes
  131488. */
  131489. export class RibbonBuilder {
  131490. /**
  131491. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131492. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131493. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131494. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131495. * * 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
  131496. * * 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
  131497. * * 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
  131498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131501. * * 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
  131502. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131503. * * 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
  131504. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131506. * @param name defines the name of the mesh
  131507. * @param options defines the options used to create the mesh
  131508. * @param scene defines the hosting scene
  131509. * @returns the ribbon mesh
  131510. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131512. */
  131513. static CreateRibbon(name: string, options: {
  131514. pathArray: Vector3[][];
  131515. closeArray?: boolean;
  131516. closePath?: boolean;
  131517. offset?: number;
  131518. updatable?: boolean;
  131519. sideOrientation?: number;
  131520. frontUVs?: Vector4;
  131521. backUVs?: Vector4;
  131522. instance?: Mesh;
  131523. invertUV?: boolean;
  131524. uvs?: Vector2[];
  131525. colors?: Color4[];
  131526. }, scene?: Nullable<Scene>): Mesh;
  131527. }
  131528. }
  131529. declare module BABYLON {
  131530. /**
  131531. * Class containing static functions to help procedurally build meshes
  131532. */
  131533. export class ShapeBuilder {
  131534. /**
  131535. * 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.
  131536. * * 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.
  131537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131538. * * 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.
  131539. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131540. * * 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
  131541. * * 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
  131542. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131545. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131547. * @param name defines the name of the mesh
  131548. * @param options defines the options used to create the mesh
  131549. * @param scene defines the hosting scene
  131550. * @returns the extruded shape mesh
  131551. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131553. */
  131554. static ExtrudeShape(name: string, options: {
  131555. shape: Vector3[];
  131556. path: Vector3[];
  131557. scale?: number;
  131558. rotation?: number;
  131559. cap?: number;
  131560. updatable?: boolean;
  131561. sideOrientation?: number;
  131562. frontUVs?: Vector4;
  131563. backUVs?: Vector4;
  131564. instance?: Mesh;
  131565. invertUV?: boolean;
  131566. }, scene?: Nullable<Scene>): Mesh;
  131567. /**
  131568. * Creates an custom extruded shape mesh.
  131569. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131570. * * 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.
  131571. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131572. * * 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
  131573. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131574. * * 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
  131575. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131576. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131577. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131578. * * 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
  131579. * * 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
  131580. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131585. * @param name defines the name of the mesh
  131586. * @param options defines the options used to create the mesh
  131587. * @param scene defines the hosting scene
  131588. * @returns the custom extruded shape mesh
  131589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131592. */
  131593. static ExtrudeShapeCustom(name: string, options: {
  131594. shape: Vector3[];
  131595. path: Vector3[];
  131596. scaleFunction?: any;
  131597. rotationFunction?: any;
  131598. ribbonCloseArray?: boolean;
  131599. ribbonClosePath?: boolean;
  131600. cap?: number;
  131601. updatable?: boolean;
  131602. sideOrientation?: number;
  131603. frontUVs?: Vector4;
  131604. backUVs?: Vector4;
  131605. instance?: Mesh;
  131606. invertUV?: boolean;
  131607. }, scene?: Nullable<Scene>): Mesh;
  131608. private static _ExtrudeShapeGeneric;
  131609. }
  131610. }
  131611. declare module BABYLON.Debug {
  131612. /**
  131613. * Class used to render a debug view of a given skeleton
  131614. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131615. */
  131616. export class SkeletonViewer {
  131617. /** defines the skeleton to render */
  131618. skeleton: Skeleton;
  131619. /** defines the mesh attached to the skeleton */
  131620. mesh: AbstractMesh;
  131621. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131622. autoUpdateBonesMatrices: boolean;
  131623. /** defines the rendering group id to use with the viewer */
  131624. renderingGroupId: number;
  131625. /** is the options for the viewer */
  131626. options: Partial<ISkeletonViewerOptions>;
  131627. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131628. static readonly DISPLAY_LINES: number;
  131629. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131630. static readonly DISPLAY_SPHERES: number;
  131631. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131632. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131633. /** public static method to create a BoneWeight Shader
  131634. * @param options The constructor options
  131635. * @param scene The scene that the shader is scoped to
  131636. * @returns The created ShaderMaterial
  131637. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131638. */
  131639. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131640. /** public static method to create a BoneWeight Shader
  131641. * @param options The constructor options
  131642. * @param scene The scene that the shader is scoped to
  131643. * @returns The created ShaderMaterial
  131644. */
  131645. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131646. /** private static method to create a BoneWeight Shader
  131647. * @param size The size of the buffer to create (usually the bone count)
  131648. * @param colorMap The gradient data to generate
  131649. * @param scene The scene that the shader is scoped to
  131650. * @returns an Array of floats from the color gradient values
  131651. */
  131652. private static _CreateBoneMapColorBuffer;
  131653. /** If SkeletonViewer scene scope. */
  131654. private _scene;
  131655. /** Gets or sets the color used to render the skeleton */
  131656. color: Color3;
  131657. /** Array of the points of the skeleton fo the line view. */
  131658. private _debugLines;
  131659. /** The SkeletonViewers Mesh. */
  131660. private _debugMesh;
  131661. /** The local axes Meshes. */
  131662. private _localAxes;
  131663. /** If SkeletonViewer is enabled. */
  131664. private _isEnabled;
  131665. /** If SkeletonViewer is ready. */
  131666. private _ready;
  131667. /** SkeletonViewer render observable. */
  131668. private _obs;
  131669. /** The Utility Layer to render the gizmos in. */
  131670. private _utilityLayer;
  131671. private _boneIndices;
  131672. /** Gets the Scene. */
  131673. get scene(): Scene;
  131674. /** Gets the utilityLayer. */
  131675. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131676. /** Checks Ready Status. */
  131677. get isReady(): Boolean;
  131678. /** Sets Ready Status. */
  131679. set ready(value: boolean);
  131680. /** Gets the debugMesh */
  131681. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131682. /** Sets the debugMesh */
  131683. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131684. /** Gets the displayMode */
  131685. get displayMode(): number;
  131686. /** Sets the displayMode */
  131687. set displayMode(value: number);
  131688. /**
  131689. * Creates a new SkeletonViewer
  131690. * @param skeleton defines the skeleton to render
  131691. * @param mesh defines the mesh attached to the skeleton
  131692. * @param scene defines the hosting scene
  131693. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131694. * @param renderingGroupId defines the rendering group id to use with the viewer
  131695. * @param options All of the extra constructor options for the SkeletonViewer
  131696. */
  131697. constructor(
  131698. /** defines the skeleton to render */
  131699. skeleton: Skeleton,
  131700. /** defines the mesh attached to the skeleton */
  131701. mesh: AbstractMesh,
  131702. /** The Scene scope*/
  131703. scene: Scene,
  131704. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131705. autoUpdateBonesMatrices?: boolean,
  131706. /** defines the rendering group id to use with the viewer */
  131707. renderingGroupId?: number,
  131708. /** is the options for the viewer */
  131709. options?: Partial<ISkeletonViewerOptions>);
  131710. /** The Dynamic bindings for the update functions */
  131711. private _bindObs;
  131712. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131713. update(): void;
  131714. /** Gets or sets a boolean indicating if the viewer is enabled */
  131715. set isEnabled(value: boolean);
  131716. get isEnabled(): boolean;
  131717. private _getBonePosition;
  131718. private _getLinesForBonesWithLength;
  131719. private _getLinesForBonesNoLength;
  131720. /** function to revert the mesh and scene back to the initial state. */
  131721. private _revert;
  131722. private getAbsoluteRestPose;
  131723. /** function to build and bind sphere joint points and spur bone representations. */
  131724. private _buildSpheresAndSpurs;
  131725. private _buildLocalAxes;
  131726. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131727. private _displayLinesUpdate;
  131728. /** Changes the displayMode of the skeleton viewer
  131729. * @param mode The displayMode numerical value
  131730. */
  131731. changeDisplayMode(mode: number): void;
  131732. /** Sets a display option of the skeleton viewer
  131733. *
  131734. * | Option | Type | Default | Description |
  131735. * | --------------- | ------- | ------- | ----------- |
  131736. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131737. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131738. *
  131739. * @param option String of the option name
  131740. * @param value The numerical option value
  131741. */
  131742. changeDisplayOptions(option: string, value: number): void;
  131743. /** Release associated resources */
  131744. dispose(): void;
  131745. }
  131746. }
  131747. declare module BABYLON {
  131748. /**
  131749. * Enum for Device Types
  131750. */
  131751. export enum DeviceType {
  131752. /** Generic */
  131753. Generic = 0,
  131754. /** Keyboard */
  131755. Keyboard = 1,
  131756. /** Mouse */
  131757. Mouse = 2,
  131758. /** Touch Pointers */
  131759. Touch = 3,
  131760. /** PS4 Dual Shock */
  131761. DualShock = 4,
  131762. /** Xbox */
  131763. Xbox = 5,
  131764. /** Switch Controller */
  131765. Switch = 6
  131766. }
  131767. /**
  131768. * Enum for All Pointers (Touch/Mouse)
  131769. */
  131770. export enum PointerInput {
  131771. /** Horizontal Axis */
  131772. Horizontal = 0,
  131773. /** Vertical Axis */
  131774. Vertical = 1,
  131775. /** Left Click or Touch */
  131776. LeftClick = 2,
  131777. /** Middle Click */
  131778. MiddleClick = 3,
  131779. /** Right Click */
  131780. RightClick = 4,
  131781. /** Browser Back */
  131782. BrowserBack = 5,
  131783. /** Browser Forward */
  131784. BrowserForward = 6
  131785. }
  131786. /**
  131787. * Enum for Dual Shock Gamepad
  131788. */
  131789. export enum DualShockInput {
  131790. /** Cross */
  131791. Cross = 0,
  131792. /** Circle */
  131793. Circle = 1,
  131794. /** Square */
  131795. Square = 2,
  131796. /** Triangle */
  131797. Triangle = 3,
  131798. /** L1 */
  131799. L1 = 4,
  131800. /** R1 */
  131801. R1 = 5,
  131802. /** L2 */
  131803. L2 = 6,
  131804. /** R2 */
  131805. R2 = 7,
  131806. /** Share */
  131807. Share = 8,
  131808. /** Options */
  131809. Options = 9,
  131810. /** L3 */
  131811. L3 = 10,
  131812. /** R3 */
  131813. R3 = 11,
  131814. /** DPadUp */
  131815. DPadUp = 12,
  131816. /** DPadDown */
  131817. DPadDown = 13,
  131818. /** DPadLeft */
  131819. DPadLeft = 14,
  131820. /** DRight */
  131821. DPadRight = 15,
  131822. /** Home */
  131823. Home = 16,
  131824. /** TouchPad */
  131825. TouchPad = 17,
  131826. /** LStickXAxis */
  131827. LStickXAxis = 18,
  131828. /** LStickYAxis */
  131829. LStickYAxis = 19,
  131830. /** RStickXAxis */
  131831. RStickXAxis = 20,
  131832. /** RStickYAxis */
  131833. RStickYAxis = 21
  131834. }
  131835. /**
  131836. * Enum for Xbox Gamepad
  131837. */
  131838. export enum XboxInput {
  131839. /** A */
  131840. A = 0,
  131841. /** B */
  131842. B = 1,
  131843. /** X */
  131844. X = 2,
  131845. /** Y */
  131846. Y = 3,
  131847. /** LB */
  131848. LB = 4,
  131849. /** RB */
  131850. RB = 5,
  131851. /** LT */
  131852. LT = 6,
  131853. /** RT */
  131854. RT = 7,
  131855. /** Back */
  131856. Back = 8,
  131857. /** Start */
  131858. Start = 9,
  131859. /** LS */
  131860. LS = 10,
  131861. /** RS */
  131862. RS = 11,
  131863. /** DPadUp */
  131864. DPadUp = 12,
  131865. /** DPadDown */
  131866. DPadDown = 13,
  131867. /** DPadLeft */
  131868. DPadLeft = 14,
  131869. /** DRight */
  131870. DPadRight = 15,
  131871. /** Home */
  131872. Home = 16,
  131873. /** LStickXAxis */
  131874. LStickXAxis = 17,
  131875. /** LStickYAxis */
  131876. LStickYAxis = 18,
  131877. /** RStickXAxis */
  131878. RStickXAxis = 19,
  131879. /** RStickYAxis */
  131880. RStickYAxis = 20
  131881. }
  131882. /**
  131883. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131884. */
  131885. export enum SwitchInput {
  131886. /** B */
  131887. B = 0,
  131888. /** A */
  131889. A = 1,
  131890. /** Y */
  131891. Y = 2,
  131892. /** X */
  131893. X = 3,
  131894. /** L */
  131895. L = 4,
  131896. /** R */
  131897. R = 5,
  131898. /** ZL */
  131899. ZL = 6,
  131900. /** ZR */
  131901. ZR = 7,
  131902. /** Minus */
  131903. Minus = 8,
  131904. /** Plus */
  131905. Plus = 9,
  131906. /** LS */
  131907. LS = 10,
  131908. /** RS */
  131909. RS = 11,
  131910. /** DPadUp */
  131911. DPadUp = 12,
  131912. /** DPadDown */
  131913. DPadDown = 13,
  131914. /** DPadLeft */
  131915. DPadLeft = 14,
  131916. /** DRight */
  131917. DPadRight = 15,
  131918. /** Home */
  131919. Home = 16,
  131920. /** Capture */
  131921. Capture = 17,
  131922. /** LStickXAxis */
  131923. LStickXAxis = 18,
  131924. /** LStickYAxis */
  131925. LStickYAxis = 19,
  131926. /** RStickXAxis */
  131927. RStickXAxis = 20,
  131928. /** RStickYAxis */
  131929. RStickYAxis = 21
  131930. }
  131931. }
  131932. declare module BABYLON {
  131933. /**
  131934. * This class will take all inputs from Keyboard, Pointer, and
  131935. * any Gamepads and provide a polling system that all devices
  131936. * will use. This class assumes that there will only be one
  131937. * pointer device and one keyboard.
  131938. */
  131939. export class DeviceInputSystem implements IDisposable {
  131940. /**
  131941. * Callback to be triggered when a device is connected
  131942. */
  131943. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131944. /**
  131945. * Callback to be triggered when a device is disconnected
  131946. */
  131947. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131948. /**
  131949. * Callback to be triggered when event driven input is updated
  131950. */
  131951. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131952. private _inputs;
  131953. private _gamepads;
  131954. private _keyboardActive;
  131955. private _pointerActive;
  131956. private _elementToAttachTo;
  131957. private _keyboardDownEvent;
  131958. private _keyboardUpEvent;
  131959. private _pointerMoveEvent;
  131960. private _pointerDownEvent;
  131961. private _pointerUpEvent;
  131962. private _gamepadConnectedEvent;
  131963. private _gamepadDisconnectedEvent;
  131964. private static _MAX_KEYCODES;
  131965. private static _MAX_POINTER_INPUTS;
  131966. private constructor();
  131967. /**
  131968. * Creates a new DeviceInputSystem instance
  131969. * @param engine Engine to pull input element from
  131970. * @returns The new instance
  131971. */
  131972. static Create(engine: Engine): DeviceInputSystem;
  131973. /**
  131974. * Checks for current device input value, given an id and input index
  131975. * @param deviceName Id of connected device
  131976. * @param inputIndex Index of device input
  131977. * @returns Current value of input
  131978. */
  131979. /**
  131980. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131981. * @param deviceType Enum specifiying device type
  131982. * @param deviceSlot "Slot" or index that device is referenced in
  131983. * @param inputIndex Id of input to be checked
  131984. * @returns Current value of input
  131985. */
  131986. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131987. /**
  131988. * Dispose of all the eventlisteners
  131989. */
  131990. dispose(): void;
  131991. /**
  131992. * Add device and inputs to device array
  131993. * @param deviceType Enum specifiying device type
  131994. * @param deviceSlot "Slot" or index that device is referenced in
  131995. * @param numberOfInputs Number of input entries to create for given device
  131996. */
  131997. private _registerDevice;
  131998. /**
  131999. * Given a specific device name, remove that device from the device map
  132000. * @param deviceType Enum specifiying device type
  132001. * @param deviceSlot "Slot" or index that device is referenced in
  132002. */
  132003. private _unregisterDevice;
  132004. /**
  132005. * Handle all actions that come from keyboard interaction
  132006. */
  132007. private _handleKeyActions;
  132008. /**
  132009. * Handle all actions that come from pointer interaction
  132010. */
  132011. private _handlePointerActions;
  132012. /**
  132013. * Handle all actions that come from gamepad interaction
  132014. */
  132015. private _handleGamepadActions;
  132016. /**
  132017. * Update all non-event based devices with each frame
  132018. * @param deviceType Enum specifiying device type
  132019. * @param deviceSlot "Slot" or index that device is referenced in
  132020. * @param inputIndex Id of input to be checked
  132021. */
  132022. private _updateDevice;
  132023. /**
  132024. * Gets DeviceType from the device name
  132025. * @param deviceName Name of Device from DeviceInputSystem
  132026. * @returns DeviceType enum value
  132027. */
  132028. private _getGamepadDeviceType;
  132029. }
  132030. }
  132031. declare module BABYLON {
  132032. /**
  132033. * Type to handle enforcement of inputs
  132034. */
  132035. 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;
  132036. }
  132037. declare module BABYLON {
  132038. /**
  132039. * Class that handles all input for a specific device
  132040. */
  132041. export class DeviceSource<T extends DeviceType> {
  132042. /** Type of device */
  132043. readonly deviceType: DeviceType;
  132044. /** "Slot" or index that device is referenced in */
  132045. readonly deviceSlot: number;
  132046. /**
  132047. * Observable to handle device input changes per device
  132048. */
  132049. readonly onInputChangedObservable: Observable<{
  132050. inputIndex: DeviceInput<T>;
  132051. previousState: Nullable<number>;
  132052. currentState: Nullable<number>;
  132053. }>;
  132054. private readonly _deviceInputSystem;
  132055. /**
  132056. * Default Constructor
  132057. * @param deviceInputSystem Reference to DeviceInputSystem
  132058. * @param deviceType Type of device
  132059. * @param deviceSlot "Slot" or index that device is referenced in
  132060. */
  132061. constructor(deviceInputSystem: DeviceInputSystem,
  132062. /** Type of device */
  132063. deviceType: DeviceType,
  132064. /** "Slot" or index that device is referenced in */
  132065. deviceSlot?: number);
  132066. /**
  132067. * Get input for specific input
  132068. * @param inputIndex index of specific input on device
  132069. * @returns Input value from DeviceInputSystem
  132070. */
  132071. getInput(inputIndex: DeviceInput<T>): number;
  132072. }
  132073. /**
  132074. * Class to keep track of devices
  132075. */
  132076. export class DeviceSourceManager implements IDisposable {
  132077. /**
  132078. * Observable to be triggered when before a device is connected
  132079. */
  132080. readonly onBeforeDeviceConnectedObservable: Observable<{
  132081. deviceType: DeviceType;
  132082. deviceSlot: number;
  132083. }>;
  132084. /**
  132085. * Observable to be triggered when before a device is disconnected
  132086. */
  132087. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132088. deviceType: DeviceType;
  132089. deviceSlot: number;
  132090. }>;
  132091. /**
  132092. * Observable to be triggered when after a device is connected
  132093. */
  132094. readonly onAfterDeviceConnectedObservable: Observable<{
  132095. deviceType: DeviceType;
  132096. deviceSlot: number;
  132097. }>;
  132098. /**
  132099. * Observable to be triggered when after a device is disconnected
  132100. */
  132101. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132102. deviceType: DeviceType;
  132103. deviceSlot: number;
  132104. }>;
  132105. private readonly _devices;
  132106. private readonly _firstDevice;
  132107. private readonly _deviceInputSystem;
  132108. /**
  132109. * Default Constructor
  132110. * @param engine engine to pull input element from
  132111. */
  132112. constructor(engine: Engine);
  132113. /**
  132114. * Gets a DeviceSource, given a type and slot
  132115. * @param deviceType Enum specifying device type
  132116. * @param deviceSlot "Slot" or index that device is referenced in
  132117. * @returns DeviceSource object
  132118. */
  132119. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132120. /**
  132121. * Gets an array of DeviceSource objects for a given device type
  132122. * @param deviceType Enum specifying device type
  132123. * @returns Array of DeviceSource objects
  132124. */
  132125. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132126. /**
  132127. * Dispose of DeviceInputSystem and other parts
  132128. */
  132129. dispose(): void;
  132130. /**
  132131. * Function to add device name to device list
  132132. * @param deviceType Enum specifying device type
  132133. * @param deviceSlot "Slot" or index that device is referenced in
  132134. */
  132135. private _addDevice;
  132136. /**
  132137. * Function to remove device name to device list
  132138. * @param deviceType Enum specifying device type
  132139. * @param deviceSlot "Slot" or index that device is referenced in
  132140. */
  132141. private _removeDevice;
  132142. /**
  132143. * Updates array storing first connected device of each type
  132144. * @param type Type of Device
  132145. */
  132146. private _updateFirstDevices;
  132147. }
  132148. }
  132149. declare module BABYLON {
  132150. /**
  132151. * Options to create the null engine
  132152. */
  132153. export class NullEngineOptions {
  132154. /**
  132155. * Render width (Default: 512)
  132156. */
  132157. renderWidth: number;
  132158. /**
  132159. * Render height (Default: 256)
  132160. */
  132161. renderHeight: number;
  132162. /**
  132163. * Texture size (Default: 512)
  132164. */
  132165. textureSize: number;
  132166. /**
  132167. * If delta time between frames should be constant
  132168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132169. */
  132170. deterministicLockstep: boolean;
  132171. /**
  132172. * Maximum about of steps between frames (Default: 4)
  132173. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132174. */
  132175. lockstepMaxSteps: number;
  132176. /**
  132177. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132178. */
  132179. useHighPrecisionMatrix?: boolean;
  132180. }
  132181. /**
  132182. * The null engine class provides support for headless version of babylon.js.
  132183. * This can be used in server side scenario or for testing purposes
  132184. */
  132185. export class NullEngine extends Engine {
  132186. private _options;
  132187. /**
  132188. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132189. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132190. * @returns true if engine is in deterministic lock step mode
  132191. */
  132192. isDeterministicLockStep(): boolean;
  132193. /**
  132194. * Gets the max steps when engine is running in deterministic lock step
  132195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132196. * @returns the max steps
  132197. */
  132198. getLockstepMaxSteps(): number;
  132199. /**
  132200. * Gets the current hardware scaling level.
  132201. * By default the hardware scaling level is computed from the window device ratio.
  132202. * 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.
  132203. * @returns a number indicating the current hardware scaling level
  132204. */
  132205. getHardwareScalingLevel(): number;
  132206. constructor(options?: NullEngineOptions);
  132207. /**
  132208. * Creates a vertex buffer
  132209. * @param vertices the data for the vertex buffer
  132210. * @returns the new WebGL static buffer
  132211. */
  132212. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132213. /**
  132214. * Creates a new index buffer
  132215. * @param indices defines the content of the index buffer
  132216. * @param updatable defines if the index buffer must be updatable
  132217. * @returns a new webGL buffer
  132218. */
  132219. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132220. /**
  132221. * Clear the current render buffer or the current render target (if any is set up)
  132222. * @param color defines the color to use
  132223. * @param backBuffer defines if the back buffer must be cleared
  132224. * @param depth defines if the depth buffer must be cleared
  132225. * @param stencil defines if the stencil buffer must be cleared
  132226. */
  132227. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132228. /**
  132229. * Gets the current render width
  132230. * @param useScreen defines if screen size must be used (or the current render target if any)
  132231. * @returns a number defining the current render width
  132232. */
  132233. getRenderWidth(useScreen?: boolean): number;
  132234. /**
  132235. * Gets the current render height
  132236. * @param useScreen defines if screen size must be used (or the current render target if any)
  132237. * @returns a number defining the current render height
  132238. */
  132239. getRenderHeight(useScreen?: boolean): number;
  132240. /**
  132241. * Set the WebGL's viewport
  132242. * @param viewport defines the viewport element to be used
  132243. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132244. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132245. */
  132246. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132247. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132248. /**
  132249. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132250. * @param pipelineContext defines the pipeline context to use
  132251. * @param uniformsNames defines the list of uniform names
  132252. * @returns an array of webGL uniform locations
  132253. */
  132254. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132255. /**
  132256. * Gets the lsit of active attributes for a given webGL program
  132257. * @param pipelineContext defines the pipeline context to use
  132258. * @param attributesNames defines the list of attribute names to get
  132259. * @returns an array of indices indicating the offset of each attribute
  132260. */
  132261. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132262. /**
  132263. * Binds an effect to the webGL context
  132264. * @param effect defines the effect to bind
  132265. */
  132266. bindSamplers(effect: Effect): void;
  132267. /**
  132268. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132269. * @param effect defines the effect to activate
  132270. */
  132271. enableEffect(effect: Effect): void;
  132272. /**
  132273. * Set various states to the webGL context
  132274. * @param culling defines backface culling state
  132275. * @param zOffset defines the value to apply to zOffset (0 by default)
  132276. * @param force defines if states must be applied even if cache is up to date
  132277. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132278. */
  132279. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132280. /**
  132281. * Set the value of an uniform to an array of int32
  132282. * @param uniform defines the webGL uniform location where to store the value
  132283. * @param array defines the array of int32 to store
  132284. * @returns true if value was set
  132285. */
  132286. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132287. /**
  132288. * Set the value of an uniform to an array of int32 (stored as vec2)
  132289. * @param uniform defines the webGL uniform location where to store the value
  132290. * @param array defines the array of int32 to store
  132291. * @returns true if value was set
  132292. */
  132293. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132294. /**
  132295. * Set the value of an uniform to an array of int32 (stored as vec3)
  132296. * @param uniform defines the webGL uniform location where to store the value
  132297. * @param array defines the array of int32 to store
  132298. * @returns true if value was set
  132299. */
  132300. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132301. /**
  132302. * Set the value of an uniform to an array of int32 (stored as vec4)
  132303. * @param uniform defines the webGL uniform location where to store the value
  132304. * @param array defines the array of int32 to store
  132305. * @returns true if value was set
  132306. */
  132307. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132308. /**
  132309. * Set the value of an uniform to an array of float32
  132310. * @param uniform defines the webGL uniform location where to store the value
  132311. * @param array defines the array of float32 to store
  132312. * @returns true if value was set
  132313. */
  132314. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132315. /**
  132316. * Set the value of an uniform to an array of float32 (stored as vec2)
  132317. * @param uniform defines the webGL uniform location where to store the value
  132318. * @param array defines the array of float32 to store
  132319. * @returns true if value was set
  132320. */
  132321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132322. /**
  132323. * Set the value of an uniform to an array of float32 (stored as vec3)
  132324. * @param uniform defines the webGL uniform location where to store the value
  132325. * @param array defines the array of float32 to store
  132326. * @returns true if value was set
  132327. */
  132328. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132329. /**
  132330. * Set the value of an uniform to an array of float32 (stored as vec4)
  132331. * @param uniform defines the webGL uniform location where to store the value
  132332. * @param array defines the array of float32 to store
  132333. * @returns true if value was set
  132334. */
  132335. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132336. /**
  132337. * Set the value of an uniform to an array of number
  132338. * @param uniform defines the webGL uniform location where to store the value
  132339. * @param array defines the array of number to store
  132340. * @returns true if value was set
  132341. */
  132342. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132343. /**
  132344. * Set the value of an uniform to an array of number (stored as vec2)
  132345. * @param uniform defines the webGL uniform location where to store the value
  132346. * @param array defines the array of number to store
  132347. * @returns true if value was set
  132348. */
  132349. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132350. /**
  132351. * Set the value of an uniform to an array of number (stored as vec3)
  132352. * @param uniform defines the webGL uniform location where to store the value
  132353. * @param array defines the array of number to store
  132354. * @returns true if value was set
  132355. */
  132356. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132357. /**
  132358. * Set the value of an uniform to an array of number (stored as vec4)
  132359. * @param uniform defines the webGL uniform location where to store the value
  132360. * @param array defines the array of number to store
  132361. * @returns true if value was set
  132362. */
  132363. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132364. /**
  132365. * Set the value of an uniform to an array of float32 (stored as matrices)
  132366. * @param uniform defines the webGL uniform location where to store the value
  132367. * @param matrices defines the array of float32 to store
  132368. * @returns true if value was set
  132369. */
  132370. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132371. /**
  132372. * Set the value of an uniform to a matrix (3x3)
  132373. * @param uniform defines the webGL uniform location where to store the value
  132374. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132375. * @returns true if value was set
  132376. */
  132377. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132378. /**
  132379. * Set the value of an uniform to a matrix (2x2)
  132380. * @param uniform defines the webGL uniform location where to store the value
  132381. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132382. * @returns true if value was set
  132383. */
  132384. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132385. /**
  132386. * Set the value of an uniform to a number (float)
  132387. * @param uniform defines the webGL uniform location where to store the value
  132388. * @param value defines the float number to store
  132389. * @returns true if value was set
  132390. */
  132391. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132392. /**
  132393. * Set the value of an uniform to a vec2
  132394. * @param uniform defines the webGL uniform location where to store the value
  132395. * @param x defines the 1st component of the value
  132396. * @param y defines the 2nd component of the value
  132397. * @returns true if value was set
  132398. */
  132399. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132400. /**
  132401. * Set the value of an uniform to a vec3
  132402. * @param uniform defines the webGL uniform location where to store the value
  132403. * @param x defines the 1st component of the value
  132404. * @param y defines the 2nd component of the value
  132405. * @param z defines the 3rd component of the value
  132406. * @returns true if value was set
  132407. */
  132408. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132409. /**
  132410. * Set the value of an uniform to a boolean
  132411. * @param uniform defines the webGL uniform location where to store the value
  132412. * @param bool defines the boolean to store
  132413. * @returns true if value was set
  132414. */
  132415. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132416. /**
  132417. * Set the value of an uniform to a vec4
  132418. * @param uniform defines the webGL uniform location where to store the value
  132419. * @param x defines the 1st component of the value
  132420. * @param y defines the 2nd component of the value
  132421. * @param z defines the 3rd component of the value
  132422. * @param w defines the 4th component of the value
  132423. * @returns true if value was set
  132424. */
  132425. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132426. /**
  132427. * Sets the current alpha mode
  132428. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132429. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132430. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132431. */
  132432. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132433. /**
  132434. * Bind webGl buffers directly to the webGL context
  132435. * @param vertexBuffers defines the vertex buffer to bind
  132436. * @param indexBuffer defines the index buffer to bind
  132437. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132438. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132439. * @param effect defines the effect associated with the vertex buffer
  132440. */
  132441. bindBuffers(vertexBuffers: {
  132442. [key: string]: VertexBuffer;
  132443. }, indexBuffer: DataBuffer, effect: Effect): void;
  132444. /**
  132445. * Force the entire cache to be cleared
  132446. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132447. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132448. */
  132449. wipeCaches(bruteForce?: boolean): void;
  132450. /**
  132451. * Send a draw order
  132452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132453. * @param indexStart defines the starting index
  132454. * @param indexCount defines the number of index to draw
  132455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132456. */
  132457. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132458. /**
  132459. * Draw a list of indexed primitives
  132460. * @param fillMode defines the primitive to use
  132461. * @param indexStart defines the starting index
  132462. * @param indexCount defines the number of index to draw
  132463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132464. */
  132465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132466. /**
  132467. * Draw a list of unindexed primitives
  132468. * @param fillMode defines the primitive to use
  132469. * @param verticesStart defines the index of first vertex to draw
  132470. * @param verticesCount defines the count of vertices to draw
  132471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132472. */
  132473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132474. /** @hidden */
  132475. _createTexture(): WebGLTexture;
  132476. /** @hidden */
  132477. _releaseTexture(texture: InternalTexture): void;
  132478. /**
  132479. * Usually called from Texture.ts.
  132480. * Passed information to create a WebGLTexture
  132481. * @param urlArg defines a value which contains one of the following:
  132482. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132483. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132484. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132485. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132486. * @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)
  132487. * @param scene needed for loading to the correct scene
  132488. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132489. * @param onLoad optional callback to be called upon successful completion
  132490. * @param onError optional callback to be called upon failure
  132491. * @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
  132492. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132493. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132494. * @param forcedExtension defines the extension to use to pick the right loader
  132495. * @param mimeType defines an optional mime type
  132496. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132497. */
  132498. 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;
  132499. /**
  132500. * Creates a new render target texture
  132501. * @param size defines the size of the texture
  132502. * @param options defines the options used to create the texture
  132503. * @returns a new render target texture stored in an InternalTexture
  132504. */
  132505. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132506. /**
  132507. * Update the sampling mode of a given texture
  132508. * @param samplingMode defines the required sampling mode
  132509. * @param texture defines the texture to update
  132510. */
  132511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132512. /**
  132513. * Binds the frame buffer to the specified texture.
  132514. * @param texture The texture to render to or null for the default canvas
  132515. * @param faceIndex The face of the texture to render to in case of cube texture
  132516. * @param requiredWidth The width of the target to render to
  132517. * @param requiredHeight The height of the target to render to
  132518. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132519. * @param lodLevel defines le lod level to bind to the frame buffer
  132520. */
  132521. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132522. /**
  132523. * Unbind the current render target texture from the webGL context
  132524. * @param texture defines the render target texture to unbind
  132525. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132526. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132527. */
  132528. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132529. /**
  132530. * Creates a dynamic vertex buffer
  132531. * @param vertices the data for the dynamic vertex buffer
  132532. * @returns the new WebGL dynamic buffer
  132533. */
  132534. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132535. /**
  132536. * Update the content of a dynamic texture
  132537. * @param texture defines the texture to update
  132538. * @param canvas defines the canvas containing the source
  132539. * @param invertY defines if data must be stored with Y axis inverted
  132540. * @param premulAlpha defines if alpha is stored as premultiplied
  132541. * @param format defines the format of the data
  132542. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132543. */
  132544. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132545. /**
  132546. * Gets a boolean indicating if all created effects are ready
  132547. * @returns true if all effects are ready
  132548. */
  132549. areAllEffectsReady(): boolean;
  132550. /**
  132551. * @hidden
  132552. * Get the current error code of the webGL context
  132553. * @returns the error code
  132554. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132555. */
  132556. getError(): number;
  132557. /** @hidden */
  132558. _getUnpackAlignement(): number;
  132559. /** @hidden */
  132560. _unpackFlipY(value: boolean): void;
  132561. /**
  132562. * Update a dynamic index buffer
  132563. * @param indexBuffer defines the target index buffer
  132564. * @param indices defines the data to update
  132565. * @param offset defines the offset in the target index buffer where update should start
  132566. */
  132567. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132568. /**
  132569. * Updates a dynamic vertex buffer.
  132570. * @param vertexBuffer the vertex buffer to update
  132571. * @param vertices the data used to update the vertex buffer
  132572. * @param byteOffset the byte offset of the data (optional)
  132573. * @param byteLength the byte length of the data (optional)
  132574. */
  132575. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132576. /** @hidden */
  132577. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132578. /** @hidden */
  132579. _bindTexture(channel: number, texture: InternalTexture): void;
  132580. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132581. /**
  132582. * 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
  132583. */
  132584. releaseEffects(): void;
  132585. displayLoadingUI(): void;
  132586. hideLoadingUI(): void;
  132587. /** @hidden */
  132588. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132589. /** @hidden */
  132590. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132591. /** @hidden */
  132592. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132593. /** @hidden */
  132594. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132595. }
  132596. }
  132597. declare module BABYLON {
  132598. /**
  132599. * @hidden
  132600. **/
  132601. export class _TimeToken {
  132602. _startTimeQuery: Nullable<WebGLQuery>;
  132603. _endTimeQuery: Nullable<WebGLQuery>;
  132604. _timeElapsedQuery: Nullable<WebGLQuery>;
  132605. _timeElapsedQueryEnded: boolean;
  132606. }
  132607. }
  132608. declare module BABYLON {
  132609. /** @hidden */
  132610. export class _OcclusionDataStorage {
  132611. /** @hidden */
  132612. occlusionInternalRetryCounter: number;
  132613. /** @hidden */
  132614. isOcclusionQueryInProgress: boolean;
  132615. /** @hidden */
  132616. isOccluded: boolean;
  132617. /** @hidden */
  132618. occlusionRetryCount: number;
  132619. /** @hidden */
  132620. occlusionType: number;
  132621. /** @hidden */
  132622. occlusionQueryAlgorithmType: number;
  132623. }
  132624. interface Engine {
  132625. /**
  132626. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132627. * @return the new query
  132628. */
  132629. createQuery(): WebGLQuery;
  132630. /**
  132631. * Delete and release a webGL query
  132632. * @param query defines the query to delete
  132633. * @return the current engine
  132634. */
  132635. deleteQuery(query: WebGLQuery): Engine;
  132636. /**
  132637. * Check if a given query has resolved and got its value
  132638. * @param query defines the query to check
  132639. * @returns true if the query got its value
  132640. */
  132641. isQueryResultAvailable(query: WebGLQuery): boolean;
  132642. /**
  132643. * Gets the value of a given query
  132644. * @param query defines the query to check
  132645. * @returns the value of the query
  132646. */
  132647. getQueryResult(query: WebGLQuery): number;
  132648. /**
  132649. * Initiates an occlusion query
  132650. * @param algorithmType defines the algorithm to use
  132651. * @param query defines the query to use
  132652. * @returns the current engine
  132653. * @see https://doc.babylonjs.com/features/occlusionquery
  132654. */
  132655. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132656. /**
  132657. * Ends an occlusion query
  132658. * @see https://doc.babylonjs.com/features/occlusionquery
  132659. * @param algorithmType defines the algorithm to use
  132660. * @returns the current engine
  132661. */
  132662. endOcclusionQuery(algorithmType: number): Engine;
  132663. /**
  132664. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132665. * Please note that only one query can be issued at a time
  132666. * @returns a time token used to track the time span
  132667. */
  132668. startTimeQuery(): Nullable<_TimeToken>;
  132669. /**
  132670. * Ends a time query
  132671. * @param token defines the token used to measure the time span
  132672. * @returns the time spent (in ns)
  132673. */
  132674. endTimeQuery(token: _TimeToken): int;
  132675. /** @hidden */
  132676. _currentNonTimestampToken: Nullable<_TimeToken>;
  132677. /** @hidden */
  132678. _createTimeQuery(): WebGLQuery;
  132679. /** @hidden */
  132680. _deleteTimeQuery(query: WebGLQuery): void;
  132681. /** @hidden */
  132682. _getGlAlgorithmType(algorithmType: number): number;
  132683. /** @hidden */
  132684. _getTimeQueryResult(query: WebGLQuery): any;
  132685. /** @hidden */
  132686. _getTimeQueryAvailability(query: WebGLQuery): any;
  132687. }
  132688. interface AbstractMesh {
  132689. /**
  132690. * Backing filed
  132691. * @hidden
  132692. */
  132693. __occlusionDataStorage: _OcclusionDataStorage;
  132694. /**
  132695. * Access property
  132696. * @hidden
  132697. */
  132698. _occlusionDataStorage: _OcclusionDataStorage;
  132699. /**
  132700. * 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.
  132701. * The default value is -1 which means don't break the query and wait till the result
  132702. * @see https://doc.babylonjs.com/features/occlusionquery
  132703. */
  132704. occlusionRetryCount: number;
  132705. /**
  132706. * 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:
  132707. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132708. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132709. * * 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.
  132710. * @see https://doc.babylonjs.com/features/occlusionquery
  132711. */
  132712. occlusionType: number;
  132713. /**
  132714. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132715. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132716. * * 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.
  132717. * @see https://doc.babylonjs.com/features/occlusionquery
  132718. */
  132719. occlusionQueryAlgorithmType: number;
  132720. /**
  132721. * 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
  132722. * @see https://doc.babylonjs.com/features/occlusionquery
  132723. */
  132724. isOccluded: boolean;
  132725. /**
  132726. * Flag to check the progress status of the query
  132727. * @see https://doc.babylonjs.com/features/occlusionquery
  132728. */
  132729. isOcclusionQueryInProgress: boolean;
  132730. }
  132731. }
  132732. declare module BABYLON {
  132733. /** @hidden */
  132734. export var _forceTransformFeedbackToBundle: boolean;
  132735. interface Engine {
  132736. /**
  132737. * Creates a webGL transform feedback object
  132738. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132739. * @returns the webGL transform feedback object
  132740. */
  132741. createTransformFeedback(): WebGLTransformFeedback;
  132742. /**
  132743. * Delete a webGL transform feedback object
  132744. * @param value defines the webGL transform feedback object to delete
  132745. */
  132746. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132747. /**
  132748. * Bind a webGL transform feedback object to the webgl context
  132749. * @param value defines the webGL transform feedback object to bind
  132750. */
  132751. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132752. /**
  132753. * Begins a transform feedback operation
  132754. * @param usePoints defines if points or triangles must be used
  132755. */
  132756. beginTransformFeedback(usePoints: boolean): void;
  132757. /**
  132758. * Ends a transform feedback operation
  132759. */
  132760. endTransformFeedback(): void;
  132761. /**
  132762. * Specify the varyings to use with transform feedback
  132763. * @param program defines the associated webGL program
  132764. * @param value defines the list of strings representing the varying names
  132765. */
  132766. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132767. /**
  132768. * Bind a webGL buffer for a transform feedback operation
  132769. * @param value defines the webGL buffer to bind
  132770. */
  132771. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132772. }
  132773. }
  132774. declare module BABYLON {
  132775. /**
  132776. * Class used to define an additional view for the engine
  132777. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132778. */
  132779. export class EngineView {
  132780. /** Defines the canvas where to render the view */
  132781. target: HTMLCanvasElement;
  132782. /** Defines an optional camera used to render the view (will use active camera else) */
  132783. camera?: Camera;
  132784. }
  132785. interface Engine {
  132786. /**
  132787. * Gets or sets the HTML element to use for attaching events
  132788. */
  132789. inputElement: Nullable<HTMLElement>;
  132790. /**
  132791. * Gets the current engine view
  132792. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132793. */
  132794. activeView: Nullable<EngineView>;
  132795. /** Gets or sets the list of views */
  132796. views: EngineView[];
  132797. /**
  132798. * Register a new child canvas
  132799. * @param canvas defines the canvas to register
  132800. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132801. * @returns the associated view
  132802. */
  132803. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132804. /**
  132805. * Remove a registered child canvas
  132806. * @param canvas defines the canvas to remove
  132807. * @returns the current engine
  132808. */
  132809. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132810. }
  132811. }
  132812. declare module BABYLON {
  132813. interface Engine {
  132814. /** @hidden */
  132815. _excludedCompressedTextures: string[];
  132816. /** @hidden */
  132817. _textureFormatInUse: string;
  132818. /**
  132819. * Gets the list of texture formats supported
  132820. */
  132821. readonly texturesSupported: Array<string>;
  132822. /**
  132823. * Gets the texture format in use
  132824. */
  132825. readonly textureFormatInUse: Nullable<string>;
  132826. /**
  132827. * Set the compressed texture extensions or file names to skip.
  132828. *
  132829. * @param skippedFiles defines the list of those texture files you want to skip
  132830. * Example: [".dds", ".env", "myfile.png"]
  132831. */
  132832. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132833. /**
  132834. * Set the compressed texture format to use, based on the formats you have, and the formats
  132835. * supported by the hardware / browser.
  132836. *
  132837. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132838. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132839. * to API arguments needed to compressed textures. This puts the burden on the container
  132840. * generator to house the arcane code for determining these for current & future formats.
  132841. *
  132842. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132843. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132844. *
  132845. * Note: The result of this call is not taken into account when a texture is base64.
  132846. *
  132847. * @param formatsAvailable defines the list of those format families you have created
  132848. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132849. *
  132850. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132851. * @returns The extension selected.
  132852. */
  132853. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132854. }
  132855. }
  132856. declare module BABYLON {
  132857. /**
  132858. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132859. */
  132860. export interface CubeMapInfo {
  132861. /**
  132862. * The pixel array for the front face.
  132863. * This is stored in format, left to right, up to down format.
  132864. */
  132865. front: Nullable<ArrayBufferView>;
  132866. /**
  132867. * The pixel array for the back face.
  132868. * This is stored in format, left to right, up to down format.
  132869. */
  132870. back: Nullable<ArrayBufferView>;
  132871. /**
  132872. * The pixel array for the left face.
  132873. * This is stored in format, left to right, up to down format.
  132874. */
  132875. left: Nullable<ArrayBufferView>;
  132876. /**
  132877. * The pixel array for the right face.
  132878. * This is stored in format, left to right, up to down format.
  132879. */
  132880. right: Nullable<ArrayBufferView>;
  132881. /**
  132882. * The pixel array for the up face.
  132883. * This is stored in format, left to right, up to down format.
  132884. */
  132885. up: Nullable<ArrayBufferView>;
  132886. /**
  132887. * The pixel array for the down face.
  132888. * This is stored in format, left to right, up to down format.
  132889. */
  132890. down: Nullable<ArrayBufferView>;
  132891. /**
  132892. * The size of the cubemap stored.
  132893. *
  132894. * Each faces will be size * size pixels.
  132895. */
  132896. size: number;
  132897. /**
  132898. * The format of the texture.
  132899. *
  132900. * RGBA, RGB.
  132901. */
  132902. format: number;
  132903. /**
  132904. * The type of the texture data.
  132905. *
  132906. * UNSIGNED_INT, FLOAT.
  132907. */
  132908. type: number;
  132909. /**
  132910. * Specifies whether the texture is in gamma space.
  132911. */
  132912. gammaSpace: boolean;
  132913. }
  132914. /**
  132915. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132916. */
  132917. export class PanoramaToCubeMapTools {
  132918. private static FACE_LEFT;
  132919. private static FACE_RIGHT;
  132920. private static FACE_FRONT;
  132921. private static FACE_BACK;
  132922. private static FACE_DOWN;
  132923. private static FACE_UP;
  132924. /**
  132925. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132926. *
  132927. * @param float32Array The source data.
  132928. * @param inputWidth The width of the input panorama.
  132929. * @param inputHeight The height of the input panorama.
  132930. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132931. * @return The cubemap data
  132932. */
  132933. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132934. private static CreateCubemapTexture;
  132935. private static CalcProjectionSpherical;
  132936. }
  132937. }
  132938. declare module BABYLON {
  132939. /**
  132940. * Helper class dealing with the extraction of spherical polynomial dataArray
  132941. * from a cube map.
  132942. */
  132943. export class CubeMapToSphericalPolynomialTools {
  132944. private static FileFaces;
  132945. /**
  132946. * Converts a texture to the according Spherical Polynomial data.
  132947. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132948. *
  132949. * @param texture The texture to extract the information from.
  132950. * @return The Spherical Polynomial data.
  132951. */
  132952. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132953. /**
  132954. * Converts a cubemap to the according Spherical Polynomial data.
  132955. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132956. *
  132957. * @param cubeInfo The Cube map to extract the information from.
  132958. * @return The Spherical Polynomial data.
  132959. */
  132960. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132961. }
  132962. }
  132963. declare module BABYLON {
  132964. interface BaseTexture {
  132965. /**
  132966. * Get the polynomial representation of the texture data.
  132967. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132968. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132969. */
  132970. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132971. }
  132972. }
  132973. declare module BABYLON {
  132974. /** @hidden */
  132975. export var rgbdEncodePixelShader: {
  132976. name: string;
  132977. shader: string;
  132978. };
  132979. }
  132980. declare module BABYLON {
  132981. /** @hidden */
  132982. export var rgbdDecodePixelShader: {
  132983. name: string;
  132984. shader: string;
  132985. };
  132986. }
  132987. declare module BABYLON {
  132988. /**
  132989. * Raw texture data and descriptor sufficient for WebGL texture upload
  132990. */
  132991. export interface EnvironmentTextureInfo {
  132992. /**
  132993. * Version of the environment map
  132994. */
  132995. version: number;
  132996. /**
  132997. * Width of image
  132998. */
  132999. width: number;
  133000. /**
  133001. * Irradiance information stored in the file.
  133002. */
  133003. irradiance: any;
  133004. /**
  133005. * Specular information stored in the file.
  133006. */
  133007. specular: any;
  133008. }
  133009. /**
  133010. * Defines One Image in the file. It requires only the position in the file
  133011. * as well as the length.
  133012. */
  133013. interface BufferImageData {
  133014. /**
  133015. * Length of the image data.
  133016. */
  133017. length: number;
  133018. /**
  133019. * Position of the data from the null terminator delimiting the end of the JSON.
  133020. */
  133021. position: number;
  133022. }
  133023. /**
  133024. * Defines the specular data enclosed in the file.
  133025. * This corresponds to the version 1 of the data.
  133026. */
  133027. export interface EnvironmentTextureSpecularInfoV1 {
  133028. /**
  133029. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133030. */
  133031. specularDataPosition?: number;
  133032. /**
  133033. * This contains all the images data needed to reconstruct the cubemap.
  133034. */
  133035. mipmaps: Array<BufferImageData>;
  133036. /**
  133037. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133038. */
  133039. lodGenerationScale: number;
  133040. }
  133041. /**
  133042. * Sets of helpers addressing the serialization and deserialization of environment texture
  133043. * stored in a BabylonJS env file.
  133044. * Those files are usually stored as .env files.
  133045. */
  133046. export class EnvironmentTextureTools {
  133047. /**
  133048. * Magic number identifying the env file.
  133049. */
  133050. private static _MagicBytes;
  133051. /**
  133052. * Gets the environment info from an env file.
  133053. * @param data The array buffer containing the .env bytes.
  133054. * @returns the environment file info (the json header) if successfully parsed.
  133055. */
  133056. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133057. /**
  133058. * Creates an environment texture from a loaded cube texture.
  133059. * @param texture defines the cube texture to convert in env file
  133060. * @return a promise containing the environment data if succesfull.
  133061. */
  133062. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133063. /**
  133064. * Creates a JSON representation of the spherical data.
  133065. * @param texture defines the texture containing the polynomials
  133066. * @return the JSON representation of the spherical info
  133067. */
  133068. private static _CreateEnvTextureIrradiance;
  133069. /**
  133070. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133071. * @param data the image data
  133072. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133073. * @return the views described by info providing access to the underlying buffer
  133074. */
  133075. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133076. /**
  133077. * Uploads the texture info contained in the env file to the GPU.
  133078. * @param texture defines the internal texture to upload to
  133079. * @param data defines the data to load
  133080. * @param info defines the texture info retrieved through the GetEnvInfo method
  133081. * @returns a promise
  133082. */
  133083. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133084. private static _OnImageReadyAsync;
  133085. /**
  133086. * Uploads the levels of image data to the GPU.
  133087. * @param texture defines the internal texture to upload to
  133088. * @param imageData defines the array buffer views of image data [mipmap][face]
  133089. * @returns a promise
  133090. */
  133091. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133092. /**
  133093. * Uploads spherical polynomials information to the texture.
  133094. * @param texture defines the texture we are trying to upload the information to
  133095. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133096. */
  133097. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133098. /** @hidden */
  133099. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133100. }
  133101. }
  133102. declare module BABYLON {
  133103. /**
  133104. * Class used to inline functions in shader code
  133105. */
  133106. export class ShaderCodeInliner {
  133107. private static readonly _RegexpFindFunctionNameAndType;
  133108. private _sourceCode;
  133109. private _functionDescr;
  133110. private _numMaxIterations;
  133111. /** Gets or sets the token used to mark the functions to inline */
  133112. inlineToken: string;
  133113. /** Gets or sets the debug mode */
  133114. debug: boolean;
  133115. /** Gets the code after the inlining process */
  133116. get code(): string;
  133117. /**
  133118. * Initializes the inliner
  133119. * @param sourceCode shader code source to inline
  133120. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133121. */
  133122. constructor(sourceCode: string, numMaxIterations?: number);
  133123. /**
  133124. * Start the processing of the shader code
  133125. */
  133126. processCode(): void;
  133127. private _collectFunctions;
  133128. private _processInlining;
  133129. private _extractBetweenMarkers;
  133130. private _skipWhitespaces;
  133131. private _removeComments;
  133132. private _replaceFunctionCallsByCode;
  133133. private _findBackward;
  133134. private _escapeRegExp;
  133135. private _replaceNames;
  133136. }
  133137. }
  133138. declare module BABYLON {
  133139. /**
  133140. * Container for accessors for natively-stored mesh data buffers.
  133141. */
  133142. class NativeDataBuffer extends DataBuffer {
  133143. /**
  133144. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133145. */
  133146. nativeIndexBuffer?: any;
  133147. /**
  133148. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133149. */
  133150. nativeVertexBuffer?: any;
  133151. }
  133152. /** @hidden */
  133153. class NativeTexture extends InternalTexture {
  133154. getInternalTexture(): InternalTexture;
  133155. getViewCount(): number;
  133156. }
  133157. /** @hidden */
  133158. export class NativeEngine extends Engine {
  133159. private readonly _native;
  133160. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133161. private readonly INVALID_HANDLE;
  133162. private _boundBuffersVertexArray;
  133163. private _currentDepthTest;
  133164. getHardwareScalingLevel(): number;
  133165. constructor();
  133166. dispose(): void;
  133167. /**
  133168. * Can be used to override the current requestAnimationFrame requester.
  133169. * @hidden
  133170. */
  133171. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133172. /**
  133173. * Override default engine behavior.
  133174. * @param color
  133175. * @param backBuffer
  133176. * @param depth
  133177. * @param stencil
  133178. */
  133179. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133180. /**
  133181. * Gets host document
  133182. * @returns the host document object
  133183. */
  133184. getHostDocument(): Nullable<Document>;
  133185. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133186. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133187. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133188. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133189. [key: string]: VertexBuffer;
  133190. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133191. bindBuffers(vertexBuffers: {
  133192. [key: string]: VertexBuffer;
  133193. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133194. recordVertexArrayObject(vertexBuffers: {
  133195. [key: string]: VertexBuffer;
  133196. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133197. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133198. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133199. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133200. /**
  133201. * Draw a list of indexed primitives
  133202. * @param fillMode defines the primitive to use
  133203. * @param indexStart defines the starting index
  133204. * @param indexCount defines the number of index to draw
  133205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133206. */
  133207. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133208. /**
  133209. * Draw a list of unindexed primitives
  133210. * @param fillMode defines the primitive to use
  133211. * @param verticesStart defines the index of first vertex to draw
  133212. * @param verticesCount defines the count of vertices to draw
  133213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133214. */
  133215. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133216. createPipelineContext(): IPipelineContext;
  133217. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133218. /** @hidden */
  133219. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133220. /** @hidden */
  133221. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133222. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133223. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133224. protected _setProgram(program: WebGLProgram): void;
  133225. _releaseEffect(effect: Effect): void;
  133226. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133227. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133228. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133229. bindSamplers(effect: Effect): void;
  133230. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133231. getRenderWidth(useScreen?: boolean): number;
  133232. getRenderHeight(useScreen?: boolean): number;
  133233. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133234. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133235. /**
  133236. * Set the z offset to apply to current rendering
  133237. * @param value defines the offset to apply
  133238. */
  133239. setZOffset(value: number): void;
  133240. /**
  133241. * Gets the current value of the zOffset
  133242. * @returns the current zOffset state
  133243. */
  133244. getZOffset(): number;
  133245. /**
  133246. * Enable or disable depth buffering
  133247. * @param enable defines the state to set
  133248. */
  133249. setDepthBuffer(enable: boolean): void;
  133250. /**
  133251. * Gets a boolean indicating if depth writing is enabled
  133252. * @returns the current depth writing state
  133253. */
  133254. getDepthWrite(): boolean;
  133255. setDepthFunctionToGreater(): void;
  133256. setDepthFunctionToGreaterOrEqual(): void;
  133257. setDepthFunctionToLess(): void;
  133258. setDepthFunctionToLessOrEqual(): void;
  133259. /**
  133260. * Enable or disable depth writing
  133261. * @param enable defines the state to set
  133262. */
  133263. setDepthWrite(enable: boolean): void;
  133264. /**
  133265. * Enable or disable color writing
  133266. * @param enable defines the state to set
  133267. */
  133268. setColorWrite(enable: boolean): void;
  133269. /**
  133270. * Gets a boolean indicating if color writing is enabled
  133271. * @returns the current color writing state
  133272. */
  133273. getColorWrite(): boolean;
  133274. /**
  133275. * Sets alpha constants used by some alpha blending modes
  133276. * @param r defines the red component
  133277. * @param g defines the green component
  133278. * @param b defines the blue component
  133279. * @param a defines the alpha component
  133280. */
  133281. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133282. /**
  133283. * Sets the current alpha mode
  133284. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133286. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133287. */
  133288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133289. /**
  133290. * Gets the current alpha mode
  133291. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133292. * @returns the current alpha mode
  133293. */
  133294. getAlphaMode(): number;
  133295. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133296. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133297. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133298. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133299. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133300. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133301. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133302. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133303. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133304. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133305. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133306. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133307. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133309. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133310. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133311. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133312. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133313. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133314. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133315. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133316. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133317. wipeCaches(bruteForce?: boolean): void;
  133318. _createTexture(): WebGLTexture;
  133319. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133320. /**
  133321. * Usually called from Texture.ts.
  133322. * Passed information to create a WebGLTexture
  133323. * @param url defines a value which contains one of the following:
  133324. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133325. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133326. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133328. * @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)
  133329. * @param scene needed for loading to the correct scene
  133330. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133331. * @param onLoad optional callback to be called upon successful completion
  133332. * @param onError optional callback to be called upon failure
  133333. * @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
  133334. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133335. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133336. * @param forcedExtension defines the extension to use to pick the right loader
  133337. * @param mimeType defines an optional mime type
  133338. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133339. */
  133340. 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;
  133341. /**
  133342. * Creates a cube texture
  133343. * @param rootUrl defines the url where the files to load is located
  133344. * @param scene defines the current scene
  133345. * @param files defines the list of files to load (1 per face)
  133346. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133347. * @param onLoad defines an optional callback raised when the texture is loaded
  133348. * @param onError defines an optional callback raised if there is an issue to load the texture
  133349. * @param format defines the format of the data
  133350. * @param forcedExtension defines the extension to use to pick the right loader
  133351. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133352. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133353. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133354. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133355. * @returns the cube texture as an InternalTexture
  133356. */
  133357. 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;
  133358. private _getSamplingFilter;
  133359. private static _GetNativeTextureFormat;
  133360. createRenderTargetTexture(size: number | {
  133361. width: number;
  133362. height: number;
  133363. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133364. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133365. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133366. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133367. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133368. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133369. /**
  133370. * Updates a dynamic vertex buffer.
  133371. * @param vertexBuffer the vertex buffer to update
  133372. * @param data the data used to update the vertex buffer
  133373. * @param byteOffset the byte offset of the data (optional)
  133374. * @param byteLength the byte length of the data (optional)
  133375. */
  133376. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133377. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133378. private _updateAnisotropicLevel;
  133379. private _getAddressMode;
  133380. /** @hidden */
  133381. _bindTexture(channel: number, texture: InternalTexture): void;
  133382. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133383. releaseEffects(): void;
  133384. /** @hidden */
  133385. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133386. /** @hidden */
  133387. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133388. /** @hidden */
  133389. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133390. /** @hidden */
  133391. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133392. }
  133393. }
  133394. declare module BABYLON {
  133395. /**
  133396. * Gather the list of clipboard event types as constants.
  133397. */
  133398. export class ClipboardEventTypes {
  133399. /**
  133400. * The clipboard event is fired when a copy command is active (pressed).
  133401. */
  133402. static readonly COPY: number;
  133403. /**
  133404. * The clipboard event is fired when a cut command is active (pressed).
  133405. */
  133406. static readonly CUT: number;
  133407. /**
  133408. * The clipboard event is fired when a paste command is active (pressed).
  133409. */
  133410. static readonly PASTE: number;
  133411. }
  133412. /**
  133413. * This class is used to store clipboard related info for the onClipboardObservable event.
  133414. */
  133415. export class ClipboardInfo {
  133416. /**
  133417. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133418. */
  133419. type: number;
  133420. /**
  133421. * Defines the related dom event
  133422. */
  133423. event: ClipboardEvent;
  133424. /**
  133425. *Creates an instance of ClipboardInfo.
  133426. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133427. * @param event Defines the related dom event
  133428. */
  133429. constructor(
  133430. /**
  133431. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133432. */
  133433. type: number,
  133434. /**
  133435. * Defines the related dom event
  133436. */
  133437. event: ClipboardEvent);
  133438. /**
  133439. * Get the clipboard event's type from the keycode.
  133440. * @param keyCode Defines the keyCode for the current keyboard event.
  133441. * @return {number}
  133442. */
  133443. static GetTypeFromCharacter(keyCode: number): number;
  133444. }
  133445. }
  133446. declare module BABYLON {
  133447. /**
  133448. * Google Daydream controller
  133449. */
  133450. export class DaydreamController extends WebVRController {
  133451. /**
  133452. * Base Url for the controller model.
  133453. */
  133454. static MODEL_BASE_URL: string;
  133455. /**
  133456. * File name for the controller model.
  133457. */
  133458. static MODEL_FILENAME: string;
  133459. /**
  133460. * Gamepad Id prefix used to identify Daydream Controller.
  133461. */
  133462. static readonly GAMEPAD_ID_PREFIX: string;
  133463. /**
  133464. * Creates a new DaydreamController from a gamepad
  133465. * @param vrGamepad the gamepad that the controller should be created from
  133466. */
  133467. constructor(vrGamepad: any);
  133468. /**
  133469. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133470. * @param scene scene in which to add meshes
  133471. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133472. */
  133473. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133474. /**
  133475. * Called once for each button that changed state since the last frame
  133476. * @param buttonIdx Which button index changed
  133477. * @param state New state of the button
  133478. * @param changes Which properties on the state changed since last frame
  133479. */
  133480. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133481. }
  133482. }
  133483. declare module BABYLON {
  133484. /**
  133485. * Gear VR Controller
  133486. */
  133487. export class GearVRController extends WebVRController {
  133488. /**
  133489. * Base Url for the controller model.
  133490. */
  133491. static MODEL_BASE_URL: string;
  133492. /**
  133493. * File name for the controller model.
  133494. */
  133495. static MODEL_FILENAME: string;
  133496. /**
  133497. * Gamepad Id prefix used to identify this controller.
  133498. */
  133499. static readonly GAMEPAD_ID_PREFIX: string;
  133500. private readonly _buttonIndexToObservableNameMap;
  133501. /**
  133502. * Creates a new GearVRController from a gamepad
  133503. * @param vrGamepad the gamepad that the controller should be created from
  133504. */
  133505. constructor(vrGamepad: any);
  133506. /**
  133507. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133508. * @param scene scene in which to add meshes
  133509. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133510. */
  133511. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133512. /**
  133513. * Called once for each button that changed state since the last frame
  133514. * @param buttonIdx Which button index changed
  133515. * @param state New state of the button
  133516. * @param changes Which properties on the state changed since last frame
  133517. */
  133518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133519. }
  133520. }
  133521. declare module BABYLON {
  133522. /**
  133523. * Generic Controller
  133524. */
  133525. export class GenericController extends WebVRController {
  133526. /**
  133527. * Base Url for the controller model.
  133528. */
  133529. static readonly MODEL_BASE_URL: string;
  133530. /**
  133531. * File name for the controller model.
  133532. */
  133533. static readonly MODEL_FILENAME: string;
  133534. /**
  133535. * Creates a new GenericController from a gamepad
  133536. * @param vrGamepad the gamepad that the controller should be created from
  133537. */
  133538. constructor(vrGamepad: any);
  133539. /**
  133540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133541. * @param scene scene in which to add meshes
  133542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133543. */
  133544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133545. /**
  133546. * Called once for each button that changed state since the last frame
  133547. * @param buttonIdx Which button index changed
  133548. * @param state New state of the button
  133549. * @param changes Which properties on the state changed since last frame
  133550. */
  133551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133552. }
  133553. }
  133554. declare module BABYLON {
  133555. /**
  133556. * Oculus Touch Controller
  133557. */
  133558. export class OculusTouchController extends WebVRController {
  133559. /**
  133560. * Base Url for the controller model.
  133561. */
  133562. static MODEL_BASE_URL: string;
  133563. /**
  133564. * File name for the left controller model.
  133565. */
  133566. static MODEL_LEFT_FILENAME: string;
  133567. /**
  133568. * File name for the right controller model.
  133569. */
  133570. static MODEL_RIGHT_FILENAME: string;
  133571. /**
  133572. * Base Url for the Quest controller model.
  133573. */
  133574. static QUEST_MODEL_BASE_URL: string;
  133575. /**
  133576. * @hidden
  133577. * If the controllers are running on a device that needs the updated Quest controller models
  133578. */
  133579. static _IsQuest: boolean;
  133580. /**
  133581. * Fired when the secondary trigger on this controller is modified
  133582. */
  133583. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133584. /**
  133585. * Fired when the thumb rest on this controller is modified
  133586. */
  133587. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133588. /**
  133589. * Creates a new OculusTouchController from a gamepad
  133590. * @param vrGamepad the gamepad that the controller should be created from
  133591. */
  133592. constructor(vrGamepad: any);
  133593. /**
  133594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133595. * @param scene scene in which to add meshes
  133596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133597. */
  133598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133599. /**
  133600. * Fired when the A button on this controller is modified
  133601. */
  133602. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133603. /**
  133604. * Fired when the B button on this controller is modified
  133605. */
  133606. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133607. /**
  133608. * Fired when the X button on this controller is modified
  133609. */
  133610. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133611. /**
  133612. * Fired when the Y button on this controller is modified
  133613. */
  133614. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133615. /**
  133616. * Called once for each button that changed state since the last frame
  133617. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133618. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133619. * 2) secondary trigger (same)
  133620. * 3) A (right) X (left), touch, pressed = value
  133621. * 4) B / Y
  133622. * 5) thumb rest
  133623. * @param buttonIdx Which button index changed
  133624. * @param state New state of the button
  133625. * @param changes Which properties on the state changed since last frame
  133626. */
  133627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133628. }
  133629. }
  133630. declare module BABYLON {
  133631. /**
  133632. * Vive Controller
  133633. */
  133634. export class ViveController extends WebVRController {
  133635. /**
  133636. * Base Url for the controller model.
  133637. */
  133638. static MODEL_BASE_URL: string;
  133639. /**
  133640. * File name for the controller model.
  133641. */
  133642. static MODEL_FILENAME: string;
  133643. /**
  133644. * Creates a new ViveController from a gamepad
  133645. * @param vrGamepad the gamepad that the controller should be created from
  133646. */
  133647. constructor(vrGamepad: any);
  133648. /**
  133649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133650. * @param scene scene in which to add meshes
  133651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133652. */
  133653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133654. /**
  133655. * Fired when the left button on this controller is modified
  133656. */
  133657. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133658. /**
  133659. * Fired when the right button on this controller is modified
  133660. */
  133661. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133662. /**
  133663. * Fired when the menu button on this controller is modified
  133664. */
  133665. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133666. /**
  133667. * Called once for each button that changed state since the last frame
  133668. * Vive mapping:
  133669. * 0: touchpad
  133670. * 1: trigger
  133671. * 2: left AND right buttons
  133672. * 3: menu button
  133673. * @param buttonIdx Which button index changed
  133674. * @param state New state of the button
  133675. * @param changes Which properties on the state changed since last frame
  133676. */
  133677. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133678. }
  133679. }
  133680. declare module BABYLON {
  133681. /**
  133682. * Defines the WindowsMotionController object that the state of the windows motion controller
  133683. */
  133684. export class WindowsMotionController extends WebVRController {
  133685. /**
  133686. * The base url used to load the left and right controller models
  133687. */
  133688. static MODEL_BASE_URL: string;
  133689. /**
  133690. * The name of the left controller model file
  133691. */
  133692. static MODEL_LEFT_FILENAME: string;
  133693. /**
  133694. * The name of the right controller model file
  133695. */
  133696. static MODEL_RIGHT_FILENAME: string;
  133697. /**
  133698. * The controller name prefix for this controller type
  133699. */
  133700. static readonly GAMEPAD_ID_PREFIX: string;
  133701. /**
  133702. * The controller id pattern for this controller type
  133703. */
  133704. private static readonly GAMEPAD_ID_PATTERN;
  133705. private _loadedMeshInfo;
  133706. protected readonly _mapping: {
  133707. buttons: string[];
  133708. buttonMeshNames: {
  133709. trigger: string;
  133710. menu: string;
  133711. grip: string;
  133712. thumbstick: string;
  133713. trackpad: string;
  133714. };
  133715. buttonObservableNames: {
  133716. trigger: string;
  133717. menu: string;
  133718. grip: string;
  133719. thumbstick: string;
  133720. trackpad: string;
  133721. };
  133722. axisMeshNames: string[];
  133723. pointingPoseMeshName: string;
  133724. };
  133725. /**
  133726. * Fired when the trackpad on this controller is clicked
  133727. */
  133728. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133729. /**
  133730. * Fired when the trackpad on this controller is modified
  133731. */
  133732. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133733. /**
  133734. * The current x and y values of this controller's trackpad
  133735. */
  133736. trackpad: StickValues;
  133737. /**
  133738. * Creates a new WindowsMotionController from a gamepad
  133739. * @param vrGamepad the gamepad that the controller should be created from
  133740. */
  133741. constructor(vrGamepad: any);
  133742. /**
  133743. * Fired when the trigger on this controller is modified
  133744. */
  133745. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133746. /**
  133747. * Fired when the menu button on this controller is modified
  133748. */
  133749. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133750. /**
  133751. * Fired when the grip button on this controller is modified
  133752. */
  133753. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133754. /**
  133755. * Fired when the thumbstick button on this controller is modified
  133756. */
  133757. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133758. /**
  133759. * Fired when the touchpad button on this controller is modified
  133760. */
  133761. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133762. /**
  133763. * Fired when the touchpad values on this controller are modified
  133764. */
  133765. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133766. protected _updateTrackpad(): void;
  133767. /**
  133768. * Called once per frame by the engine.
  133769. */
  133770. update(): void;
  133771. /**
  133772. * Called once for each button that changed state since the last frame
  133773. * @param buttonIdx Which button index changed
  133774. * @param state New state of the button
  133775. * @param changes Which properties on the state changed since last frame
  133776. */
  133777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133778. /**
  133779. * Moves the buttons on the controller mesh based on their current state
  133780. * @param buttonName the name of the button to move
  133781. * @param buttonValue the value of the button which determines the buttons new position
  133782. */
  133783. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133784. /**
  133785. * Moves the axis on the controller mesh based on its current state
  133786. * @param axis the index of the axis
  133787. * @param axisValue the value of the axis which determines the meshes new position
  133788. * @hidden
  133789. */
  133790. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133791. /**
  133792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133793. * @param scene scene in which to add meshes
  133794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133795. */
  133796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133797. /**
  133798. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133799. * can be transformed by button presses and axes values, based on this._mapping.
  133800. *
  133801. * @param scene scene in which the meshes exist
  133802. * @param meshes list of meshes that make up the controller model to process
  133803. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133804. */
  133805. private processModel;
  133806. private createMeshInfo;
  133807. /**
  133808. * Gets the ray of the controller in the direction the controller is pointing
  133809. * @param length the length the resulting ray should be
  133810. * @returns a ray in the direction the controller is pointing
  133811. */
  133812. getForwardRay(length?: number): Ray;
  133813. /**
  133814. * Disposes of the controller
  133815. */
  133816. dispose(): void;
  133817. }
  133818. /**
  133819. * This class represents a new windows motion controller in XR.
  133820. */
  133821. export class XRWindowsMotionController extends WindowsMotionController {
  133822. /**
  133823. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133824. */
  133825. protected readonly _mapping: {
  133826. buttons: string[];
  133827. buttonMeshNames: {
  133828. trigger: string;
  133829. menu: string;
  133830. grip: string;
  133831. thumbstick: string;
  133832. trackpad: string;
  133833. };
  133834. buttonObservableNames: {
  133835. trigger: string;
  133836. menu: string;
  133837. grip: string;
  133838. thumbstick: string;
  133839. trackpad: string;
  133840. };
  133841. axisMeshNames: string[];
  133842. pointingPoseMeshName: string;
  133843. };
  133844. /**
  133845. * Construct a new XR-Based windows motion controller
  133846. *
  133847. * @param gamepadInfo the gamepad object from the browser
  133848. */
  133849. constructor(gamepadInfo: any);
  133850. /**
  133851. * holds the thumbstick values (X,Y)
  133852. */
  133853. thumbstickValues: StickValues;
  133854. /**
  133855. * Fired when the thumbstick on this controller is clicked
  133856. */
  133857. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133858. /**
  133859. * Fired when the thumbstick on this controller is modified
  133860. */
  133861. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133862. /**
  133863. * Fired when the touchpad button on this controller is modified
  133864. */
  133865. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133866. /**
  133867. * Fired when the touchpad values on this controller are modified
  133868. */
  133869. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133870. /**
  133871. * Fired when the thumbstick button on this controller is modified
  133872. * here to prevent breaking changes
  133873. */
  133874. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133875. /**
  133876. * updating the thumbstick(!) and not the trackpad.
  133877. * This is named this way due to the difference between WebVR and XR and to avoid
  133878. * changing the parent class.
  133879. */
  133880. protected _updateTrackpad(): void;
  133881. /**
  133882. * Disposes the class with joy
  133883. */
  133884. dispose(): void;
  133885. }
  133886. }
  133887. declare module BABYLON {
  133888. /**
  133889. * Class containing static functions to help procedurally build meshes
  133890. */
  133891. export class PolyhedronBuilder {
  133892. /**
  133893. * Creates a polyhedron mesh
  133894. * * 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
  133895. * * The parameter `size` (positive float, default 1) sets the polygon size
  133896. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133897. * * 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`
  133898. * * 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
  133899. * * 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)`)
  133900. * * 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
  133901. * * 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
  133902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133905. * @param name defines the name of the mesh
  133906. * @param options defines the options used to create the mesh
  133907. * @param scene defines the hosting scene
  133908. * @returns the polyhedron mesh
  133909. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133910. */
  133911. static CreatePolyhedron(name: string, options: {
  133912. type?: number;
  133913. size?: number;
  133914. sizeX?: number;
  133915. sizeY?: number;
  133916. sizeZ?: number;
  133917. custom?: any;
  133918. faceUV?: Vector4[];
  133919. faceColors?: Color4[];
  133920. flat?: boolean;
  133921. updatable?: boolean;
  133922. sideOrientation?: number;
  133923. frontUVs?: Vector4;
  133924. backUVs?: Vector4;
  133925. }, scene?: Nullable<Scene>): Mesh;
  133926. }
  133927. }
  133928. declare module BABYLON {
  133929. /**
  133930. * Gizmo that enables scaling a mesh along 3 axis
  133931. */
  133932. export class ScaleGizmo extends Gizmo {
  133933. /**
  133934. * Internal gizmo used for interactions on the x axis
  133935. */
  133936. xGizmo: AxisScaleGizmo;
  133937. /**
  133938. * Internal gizmo used for interactions on the y axis
  133939. */
  133940. yGizmo: AxisScaleGizmo;
  133941. /**
  133942. * Internal gizmo used for interactions on the z axis
  133943. */
  133944. zGizmo: AxisScaleGizmo;
  133945. /**
  133946. * Internal gizmo used to scale all axis equally
  133947. */
  133948. uniformScaleGizmo: AxisScaleGizmo;
  133949. private _meshAttached;
  133950. private _nodeAttached;
  133951. private _snapDistance;
  133952. private _uniformScalingMesh;
  133953. private _octahedron;
  133954. private _sensitivity;
  133955. /** Fires an event when any of it's sub gizmos are dragged */
  133956. onDragStartObservable: Observable<unknown>;
  133957. /** Fires an event when any of it's sub gizmos are released from dragging */
  133958. onDragEndObservable: Observable<unknown>;
  133959. get attachedMesh(): Nullable<AbstractMesh>;
  133960. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133961. get attachedNode(): Nullable<Node>;
  133962. set attachedNode(node: Nullable<Node>);
  133963. /**
  133964. * True when the mouse pointer is hovering a gizmo mesh
  133965. */
  133966. get isHovered(): boolean;
  133967. /**
  133968. * Creates a ScaleGizmo
  133969. * @param gizmoLayer The utility layer the gizmo will be added to
  133970. * @param thickness display gizmo axis thickness
  133971. */
  133972. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133973. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133974. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133975. /**
  133976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133977. */
  133978. set snapDistance(value: number);
  133979. get snapDistance(): number;
  133980. /**
  133981. * Ratio for the scale of the gizmo (Default: 1)
  133982. */
  133983. set scaleRatio(value: number);
  133984. get scaleRatio(): number;
  133985. /**
  133986. * Sensitivity factor for dragging (Default: 1)
  133987. */
  133988. set sensitivity(value: number);
  133989. get sensitivity(): number;
  133990. /**
  133991. * Disposes of the gizmo
  133992. */
  133993. dispose(): void;
  133994. }
  133995. }
  133996. declare module BABYLON {
  133997. /**
  133998. * Single axis scale gizmo
  133999. */
  134000. export class AxisScaleGizmo extends Gizmo {
  134001. /**
  134002. * Drag behavior responsible for the gizmos dragging interactions
  134003. */
  134004. dragBehavior: PointerDragBehavior;
  134005. private _pointerObserver;
  134006. /**
  134007. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134008. */
  134009. snapDistance: number;
  134010. /**
  134011. * Event that fires each time the gizmo snaps to a new location.
  134012. * * snapDistance is the the change in distance
  134013. */
  134014. onSnapObservable: Observable<{
  134015. snapDistance: number;
  134016. }>;
  134017. /**
  134018. * If the scaling operation should be done on all axis (default: false)
  134019. */
  134020. uniformScaling: boolean;
  134021. /**
  134022. * Custom sensitivity value for the drag strength
  134023. */
  134024. sensitivity: number;
  134025. private _isEnabled;
  134026. private _parent;
  134027. private _arrow;
  134028. private _coloredMaterial;
  134029. private _hoverMaterial;
  134030. /**
  134031. * Creates an AxisScaleGizmo
  134032. * @param gizmoLayer The utility layer the gizmo will be added to
  134033. * @param dragAxis The axis which the gizmo will be able to scale on
  134034. * @param color The color of the gizmo
  134035. * @param thickness display gizmo axis thickness
  134036. */
  134037. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134038. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134039. /**
  134040. * If the gizmo is enabled
  134041. */
  134042. set isEnabled(value: boolean);
  134043. get isEnabled(): boolean;
  134044. /**
  134045. * Disposes of the gizmo
  134046. */
  134047. dispose(): void;
  134048. /**
  134049. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134050. * @param mesh The mesh to replace the default mesh of the gizmo
  134051. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134052. */
  134053. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134054. }
  134055. }
  134056. declare module BABYLON {
  134057. /**
  134058. * Bounding box gizmo
  134059. */
  134060. export class BoundingBoxGizmo extends Gizmo {
  134061. private _lineBoundingBox;
  134062. private _rotateSpheresParent;
  134063. private _scaleBoxesParent;
  134064. private _boundingDimensions;
  134065. private _renderObserver;
  134066. private _pointerObserver;
  134067. private _scaleDragSpeed;
  134068. private _tmpQuaternion;
  134069. private _tmpVector;
  134070. private _tmpRotationMatrix;
  134071. /**
  134072. * 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)
  134073. */
  134074. ignoreChildren: boolean;
  134075. /**
  134076. * 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)
  134077. */
  134078. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134079. /**
  134080. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134081. */
  134082. rotationSphereSize: number;
  134083. /**
  134084. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134085. */
  134086. scaleBoxSize: number;
  134087. /**
  134088. * 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)
  134089. */
  134090. fixedDragMeshScreenSize: boolean;
  134091. /**
  134092. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134093. */
  134094. fixedDragMeshScreenSizeDistanceFactor: number;
  134095. /**
  134096. * Fired when a rotation sphere or scale box is dragged
  134097. */
  134098. onDragStartObservable: Observable<{}>;
  134099. /**
  134100. * Fired when a scale box is dragged
  134101. */
  134102. onScaleBoxDragObservable: Observable<{}>;
  134103. /**
  134104. * Fired when a scale box drag is ended
  134105. */
  134106. onScaleBoxDragEndObservable: Observable<{}>;
  134107. /**
  134108. * Fired when a rotation sphere is dragged
  134109. */
  134110. onRotationSphereDragObservable: Observable<{}>;
  134111. /**
  134112. * Fired when a rotation sphere drag is ended
  134113. */
  134114. onRotationSphereDragEndObservable: Observable<{}>;
  134115. /**
  134116. * 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)
  134117. */
  134118. scalePivot: Nullable<Vector3>;
  134119. /**
  134120. * Mesh used as a pivot to rotate the attached node
  134121. */
  134122. private _anchorMesh;
  134123. private _existingMeshScale;
  134124. private _dragMesh;
  134125. private pointerDragBehavior;
  134126. private coloredMaterial;
  134127. private hoverColoredMaterial;
  134128. /**
  134129. * Sets the color of the bounding box gizmo
  134130. * @param color the color to set
  134131. */
  134132. setColor(color: Color3): void;
  134133. /**
  134134. * Creates an BoundingBoxGizmo
  134135. * @param gizmoLayer The utility layer the gizmo will be added to
  134136. * @param color The color of the gizmo
  134137. */
  134138. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134139. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134140. private _selectNode;
  134141. /**
  134142. * Updates the bounding box information for the Gizmo
  134143. */
  134144. updateBoundingBox(): void;
  134145. private _updateRotationSpheres;
  134146. private _updateScaleBoxes;
  134147. /**
  134148. * Enables rotation on the specified axis and disables rotation on the others
  134149. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134150. */
  134151. setEnabledRotationAxis(axis: string): void;
  134152. /**
  134153. * Enables/disables scaling
  134154. * @param enable if scaling should be enabled
  134155. * @param homogeneousScaling defines if scaling should only be homogeneous
  134156. */
  134157. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134158. private _updateDummy;
  134159. /**
  134160. * Enables a pointer drag behavior on the bounding box of the gizmo
  134161. */
  134162. enableDragBehavior(): void;
  134163. /**
  134164. * Disposes of the gizmo
  134165. */
  134166. dispose(): void;
  134167. /**
  134168. * 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)
  134169. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134170. * @returns the bounding box mesh with the passed in mesh as a child
  134171. */
  134172. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134173. /**
  134174. * CustomMeshes are not supported by this gizmo
  134175. * @param mesh The mesh to replace the default mesh of the gizmo
  134176. */
  134177. setCustomMesh(mesh: Mesh): void;
  134178. }
  134179. }
  134180. declare module BABYLON {
  134181. /**
  134182. * Single plane rotation gizmo
  134183. */
  134184. export class PlaneRotationGizmo extends Gizmo {
  134185. /**
  134186. * Drag behavior responsible for the gizmos dragging interactions
  134187. */
  134188. dragBehavior: PointerDragBehavior;
  134189. private _pointerObserver;
  134190. /**
  134191. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134192. */
  134193. snapDistance: number;
  134194. /**
  134195. * Event that fires each time the gizmo snaps to a new location.
  134196. * * snapDistance is the the change in distance
  134197. */
  134198. onSnapObservable: Observable<{
  134199. snapDistance: number;
  134200. }>;
  134201. private _isEnabled;
  134202. private _parent;
  134203. /**
  134204. * Creates a PlaneRotationGizmo
  134205. * @param gizmoLayer The utility layer the gizmo will be added to
  134206. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134207. * @param color The color of the gizmo
  134208. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134209. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134210. * @param thickness display gizmo axis thickness
  134211. */
  134212. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134213. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134214. /**
  134215. * If the gizmo is enabled
  134216. */
  134217. set isEnabled(value: boolean);
  134218. get isEnabled(): boolean;
  134219. /**
  134220. * Disposes of the gizmo
  134221. */
  134222. dispose(): void;
  134223. }
  134224. }
  134225. declare module BABYLON {
  134226. /**
  134227. * Gizmo that enables rotating a mesh along 3 axis
  134228. */
  134229. export class RotationGizmo extends Gizmo {
  134230. /**
  134231. * Internal gizmo used for interactions on the x axis
  134232. */
  134233. xGizmo: PlaneRotationGizmo;
  134234. /**
  134235. * Internal gizmo used for interactions on the y axis
  134236. */
  134237. yGizmo: PlaneRotationGizmo;
  134238. /**
  134239. * Internal gizmo used for interactions on the z axis
  134240. */
  134241. zGizmo: PlaneRotationGizmo;
  134242. /** Fires an event when any of it's sub gizmos are dragged */
  134243. onDragStartObservable: Observable<unknown>;
  134244. /** Fires an event when any of it's sub gizmos are released from dragging */
  134245. onDragEndObservable: Observable<unknown>;
  134246. private _meshAttached;
  134247. private _nodeAttached;
  134248. get attachedMesh(): Nullable<AbstractMesh>;
  134249. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134250. get attachedNode(): Nullable<Node>;
  134251. set attachedNode(node: Nullable<Node>);
  134252. /**
  134253. * True when the mouse pointer is hovering a gizmo mesh
  134254. */
  134255. get isHovered(): boolean;
  134256. /**
  134257. * Creates a RotationGizmo
  134258. * @param gizmoLayer The utility layer the gizmo will be added to
  134259. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134260. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134261. * @param thickness display gizmo axis thickness
  134262. */
  134263. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134264. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134265. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134266. /**
  134267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134268. */
  134269. set snapDistance(value: number);
  134270. get snapDistance(): number;
  134271. /**
  134272. * Ratio for the scale of the gizmo (Default: 1)
  134273. */
  134274. set scaleRatio(value: number);
  134275. get scaleRatio(): number;
  134276. /**
  134277. * Disposes of the gizmo
  134278. */
  134279. dispose(): void;
  134280. /**
  134281. * CustomMeshes are not supported by this gizmo
  134282. * @param mesh The mesh to replace the default mesh of the gizmo
  134283. */
  134284. setCustomMesh(mesh: Mesh): void;
  134285. }
  134286. }
  134287. declare module BABYLON {
  134288. /**
  134289. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134290. */
  134291. export class GizmoManager implements IDisposable {
  134292. private scene;
  134293. /**
  134294. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134295. */
  134296. gizmos: {
  134297. positionGizmo: Nullable<PositionGizmo>;
  134298. rotationGizmo: Nullable<RotationGizmo>;
  134299. scaleGizmo: Nullable<ScaleGizmo>;
  134300. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134301. };
  134302. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134303. clearGizmoOnEmptyPointerEvent: boolean;
  134304. /** Fires an event when the manager is attached to a mesh */
  134305. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134306. /** Fires an event when the manager is attached to a node */
  134307. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134308. private _gizmosEnabled;
  134309. private _pointerObserver;
  134310. private _attachedMesh;
  134311. private _attachedNode;
  134312. private _boundingBoxColor;
  134313. private _defaultUtilityLayer;
  134314. private _defaultKeepDepthUtilityLayer;
  134315. private _thickness;
  134316. /**
  134317. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134318. */
  134319. boundingBoxDragBehavior: SixDofDragBehavior;
  134320. /**
  134321. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134322. */
  134323. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134324. /**
  134325. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134326. */
  134327. attachableNodes: Nullable<Array<Node>>;
  134328. /**
  134329. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134330. */
  134331. usePointerToAttachGizmos: boolean;
  134332. /**
  134333. * Utility layer that the bounding box gizmo belongs to
  134334. */
  134335. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134336. /**
  134337. * Utility layer that all gizmos besides bounding box belong to
  134338. */
  134339. get utilityLayer(): UtilityLayerRenderer;
  134340. /**
  134341. * True when the mouse pointer is hovering a gizmo mesh
  134342. */
  134343. get isHovered(): boolean;
  134344. /**
  134345. * Instatiates a gizmo manager
  134346. * @param scene the scene to overlay the gizmos on top of
  134347. * @param thickness display gizmo axis thickness
  134348. */
  134349. constructor(scene: Scene, thickness?: number);
  134350. /**
  134351. * Attaches a set of gizmos to the specified mesh
  134352. * @param mesh The mesh the gizmo's should be attached to
  134353. */
  134354. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134355. /**
  134356. * Attaches a set of gizmos to the specified node
  134357. * @param node The node the gizmo's should be attached to
  134358. */
  134359. attachToNode(node: Nullable<Node>): void;
  134360. /**
  134361. * If the position gizmo is enabled
  134362. */
  134363. set positionGizmoEnabled(value: boolean);
  134364. get positionGizmoEnabled(): boolean;
  134365. /**
  134366. * If the rotation gizmo is enabled
  134367. */
  134368. set rotationGizmoEnabled(value: boolean);
  134369. get rotationGizmoEnabled(): boolean;
  134370. /**
  134371. * If the scale gizmo is enabled
  134372. */
  134373. set scaleGizmoEnabled(value: boolean);
  134374. get scaleGizmoEnabled(): boolean;
  134375. /**
  134376. * If the boundingBox gizmo is enabled
  134377. */
  134378. set boundingBoxGizmoEnabled(value: boolean);
  134379. get boundingBoxGizmoEnabled(): boolean;
  134380. /**
  134381. * Disposes of the gizmo manager
  134382. */
  134383. dispose(): void;
  134384. }
  134385. }
  134386. declare module BABYLON {
  134387. /**
  134388. * A directional light is defined by a direction (what a surprise!).
  134389. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134390. * 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.
  134391. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134392. */
  134393. export class DirectionalLight extends ShadowLight {
  134394. private _shadowFrustumSize;
  134395. /**
  134396. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134397. */
  134398. get shadowFrustumSize(): number;
  134399. /**
  134400. * Specifies a fix frustum size for the shadow generation.
  134401. */
  134402. set shadowFrustumSize(value: number);
  134403. private _shadowOrthoScale;
  134404. /**
  134405. * Gets the shadow projection scale against the optimal computed one.
  134406. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134407. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134408. */
  134409. get shadowOrthoScale(): number;
  134410. /**
  134411. * Sets the shadow projection scale against the optimal computed one.
  134412. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134413. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134414. */
  134415. set shadowOrthoScale(value: number);
  134416. /**
  134417. * Automatically compute the projection matrix to best fit (including all the casters)
  134418. * on each frame.
  134419. */
  134420. autoUpdateExtends: boolean;
  134421. /**
  134422. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134423. * on each frame. autoUpdateExtends must be set to true for this to work
  134424. */
  134425. autoCalcShadowZBounds: boolean;
  134426. private _orthoLeft;
  134427. private _orthoRight;
  134428. private _orthoTop;
  134429. private _orthoBottom;
  134430. /**
  134431. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134432. * The directional light is emitted from everywhere in the given direction.
  134433. * It can cast shadows.
  134434. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134435. * @param name The friendly name of the light
  134436. * @param direction The direction of the light
  134437. * @param scene The scene the light belongs to
  134438. */
  134439. constructor(name: string, direction: Vector3, scene: Scene);
  134440. /**
  134441. * Returns the string "DirectionalLight".
  134442. * @return The class name
  134443. */
  134444. getClassName(): string;
  134445. /**
  134446. * Returns the integer 1.
  134447. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134448. */
  134449. getTypeID(): number;
  134450. /**
  134451. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134452. * Returns the DirectionalLight Shadow projection matrix.
  134453. */
  134454. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134455. /**
  134456. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134457. * Returns the DirectionalLight Shadow projection matrix.
  134458. */
  134459. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134460. /**
  134461. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134462. * Returns the DirectionalLight Shadow projection matrix.
  134463. */
  134464. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134465. protected _buildUniformLayout(): void;
  134466. /**
  134467. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134468. * @param effect The effect to update
  134469. * @param lightIndex The index of the light in the effect to update
  134470. * @returns The directional light
  134471. */
  134472. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134473. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134474. /**
  134475. * Gets the minZ used for shadow according to both the scene and the light.
  134476. *
  134477. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134478. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134479. * @param activeCamera The camera we are returning the min for
  134480. * @returns the depth min z
  134481. */
  134482. getDepthMinZ(activeCamera: Camera): number;
  134483. /**
  134484. * Gets the maxZ used for shadow according to both the scene and the light.
  134485. *
  134486. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134487. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134488. * @param activeCamera The camera we are returning the max for
  134489. * @returns the depth max z
  134490. */
  134491. getDepthMaxZ(activeCamera: Camera): number;
  134492. /**
  134493. * Prepares the list of defines specific to the light type.
  134494. * @param defines the list of defines
  134495. * @param lightIndex defines the index of the light for the effect
  134496. */
  134497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134498. }
  134499. }
  134500. declare module BABYLON {
  134501. /**
  134502. * Class containing static functions to help procedurally build meshes
  134503. */
  134504. export class HemisphereBuilder {
  134505. /**
  134506. * Creates a hemisphere mesh
  134507. * @param name defines the name of the mesh
  134508. * @param options defines the options used to create the mesh
  134509. * @param scene defines the hosting scene
  134510. * @returns the hemisphere mesh
  134511. */
  134512. static CreateHemisphere(name: string, options: {
  134513. segments?: number;
  134514. diameter?: number;
  134515. sideOrientation?: number;
  134516. }, scene: any): Mesh;
  134517. }
  134518. }
  134519. declare module BABYLON {
  134520. /**
  134521. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134522. * These values define a cone of light starting from the position, emitting toward the direction.
  134523. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134524. * and the exponent defines the speed of the decay of the light with distance (reach).
  134525. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134526. */
  134527. export class SpotLight extends ShadowLight {
  134528. private _angle;
  134529. private _innerAngle;
  134530. private _cosHalfAngle;
  134531. private _lightAngleScale;
  134532. private _lightAngleOffset;
  134533. /**
  134534. * Gets the cone angle of the spot light in Radians.
  134535. */
  134536. get angle(): number;
  134537. /**
  134538. * Sets the cone angle of the spot light in Radians.
  134539. */
  134540. set angle(value: number);
  134541. /**
  134542. * Only used in gltf falloff mode, this defines the angle where
  134543. * the directional falloff will start before cutting at angle which could be seen
  134544. * as outer angle.
  134545. */
  134546. get innerAngle(): number;
  134547. /**
  134548. * Only used in gltf falloff mode, this defines the angle where
  134549. * the directional falloff will start before cutting at angle which could be seen
  134550. * as outer angle.
  134551. */
  134552. set innerAngle(value: number);
  134553. private _shadowAngleScale;
  134554. /**
  134555. * Allows scaling the angle of the light for shadow generation only.
  134556. */
  134557. get shadowAngleScale(): number;
  134558. /**
  134559. * Allows scaling the angle of the light for shadow generation only.
  134560. */
  134561. set shadowAngleScale(value: number);
  134562. /**
  134563. * The light decay speed with the distance from the emission spot.
  134564. */
  134565. exponent: number;
  134566. private _projectionTextureMatrix;
  134567. /**
  134568. * Allows reading the projecton texture
  134569. */
  134570. get projectionTextureMatrix(): Matrix;
  134571. protected _projectionTextureLightNear: number;
  134572. /**
  134573. * Gets the near clip of the Spotlight for texture projection.
  134574. */
  134575. get projectionTextureLightNear(): number;
  134576. /**
  134577. * Sets the near clip of the Spotlight for texture projection.
  134578. */
  134579. set projectionTextureLightNear(value: number);
  134580. protected _projectionTextureLightFar: number;
  134581. /**
  134582. * Gets the far clip of the Spotlight for texture projection.
  134583. */
  134584. get projectionTextureLightFar(): number;
  134585. /**
  134586. * Sets the far clip of the Spotlight for texture projection.
  134587. */
  134588. set projectionTextureLightFar(value: number);
  134589. protected _projectionTextureUpDirection: Vector3;
  134590. /**
  134591. * Gets the Up vector of the Spotlight for texture projection.
  134592. */
  134593. get projectionTextureUpDirection(): Vector3;
  134594. /**
  134595. * Sets the Up vector of the Spotlight for texture projection.
  134596. */
  134597. set projectionTextureUpDirection(value: Vector3);
  134598. private _projectionTexture;
  134599. /**
  134600. * Gets the projection texture of the light.
  134601. */
  134602. get projectionTexture(): Nullable<BaseTexture>;
  134603. /**
  134604. * Sets the projection texture of the light.
  134605. */
  134606. set projectionTexture(value: Nullable<BaseTexture>);
  134607. private _projectionTextureViewLightDirty;
  134608. private _projectionTextureProjectionLightDirty;
  134609. private _projectionTextureDirty;
  134610. private _projectionTextureViewTargetVector;
  134611. private _projectionTextureViewLightMatrix;
  134612. private _projectionTextureProjectionLightMatrix;
  134613. private _projectionTextureScalingMatrix;
  134614. /**
  134615. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134616. * It can cast shadows.
  134617. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134618. * @param name The light friendly name
  134619. * @param position The position of the spot light in the scene
  134620. * @param direction The direction of the light in the scene
  134621. * @param angle The cone angle of the light in Radians
  134622. * @param exponent The light decay speed with the distance from the emission spot
  134623. * @param scene The scene the lights belongs to
  134624. */
  134625. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134626. /**
  134627. * Returns the string "SpotLight".
  134628. * @returns the class name
  134629. */
  134630. getClassName(): string;
  134631. /**
  134632. * Returns the integer 2.
  134633. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134634. */
  134635. getTypeID(): number;
  134636. /**
  134637. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134638. */
  134639. protected _setDirection(value: Vector3): void;
  134640. /**
  134641. * Overrides the position setter to recompute the projection texture view light Matrix.
  134642. */
  134643. protected _setPosition(value: Vector3): void;
  134644. /**
  134645. * 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.
  134646. * Returns the SpotLight.
  134647. */
  134648. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134649. protected _computeProjectionTextureViewLightMatrix(): void;
  134650. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134651. /**
  134652. * Main function for light texture projection matrix computing.
  134653. */
  134654. protected _computeProjectionTextureMatrix(): void;
  134655. protected _buildUniformLayout(): void;
  134656. private _computeAngleValues;
  134657. /**
  134658. * Sets the passed Effect "effect" with the Light textures.
  134659. * @param effect The effect to update
  134660. * @param lightIndex The index of the light in the effect to update
  134661. * @returns The light
  134662. */
  134663. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134664. /**
  134665. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134666. * @param effect The effect to update
  134667. * @param lightIndex The index of the light in the effect to update
  134668. * @returns The spot light
  134669. */
  134670. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134671. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134672. /**
  134673. * Disposes the light and the associated resources.
  134674. */
  134675. dispose(): void;
  134676. /**
  134677. * Prepares the list of defines specific to the light type.
  134678. * @param defines the list of defines
  134679. * @param lightIndex defines the index of the light for the effect
  134680. */
  134681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134682. }
  134683. }
  134684. declare module BABYLON {
  134685. /**
  134686. * Gizmo that enables viewing a light
  134687. */
  134688. export class LightGizmo extends Gizmo {
  134689. private _lightMesh;
  134690. private _material;
  134691. private _cachedPosition;
  134692. private _cachedForward;
  134693. private _attachedMeshParent;
  134694. private _pointerObserver;
  134695. /**
  134696. * Event that fires each time the gizmo is clicked
  134697. */
  134698. onClickedObservable: Observable<Light>;
  134699. /**
  134700. * Creates a LightGizmo
  134701. * @param gizmoLayer The utility layer the gizmo will be added to
  134702. */
  134703. constructor(gizmoLayer?: UtilityLayerRenderer);
  134704. private _light;
  134705. /**
  134706. * The light that the gizmo is attached to
  134707. */
  134708. set light(light: Nullable<Light>);
  134709. get light(): Nullable<Light>;
  134710. /**
  134711. * Gets the material used to render the light gizmo
  134712. */
  134713. get material(): StandardMaterial;
  134714. /**
  134715. * @hidden
  134716. * Updates the gizmo to match the attached mesh's position/rotation
  134717. */
  134718. protected _update(): void;
  134719. private static _Scale;
  134720. /**
  134721. * Creates the lines for a light mesh
  134722. */
  134723. private static _CreateLightLines;
  134724. /**
  134725. * Disposes of the light gizmo
  134726. */
  134727. dispose(): void;
  134728. private static _CreateHemisphericLightMesh;
  134729. private static _CreatePointLightMesh;
  134730. private static _CreateSpotLightMesh;
  134731. private static _CreateDirectionalLightMesh;
  134732. }
  134733. }
  134734. declare module BABYLON {
  134735. /**
  134736. * Gizmo that enables viewing a camera
  134737. */
  134738. export class CameraGizmo extends Gizmo {
  134739. private _cameraMesh;
  134740. private _cameraLinesMesh;
  134741. private _material;
  134742. private _pointerObserver;
  134743. /**
  134744. * Event that fires each time the gizmo is clicked
  134745. */
  134746. onClickedObservable: Observable<Camera>;
  134747. /**
  134748. * Creates a CameraGizmo
  134749. * @param gizmoLayer The utility layer the gizmo will be added to
  134750. */
  134751. constructor(gizmoLayer?: UtilityLayerRenderer);
  134752. private _camera;
  134753. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134754. get displayFrustum(): boolean;
  134755. set displayFrustum(value: boolean);
  134756. /**
  134757. * The camera that the gizmo is attached to
  134758. */
  134759. set camera(camera: Nullable<Camera>);
  134760. get camera(): Nullable<Camera>;
  134761. /**
  134762. * Gets the material used to render the camera gizmo
  134763. */
  134764. get material(): StandardMaterial;
  134765. /**
  134766. * @hidden
  134767. * Updates the gizmo to match the attached mesh's position/rotation
  134768. */
  134769. protected _update(): void;
  134770. private static _Scale;
  134771. private _invProjection;
  134772. /**
  134773. * Disposes of the camera gizmo
  134774. */
  134775. dispose(): void;
  134776. private static _CreateCameraMesh;
  134777. private static _CreateCameraFrustum;
  134778. }
  134779. }
  134780. declare module BABYLON {
  134781. /** @hidden */
  134782. export var backgroundFragmentDeclaration: {
  134783. name: string;
  134784. shader: string;
  134785. };
  134786. }
  134787. declare module BABYLON {
  134788. /** @hidden */
  134789. export var backgroundUboDeclaration: {
  134790. name: string;
  134791. shader: string;
  134792. };
  134793. }
  134794. declare module BABYLON {
  134795. /** @hidden */
  134796. export var backgroundPixelShader: {
  134797. name: string;
  134798. shader: string;
  134799. };
  134800. }
  134801. declare module BABYLON {
  134802. /** @hidden */
  134803. export var backgroundVertexDeclaration: {
  134804. name: string;
  134805. shader: string;
  134806. };
  134807. }
  134808. declare module BABYLON {
  134809. /** @hidden */
  134810. export var backgroundVertexShader: {
  134811. name: string;
  134812. shader: string;
  134813. };
  134814. }
  134815. declare module BABYLON {
  134816. /**
  134817. * Background material used to create an efficient environement around your scene.
  134818. */
  134819. export class BackgroundMaterial extends PushMaterial {
  134820. /**
  134821. * Standard reflectance value at parallel view angle.
  134822. */
  134823. static StandardReflectance0: number;
  134824. /**
  134825. * Standard reflectance value at grazing angle.
  134826. */
  134827. static StandardReflectance90: number;
  134828. protected _primaryColor: Color3;
  134829. /**
  134830. * Key light Color (multiply against the environement texture)
  134831. */
  134832. primaryColor: Color3;
  134833. protected __perceptualColor: Nullable<Color3>;
  134834. /**
  134835. * Experimental Internal Use Only.
  134836. *
  134837. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134838. * This acts as a helper to set the primary color to a more "human friendly" value.
  134839. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134840. * output color as close as possible from the chosen value.
  134841. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134842. * part of lighting setup.)
  134843. */
  134844. get _perceptualColor(): Nullable<Color3>;
  134845. set _perceptualColor(value: Nullable<Color3>);
  134846. protected _primaryColorShadowLevel: float;
  134847. /**
  134848. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134849. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134850. */
  134851. get primaryColorShadowLevel(): float;
  134852. set primaryColorShadowLevel(value: float);
  134853. protected _primaryColorHighlightLevel: float;
  134854. /**
  134855. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134856. * The primary color is used at the level chosen to define what the white area would look.
  134857. */
  134858. get primaryColorHighlightLevel(): float;
  134859. set primaryColorHighlightLevel(value: float);
  134860. protected _reflectionTexture: Nullable<BaseTexture>;
  134861. /**
  134862. * Reflection Texture used in the material.
  134863. * Should be author in a specific way for the best result (refer to the documentation).
  134864. */
  134865. reflectionTexture: Nullable<BaseTexture>;
  134866. protected _reflectionBlur: float;
  134867. /**
  134868. * Reflection Texture level of blur.
  134869. *
  134870. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134871. * texture twice.
  134872. */
  134873. reflectionBlur: float;
  134874. protected _diffuseTexture: Nullable<BaseTexture>;
  134875. /**
  134876. * Diffuse Texture used in the material.
  134877. * Should be author in a specific way for the best result (refer to the documentation).
  134878. */
  134879. diffuseTexture: Nullable<BaseTexture>;
  134880. protected _shadowLights: Nullable<IShadowLight[]>;
  134881. /**
  134882. * Specify the list of lights casting shadow on the material.
  134883. * All scene shadow lights will be included if null.
  134884. */
  134885. shadowLights: Nullable<IShadowLight[]>;
  134886. protected _shadowLevel: float;
  134887. /**
  134888. * Helps adjusting the shadow to a softer level if required.
  134889. * 0 means black shadows and 1 means no shadows.
  134890. */
  134891. shadowLevel: float;
  134892. protected _sceneCenter: Vector3;
  134893. /**
  134894. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134895. * It is usually zero but might be interesting to modify according to your setup.
  134896. */
  134897. sceneCenter: Vector3;
  134898. protected _opacityFresnel: boolean;
  134899. /**
  134900. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134901. * This helps ensuring a nice transition when the camera goes under the ground.
  134902. */
  134903. opacityFresnel: boolean;
  134904. protected _reflectionFresnel: boolean;
  134905. /**
  134906. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134907. * This helps adding a mirror texture on the ground.
  134908. */
  134909. reflectionFresnel: boolean;
  134910. protected _reflectionFalloffDistance: number;
  134911. /**
  134912. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134913. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134914. */
  134915. reflectionFalloffDistance: number;
  134916. protected _reflectionAmount: number;
  134917. /**
  134918. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134919. */
  134920. reflectionAmount: number;
  134921. protected _reflectionReflectance0: number;
  134922. /**
  134923. * This specifies the weight of the reflection at grazing angle.
  134924. */
  134925. reflectionReflectance0: number;
  134926. protected _reflectionReflectance90: number;
  134927. /**
  134928. * This specifies the weight of the reflection at a perpendicular point of view.
  134929. */
  134930. reflectionReflectance90: number;
  134931. /**
  134932. * Sets the reflection reflectance fresnel values according to the default standard
  134933. * empirically know to work well :-)
  134934. */
  134935. set reflectionStandardFresnelWeight(value: number);
  134936. protected _useRGBColor: boolean;
  134937. /**
  134938. * Helps to directly use the maps channels instead of their level.
  134939. */
  134940. useRGBColor: boolean;
  134941. protected _enableNoise: boolean;
  134942. /**
  134943. * This helps reducing the banding effect that could occur on the background.
  134944. */
  134945. enableNoise: boolean;
  134946. /**
  134947. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134948. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134949. * Recommended to be keep at 1.0 except for special cases.
  134950. */
  134951. get fovMultiplier(): number;
  134952. set fovMultiplier(value: number);
  134953. private _fovMultiplier;
  134954. /**
  134955. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134956. */
  134957. useEquirectangularFOV: boolean;
  134958. private _maxSimultaneousLights;
  134959. /**
  134960. * Number of Simultaneous lights allowed on the material.
  134961. */
  134962. maxSimultaneousLights: int;
  134963. private _shadowOnly;
  134964. /**
  134965. * Make the material only render shadows
  134966. */
  134967. shadowOnly: boolean;
  134968. /**
  134969. * Default configuration related to image processing available in the Background Material.
  134970. */
  134971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134972. /**
  134973. * Keep track of the image processing observer to allow dispose and replace.
  134974. */
  134975. private _imageProcessingObserver;
  134976. /**
  134977. * Attaches a new image processing configuration to the PBR Material.
  134978. * @param configuration (if null the scene configuration will be use)
  134979. */
  134980. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134981. /**
  134982. * Gets the image processing configuration used either in this material.
  134983. */
  134984. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134985. /**
  134986. * Sets the Default image processing configuration used either in the this material.
  134987. *
  134988. * If sets to null, the scene one is in use.
  134989. */
  134990. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134991. /**
  134992. * Gets wether the color curves effect is enabled.
  134993. */
  134994. get cameraColorCurvesEnabled(): boolean;
  134995. /**
  134996. * Sets wether the color curves effect is enabled.
  134997. */
  134998. set cameraColorCurvesEnabled(value: boolean);
  134999. /**
  135000. * Gets wether the color grading effect is enabled.
  135001. */
  135002. get cameraColorGradingEnabled(): boolean;
  135003. /**
  135004. * Gets wether the color grading effect is enabled.
  135005. */
  135006. set cameraColorGradingEnabled(value: boolean);
  135007. /**
  135008. * Gets wether tonemapping is enabled or not.
  135009. */
  135010. get cameraToneMappingEnabled(): boolean;
  135011. /**
  135012. * Sets wether tonemapping is enabled or not
  135013. */
  135014. set cameraToneMappingEnabled(value: boolean);
  135015. /**
  135016. * The camera exposure used on this material.
  135017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135018. * This corresponds to a photographic exposure.
  135019. */
  135020. get cameraExposure(): float;
  135021. /**
  135022. * The camera exposure used on this material.
  135023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135024. * This corresponds to a photographic exposure.
  135025. */
  135026. set cameraExposure(value: float);
  135027. /**
  135028. * Gets The camera contrast used on this material.
  135029. */
  135030. get cameraContrast(): float;
  135031. /**
  135032. * Sets The camera contrast used on this material.
  135033. */
  135034. set cameraContrast(value: float);
  135035. /**
  135036. * Gets the Color Grading 2D Lookup Texture.
  135037. */
  135038. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135039. /**
  135040. * Sets the Color Grading 2D Lookup Texture.
  135041. */
  135042. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135043. /**
  135044. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135045. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135046. * 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;
  135047. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135048. */
  135049. get cameraColorCurves(): Nullable<ColorCurves>;
  135050. /**
  135051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135053. * 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;
  135054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135055. */
  135056. set cameraColorCurves(value: Nullable<ColorCurves>);
  135057. /**
  135058. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135059. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135060. */
  135061. switchToBGR: boolean;
  135062. private _renderTargets;
  135063. private _reflectionControls;
  135064. private _white;
  135065. private _primaryShadowColor;
  135066. private _primaryHighlightColor;
  135067. /**
  135068. * Instantiates a Background Material in the given scene
  135069. * @param name The friendly name of the material
  135070. * @param scene The scene to add the material to
  135071. */
  135072. constructor(name: string, scene: Scene);
  135073. /**
  135074. * Gets a boolean indicating that current material needs to register RTT
  135075. */
  135076. get hasRenderTargetTextures(): boolean;
  135077. /**
  135078. * The entire material has been created in order to prevent overdraw.
  135079. * @returns false
  135080. */
  135081. needAlphaTesting(): boolean;
  135082. /**
  135083. * The entire material has been created in order to prevent overdraw.
  135084. * @returns true if blending is enable
  135085. */
  135086. needAlphaBlending(): boolean;
  135087. /**
  135088. * Checks wether the material is ready to be rendered for a given mesh.
  135089. * @param mesh The mesh to render
  135090. * @param subMesh The submesh to check against
  135091. * @param useInstances Specify wether or not the material is used with instances
  135092. * @returns true if all the dependencies are ready (Textures, Effects...)
  135093. */
  135094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135095. /**
  135096. * Compute the primary color according to the chosen perceptual color.
  135097. */
  135098. private _computePrimaryColorFromPerceptualColor;
  135099. /**
  135100. * Compute the highlights and shadow colors according to their chosen levels.
  135101. */
  135102. private _computePrimaryColors;
  135103. /**
  135104. * Build the uniform buffer used in the material.
  135105. */
  135106. buildUniformLayout(): void;
  135107. /**
  135108. * Unbind the material.
  135109. */
  135110. unbind(): void;
  135111. /**
  135112. * Bind only the world matrix to the material.
  135113. * @param world The world matrix to bind.
  135114. */
  135115. bindOnlyWorldMatrix(world: Matrix): void;
  135116. /**
  135117. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135118. * @param world The world matrix to bind.
  135119. * @param subMesh The submesh to bind for.
  135120. */
  135121. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135122. /**
  135123. * Checks to see if a texture is used in the material.
  135124. * @param texture - Base texture to use.
  135125. * @returns - Boolean specifying if a texture is used in the material.
  135126. */
  135127. hasTexture(texture: BaseTexture): boolean;
  135128. /**
  135129. * Dispose the material.
  135130. * @param forceDisposeEffect Force disposal of the associated effect.
  135131. * @param forceDisposeTextures Force disposal of the associated textures.
  135132. */
  135133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135134. /**
  135135. * Clones the material.
  135136. * @param name The cloned name.
  135137. * @returns The cloned material.
  135138. */
  135139. clone(name: string): BackgroundMaterial;
  135140. /**
  135141. * Serializes the current material to its JSON representation.
  135142. * @returns The JSON representation.
  135143. */
  135144. serialize(): any;
  135145. /**
  135146. * Gets the class name of the material
  135147. * @returns "BackgroundMaterial"
  135148. */
  135149. getClassName(): string;
  135150. /**
  135151. * Parse a JSON input to create back a background material.
  135152. * @param source The JSON data to parse
  135153. * @param scene The scene to create the parsed material in
  135154. * @param rootUrl The root url of the assets the material depends upon
  135155. * @returns the instantiated BackgroundMaterial.
  135156. */
  135157. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135158. }
  135159. }
  135160. declare module BABYLON {
  135161. /**
  135162. * Represents the different options available during the creation of
  135163. * a Environment helper.
  135164. *
  135165. * This can control the default ground, skybox and image processing setup of your scene.
  135166. */
  135167. export interface IEnvironmentHelperOptions {
  135168. /**
  135169. * Specifies whether or not to create a ground.
  135170. * True by default.
  135171. */
  135172. createGround: boolean;
  135173. /**
  135174. * Specifies the ground size.
  135175. * 15 by default.
  135176. */
  135177. groundSize: number;
  135178. /**
  135179. * The texture used on the ground for the main color.
  135180. * Comes from the BabylonJS CDN by default.
  135181. *
  135182. * Remarks: Can be either a texture or a url.
  135183. */
  135184. groundTexture: string | BaseTexture;
  135185. /**
  135186. * The color mixed in the ground texture by default.
  135187. * BabylonJS clearColor by default.
  135188. */
  135189. groundColor: Color3;
  135190. /**
  135191. * Specifies the ground opacity.
  135192. * 1 by default.
  135193. */
  135194. groundOpacity: number;
  135195. /**
  135196. * Enables the ground to receive shadows.
  135197. * True by default.
  135198. */
  135199. enableGroundShadow: boolean;
  135200. /**
  135201. * Helps preventing the shadow to be fully black on the ground.
  135202. * 0.5 by default.
  135203. */
  135204. groundShadowLevel: number;
  135205. /**
  135206. * Creates a mirror texture attach to the ground.
  135207. * false by default.
  135208. */
  135209. enableGroundMirror: boolean;
  135210. /**
  135211. * Specifies the ground mirror size ratio.
  135212. * 0.3 by default as the default kernel is 64.
  135213. */
  135214. groundMirrorSizeRatio: number;
  135215. /**
  135216. * Specifies the ground mirror blur kernel size.
  135217. * 64 by default.
  135218. */
  135219. groundMirrorBlurKernel: number;
  135220. /**
  135221. * Specifies the ground mirror visibility amount.
  135222. * 1 by default
  135223. */
  135224. groundMirrorAmount: number;
  135225. /**
  135226. * Specifies the ground mirror reflectance weight.
  135227. * This uses the standard weight of the background material to setup the fresnel effect
  135228. * of the mirror.
  135229. * 1 by default.
  135230. */
  135231. groundMirrorFresnelWeight: number;
  135232. /**
  135233. * Specifies the ground mirror Falloff distance.
  135234. * This can helps reducing the size of the reflection.
  135235. * 0 by Default.
  135236. */
  135237. groundMirrorFallOffDistance: number;
  135238. /**
  135239. * Specifies the ground mirror texture type.
  135240. * Unsigned Int by Default.
  135241. */
  135242. groundMirrorTextureType: number;
  135243. /**
  135244. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135245. * the shown objects.
  135246. */
  135247. groundYBias: number;
  135248. /**
  135249. * Specifies whether or not to create a skybox.
  135250. * True by default.
  135251. */
  135252. createSkybox: boolean;
  135253. /**
  135254. * Specifies the skybox size.
  135255. * 20 by default.
  135256. */
  135257. skyboxSize: number;
  135258. /**
  135259. * The texture used on the skybox for the main color.
  135260. * Comes from the BabylonJS CDN by default.
  135261. *
  135262. * Remarks: Can be either a texture or a url.
  135263. */
  135264. skyboxTexture: string | BaseTexture;
  135265. /**
  135266. * The color mixed in the skybox texture by default.
  135267. * BabylonJS clearColor by default.
  135268. */
  135269. skyboxColor: Color3;
  135270. /**
  135271. * The background rotation around the Y axis of the scene.
  135272. * This helps aligning the key lights of your scene with the background.
  135273. * 0 by default.
  135274. */
  135275. backgroundYRotation: number;
  135276. /**
  135277. * Compute automatically the size of the elements to best fit with the scene.
  135278. */
  135279. sizeAuto: boolean;
  135280. /**
  135281. * Default position of the rootMesh if autoSize is not true.
  135282. */
  135283. rootPosition: Vector3;
  135284. /**
  135285. * Sets up the image processing in the scene.
  135286. * true by default.
  135287. */
  135288. setupImageProcessing: boolean;
  135289. /**
  135290. * The texture used as your environment texture in the scene.
  135291. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135292. *
  135293. * Remarks: Can be either a texture or a url.
  135294. */
  135295. environmentTexture: string | BaseTexture;
  135296. /**
  135297. * The value of the exposure to apply to the scene.
  135298. * 0.6 by default if setupImageProcessing is true.
  135299. */
  135300. cameraExposure: number;
  135301. /**
  135302. * The value of the contrast to apply to the scene.
  135303. * 1.6 by default if setupImageProcessing is true.
  135304. */
  135305. cameraContrast: number;
  135306. /**
  135307. * Specifies whether or not tonemapping should be enabled in the scene.
  135308. * true by default if setupImageProcessing is true.
  135309. */
  135310. toneMappingEnabled: boolean;
  135311. }
  135312. /**
  135313. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135314. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135315. * It also helps with the default setup of your imageProcessing configuration.
  135316. */
  135317. export class EnvironmentHelper {
  135318. /**
  135319. * Default ground texture URL.
  135320. */
  135321. private static _groundTextureCDNUrl;
  135322. /**
  135323. * Default skybox texture URL.
  135324. */
  135325. private static _skyboxTextureCDNUrl;
  135326. /**
  135327. * Default environment texture URL.
  135328. */
  135329. private static _environmentTextureCDNUrl;
  135330. /**
  135331. * Creates the default options for the helper.
  135332. */
  135333. private static _getDefaultOptions;
  135334. private _rootMesh;
  135335. /**
  135336. * Gets the root mesh created by the helper.
  135337. */
  135338. get rootMesh(): Mesh;
  135339. private _skybox;
  135340. /**
  135341. * Gets the skybox created by the helper.
  135342. */
  135343. get skybox(): Nullable<Mesh>;
  135344. private _skyboxTexture;
  135345. /**
  135346. * Gets the skybox texture created by the helper.
  135347. */
  135348. get skyboxTexture(): Nullable<BaseTexture>;
  135349. private _skyboxMaterial;
  135350. /**
  135351. * Gets the skybox material created by the helper.
  135352. */
  135353. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135354. private _ground;
  135355. /**
  135356. * Gets the ground mesh created by the helper.
  135357. */
  135358. get ground(): Nullable<Mesh>;
  135359. private _groundTexture;
  135360. /**
  135361. * Gets the ground texture created by the helper.
  135362. */
  135363. get groundTexture(): Nullable<BaseTexture>;
  135364. private _groundMirror;
  135365. /**
  135366. * Gets the ground mirror created by the helper.
  135367. */
  135368. get groundMirror(): Nullable<MirrorTexture>;
  135369. /**
  135370. * Gets the ground mirror render list to helps pushing the meshes
  135371. * you wish in the ground reflection.
  135372. */
  135373. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135374. private _groundMaterial;
  135375. /**
  135376. * Gets the ground material created by the helper.
  135377. */
  135378. get groundMaterial(): Nullable<BackgroundMaterial>;
  135379. /**
  135380. * Stores the creation options.
  135381. */
  135382. private readonly _scene;
  135383. private _options;
  135384. /**
  135385. * This observable will be notified with any error during the creation of the environment,
  135386. * mainly texture creation errors.
  135387. */
  135388. onErrorObservable: Observable<{
  135389. message?: string;
  135390. exception?: any;
  135391. }>;
  135392. /**
  135393. * constructor
  135394. * @param options Defines the options we want to customize the helper
  135395. * @param scene The scene to add the material to
  135396. */
  135397. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135398. /**
  135399. * Updates the background according to the new options
  135400. * @param options
  135401. */
  135402. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135403. /**
  135404. * Sets the primary color of all the available elements.
  135405. * @param color the main color to affect to the ground and the background
  135406. */
  135407. setMainColor(color: Color3): void;
  135408. /**
  135409. * Setup the image processing according to the specified options.
  135410. */
  135411. private _setupImageProcessing;
  135412. /**
  135413. * Setup the environment texture according to the specified options.
  135414. */
  135415. private _setupEnvironmentTexture;
  135416. /**
  135417. * Setup the background according to the specified options.
  135418. */
  135419. private _setupBackground;
  135420. /**
  135421. * Get the scene sizes according to the setup.
  135422. */
  135423. private _getSceneSize;
  135424. /**
  135425. * Setup the ground according to the specified options.
  135426. */
  135427. private _setupGround;
  135428. /**
  135429. * Setup the ground material according to the specified options.
  135430. */
  135431. private _setupGroundMaterial;
  135432. /**
  135433. * Setup the ground diffuse texture according to the specified options.
  135434. */
  135435. private _setupGroundDiffuseTexture;
  135436. /**
  135437. * Setup the ground mirror texture according to the specified options.
  135438. */
  135439. private _setupGroundMirrorTexture;
  135440. /**
  135441. * Setup the ground to receive the mirror texture.
  135442. */
  135443. private _setupMirrorInGroundMaterial;
  135444. /**
  135445. * Setup the skybox according to the specified options.
  135446. */
  135447. private _setupSkybox;
  135448. /**
  135449. * Setup the skybox material according to the specified options.
  135450. */
  135451. private _setupSkyboxMaterial;
  135452. /**
  135453. * Setup the skybox reflection texture according to the specified options.
  135454. */
  135455. private _setupSkyboxReflectionTexture;
  135456. private _errorHandler;
  135457. /**
  135458. * Dispose all the elements created by the Helper.
  135459. */
  135460. dispose(): void;
  135461. }
  135462. }
  135463. declare module BABYLON {
  135464. /**
  135465. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135466. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135467. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135468. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135469. */
  135470. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135471. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135472. /**
  135473. * Define the source as a Monoscopic panoramic 360/180.
  135474. */
  135475. static readonly MODE_MONOSCOPIC: number;
  135476. /**
  135477. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135478. */
  135479. static readonly MODE_TOPBOTTOM: number;
  135480. /**
  135481. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135482. */
  135483. static readonly MODE_SIDEBYSIDE: number;
  135484. private _halfDome;
  135485. protected _useDirectMapping: boolean;
  135486. /**
  135487. * The texture being displayed on the sphere
  135488. */
  135489. protected _texture: T;
  135490. /**
  135491. * Gets the texture being displayed on the sphere
  135492. */
  135493. get texture(): T;
  135494. /**
  135495. * Sets the texture being displayed on the sphere
  135496. */
  135497. set texture(newTexture: T);
  135498. /**
  135499. * The skybox material
  135500. */
  135501. protected _material: BackgroundMaterial;
  135502. /**
  135503. * The surface used for the dome
  135504. */
  135505. protected _mesh: Mesh;
  135506. /**
  135507. * Gets the mesh used for the dome.
  135508. */
  135509. get mesh(): Mesh;
  135510. /**
  135511. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135512. */
  135513. private _halfDomeMask;
  135514. /**
  135515. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135516. * Also see the options.resolution property.
  135517. */
  135518. get fovMultiplier(): number;
  135519. set fovMultiplier(value: number);
  135520. protected _textureMode: number;
  135521. /**
  135522. * Gets or set the current texture mode for the texture. It can be:
  135523. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135524. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135525. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135526. */
  135527. get textureMode(): number;
  135528. /**
  135529. * Sets the current texture mode for the texture. It can be:
  135530. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135531. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135532. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135533. */
  135534. set textureMode(value: number);
  135535. /**
  135536. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135537. */
  135538. get halfDome(): boolean;
  135539. /**
  135540. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135541. */
  135542. set halfDome(enabled: boolean);
  135543. /**
  135544. * Oberserver used in Stereoscopic VR Mode.
  135545. */
  135546. private _onBeforeCameraRenderObserver;
  135547. /**
  135548. * Observable raised when an error occured while loading the 360 image
  135549. */
  135550. onLoadErrorObservable: Observable<string>;
  135551. /**
  135552. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135553. * @param name Element's name, child elements will append suffixes for their own names.
  135554. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135555. * @param options An object containing optional or exposed sub element properties
  135556. */
  135557. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135558. resolution?: number;
  135559. clickToPlay?: boolean;
  135560. autoPlay?: boolean;
  135561. loop?: boolean;
  135562. size?: number;
  135563. poster?: string;
  135564. faceForward?: boolean;
  135565. useDirectMapping?: boolean;
  135566. halfDomeMode?: boolean;
  135567. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135568. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135569. protected _changeTextureMode(value: number): void;
  135570. /**
  135571. * Releases resources associated with this node.
  135572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135574. */
  135575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135576. }
  135577. }
  135578. declare module BABYLON {
  135579. /**
  135580. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135581. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135582. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135583. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135584. */
  135585. export class PhotoDome extends TextureDome<Texture> {
  135586. /**
  135587. * Define the image as a Monoscopic panoramic 360 image.
  135588. */
  135589. static readonly MODE_MONOSCOPIC: number;
  135590. /**
  135591. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135592. */
  135593. static readonly MODE_TOPBOTTOM: number;
  135594. /**
  135595. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135596. */
  135597. static readonly MODE_SIDEBYSIDE: number;
  135598. /**
  135599. * Gets or sets the texture being displayed on the sphere
  135600. */
  135601. get photoTexture(): Texture;
  135602. /**
  135603. * sets the texture being displayed on the sphere
  135604. */
  135605. set photoTexture(value: Texture);
  135606. /**
  135607. * Gets the current video mode for the video. It can be:
  135608. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135609. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135610. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135611. */
  135612. get imageMode(): number;
  135613. /**
  135614. * Sets the current video mode for the video. It can be:
  135615. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135616. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135617. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135618. */
  135619. set imageMode(value: number);
  135620. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135621. }
  135622. }
  135623. declare module BABYLON {
  135624. /**
  135625. * Class used to host RGBD texture specific utilities
  135626. */
  135627. export class RGBDTextureTools {
  135628. /**
  135629. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135630. * @param texture the texture to expand.
  135631. */
  135632. static ExpandRGBDTexture(texture: Texture): void;
  135633. }
  135634. }
  135635. declare module BABYLON {
  135636. /**
  135637. * Class used to host texture specific utilities
  135638. */
  135639. export class BRDFTextureTools {
  135640. /**
  135641. * Prevents texture cache collision
  135642. */
  135643. private static _instanceNumber;
  135644. /**
  135645. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135646. * @param scene defines the hosting scene
  135647. * @returns the environment BRDF texture
  135648. */
  135649. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135650. private static _environmentBRDFBase64Texture;
  135651. }
  135652. }
  135653. declare module BABYLON {
  135654. /**
  135655. * @hidden
  135656. */
  135657. export interface IMaterialClearCoatDefines {
  135658. CLEARCOAT: boolean;
  135659. CLEARCOAT_DEFAULTIOR: boolean;
  135660. CLEARCOAT_TEXTURE: boolean;
  135661. CLEARCOAT_TEXTUREDIRECTUV: number;
  135662. CLEARCOAT_BUMP: boolean;
  135663. CLEARCOAT_BUMPDIRECTUV: number;
  135664. CLEARCOAT_TINT: boolean;
  135665. CLEARCOAT_TINT_TEXTURE: boolean;
  135666. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135667. /** @hidden */
  135668. _areTexturesDirty: boolean;
  135669. }
  135670. /**
  135671. * Define the code related to the clear coat parameters of the pbr material.
  135672. */
  135673. export class PBRClearCoatConfiguration {
  135674. /**
  135675. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135676. * The default fits with a polyurethane material.
  135677. */
  135678. private static readonly _DefaultIndexOfRefraction;
  135679. private _isEnabled;
  135680. /**
  135681. * Defines if the clear coat is enabled in the material.
  135682. */
  135683. isEnabled: boolean;
  135684. /**
  135685. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135686. */
  135687. intensity: number;
  135688. /**
  135689. * Defines the clear coat layer roughness.
  135690. */
  135691. roughness: number;
  135692. private _indexOfRefraction;
  135693. /**
  135694. * Defines the index of refraction of the clear coat.
  135695. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135696. * The default fits with a polyurethane material.
  135697. * Changing the default value is more performance intensive.
  135698. */
  135699. indexOfRefraction: number;
  135700. private _texture;
  135701. /**
  135702. * Stores the clear coat values in a texture.
  135703. */
  135704. texture: Nullable<BaseTexture>;
  135705. private _bumpTexture;
  135706. /**
  135707. * Define the clear coat specific bump texture.
  135708. */
  135709. bumpTexture: Nullable<BaseTexture>;
  135710. private _isTintEnabled;
  135711. /**
  135712. * Defines if the clear coat tint is enabled in the material.
  135713. */
  135714. isTintEnabled: boolean;
  135715. /**
  135716. * Defines the clear coat tint of the material.
  135717. * This is only use if tint is enabled
  135718. */
  135719. tintColor: Color3;
  135720. /**
  135721. * Defines the distance at which the tint color should be found in the
  135722. * clear coat media.
  135723. * This is only use if tint is enabled
  135724. */
  135725. tintColorAtDistance: number;
  135726. /**
  135727. * Defines the clear coat layer thickness.
  135728. * This is only use if tint is enabled
  135729. */
  135730. tintThickness: number;
  135731. private _tintTexture;
  135732. /**
  135733. * Stores the clear tint values in a texture.
  135734. * rgb is tint
  135735. * a is a thickness factor
  135736. */
  135737. tintTexture: Nullable<BaseTexture>;
  135738. /** @hidden */
  135739. private _internalMarkAllSubMeshesAsTexturesDirty;
  135740. /** @hidden */
  135741. _markAllSubMeshesAsTexturesDirty(): void;
  135742. /**
  135743. * Instantiate a new istance of clear coat configuration.
  135744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135745. */
  135746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135747. /**
  135748. * Gets wehter the submesh is ready to be used or not.
  135749. * @param defines the list of "defines" to update.
  135750. * @param scene defines the scene the material belongs to.
  135751. * @param engine defines the engine the material belongs to.
  135752. * @param disableBumpMap defines wether the material disables bump or not.
  135753. * @returns - boolean indicating that the submesh is ready or not.
  135754. */
  135755. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135756. /**
  135757. * Checks to see if a texture is used in the material.
  135758. * @param defines the list of "defines" to update.
  135759. * @param scene defines the scene to the material belongs to.
  135760. */
  135761. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135762. /**
  135763. * Binds the material data.
  135764. * @param uniformBuffer defines the Uniform buffer to fill in.
  135765. * @param scene defines the scene the material belongs to.
  135766. * @param engine defines the engine the material belongs to.
  135767. * @param disableBumpMap defines wether the material disables bump or not.
  135768. * @param isFrozen defines wether the material is frozen or not.
  135769. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135770. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135771. */
  135772. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135773. /**
  135774. * Checks to see if a texture is used in the material.
  135775. * @param texture - Base texture to use.
  135776. * @returns - Boolean specifying if a texture is used in the material.
  135777. */
  135778. hasTexture(texture: BaseTexture): boolean;
  135779. /**
  135780. * Returns an array of the actively used textures.
  135781. * @param activeTextures Array of BaseTextures
  135782. */
  135783. getActiveTextures(activeTextures: BaseTexture[]): void;
  135784. /**
  135785. * Returns the animatable textures.
  135786. * @param animatables Array of animatable textures.
  135787. */
  135788. getAnimatables(animatables: IAnimatable[]): void;
  135789. /**
  135790. * Disposes the resources of the material.
  135791. * @param forceDisposeTextures - Forces the disposal of all textures.
  135792. */
  135793. dispose(forceDisposeTextures?: boolean): void;
  135794. /**
  135795. * Get the current class name of the texture useful for serialization or dynamic coding.
  135796. * @returns "PBRClearCoatConfiguration"
  135797. */
  135798. getClassName(): string;
  135799. /**
  135800. * Add fallbacks to the effect fallbacks list.
  135801. * @param defines defines the Base texture to use.
  135802. * @param fallbacks defines the current fallback list.
  135803. * @param currentRank defines the current fallback rank.
  135804. * @returns the new fallback rank.
  135805. */
  135806. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135807. /**
  135808. * Add the required uniforms to the current list.
  135809. * @param uniforms defines the current uniform list.
  135810. */
  135811. static AddUniforms(uniforms: string[]): void;
  135812. /**
  135813. * Add the required samplers to the current list.
  135814. * @param samplers defines the current sampler list.
  135815. */
  135816. static AddSamplers(samplers: string[]): void;
  135817. /**
  135818. * Add the required uniforms to the current buffer.
  135819. * @param uniformBuffer defines the current uniform buffer.
  135820. */
  135821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135822. /**
  135823. * Makes a duplicate of the current configuration into another one.
  135824. * @param clearCoatConfiguration define the config where to copy the info
  135825. */
  135826. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135827. /**
  135828. * Serializes this clear coat configuration.
  135829. * @returns - An object with the serialized config.
  135830. */
  135831. serialize(): any;
  135832. /**
  135833. * Parses a anisotropy Configuration from a serialized object.
  135834. * @param source - Serialized object.
  135835. * @param scene Defines the scene we are parsing for
  135836. * @param rootUrl Defines the rootUrl to load from
  135837. */
  135838. parse(source: any, scene: Scene, rootUrl: string): void;
  135839. }
  135840. }
  135841. declare module BABYLON {
  135842. /**
  135843. * @hidden
  135844. */
  135845. export interface IMaterialAnisotropicDefines {
  135846. ANISOTROPIC: boolean;
  135847. ANISOTROPIC_TEXTURE: boolean;
  135848. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135849. MAINUV1: boolean;
  135850. _areTexturesDirty: boolean;
  135851. _needUVs: boolean;
  135852. }
  135853. /**
  135854. * Define the code related to the anisotropic parameters of the pbr material.
  135855. */
  135856. export class PBRAnisotropicConfiguration {
  135857. private _isEnabled;
  135858. /**
  135859. * Defines if the anisotropy is enabled in the material.
  135860. */
  135861. isEnabled: boolean;
  135862. /**
  135863. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135864. */
  135865. intensity: number;
  135866. /**
  135867. * Defines if the effect is along the tangents, bitangents or in between.
  135868. * By default, the effect is "strectching" the highlights along the tangents.
  135869. */
  135870. direction: Vector2;
  135871. private _texture;
  135872. /**
  135873. * Stores the anisotropy values in a texture.
  135874. * rg is direction (like normal from -1 to 1)
  135875. * b is a intensity
  135876. */
  135877. texture: Nullable<BaseTexture>;
  135878. /** @hidden */
  135879. private _internalMarkAllSubMeshesAsTexturesDirty;
  135880. /** @hidden */
  135881. _markAllSubMeshesAsTexturesDirty(): void;
  135882. /**
  135883. * Instantiate a new istance of anisotropy configuration.
  135884. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135885. */
  135886. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135887. /**
  135888. * Specifies that the submesh is ready to be used.
  135889. * @param defines the list of "defines" to update.
  135890. * @param scene defines the scene the material belongs to.
  135891. * @returns - boolean indicating that the submesh is ready or not.
  135892. */
  135893. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135894. /**
  135895. * Checks to see if a texture is used in the material.
  135896. * @param defines the list of "defines" to update.
  135897. * @param mesh the mesh we are preparing the defines for.
  135898. * @param scene defines the scene the material belongs to.
  135899. */
  135900. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135901. /**
  135902. * Binds the material data.
  135903. * @param uniformBuffer defines the Uniform buffer to fill in.
  135904. * @param scene defines the scene the material belongs to.
  135905. * @param isFrozen defines wether the material is frozen or not.
  135906. */
  135907. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135908. /**
  135909. * Checks to see if a texture is used in the material.
  135910. * @param texture - Base texture to use.
  135911. * @returns - Boolean specifying if a texture is used in the material.
  135912. */
  135913. hasTexture(texture: BaseTexture): boolean;
  135914. /**
  135915. * Returns an array of the actively used textures.
  135916. * @param activeTextures Array of BaseTextures
  135917. */
  135918. getActiveTextures(activeTextures: BaseTexture[]): void;
  135919. /**
  135920. * Returns the animatable textures.
  135921. * @param animatables Array of animatable textures.
  135922. */
  135923. getAnimatables(animatables: IAnimatable[]): void;
  135924. /**
  135925. * Disposes the resources of the material.
  135926. * @param forceDisposeTextures - Forces the disposal of all textures.
  135927. */
  135928. dispose(forceDisposeTextures?: boolean): void;
  135929. /**
  135930. * Get the current class name of the texture useful for serialization or dynamic coding.
  135931. * @returns "PBRAnisotropicConfiguration"
  135932. */
  135933. getClassName(): string;
  135934. /**
  135935. * Add fallbacks to the effect fallbacks list.
  135936. * @param defines defines the Base texture to use.
  135937. * @param fallbacks defines the current fallback list.
  135938. * @param currentRank defines the current fallback rank.
  135939. * @returns the new fallback rank.
  135940. */
  135941. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135942. /**
  135943. * Add the required uniforms to the current list.
  135944. * @param uniforms defines the current uniform list.
  135945. */
  135946. static AddUniforms(uniforms: string[]): void;
  135947. /**
  135948. * Add the required uniforms to the current buffer.
  135949. * @param uniformBuffer defines the current uniform buffer.
  135950. */
  135951. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135952. /**
  135953. * Add the required samplers to the current list.
  135954. * @param samplers defines the current sampler list.
  135955. */
  135956. static AddSamplers(samplers: string[]): void;
  135957. /**
  135958. * Makes a duplicate of the current configuration into another one.
  135959. * @param anisotropicConfiguration define the config where to copy the info
  135960. */
  135961. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135962. /**
  135963. * Serializes this anisotropy configuration.
  135964. * @returns - An object with the serialized config.
  135965. */
  135966. serialize(): any;
  135967. /**
  135968. * Parses a anisotropy Configuration from a serialized object.
  135969. * @param source - Serialized object.
  135970. * @param scene Defines the scene we are parsing for
  135971. * @param rootUrl Defines the rootUrl to load from
  135972. */
  135973. parse(source: any, scene: Scene, rootUrl: string): void;
  135974. }
  135975. }
  135976. declare module BABYLON {
  135977. /**
  135978. * @hidden
  135979. */
  135980. export interface IMaterialBRDFDefines {
  135981. BRDF_V_HEIGHT_CORRELATED: boolean;
  135982. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135983. SPHERICAL_HARMONICS: boolean;
  135984. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135985. /** @hidden */
  135986. _areMiscDirty: boolean;
  135987. }
  135988. /**
  135989. * Define the code related to the BRDF parameters of the pbr material.
  135990. */
  135991. export class PBRBRDFConfiguration {
  135992. /**
  135993. * Default value used for the energy conservation.
  135994. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135995. */
  135996. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135997. /**
  135998. * Default value used for the Smith Visibility Height Correlated mode.
  135999. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136000. */
  136001. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136002. /**
  136003. * Default value used for the IBL diffuse part.
  136004. * This can help switching back to the polynomials mode globally which is a tiny bit
  136005. * less GPU intensive at the drawback of a lower quality.
  136006. */
  136007. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136008. /**
  136009. * Default value used for activating energy conservation for the specular workflow.
  136010. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136011. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136012. */
  136013. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136014. private _useEnergyConservation;
  136015. /**
  136016. * Defines if the material uses energy conservation.
  136017. */
  136018. useEnergyConservation: boolean;
  136019. private _useSmithVisibilityHeightCorrelated;
  136020. /**
  136021. * LEGACY Mode set to false
  136022. * Defines if the material uses height smith correlated visibility term.
  136023. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136024. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136025. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136026. * Not relying on height correlated will also disable energy conservation.
  136027. */
  136028. useSmithVisibilityHeightCorrelated: boolean;
  136029. private _useSphericalHarmonics;
  136030. /**
  136031. * LEGACY Mode set to false
  136032. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136033. * diffuse part of the IBL.
  136034. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136035. * to the ground truth.
  136036. */
  136037. useSphericalHarmonics: boolean;
  136038. private _useSpecularGlossinessInputEnergyConservation;
  136039. /**
  136040. * Defines if the material uses energy conservation, when the specular workflow is active.
  136041. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136042. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136043. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136044. */
  136045. useSpecularGlossinessInputEnergyConservation: boolean;
  136046. /** @hidden */
  136047. private _internalMarkAllSubMeshesAsMiscDirty;
  136048. /** @hidden */
  136049. _markAllSubMeshesAsMiscDirty(): void;
  136050. /**
  136051. * Instantiate a new istance of clear coat configuration.
  136052. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136053. */
  136054. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136055. /**
  136056. * Checks to see if a texture is used in the material.
  136057. * @param defines the list of "defines" to update.
  136058. */
  136059. prepareDefines(defines: IMaterialBRDFDefines): void;
  136060. /**
  136061. * Get the current class name of the texture useful for serialization or dynamic coding.
  136062. * @returns "PBRClearCoatConfiguration"
  136063. */
  136064. getClassName(): string;
  136065. /**
  136066. * Makes a duplicate of the current configuration into another one.
  136067. * @param brdfConfiguration define the config where to copy the info
  136068. */
  136069. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136070. /**
  136071. * Serializes this BRDF configuration.
  136072. * @returns - An object with the serialized config.
  136073. */
  136074. serialize(): any;
  136075. /**
  136076. * Parses a anisotropy Configuration from a serialized object.
  136077. * @param source - Serialized object.
  136078. * @param scene Defines the scene we are parsing for
  136079. * @param rootUrl Defines the rootUrl to load from
  136080. */
  136081. parse(source: any, scene: Scene, rootUrl: string): void;
  136082. }
  136083. }
  136084. declare module BABYLON {
  136085. /**
  136086. * @hidden
  136087. */
  136088. export interface IMaterialSheenDefines {
  136089. SHEEN: boolean;
  136090. SHEEN_TEXTURE: boolean;
  136091. SHEEN_TEXTUREDIRECTUV: number;
  136092. SHEEN_LINKWITHALBEDO: boolean;
  136093. SHEEN_ROUGHNESS: boolean;
  136094. SHEEN_ALBEDOSCALING: boolean;
  136095. /** @hidden */
  136096. _areTexturesDirty: boolean;
  136097. }
  136098. /**
  136099. * Define the code related to the Sheen parameters of the pbr material.
  136100. */
  136101. export class PBRSheenConfiguration {
  136102. private _isEnabled;
  136103. /**
  136104. * Defines if the material uses sheen.
  136105. */
  136106. isEnabled: boolean;
  136107. private _linkSheenWithAlbedo;
  136108. /**
  136109. * Defines if the sheen is linked to the sheen color.
  136110. */
  136111. linkSheenWithAlbedo: boolean;
  136112. /**
  136113. * Defines the sheen intensity.
  136114. */
  136115. intensity: number;
  136116. /**
  136117. * Defines the sheen color.
  136118. */
  136119. color: Color3;
  136120. private _texture;
  136121. /**
  136122. * Stores the sheen tint values in a texture.
  136123. * rgb is tint
  136124. * a is a intensity or roughness if roughness has been defined
  136125. */
  136126. texture: Nullable<BaseTexture>;
  136127. private _roughness;
  136128. /**
  136129. * Defines the sheen roughness.
  136130. * It is not taken into account if linkSheenWithAlbedo is true.
  136131. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136132. */
  136133. roughness: Nullable<number>;
  136134. private _albedoScaling;
  136135. /**
  136136. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136137. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136138. * making it easier to setup and tweak the effect
  136139. */
  136140. albedoScaling: boolean;
  136141. /** @hidden */
  136142. private _internalMarkAllSubMeshesAsTexturesDirty;
  136143. /** @hidden */
  136144. _markAllSubMeshesAsTexturesDirty(): void;
  136145. /**
  136146. * Instantiate a new istance of clear coat configuration.
  136147. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136148. */
  136149. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136150. /**
  136151. * Specifies that the submesh is ready to be used.
  136152. * @param defines the list of "defines" to update.
  136153. * @param scene defines the scene the material belongs to.
  136154. * @returns - boolean indicating that the submesh is ready or not.
  136155. */
  136156. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136157. /**
  136158. * Checks to see if a texture is used in the material.
  136159. * @param defines the list of "defines" to update.
  136160. * @param scene defines the scene the material belongs to.
  136161. */
  136162. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136163. /**
  136164. * Binds the material data.
  136165. * @param uniformBuffer defines the Uniform buffer to fill in.
  136166. * @param scene defines the scene the material belongs to.
  136167. * @param isFrozen defines wether the material is frozen or not.
  136168. */
  136169. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136170. /**
  136171. * Checks to see if a texture is used in the material.
  136172. * @param texture - Base texture to use.
  136173. * @returns - Boolean specifying if a texture is used in the material.
  136174. */
  136175. hasTexture(texture: BaseTexture): boolean;
  136176. /**
  136177. * Returns an array of the actively used textures.
  136178. * @param activeTextures Array of BaseTextures
  136179. */
  136180. getActiveTextures(activeTextures: BaseTexture[]): void;
  136181. /**
  136182. * Returns the animatable textures.
  136183. * @param animatables Array of animatable textures.
  136184. */
  136185. getAnimatables(animatables: IAnimatable[]): void;
  136186. /**
  136187. * Disposes the resources of the material.
  136188. * @param forceDisposeTextures - Forces the disposal of all textures.
  136189. */
  136190. dispose(forceDisposeTextures?: boolean): void;
  136191. /**
  136192. * Get the current class name of the texture useful for serialization or dynamic coding.
  136193. * @returns "PBRSheenConfiguration"
  136194. */
  136195. getClassName(): string;
  136196. /**
  136197. * Add fallbacks to the effect fallbacks list.
  136198. * @param defines defines the Base texture to use.
  136199. * @param fallbacks defines the current fallback list.
  136200. * @param currentRank defines the current fallback rank.
  136201. * @returns the new fallback rank.
  136202. */
  136203. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136204. /**
  136205. * Add the required uniforms to the current list.
  136206. * @param uniforms defines the current uniform list.
  136207. */
  136208. static AddUniforms(uniforms: string[]): void;
  136209. /**
  136210. * Add the required uniforms to the current buffer.
  136211. * @param uniformBuffer defines the current uniform buffer.
  136212. */
  136213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136214. /**
  136215. * Add the required samplers to the current list.
  136216. * @param samplers defines the current sampler list.
  136217. */
  136218. static AddSamplers(samplers: string[]): void;
  136219. /**
  136220. * Makes a duplicate of the current configuration into another one.
  136221. * @param sheenConfiguration define the config where to copy the info
  136222. */
  136223. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136224. /**
  136225. * Serializes this BRDF configuration.
  136226. * @returns - An object with the serialized config.
  136227. */
  136228. serialize(): any;
  136229. /**
  136230. * Parses a anisotropy Configuration from a serialized object.
  136231. * @param source - Serialized object.
  136232. * @param scene Defines the scene we are parsing for
  136233. * @param rootUrl Defines the rootUrl to load from
  136234. */
  136235. parse(source: any, scene: Scene, rootUrl: string): void;
  136236. }
  136237. }
  136238. declare module BABYLON {
  136239. /**
  136240. * @hidden
  136241. */
  136242. export interface IMaterialSubSurfaceDefines {
  136243. SUBSURFACE: boolean;
  136244. SS_REFRACTION: boolean;
  136245. SS_TRANSLUCENCY: boolean;
  136246. SS_SCATTERING: boolean;
  136247. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136248. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136249. SS_REFRACTIONMAP_3D: boolean;
  136250. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136251. SS_LODINREFRACTIONALPHA: boolean;
  136252. SS_GAMMAREFRACTION: boolean;
  136253. SS_RGBDREFRACTION: boolean;
  136254. SS_LINEARSPECULARREFRACTION: boolean;
  136255. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136256. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136257. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136258. /** @hidden */
  136259. _areTexturesDirty: boolean;
  136260. }
  136261. /**
  136262. * Define the code related to the sub surface parameters of the pbr material.
  136263. */
  136264. export class PBRSubSurfaceConfiguration {
  136265. private _isRefractionEnabled;
  136266. /**
  136267. * Defines if the refraction is enabled in the material.
  136268. */
  136269. isRefractionEnabled: boolean;
  136270. private _isTranslucencyEnabled;
  136271. /**
  136272. * Defines if the translucency is enabled in the material.
  136273. */
  136274. isTranslucencyEnabled: boolean;
  136275. private _isScatteringEnabled;
  136276. /**
  136277. * Defines if the sub surface scattering is enabled in the material.
  136278. */
  136279. isScatteringEnabled: boolean;
  136280. private _scatteringDiffusionProfileIndex;
  136281. /**
  136282. * Diffusion profile for subsurface scattering.
  136283. * Useful for better scattering in the skins or foliages.
  136284. */
  136285. get scatteringDiffusionProfile(): Nullable<Color3>;
  136286. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136287. /**
  136288. * Defines the refraction intensity of the material.
  136289. * The refraction when enabled replaces the Diffuse part of the material.
  136290. * The intensity helps transitionning between diffuse and refraction.
  136291. */
  136292. refractionIntensity: number;
  136293. /**
  136294. * Defines the translucency intensity of the material.
  136295. * When translucency has been enabled, this defines how much of the "translucency"
  136296. * is addded to the diffuse part of the material.
  136297. */
  136298. translucencyIntensity: number;
  136299. /**
  136300. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136301. */
  136302. useAlbedoToTintRefraction: boolean;
  136303. private _thicknessTexture;
  136304. /**
  136305. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136306. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136307. * 0 would mean minimumThickness
  136308. * 1 would mean maximumThickness
  136309. * The other channels might be use as a mask to vary the different effects intensity.
  136310. */
  136311. thicknessTexture: Nullable<BaseTexture>;
  136312. private _refractionTexture;
  136313. /**
  136314. * Defines the texture to use for refraction.
  136315. */
  136316. refractionTexture: Nullable<BaseTexture>;
  136317. private _indexOfRefraction;
  136318. /**
  136319. * Index of refraction of the material base layer.
  136320. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136321. *
  136322. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136323. *
  136324. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136325. */
  136326. indexOfRefraction: number;
  136327. private _volumeIndexOfRefraction;
  136328. /**
  136329. * Index of refraction of the material's volume.
  136330. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136331. *
  136332. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136333. * the volume will use the same IOR as the surface.
  136334. */
  136335. get volumeIndexOfRefraction(): number;
  136336. set volumeIndexOfRefraction(value: number);
  136337. private _invertRefractionY;
  136338. /**
  136339. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136340. */
  136341. invertRefractionY: boolean;
  136342. private _linkRefractionWithTransparency;
  136343. /**
  136344. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136345. * Materials half opaque for instance using refraction could benefit from this control.
  136346. */
  136347. linkRefractionWithTransparency: boolean;
  136348. /**
  136349. * Defines the minimum thickness stored in the thickness map.
  136350. * If no thickness map is defined, this value will be used to simulate thickness.
  136351. */
  136352. minimumThickness: number;
  136353. /**
  136354. * Defines the maximum thickness stored in the thickness map.
  136355. */
  136356. maximumThickness: number;
  136357. /**
  136358. * Defines the volume tint of the material.
  136359. * This is used for both translucency and scattering.
  136360. */
  136361. tintColor: Color3;
  136362. /**
  136363. * Defines the distance at which the tint color should be found in the media.
  136364. * This is used for refraction only.
  136365. */
  136366. tintColorAtDistance: number;
  136367. /**
  136368. * Defines how far each channel transmit through the media.
  136369. * It is defined as a color to simplify it selection.
  136370. */
  136371. diffusionDistance: Color3;
  136372. private _useMaskFromThicknessTexture;
  136373. /**
  136374. * Stores the intensity of the different subsurface effects in the thickness texture.
  136375. * * the green channel is the translucency intensity.
  136376. * * the blue channel is the scattering intensity.
  136377. * * the alpha channel is the refraction intensity.
  136378. */
  136379. useMaskFromThicknessTexture: boolean;
  136380. private _scene;
  136381. /** @hidden */
  136382. private _internalMarkAllSubMeshesAsTexturesDirty;
  136383. private _internalMarkScenePrePassDirty;
  136384. /** @hidden */
  136385. _markAllSubMeshesAsTexturesDirty(): void;
  136386. /** @hidden */
  136387. _markScenePrePassDirty(): void;
  136388. /**
  136389. * Instantiate a new istance of sub surface configuration.
  136390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136391. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136392. * @param scene The scene
  136393. */
  136394. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136395. /**
  136396. * Gets wehter the submesh is ready to be used or not.
  136397. * @param defines the list of "defines" to update.
  136398. * @param scene defines the scene the material belongs to.
  136399. * @returns - boolean indicating that the submesh is ready or not.
  136400. */
  136401. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136402. /**
  136403. * Checks to see if a texture is used in the material.
  136404. * @param defines the list of "defines" to update.
  136405. * @param scene defines the scene to the material belongs to.
  136406. */
  136407. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136408. /**
  136409. * Binds the material data.
  136410. * @param uniformBuffer defines the Uniform buffer to fill in.
  136411. * @param scene defines the scene the material belongs to.
  136412. * @param engine defines the engine the material belongs to.
  136413. * @param isFrozen defines whether the material is frozen or not.
  136414. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136415. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136416. */
  136417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136418. /**
  136419. * Unbinds the material from the mesh.
  136420. * @param activeEffect defines the effect that should be unbound from.
  136421. * @returns true if unbound, otherwise false
  136422. */
  136423. unbind(activeEffect: Effect): boolean;
  136424. /**
  136425. * Returns the texture used for refraction or null if none is used.
  136426. * @param scene defines the scene the material belongs to.
  136427. * @returns - Refraction texture if present. If no refraction texture and refraction
  136428. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136429. */
  136430. private _getRefractionTexture;
  136431. /**
  136432. * Returns true if alpha blending should be disabled.
  136433. */
  136434. get disableAlphaBlending(): boolean;
  136435. /**
  136436. * Fills the list of render target textures.
  136437. * @param renderTargets the list of render targets to update
  136438. */
  136439. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136440. /**
  136441. * Checks to see if a texture is used in the material.
  136442. * @param texture - Base texture to use.
  136443. * @returns - Boolean specifying if a texture is used in the material.
  136444. */
  136445. hasTexture(texture: BaseTexture): boolean;
  136446. /**
  136447. * Gets a boolean indicating that current material needs to register RTT
  136448. * @returns true if this uses a render target otherwise false.
  136449. */
  136450. hasRenderTargetTextures(): boolean;
  136451. /**
  136452. * Returns an array of the actively used textures.
  136453. * @param activeTextures Array of BaseTextures
  136454. */
  136455. getActiveTextures(activeTextures: BaseTexture[]): void;
  136456. /**
  136457. * Returns the animatable textures.
  136458. * @param animatables Array of animatable textures.
  136459. */
  136460. getAnimatables(animatables: IAnimatable[]): void;
  136461. /**
  136462. * Disposes the resources of the material.
  136463. * @param forceDisposeTextures - Forces the disposal of all textures.
  136464. */
  136465. dispose(forceDisposeTextures?: boolean): void;
  136466. /**
  136467. * Get the current class name of the texture useful for serialization or dynamic coding.
  136468. * @returns "PBRSubSurfaceConfiguration"
  136469. */
  136470. getClassName(): string;
  136471. /**
  136472. * Add fallbacks to the effect fallbacks list.
  136473. * @param defines defines the Base texture to use.
  136474. * @param fallbacks defines the current fallback list.
  136475. * @param currentRank defines the current fallback rank.
  136476. * @returns the new fallback rank.
  136477. */
  136478. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136479. /**
  136480. * Add the required uniforms to the current list.
  136481. * @param uniforms defines the current uniform list.
  136482. */
  136483. static AddUniforms(uniforms: string[]): void;
  136484. /**
  136485. * Add the required samplers to the current list.
  136486. * @param samplers defines the current sampler list.
  136487. */
  136488. static AddSamplers(samplers: string[]): void;
  136489. /**
  136490. * Add the required uniforms to the current buffer.
  136491. * @param uniformBuffer defines the current uniform buffer.
  136492. */
  136493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136494. /**
  136495. * Makes a duplicate of the current configuration into another one.
  136496. * @param configuration define the config where to copy the info
  136497. */
  136498. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136499. /**
  136500. * Serializes this Sub Surface configuration.
  136501. * @returns - An object with the serialized config.
  136502. */
  136503. serialize(): any;
  136504. /**
  136505. * Parses a anisotropy Configuration from a serialized object.
  136506. * @param source - Serialized object.
  136507. * @param scene Defines the scene we are parsing for
  136508. * @param rootUrl Defines the rootUrl to load from
  136509. */
  136510. parse(source: any, scene: Scene, rootUrl: string): void;
  136511. }
  136512. }
  136513. declare module BABYLON {
  136514. /** @hidden */
  136515. export var pbrFragmentDeclaration: {
  136516. name: string;
  136517. shader: string;
  136518. };
  136519. }
  136520. declare module BABYLON {
  136521. /** @hidden */
  136522. export var pbrUboDeclaration: {
  136523. name: string;
  136524. shader: string;
  136525. };
  136526. }
  136527. declare module BABYLON {
  136528. /** @hidden */
  136529. export var pbrFragmentExtraDeclaration: {
  136530. name: string;
  136531. shader: string;
  136532. };
  136533. }
  136534. declare module BABYLON {
  136535. /** @hidden */
  136536. export var pbrFragmentSamplersDeclaration: {
  136537. name: string;
  136538. shader: string;
  136539. };
  136540. }
  136541. declare module BABYLON {
  136542. /** @hidden */
  136543. export var subSurfaceScatteringFunctions: {
  136544. name: string;
  136545. shader: string;
  136546. };
  136547. }
  136548. declare module BABYLON {
  136549. /** @hidden */
  136550. export var importanceSampling: {
  136551. name: string;
  136552. shader: string;
  136553. };
  136554. }
  136555. declare module BABYLON {
  136556. /** @hidden */
  136557. export var pbrHelperFunctions: {
  136558. name: string;
  136559. shader: string;
  136560. };
  136561. }
  136562. declare module BABYLON {
  136563. /** @hidden */
  136564. export var harmonicsFunctions: {
  136565. name: string;
  136566. shader: string;
  136567. };
  136568. }
  136569. declare module BABYLON {
  136570. /** @hidden */
  136571. export var pbrDirectLightingSetupFunctions: {
  136572. name: string;
  136573. shader: string;
  136574. };
  136575. }
  136576. declare module BABYLON {
  136577. /** @hidden */
  136578. export var pbrDirectLightingFalloffFunctions: {
  136579. name: string;
  136580. shader: string;
  136581. };
  136582. }
  136583. declare module BABYLON {
  136584. /** @hidden */
  136585. export var pbrBRDFFunctions: {
  136586. name: string;
  136587. shader: string;
  136588. };
  136589. }
  136590. declare module BABYLON {
  136591. /** @hidden */
  136592. export var hdrFilteringFunctions: {
  136593. name: string;
  136594. shader: string;
  136595. };
  136596. }
  136597. declare module BABYLON {
  136598. /** @hidden */
  136599. export var pbrDirectLightingFunctions: {
  136600. name: string;
  136601. shader: string;
  136602. };
  136603. }
  136604. declare module BABYLON {
  136605. /** @hidden */
  136606. export var pbrIBLFunctions: {
  136607. name: string;
  136608. shader: string;
  136609. };
  136610. }
  136611. declare module BABYLON {
  136612. /** @hidden */
  136613. export var pbrBlockAlbedoOpacity: {
  136614. name: string;
  136615. shader: string;
  136616. };
  136617. }
  136618. declare module BABYLON {
  136619. /** @hidden */
  136620. export var pbrBlockReflectivity: {
  136621. name: string;
  136622. shader: string;
  136623. };
  136624. }
  136625. declare module BABYLON {
  136626. /** @hidden */
  136627. export var pbrBlockAmbientOcclusion: {
  136628. name: string;
  136629. shader: string;
  136630. };
  136631. }
  136632. declare module BABYLON {
  136633. /** @hidden */
  136634. export var pbrBlockAlphaFresnel: {
  136635. name: string;
  136636. shader: string;
  136637. };
  136638. }
  136639. declare module BABYLON {
  136640. /** @hidden */
  136641. export var pbrBlockAnisotropic: {
  136642. name: string;
  136643. shader: string;
  136644. };
  136645. }
  136646. declare module BABYLON {
  136647. /** @hidden */
  136648. export var pbrBlockReflection: {
  136649. name: string;
  136650. shader: string;
  136651. };
  136652. }
  136653. declare module BABYLON {
  136654. /** @hidden */
  136655. export var pbrBlockSheen: {
  136656. name: string;
  136657. shader: string;
  136658. };
  136659. }
  136660. declare module BABYLON {
  136661. /** @hidden */
  136662. export var pbrBlockClearcoat: {
  136663. name: string;
  136664. shader: string;
  136665. };
  136666. }
  136667. declare module BABYLON {
  136668. /** @hidden */
  136669. export var pbrBlockSubSurface: {
  136670. name: string;
  136671. shader: string;
  136672. };
  136673. }
  136674. declare module BABYLON {
  136675. /** @hidden */
  136676. export var pbrBlockNormalGeometric: {
  136677. name: string;
  136678. shader: string;
  136679. };
  136680. }
  136681. declare module BABYLON {
  136682. /** @hidden */
  136683. export var pbrBlockNormalFinal: {
  136684. name: string;
  136685. shader: string;
  136686. };
  136687. }
  136688. declare module BABYLON {
  136689. /** @hidden */
  136690. export var pbrBlockLightmapInit: {
  136691. name: string;
  136692. shader: string;
  136693. };
  136694. }
  136695. declare module BABYLON {
  136696. /** @hidden */
  136697. export var pbrBlockGeometryInfo: {
  136698. name: string;
  136699. shader: string;
  136700. };
  136701. }
  136702. declare module BABYLON {
  136703. /** @hidden */
  136704. export var pbrBlockReflectance0: {
  136705. name: string;
  136706. shader: string;
  136707. };
  136708. }
  136709. declare module BABYLON {
  136710. /** @hidden */
  136711. export var pbrBlockReflectance: {
  136712. name: string;
  136713. shader: string;
  136714. };
  136715. }
  136716. declare module BABYLON {
  136717. /** @hidden */
  136718. export var pbrBlockDirectLighting: {
  136719. name: string;
  136720. shader: string;
  136721. };
  136722. }
  136723. declare module BABYLON {
  136724. /** @hidden */
  136725. export var pbrBlockFinalLitComponents: {
  136726. name: string;
  136727. shader: string;
  136728. };
  136729. }
  136730. declare module BABYLON {
  136731. /** @hidden */
  136732. export var pbrBlockFinalUnlitComponents: {
  136733. name: string;
  136734. shader: string;
  136735. };
  136736. }
  136737. declare module BABYLON {
  136738. /** @hidden */
  136739. export var pbrBlockFinalColorComposition: {
  136740. name: string;
  136741. shader: string;
  136742. };
  136743. }
  136744. declare module BABYLON {
  136745. /** @hidden */
  136746. export var pbrBlockImageProcessing: {
  136747. name: string;
  136748. shader: string;
  136749. };
  136750. }
  136751. declare module BABYLON {
  136752. /** @hidden */
  136753. export var pbrDebug: {
  136754. name: string;
  136755. shader: string;
  136756. };
  136757. }
  136758. declare module BABYLON {
  136759. /** @hidden */
  136760. export var pbrPixelShader: {
  136761. name: string;
  136762. shader: string;
  136763. };
  136764. }
  136765. declare module BABYLON {
  136766. /** @hidden */
  136767. export var pbrVertexDeclaration: {
  136768. name: string;
  136769. shader: string;
  136770. };
  136771. }
  136772. declare module BABYLON {
  136773. /** @hidden */
  136774. export var pbrVertexShader: {
  136775. name: string;
  136776. shader: string;
  136777. };
  136778. }
  136779. declare module BABYLON {
  136780. /**
  136781. * Manages the defines for the PBR Material.
  136782. * @hidden
  136783. */
  136784. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136785. PBR: boolean;
  136786. NUM_SAMPLES: string;
  136787. REALTIME_FILTERING: boolean;
  136788. MAINUV1: boolean;
  136789. MAINUV2: boolean;
  136790. UV1: boolean;
  136791. UV2: boolean;
  136792. ALBEDO: boolean;
  136793. GAMMAALBEDO: boolean;
  136794. ALBEDODIRECTUV: number;
  136795. VERTEXCOLOR: boolean;
  136796. DETAIL: boolean;
  136797. DETAILDIRECTUV: number;
  136798. DETAIL_NORMALBLENDMETHOD: number;
  136799. AMBIENT: boolean;
  136800. AMBIENTDIRECTUV: number;
  136801. AMBIENTINGRAYSCALE: boolean;
  136802. OPACITY: boolean;
  136803. VERTEXALPHA: boolean;
  136804. OPACITYDIRECTUV: number;
  136805. OPACITYRGB: boolean;
  136806. ALPHATEST: boolean;
  136807. DEPTHPREPASS: boolean;
  136808. ALPHABLEND: boolean;
  136809. ALPHAFROMALBEDO: boolean;
  136810. ALPHATESTVALUE: string;
  136811. SPECULAROVERALPHA: boolean;
  136812. RADIANCEOVERALPHA: boolean;
  136813. ALPHAFRESNEL: boolean;
  136814. LINEARALPHAFRESNEL: boolean;
  136815. PREMULTIPLYALPHA: boolean;
  136816. EMISSIVE: boolean;
  136817. EMISSIVEDIRECTUV: number;
  136818. REFLECTIVITY: boolean;
  136819. REFLECTIVITYDIRECTUV: number;
  136820. SPECULARTERM: boolean;
  136821. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136822. MICROSURFACEAUTOMATIC: boolean;
  136823. LODBASEDMICROSFURACE: boolean;
  136824. MICROSURFACEMAP: boolean;
  136825. MICROSURFACEMAPDIRECTUV: number;
  136826. METALLICWORKFLOW: boolean;
  136827. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136828. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136829. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136830. AOSTOREINMETALMAPRED: boolean;
  136831. METALLIC_REFLECTANCE: boolean;
  136832. METALLIC_REFLECTANCEDIRECTUV: number;
  136833. ENVIRONMENTBRDF: boolean;
  136834. ENVIRONMENTBRDF_RGBD: boolean;
  136835. NORMAL: boolean;
  136836. TANGENT: boolean;
  136837. BUMP: boolean;
  136838. BUMPDIRECTUV: number;
  136839. OBJECTSPACE_NORMALMAP: boolean;
  136840. PARALLAX: boolean;
  136841. PARALLAXOCCLUSION: boolean;
  136842. NORMALXYSCALE: boolean;
  136843. LIGHTMAP: boolean;
  136844. LIGHTMAPDIRECTUV: number;
  136845. USELIGHTMAPASSHADOWMAP: boolean;
  136846. GAMMALIGHTMAP: boolean;
  136847. RGBDLIGHTMAP: boolean;
  136848. REFLECTION: boolean;
  136849. REFLECTIONMAP_3D: boolean;
  136850. REFLECTIONMAP_SPHERICAL: boolean;
  136851. REFLECTIONMAP_PLANAR: boolean;
  136852. REFLECTIONMAP_CUBIC: boolean;
  136853. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136854. REFLECTIONMAP_PROJECTION: boolean;
  136855. REFLECTIONMAP_SKYBOX: boolean;
  136856. REFLECTIONMAP_EXPLICIT: boolean;
  136857. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136858. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136859. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136860. INVERTCUBICMAP: boolean;
  136861. USESPHERICALFROMREFLECTIONMAP: boolean;
  136862. USEIRRADIANCEMAP: boolean;
  136863. SPHERICAL_HARMONICS: boolean;
  136864. USESPHERICALINVERTEX: boolean;
  136865. REFLECTIONMAP_OPPOSITEZ: boolean;
  136866. LODINREFLECTIONALPHA: boolean;
  136867. GAMMAREFLECTION: boolean;
  136868. RGBDREFLECTION: boolean;
  136869. LINEARSPECULARREFLECTION: boolean;
  136870. RADIANCEOCCLUSION: boolean;
  136871. HORIZONOCCLUSION: boolean;
  136872. INSTANCES: boolean;
  136873. THIN_INSTANCES: boolean;
  136874. PREPASS: boolean;
  136875. PREPASS_IRRADIANCE: boolean;
  136876. PREPASS_IRRADIANCE_INDEX: number;
  136877. PREPASS_ALBEDO: boolean;
  136878. PREPASS_ALBEDO_INDEX: number;
  136879. PREPASS_DEPTHNORMAL: boolean;
  136880. PREPASS_DEPTHNORMAL_INDEX: number;
  136881. SCENE_MRT_COUNT: number;
  136882. NUM_BONE_INFLUENCERS: number;
  136883. BonesPerMesh: number;
  136884. BONETEXTURE: boolean;
  136885. NONUNIFORMSCALING: boolean;
  136886. MORPHTARGETS: boolean;
  136887. MORPHTARGETS_NORMAL: boolean;
  136888. MORPHTARGETS_TANGENT: boolean;
  136889. MORPHTARGETS_UV: boolean;
  136890. NUM_MORPH_INFLUENCERS: number;
  136891. IMAGEPROCESSING: boolean;
  136892. VIGNETTE: boolean;
  136893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136894. VIGNETTEBLENDMODEOPAQUE: boolean;
  136895. TONEMAPPING: boolean;
  136896. TONEMAPPING_ACES: boolean;
  136897. CONTRAST: boolean;
  136898. COLORCURVES: boolean;
  136899. COLORGRADING: boolean;
  136900. COLORGRADING3D: boolean;
  136901. SAMPLER3DGREENDEPTH: boolean;
  136902. SAMPLER3DBGRMAP: boolean;
  136903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136904. EXPOSURE: boolean;
  136905. MULTIVIEW: boolean;
  136906. USEPHYSICALLIGHTFALLOFF: boolean;
  136907. USEGLTFLIGHTFALLOFF: boolean;
  136908. TWOSIDEDLIGHTING: boolean;
  136909. SHADOWFLOAT: boolean;
  136910. CLIPPLANE: boolean;
  136911. CLIPPLANE2: boolean;
  136912. CLIPPLANE3: boolean;
  136913. CLIPPLANE4: boolean;
  136914. CLIPPLANE5: boolean;
  136915. CLIPPLANE6: boolean;
  136916. POINTSIZE: boolean;
  136917. FOG: boolean;
  136918. LOGARITHMICDEPTH: boolean;
  136919. FORCENORMALFORWARD: boolean;
  136920. SPECULARAA: boolean;
  136921. CLEARCOAT: boolean;
  136922. CLEARCOAT_DEFAULTIOR: boolean;
  136923. CLEARCOAT_TEXTURE: boolean;
  136924. CLEARCOAT_TEXTUREDIRECTUV: number;
  136925. CLEARCOAT_BUMP: boolean;
  136926. CLEARCOAT_BUMPDIRECTUV: number;
  136927. CLEARCOAT_TINT: boolean;
  136928. CLEARCOAT_TINT_TEXTURE: boolean;
  136929. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136930. ANISOTROPIC: boolean;
  136931. ANISOTROPIC_TEXTURE: boolean;
  136932. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136933. BRDF_V_HEIGHT_CORRELATED: boolean;
  136934. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136935. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136936. SHEEN: boolean;
  136937. SHEEN_TEXTURE: boolean;
  136938. SHEEN_TEXTUREDIRECTUV: number;
  136939. SHEEN_LINKWITHALBEDO: boolean;
  136940. SHEEN_ROUGHNESS: boolean;
  136941. SHEEN_ALBEDOSCALING: boolean;
  136942. SUBSURFACE: boolean;
  136943. SS_REFRACTION: boolean;
  136944. SS_TRANSLUCENCY: boolean;
  136945. SS_SCATTERING: boolean;
  136946. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136947. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136948. SS_REFRACTIONMAP_3D: boolean;
  136949. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136950. SS_LODINREFRACTIONALPHA: boolean;
  136951. SS_GAMMAREFRACTION: boolean;
  136952. SS_RGBDREFRACTION: boolean;
  136953. SS_LINEARSPECULARREFRACTION: boolean;
  136954. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136955. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136956. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136957. UNLIT: boolean;
  136958. DEBUGMODE: number;
  136959. /**
  136960. * Initializes the PBR Material defines.
  136961. */
  136962. constructor();
  136963. /**
  136964. * Resets the PBR Material defines.
  136965. */
  136966. reset(): void;
  136967. }
  136968. /**
  136969. * The Physically based material base class of BJS.
  136970. *
  136971. * This offers the main features of a standard PBR material.
  136972. * For more information, please refer to the documentation :
  136973. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136974. */
  136975. export abstract class PBRBaseMaterial extends PushMaterial {
  136976. /**
  136977. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136978. */
  136979. static readonly PBRMATERIAL_OPAQUE: number;
  136980. /**
  136981. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136982. */
  136983. static readonly PBRMATERIAL_ALPHATEST: number;
  136984. /**
  136985. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136986. */
  136987. static readonly PBRMATERIAL_ALPHABLEND: number;
  136988. /**
  136989. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136990. * They are also discarded below the alpha cutoff threshold to improve performances.
  136991. */
  136992. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136993. /**
  136994. * Defines the default value of how much AO map is occluding the analytical lights
  136995. * (point spot...).
  136996. */
  136997. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136998. /**
  136999. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137000. */
  137001. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137002. /**
  137003. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137004. * to enhance interoperability with other engines.
  137005. */
  137006. static readonly LIGHTFALLOFF_GLTF: number;
  137007. /**
  137008. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137009. * to enhance interoperability with other materials.
  137010. */
  137011. static readonly LIGHTFALLOFF_STANDARD: number;
  137012. /**
  137013. * Intensity of the direct lights e.g. the four lights available in your scene.
  137014. * This impacts both the direct diffuse and specular highlights.
  137015. */
  137016. protected _directIntensity: number;
  137017. /**
  137018. * Intensity of the emissive part of the material.
  137019. * This helps controlling the emissive effect without modifying the emissive color.
  137020. */
  137021. protected _emissiveIntensity: number;
  137022. /**
  137023. * Intensity of the environment e.g. how much the environment will light the object
  137024. * either through harmonics for rough material or through the refelction for shiny ones.
  137025. */
  137026. protected _environmentIntensity: number;
  137027. /**
  137028. * This is a special control allowing the reduction of the specular highlights coming from the
  137029. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137030. */
  137031. protected _specularIntensity: number;
  137032. /**
  137033. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137034. */
  137035. private _lightingInfos;
  137036. /**
  137037. * Debug Control allowing disabling the bump map on this material.
  137038. */
  137039. protected _disableBumpMap: boolean;
  137040. /**
  137041. * AKA Diffuse Texture in standard nomenclature.
  137042. */
  137043. protected _albedoTexture: Nullable<BaseTexture>;
  137044. /**
  137045. * AKA Occlusion Texture in other nomenclature.
  137046. */
  137047. protected _ambientTexture: Nullable<BaseTexture>;
  137048. /**
  137049. * AKA Occlusion Texture Intensity in other nomenclature.
  137050. */
  137051. protected _ambientTextureStrength: number;
  137052. /**
  137053. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137054. * 1 means it completely occludes it
  137055. * 0 mean it has no impact
  137056. */
  137057. protected _ambientTextureImpactOnAnalyticalLights: number;
  137058. /**
  137059. * Stores the alpha values in a texture.
  137060. */
  137061. protected _opacityTexture: Nullable<BaseTexture>;
  137062. /**
  137063. * Stores the reflection values in a texture.
  137064. */
  137065. protected _reflectionTexture: Nullable<BaseTexture>;
  137066. /**
  137067. * Stores the emissive values in a texture.
  137068. */
  137069. protected _emissiveTexture: Nullable<BaseTexture>;
  137070. /**
  137071. * AKA Specular texture in other nomenclature.
  137072. */
  137073. protected _reflectivityTexture: Nullable<BaseTexture>;
  137074. /**
  137075. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137076. */
  137077. protected _metallicTexture: Nullable<BaseTexture>;
  137078. /**
  137079. * Specifies the metallic scalar of the metallic/roughness workflow.
  137080. * Can also be used to scale the metalness values of the metallic texture.
  137081. */
  137082. protected _metallic: Nullable<number>;
  137083. /**
  137084. * Specifies the roughness scalar of the metallic/roughness workflow.
  137085. * Can also be used to scale the roughness values of the metallic texture.
  137086. */
  137087. protected _roughness: Nullable<number>;
  137088. /**
  137089. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137090. * By default the indexOfrefraction is used to compute F0;
  137091. *
  137092. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137093. *
  137094. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137095. * F90 = metallicReflectanceColor;
  137096. */
  137097. protected _metallicF0Factor: number;
  137098. /**
  137099. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137100. * By default the F90 is always 1;
  137101. *
  137102. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137103. *
  137104. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137105. * F90 = metallicReflectanceColor;
  137106. */
  137107. protected _metallicReflectanceColor: Color3;
  137108. /**
  137109. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137110. * This is multiply against the scalar values defined in the material.
  137111. */
  137112. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137113. /**
  137114. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137115. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137116. */
  137117. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137118. /**
  137119. * Stores surface normal data used to displace a mesh in a texture.
  137120. */
  137121. protected _bumpTexture: Nullable<BaseTexture>;
  137122. /**
  137123. * Stores the pre-calculated light information of a mesh in a texture.
  137124. */
  137125. protected _lightmapTexture: Nullable<BaseTexture>;
  137126. /**
  137127. * The color of a material in ambient lighting.
  137128. */
  137129. protected _ambientColor: Color3;
  137130. /**
  137131. * AKA Diffuse Color in other nomenclature.
  137132. */
  137133. protected _albedoColor: Color3;
  137134. /**
  137135. * AKA Specular Color in other nomenclature.
  137136. */
  137137. protected _reflectivityColor: Color3;
  137138. /**
  137139. * The color applied when light is reflected from a material.
  137140. */
  137141. protected _reflectionColor: Color3;
  137142. /**
  137143. * The color applied when light is emitted from a material.
  137144. */
  137145. protected _emissiveColor: Color3;
  137146. /**
  137147. * AKA Glossiness in other nomenclature.
  137148. */
  137149. protected _microSurface: number;
  137150. /**
  137151. * Specifies that the material will use the light map as a show map.
  137152. */
  137153. protected _useLightmapAsShadowmap: boolean;
  137154. /**
  137155. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137156. * makes the reflect vector face the model (under horizon).
  137157. */
  137158. protected _useHorizonOcclusion: boolean;
  137159. /**
  137160. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137161. * too much the area relying on ambient texture to define their ambient occlusion.
  137162. */
  137163. protected _useRadianceOcclusion: boolean;
  137164. /**
  137165. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137166. */
  137167. protected _useAlphaFromAlbedoTexture: boolean;
  137168. /**
  137169. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137170. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137171. */
  137172. protected _useSpecularOverAlpha: boolean;
  137173. /**
  137174. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137175. */
  137176. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137177. /**
  137178. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137179. */
  137180. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137181. /**
  137182. * Specifies if the metallic texture contains the roughness information in its green channel.
  137183. */
  137184. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137185. /**
  137186. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137187. */
  137188. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137189. /**
  137190. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137191. */
  137192. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137193. /**
  137194. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137195. */
  137196. protected _useAmbientInGrayScale: boolean;
  137197. /**
  137198. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137199. * The material will try to infer what glossiness each pixel should be.
  137200. */
  137201. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137202. /**
  137203. * Defines the falloff type used in this material.
  137204. * It by default is Physical.
  137205. */
  137206. protected _lightFalloff: number;
  137207. /**
  137208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137210. */
  137211. protected _useRadianceOverAlpha: boolean;
  137212. /**
  137213. * Allows using an object space normal map (instead of tangent space).
  137214. */
  137215. protected _useObjectSpaceNormalMap: boolean;
  137216. /**
  137217. * Allows using the bump map in parallax mode.
  137218. */
  137219. protected _useParallax: boolean;
  137220. /**
  137221. * Allows using the bump map in parallax occlusion mode.
  137222. */
  137223. protected _useParallaxOcclusion: boolean;
  137224. /**
  137225. * Controls the scale bias of the parallax mode.
  137226. */
  137227. protected _parallaxScaleBias: number;
  137228. /**
  137229. * If sets to true, disables all the lights affecting the material.
  137230. */
  137231. protected _disableLighting: boolean;
  137232. /**
  137233. * Number of Simultaneous lights allowed on the material.
  137234. */
  137235. protected _maxSimultaneousLights: number;
  137236. /**
  137237. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137238. */
  137239. protected _invertNormalMapX: boolean;
  137240. /**
  137241. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137242. */
  137243. protected _invertNormalMapY: boolean;
  137244. /**
  137245. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137246. */
  137247. protected _twoSidedLighting: boolean;
  137248. /**
  137249. * Defines the alpha limits in alpha test mode.
  137250. */
  137251. protected _alphaCutOff: number;
  137252. /**
  137253. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137254. */
  137255. protected _forceAlphaTest: boolean;
  137256. /**
  137257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137258. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137259. */
  137260. protected _useAlphaFresnel: boolean;
  137261. /**
  137262. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137263. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137264. */
  137265. protected _useLinearAlphaFresnel: boolean;
  137266. /**
  137267. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137268. * from cos thetav and roughness:
  137269. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137270. */
  137271. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137272. /**
  137273. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137274. */
  137275. protected _forceIrradianceInFragment: boolean;
  137276. private _realTimeFiltering;
  137277. /**
  137278. * Enables realtime filtering on the texture.
  137279. */
  137280. get realTimeFiltering(): boolean;
  137281. set realTimeFiltering(b: boolean);
  137282. private _realTimeFilteringQuality;
  137283. /**
  137284. * Quality switch for realtime filtering
  137285. */
  137286. get realTimeFilteringQuality(): number;
  137287. set realTimeFilteringQuality(n: number);
  137288. /**
  137289. * Can this material render to several textures at once
  137290. */
  137291. get canRenderToMRT(): boolean;
  137292. /**
  137293. * Force normal to face away from face.
  137294. */
  137295. protected _forceNormalForward: boolean;
  137296. /**
  137297. * Enables specular anti aliasing in the PBR shader.
  137298. * It will both interacts on the Geometry for analytical and IBL lighting.
  137299. * It also prefilter the roughness map based on the bump values.
  137300. */
  137301. protected _enableSpecularAntiAliasing: boolean;
  137302. /**
  137303. * Default configuration related to image processing available in the PBR Material.
  137304. */
  137305. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137306. /**
  137307. * Keep track of the image processing observer to allow dispose and replace.
  137308. */
  137309. private _imageProcessingObserver;
  137310. /**
  137311. * Attaches a new image processing configuration to the PBR Material.
  137312. * @param configuration
  137313. */
  137314. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137315. /**
  137316. * Stores the available render targets.
  137317. */
  137318. private _renderTargets;
  137319. /**
  137320. * Sets the global ambient color for the material used in lighting calculations.
  137321. */
  137322. private _globalAmbientColor;
  137323. /**
  137324. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137325. */
  137326. private _useLogarithmicDepth;
  137327. /**
  137328. * If set to true, no lighting calculations will be applied.
  137329. */
  137330. private _unlit;
  137331. private _debugMode;
  137332. /**
  137333. * @hidden
  137334. * This is reserved for the inspector.
  137335. * Defines the material debug mode.
  137336. * It helps seeing only some components of the material while troubleshooting.
  137337. */
  137338. debugMode: number;
  137339. /**
  137340. * @hidden
  137341. * This is reserved for the inspector.
  137342. * Specify from where on screen the debug mode should start.
  137343. * The value goes from -1 (full screen) to 1 (not visible)
  137344. * It helps with side by side comparison against the final render
  137345. * This defaults to -1
  137346. */
  137347. private debugLimit;
  137348. /**
  137349. * @hidden
  137350. * This is reserved for the inspector.
  137351. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137352. * You can use the factor to better multiply the final value.
  137353. */
  137354. private debugFactor;
  137355. /**
  137356. * Defines the clear coat layer parameters for the material.
  137357. */
  137358. readonly clearCoat: PBRClearCoatConfiguration;
  137359. /**
  137360. * Defines the anisotropic parameters for the material.
  137361. */
  137362. readonly anisotropy: PBRAnisotropicConfiguration;
  137363. /**
  137364. * Defines the BRDF parameters for the material.
  137365. */
  137366. readonly brdf: PBRBRDFConfiguration;
  137367. /**
  137368. * Defines the Sheen parameters for the material.
  137369. */
  137370. readonly sheen: PBRSheenConfiguration;
  137371. /**
  137372. * Defines the SubSurface parameters for the material.
  137373. */
  137374. readonly subSurface: PBRSubSurfaceConfiguration;
  137375. /**
  137376. * Defines the detail map parameters for the material.
  137377. */
  137378. readonly detailMap: DetailMapConfiguration;
  137379. protected _rebuildInParallel: boolean;
  137380. /**
  137381. * Instantiates a new PBRMaterial instance.
  137382. *
  137383. * @param name The material name
  137384. * @param scene The scene the material will be use in.
  137385. */
  137386. constructor(name: string, scene: Scene);
  137387. /**
  137388. * Gets a boolean indicating that current material needs to register RTT
  137389. */
  137390. get hasRenderTargetTextures(): boolean;
  137391. /**
  137392. * Gets the name of the material class.
  137393. */
  137394. getClassName(): string;
  137395. /**
  137396. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137397. */
  137398. get useLogarithmicDepth(): boolean;
  137399. /**
  137400. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137401. */
  137402. set useLogarithmicDepth(value: boolean);
  137403. /**
  137404. * Returns true if alpha blending should be disabled.
  137405. */
  137406. protected get _disableAlphaBlending(): boolean;
  137407. /**
  137408. * Specifies whether or not this material should be rendered in alpha blend mode.
  137409. */
  137410. needAlphaBlending(): boolean;
  137411. /**
  137412. * Specifies whether or not this material should be rendered in alpha test mode.
  137413. */
  137414. needAlphaTesting(): boolean;
  137415. /**
  137416. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137417. */
  137418. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137419. /**
  137420. * Gets the texture used for the alpha test.
  137421. */
  137422. getAlphaTestTexture(): Nullable<BaseTexture>;
  137423. /**
  137424. * Specifies that the submesh is ready to be used.
  137425. * @param mesh - BJS mesh.
  137426. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137427. * @param useInstances - Specifies that instances should be used.
  137428. * @returns - boolean indicating that the submesh is ready or not.
  137429. */
  137430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137431. /**
  137432. * Specifies if the material uses metallic roughness workflow.
  137433. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137434. */
  137435. isMetallicWorkflow(): boolean;
  137436. private _prepareEffect;
  137437. private _prepareDefines;
  137438. /**
  137439. * Force shader compilation
  137440. */
  137441. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137442. /**
  137443. * Initializes the uniform buffer layout for the shader.
  137444. */
  137445. buildUniformLayout(): void;
  137446. /**
  137447. * Unbinds the material from the mesh
  137448. */
  137449. unbind(): void;
  137450. /**
  137451. * Binds the submesh data.
  137452. * @param world - The world matrix.
  137453. * @param mesh - The BJS mesh.
  137454. * @param subMesh - A submesh of the BJS mesh.
  137455. */
  137456. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137457. /**
  137458. * Returns the animatable textures.
  137459. * @returns - Array of animatable textures.
  137460. */
  137461. getAnimatables(): IAnimatable[];
  137462. /**
  137463. * Returns the texture used for reflections.
  137464. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137465. */
  137466. private _getReflectionTexture;
  137467. /**
  137468. * Returns an array of the actively used textures.
  137469. * @returns - Array of BaseTextures
  137470. */
  137471. getActiveTextures(): BaseTexture[];
  137472. /**
  137473. * Checks to see if a texture is used in the material.
  137474. * @param texture - Base texture to use.
  137475. * @returns - Boolean specifying if a texture is used in the material.
  137476. */
  137477. hasTexture(texture: BaseTexture): boolean;
  137478. /**
  137479. * Sets the required values to the prepass renderer.
  137480. * @param prePassRenderer defines the prepass renderer to setup
  137481. */
  137482. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137483. /**
  137484. * Disposes the resources of the material.
  137485. * @param forceDisposeEffect - Forces the disposal of effects.
  137486. * @param forceDisposeTextures - Forces the disposal of all textures.
  137487. */
  137488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137489. }
  137490. }
  137491. declare module BABYLON {
  137492. /**
  137493. * The Physically based material of BJS.
  137494. *
  137495. * This offers the main features of a standard PBR material.
  137496. * For more information, please refer to the documentation :
  137497. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137498. */
  137499. export class PBRMaterial extends PBRBaseMaterial {
  137500. /**
  137501. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137502. */
  137503. static readonly PBRMATERIAL_OPAQUE: number;
  137504. /**
  137505. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137506. */
  137507. static readonly PBRMATERIAL_ALPHATEST: number;
  137508. /**
  137509. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137510. */
  137511. static readonly PBRMATERIAL_ALPHABLEND: number;
  137512. /**
  137513. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137514. * They are also discarded below the alpha cutoff threshold to improve performances.
  137515. */
  137516. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137517. /**
  137518. * Defines the default value of how much AO map is occluding the analytical lights
  137519. * (point spot...).
  137520. */
  137521. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137522. /**
  137523. * Intensity of the direct lights e.g. the four lights available in your scene.
  137524. * This impacts both the direct diffuse and specular highlights.
  137525. */
  137526. directIntensity: number;
  137527. /**
  137528. * Intensity of the emissive part of the material.
  137529. * This helps controlling the emissive effect without modifying the emissive color.
  137530. */
  137531. emissiveIntensity: number;
  137532. /**
  137533. * Intensity of the environment e.g. how much the environment will light the object
  137534. * either through harmonics for rough material or through the refelction for shiny ones.
  137535. */
  137536. environmentIntensity: number;
  137537. /**
  137538. * This is a special control allowing the reduction of the specular highlights coming from the
  137539. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137540. */
  137541. specularIntensity: number;
  137542. /**
  137543. * Debug Control allowing disabling the bump map on this material.
  137544. */
  137545. disableBumpMap: boolean;
  137546. /**
  137547. * AKA Diffuse Texture in standard nomenclature.
  137548. */
  137549. albedoTexture: BaseTexture;
  137550. /**
  137551. * AKA Occlusion Texture in other nomenclature.
  137552. */
  137553. ambientTexture: BaseTexture;
  137554. /**
  137555. * AKA Occlusion Texture Intensity in other nomenclature.
  137556. */
  137557. ambientTextureStrength: number;
  137558. /**
  137559. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137560. * 1 means it completely occludes it
  137561. * 0 mean it has no impact
  137562. */
  137563. ambientTextureImpactOnAnalyticalLights: number;
  137564. /**
  137565. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137566. */
  137567. opacityTexture: BaseTexture;
  137568. /**
  137569. * Stores the reflection values in a texture.
  137570. */
  137571. reflectionTexture: Nullable<BaseTexture>;
  137572. /**
  137573. * Stores the emissive values in a texture.
  137574. */
  137575. emissiveTexture: BaseTexture;
  137576. /**
  137577. * AKA Specular texture in other nomenclature.
  137578. */
  137579. reflectivityTexture: BaseTexture;
  137580. /**
  137581. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137582. */
  137583. metallicTexture: BaseTexture;
  137584. /**
  137585. * Specifies the metallic scalar of the metallic/roughness workflow.
  137586. * Can also be used to scale the metalness values of the metallic texture.
  137587. */
  137588. metallic: Nullable<number>;
  137589. /**
  137590. * Specifies the roughness scalar of the metallic/roughness workflow.
  137591. * Can also be used to scale the roughness values of the metallic texture.
  137592. */
  137593. roughness: Nullable<number>;
  137594. /**
  137595. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137596. * By default the indexOfrefraction is used to compute F0;
  137597. *
  137598. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137599. *
  137600. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137601. * F90 = metallicReflectanceColor;
  137602. */
  137603. metallicF0Factor: number;
  137604. /**
  137605. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137606. * By default the F90 is always 1;
  137607. *
  137608. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137609. *
  137610. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137611. * F90 = metallicReflectanceColor;
  137612. */
  137613. metallicReflectanceColor: Color3;
  137614. /**
  137615. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137616. * This is multiply against the scalar values defined in the material.
  137617. */
  137618. metallicReflectanceTexture: Nullable<BaseTexture>;
  137619. /**
  137620. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137621. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137622. */
  137623. microSurfaceTexture: BaseTexture;
  137624. /**
  137625. * Stores surface normal data used to displace a mesh in a texture.
  137626. */
  137627. bumpTexture: BaseTexture;
  137628. /**
  137629. * Stores the pre-calculated light information of a mesh in a texture.
  137630. */
  137631. lightmapTexture: BaseTexture;
  137632. /**
  137633. * Stores the refracted light information in a texture.
  137634. */
  137635. get refractionTexture(): Nullable<BaseTexture>;
  137636. set refractionTexture(value: Nullable<BaseTexture>);
  137637. /**
  137638. * The color of a material in ambient lighting.
  137639. */
  137640. ambientColor: Color3;
  137641. /**
  137642. * AKA Diffuse Color in other nomenclature.
  137643. */
  137644. albedoColor: Color3;
  137645. /**
  137646. * AKA Specular Color in other nomenclature.
  137647. */
  137648. reflectivityColor: Color3;
  137649. /**
  137650. * The color reflected from the material.
  137651. */
  137652. reflectionColor: Color3;
  137653. /**
  137654. * The color emitted from the material.
  137655. */
  137656. emissiveColor: Color3;
  137657. /**
  137658. * AKA Glossiness in other nomenclature.
  137659. */
  137660. microSurface: number;
  137661. /**
  137662. * Index of refraction of the material base layer.
  137663. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137664. *
  137665. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137666. *
  137667. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137668. */
  137669. get indexOfRefraction(): number;
  137670. set indexOfRefraction(value: number);
  137671. /**
  137672. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137673. */
  137674. get invertRefractionY(): boolean;
  137675. set invertRefractionY(value: boolean);
  137676. /**
  137677. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137678. * Materials half opaque for instance using refraction could benefit from this control.
  137679. */
  137680. get linkRefractionWithTransparency(): boolean;
  137681. set linkRefractionWithTransparency(value: boolean);
  137682. /**
  137683. * If true, the light map contains occlusion information instead of lighting info.
  137684. */
  137685. useLightmapAsShadowmap: boolean;
  137686. /**
  137687. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137688. */
  137689. useAlphaFromAlbedoTexture: boolean;
  137690. /**
  137691. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137692. */
  137693. forceAlphaTest: boolean;
  137694. /**
  137695. * Defines the alpha limits in alpha test mode.
  137696. */
  137697. alphaCutOff: number;
  137698. /**
  137699. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137700. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137701. */
  137702. useSpecularOverAlpha: boolean;
  137703. /**
  137704. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137705. */
  137706. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137707. /**
  137708. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137709. */
  137710. useRoughnessFromMetallicTextureAlpha: boolean;
  137711. /**
  137712. * Specifies if the metallic texture contains the roughness information in its green channel.
  137713. */
  137714. useRoughnessFromMetallicTextureGreen: boolean;
  137715. /**
  137716. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137717. */
  137718. useMetallnessFromMetallicTextureBlue: boolean;
  137719. /**
  137720. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137721. */
  137722. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137723. /**
  137724. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137725. */
  137726. useAmbientInGrayScale: boolean;
  137727. /**
  137728. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137729. * The material will try to infer what glossiness each pixel should be.
  137730. */
  137731. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137732. /**
  137733. * BJS is using an harcoded light falloff based on a manually sets up range.
  137734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137736. */
  137737. get usePhysicalLightFalloff(): boolean;
  137738. /**
  137739. * BJS is using an harcoded light falloff based on a manually sets up range.
  137740. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137741. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137742. */
  137743. set usePhysicalLightFalloff(value: boolean);
  137744. /**
  137745. * In order to support the falloff compatibility with gltf, a special mode has been added
  137746. * to reproduce the gltf light falloff.
  137747. */
  137748. get useGLTFLightFalloff(): boolean;
  137749. /**
  137750. * In order to support the falloff compatibility with gltf, a special mode has been added
  137751. * to reproduce the gltf light falloff.
  137752. */
  137753. set useGLTFLightFalloff(value: boolean);
  137754. /**
  137755. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137756. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137757. */
  137758. useRadianceOverAlpha: boolean;
  137759. /**
  137760. * Allows using an object space normal map (instead of tangent space).
  137761. */
  137762. useObjectSpaceNormalMap: boolean;
  137763. /**
  137764. * Allows using the bump map in parallax mode.
  137765. */
  137766. useParallax: boolean;
  137767. /**
  137768. * Allows using the bump map in parallax occlusion mode.
  137769. */
  137770. useParallaxOcclusion: boolean;
  137771. /**
  137772. * Controls the scale bias of the parallax mode.
  137773. */
  137774. parallaxScaleBias: number;
  137775. /**
  137776. * If sets to true, disables all the lights affecting the material.
  137777. */
  137778. disableLighting: boolean;
  137779. /**
  137780. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137781. */
  137782. forceIrradianceInFragment: boolean;
  137783. /**
  137784. * Number of Simultaneous lights allowed on the material.
  137785. */
  137786. maxSimultaneousLights: number;
  137787. /**
  137788. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137789. */
  137790. invertNormalMapX: boolean;
  137791. /**
  137792. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137793. */
  137794. invertNormalMapY: boolean;
  137795. /**
  137796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137797. */
  137798. twoSidedLighting: boolean;
  137799. /**
  137800. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137801. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137802. */
  137803. useAlphaFresnel: boolean;
  137804. /**
  137805. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137806. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137807. */
  137808. useLinearAlphaFresnel: boolean;
  137809. /**
  137810. * Let user defines the brdf lookup texture used for IBL.
  137811. * A default 8bit version is embedded but you could point at :
  137812. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137813. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137814. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137815. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137816. */
  137817. environmentBRDFTexture: Nullable<BaseTexture>;
  137818. /**
  137819. * Force normal to face away from face.
  137820. */
  137821. forceNormalForward: boolean;
  137822. /**
  137823. * Enables specular anti aliasing in the PBR shader.
  137824. * It will both interacts on the Geometry for analytical and IBL lighting.
  137825. * It also prefilter the roughness map based on the bump values.
  137826. */
  137827. enableSpecularAntiAliasing: boolean;
  137828. /**
  137829. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137830. * makes the reflect vector face the model (under horizon).
  137831. */
  137832. useHorizonOcclusion: boolean;
  137833. /**
  137834. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137835. * too much the area relying on ambient texture to define their ambient occlusion.
  137836. */
  137837. useRadianceOcclusion: boolean;
  137838. /**
  137839. * If set to true, no lighting calculations will be applied.
  137840. */
  137841. unlit: boolean;
  137842. /**
  137843. * Gets the image processing configuration used either in this material.
  137844. */
  137845. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137846. /**
  137847. * Sets the Default image processing configuration used either in the this material.
  137848. *
  137849. * If sets to null, the scene one is in use.
  137850. */
  137851. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137852. /**
  137853. * Gets wether the color curves effect is enabled.
  137854. */
  137855. get cameraColorCurvesEnabled(): boolean;
  137856. /**
  137857. * Sets wether the color curves effect is enabled.
  137858. */
  137859. set cameraColorCurvesEnabled(value: boolean);
  137860. /**
  137861. * Gets wether the color grading effect is enabled.
  137862. */
  137863. get cameraColorGradingEnabled(): boolean;
  137864. /**
  137865. * Gets wether the color grading effect is enabled.
  137866. */
  137867. set cameraColorGradingEnabled(value: boolean);
  137868. /**
  137869. * Gets wether tonemapping is enabled or not.
  137870. */
  137871. get cameraToneMappingEnabled(): boolean;
  137872. /**
  137873. * Sets wether tonemapping is enabled or not
  137874. */
  137875. set cameraToneMappingEnabled(value: boolean);
  137876. /**
  137877. * The camera exposure used on this material.
  137878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137879. * This corresponds to a photographic exposure.
  137880. */
  137881. get cameraExposure(): number;
  137882. /**
  137883. * The camera exposure used on this material.
  137884. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137885. * This corresponds to a photographic exposure.
  137886. */
  137887. set cameraExposure(value: number);
  137888. /**
  137889. * Gets The camera contrast used on this material.
  137890. */
  137891. get cameraContrast(): number;
  137892. /**
  137893. * Sets The camera contrast used on this material.
  137894. */
  137895. set cameraContrast(value: number);
  137896. /**
  137897. * Gets the Color Grading 2D Lookup Texture.
  137898. */
  137899. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137900. /**
  137901. * Sets the Color Grading 2D Lookup Texture.
  137902. */
  137903. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137904. /**
  137905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137907. * 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;
  137908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137909. */
  137910. get cameraColorCurves(): Nullable<ColorCurves>;
  137911. /**
  137912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137914. * 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;
  137915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137916. */
  137917. set cameraColorCurves(value: Nullable<ColorCurves>);
  137918. /**
  137919. * Instantiates a new PBRMaterial instance.
  137920. *
  137921. * @param name The material name
  137922. * @param scene The scene the material will be use in.
  137923. */
  137924. constructor(name: string, scene: Scene);
  137925. /**
  137926. * Returns the name of this material class.
  137927. */
  137928. getClassName(): string;
  137929. /**
  137930. * Makes a duplicate of the current material.
  137931. * @param name - name to use for the new material.
  137932. */
  137933. clone(name: string): PBRMaterial;
  137934. /**
  137935. * Serializes this PBR Material.
  137936. * @returns - An object with the serialized material.
  137937. */
  137938. serialize(): any;
  137939. /**
  137940. * Parses a PBR Material from a serialized object.
  137941. * @param source - Serialized object.
  137942. * @param scene - BJS scene instance.
  137943. * @param rootUrl - url for the scene object
  137944. * @returns - PBRMaterial
  137945. */
  137946. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137947. }
  137948. }
  137949. declare module BABYLON {
  137950. /**
  137951. * Direct draw surface info
  137952. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137953. */
  137954. export interface DDSInfo {
  137955. /**
  137956. * Width of the texture
  137957. */
  137958. width: number;
  137959. /**
  137960. * Width of the texture
  137961. */
  137962. height: number;
  137963. /**
  137964. * Number of Mipmaps for the texture
  137965. * @see https://en.wikipedia.org/wiki/Mipmap
  137966. */
  137967. mipmapCount: number;
  137968. /**
  137969. * If the textures format is a known fourCC format
  137970. * @see https://www.fourcc.org/
  137971. */
  137972. isFourCC: boolean;
  137973. /**
  137974. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137975. */
  137976. isRGB: boolean;
  137977. /**
  137978. * If the texture is a lumincance format
  137979. */
  137980. isLuminance: boolean;
  137981. /**
  137982. * If this is a cube texture
  137983. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137984. */
  137985. isCube: boolean;
  137986. /**
  137987. * If the texture is a compressed format eg. FOURCC_DXT1
  137988. */
  137989. isCompressed: boolean;
  137990. /**
  137991. * The dxgiFormat of the texture
  137992. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137993. */
  137994. dxgiFormat: number;
  137995. /**
  137996. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137997. */
  137998. textureType: number;
  137999. /**
  138000. * Sphericle polynomial created for the dds texture
  138001. */
  138002. sphericalPolynomial?: SphericalPolynomial;
  138003. }
  138004. /**
  138005. * Class used to provide DDS decompression tools
  138006. */
  138007. export class DDSTools {
  138008. /**
  138009. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138010. */
  138011. static StoreLODInAlphaChannel: boolean;
  138012. /**
  138013. * Gets DDS information from an array buffer
  138014. * @param data defines the array buffer view to read data from
  138015. * @returns the DDS information
  138016. */
  138017. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138018. private static _FloatView;
  138019. private static _Int32View;
  138020. private static _ToHalfFloat;
  138021. private static _FromHalfFloat;
  138022. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138023. private static _GetHalfFloatRGBAArrayBuffer;
  138024. private static _GetFloatRGBAArrayBuffer;
  138025. private static _GetFloatAsUIntRGBAArrayBuffer;
  138026. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138027. private static _GetRGBAArrayBuffer;
  138028. private static _ExtractLongWordOrder;
  138029. private static _GetRGBArrayBuffer;
  138030. private static _GetLuminanceArrayBuffer;
  138031. /**
  138032. * Uploads DDS Levels to a Babylon Texture
  138033. * @hidden
  138034. */
  138035. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138036. }
  138037. interface ThinEngine {
  138038. /**
  138039. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138040. * @param rootUrl defines the url where the file to load is located
  138041. * @param scene defines the current scene
  138042. * @param lodScale defines scale to apply to the mip map selection
  138043. * @param lodOffset defines offset to apply to the mip map selection
  138044. * @param onLoad defines an optional callback raised when the texture is loaded
  138045. * @param onError defines an optional callback raised if there is an issue to load the texture
  138046. * @param format defines the format of the data
  138047. * @param forcedExtension defines the extension to use to pick the right loader
  138048. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138049. * @returns the cube texture as an InternalTexture
  138050. */
  138051. 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;
  138052. }
  138053. }
  138054. declare module BABYLON {
  138055. /**
  138056. * Implementation of the DDS Texture Loader.
  138057. * @hidden
  138058. */
  138059. export class _DDSTextureLoader implements IInternalTextureLoader {
  138060. /**
  138061. * Defines wether the loader supports cascade loading the different faces.
  138062. */
  138063. readonly supportCascades: boolean;
  138064. /**
  138065. * This returns if the loader support the current file information.
  138066. * @param extension defines the file extension of the file being loaded
  138067. * @returns true if the loader can load the specified file
  138068. */
  138069. canLoad(extension: string): boolean;
  138070. /**
  138071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138072. * @param data contains the texture data
  138073. * @param texture defines the BabylonJS internal texture
  138074. * @param createPolynomials will be true if polynomials have been requested
  138075. * @param onLoad defines the callback to trigger once the texture is ready
  138076. * @param onError defines the callback to trigger in case of error
  138077. */
  138078. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138079. /**
  138080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138081. * @param data contains the texture data
  138082. * @param texture defines the BabylonJS internal texture
  138083. * @param callback defines the method to call once ready to upload
  138084. */
  138085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138086. }
  138087. }
  138088. declare module BABYLON {
  138089. /**
  138090. * Implementation of the ENV Texture Loader.
  138091. * @hidden
  138092. */
  138093. export class _ENVTextureLoader implements IInternalTextureLoader {
  138094. /**
  138095. * Defines wether the loader supports cascade loading the different faces.
  138096. */
  138097. readonly supportCascades: boolean;
  138098. /**
  138099. * This returns if the loader support the current file information.
  138100. * @param extension defines the file extension of the file being loaded
  138101. * @returns true if the loader can load the specified file
  138102. */
  138103. canLoad(extension: string): boolean;
  138104. /**
  138105. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138106. * @param data contains the texture data
  138107. * @param texture defines the BabylonJS internal texture
  138108. * @param createPolynomials will be true if polynomials have been requested
  138109. * @param onLoad defines the callback to trigger once the texture is ready
  138110. * @param onError defines the callback to trigger in case of error
  138111. */
  138112. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138113. /**
  138114. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138115. * @param data contains the texture data
  138116. * @param texture defines the BabylonJS internal texture
  138117. * @param callback defines the method to call once ready to upload
  138118. */
  138119. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138120. }
  138121. }
  138122. declare module BABYLON {
  138123. /**
  138124. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138125. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138126. */
  138127. export class KhronosTextureContainer {
  138128. /** contents of the KTX container file */
  138129. data: ArrayBufferView;
  138130. private static HEADER_LEN;
  138131. private static COMPRESSED_2D;
  138132. private static COMPRESSED_3D;
  138133. private static TEX_2D;
  138134. private static TEX_3D;
  138135. /**
  138136. * Gets the openGL type
  138137. */
  138138. glType: number;
  138139. /**
  138140. * Gets the openGL type size
  138141. */
  138142. glTypeSize: number;
  138143. /**
  138144. * Gets the openGL format
  138145. */
  138146. glFormat: number;
  138147. /**
  138148. * Gets the openGL internal format
  138149. */
  138150. glInternalFormat: number;
  138151. /**
  138152. * Gets the base internal format
  138153. */
  138154. glBaseInternalFormat: number;
  138155. /**
  138156. * Gets image width in pixel
  138157. */
  138158. pixelWidth: number;
  138159. /**
  138160. * Gets image height in pixel
  138161. */
  138162. pixelHeight: number;
  138163. /**
  138164. * Gets image depth in pixels
  138165. */
  138166. pixelDepth: number;
  138167. /**
  138168. * Gets the number of array elements
  138169. */
  138170. numberOfArrayElements: number;
  138171. /**
  138172. * Gets the number of faces
  138173. */
  138174. numberOfFaces: number;
  138175. /**
  138176. * Gets the number of mipmap levels
  138177. */
  138178. numberOfMipmapLevels: number;
  138179. /**
  138180. * Gets the bytes of key value data
  138181. */
  138182. bytesOfKeyValueData: number;
  138183. /**
  138184. * Gets the load type
  138185. */
  138186. loadType: number;
  138187. /**
  138188. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138189. */
  138190. isInvalid: boolean;
  138191. /**
  138192. * Creates a new KhronosTextureContainer
  138193. * @param data contents of the KTX container file
  138194. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138195. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138196. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138197. */
  138198. constructor(
  138199. /** contents of the KTX container file */
  138200. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138201. /**
  138202. * Uploads KTX content to a Babylon Texture.
  138203. * It is assumed that the texture has already been created & is currently bound
  138204. * @hidden
  138205. */
  138206. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138207. private _upload2DCompressedLevels;
  138208. /**
  138209. * Checks if the given data starts with a KTX file identifier.
  138210. * @param data the data to check
  138211. * @returns true if the data is a KTX file or false otherwise
  138212. */
  138213. static IsValid(data: ArrayBufferView): boolean;
  138214. }
  138215. }
  138216. declare module BABYLON {
  138217. /**
  138218. * Helper class to push actions to a pool of workers.
  138219. */
  138220. export class WorkerPool implements IDisposable {
  138221. private _workerInfos;
  138222. private _pendingActions;
  138223. /**
  138224. * Constructor
  138225. * @param workers Array of workers to use for actions
  138226. */
  138227. constructor(workers: Array<Worker>);
  138228. /**
  138229. * Terminates all workers and clears any pending actions.
  138230. */
  138231. dispose(): void;
  138232. /**
  138233. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138234. * pended until a worker has completed its action.
  138235. * @param action The action to perform. Call onComplete when the action is complete.
  138236. */
  138237. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138238. private _execute;
  138239. }
  138240. }
  138241. declare module BABYLON {
  138242. /**
  138243. * Class for loading KTX2 files
  138244. * @hidden
  138245. */
  138246. export class KhronosTextureContainer2 {
  138247. private static _WorkerPoolPromise?;
  138248. private static _Initialized;
  138249. private static _Ktx2Decoder;
  138250. /**
  138251. * URL to use when loading the KTX2 decoder module
  138252. */
  138253. static JSModuleURL: string;
  138254. /**
  138255. * Default number of workers used to handle data decoding
  138256. */
  138257. static DefaultNumWorkers: number;
  138258. private static GetDefaultNumWorkers;
  138259. private _engine;
  138260. private static _CreateWorkerPool;
  138261. /**
  138262. * Constructor
  138263. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138264. */
  138265. constructor(engine: ThinEngine, numWorkers?: number);
  138266. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138267. /**
  138268. * Stop all async operations and release resources.
  138269. */
  138270. dispose(): void;
  138271. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138272. /**
  138273. * Checks if the given data starts with a KTX2 file identifier.
  138274. * @param data the data to check
  138275. * @returns true if the data is a KTX2 file or false otherwise
  138276. */
  138277. static IsValid(data: ArrayBufferView): boolean;
  138278. }
  138279. export function workerFunc(): void;
  138280. }
  138281. declare module BABYLON {
  138282. /**
  138283. * Implementation of the KTX Texture Loader.
  138284. * @hidden
  138285. */
  138286. export class _KTXTextureLoader implements IInternalTextureLoader {
  138287. /**
  138288. * Defines wether the loader supports cascade loading the different faces.
  138289. */
  138290. readonly supportCascades: boolean;
  138291. /**
  138292. * This returns if the loader support the current file information.
  138293. * @param extension defines the file extension of the file being loaded
  138294. * @param mimeType defines the optional mime type of the file being loaded
  138295. * @returns true if the loader can load the specified file
  138296. */
  138297. canLoad(extension: string, mimeType?: string): boolean;
  138298. /**
  138299. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138300. * @param data contains the texture data
  138301. * @param texture defines the BabylonJS internal texture
  138302. * @param createPolynomials will be true if polynomials have been requested
  138303. * @param onLoad defines the callback to trigger once the texture is ready
  138304. * @param onError defines the callback to trigger in case of error
  138305. */
  138306. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138307. /**
  138308. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138309. * @param data contains the texture data
  138310. * @param texture defines the BabylonJS internal texture
  138311. * @param callback defines the method to call once ready to upload
  138312. */
  138313. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138314. }
  138315. }
  138316. declare module BABYLON {
  138317. /** @hidden */
  138318. export var _forceSceneHelpersToBundle: boolean;
  138319. interface Scene {
  138320. /**
  138321. * Creates a default light for the scene.
  138322. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138323. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138324. */
  138325. createDefaultLight(replace?: boolean): void;
  138326. /**
  138327. * Creates a default camera for the scene.
  138328. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138329. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138330. * @param replace has default false, when true replaces the active camera in the scene
  138331. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138332. */
  138333. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138334. /**
  138335. * Creates a default camera and a default light.
  138336. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138337. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138338. * @param replace has the default false, when true replaces the active camera/light in the scene
  138339. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138340. */
  138341. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138342. /**
  138343. * Creates a new sky box
  138344. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138345. * @param environmentTexture defines the texture to use as environment texture
  138346. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138347. * @param scale defines the overall scale of the skybox
  138348. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138349. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138350. * @returns a new mesh holding the sky box
  138351. */
  138352. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138353. /**
  138354. * Creates a new environment
  138355. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138356. * @param options defines the options you can use to configure the environment
  138357. * @returns the new EnvironmentHelper
  138358. */
  138359. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138360. /**
  138361. * Creates a new VREXperienceHelper
  138362. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138363. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138364. * @returns a new VREXperienceHelper
  138365. */
  138366. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138367. /**
  138368. * Creates a new WebXRDefaultExperience
  138369. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138370. * @param options experience options
  138371. * @returns a promise for a new WebXRDefaultExperience
  138372. */
  138373. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138374. }
  138375. }
  138376. declare module BABYLON {
  138377. /**
  138378. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138379. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138380. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138381. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138382. */
  138383. export class VideoDome extends TextureDome<VideoTexture> {
  138384. /**
  138385. * Define the video source as a Monoscopic panoramic 360 video.
  138386. */
  138387. static readonly MODE_MONOSCOPIC: number;
  138388. /**
  138389. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138390. */
  138391. static readonly MODE_TOPBOTTOM: number;
  138392. /**
  138393. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138394. */
  138395. static readonly MODE_SIDEBYSIDE: number;
  138396. /**
  138397. * Get the video texture associated with this video dome
  138398. */
  138399. get videoTexture(): VideoTexture;
  138400. /**
  138401. * Get the video mode of this dome
  138402. */
  138403. get videoMode(): number;
  138404. /**
  138405. * Set the video mode of this dome.
  138406. * @see textureMode
  138407. */
  138408. set videoMode(value: number);
  138409. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138410. }
  138411. }
  138412. declare module BABYLON {
  138413. /**
  138414. * This class can be used to get instrumentation data from a Babylon engine
  138415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138416. */
  138417. export class EngineInstrumentation implements IDisposable {
  138418. /**
  138419. * Define the instrumented engine.
  138420. */
  138421. engine: Engine;
  138422. private _captureGPUFrameTime;
  138423. private _gpuFrameTimeToken;
  138424. private _gpuFrameTime;
  138425. private _captureShaderCompilationTime;
  138426. private _shaderCompilationTime;
  138427. private _onBeginFrameObserver;
  138428. private _onEndFrameObserver;
  138429. private _onBeforeShaderCompilationObserver;
  138430. private _onAfterShaderCompilationObserver;
  138431. /**
  138432. * Gets the perf counter used for GPU frame time
  138433. */
  138434. get gpuFrameTimeCounter(): PerfCounter;
  138435. /**
  138436. * Gets the GPU frame time capture status
  138437. */
  138438. get captureGPUFrameTime(): boolean;
  138439. /**
  138440. * Enable or disable the GPU frame time capture
  138441. */
  138442. set captureGPUFrameTime(value: boolean);
  138443. /**
  138444. * Gets the perf counter used for shader compilation time
  138445. */
  138446. get shaderCompilationTimeCounter(): PerfCounter;
  138447. /**
  138448. * Gets the shader compilation time capture status
  138449. */
  138450. get captureShaderCompilationTime(): boolean;
  138451. /**
  138452. * Enable or disable the shader compilation time capture
  138453. */
  138454. set captureShaderCompilationTime(value: boolean);
  138455. /**
  138456. * Instantiates a new engine instrumentation.
  138457. * This class can be used to get instrumentation data from a Babylon engine
  138458. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138459. * @param engine Defines the engine to instrument
  138460. */
  138461. constructor(
  138462. /**
  138463. * Define the instrumented engine.
  138464. */
  138465. engine: Engine);
  138466. /**
  138467. * Dispose and release associated resources.
  138468. */
  138469. dispose(): void;
  138470. }
  138471. }
  138472. declare module BABYLON {
  138473. /**
  138474. * This class can be used to get instrumentation data from a Babylon engine
  138475. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138476. */
  138477. export class SceneInstrumentation implements IDisposable {
  138478. /**
  138479. * Defines the scene to instrument
  138480. */
  138481. scene: Scene;
  138482. private _captureActiveMeshesEvaluationTime;
  138483. private _activeMeshesEvaluationTime;
  138484. private _captureRenderTargetsRenderTime;
  138485. private _renderTargetsRenderTime;
  138486. private _captureFrameTime;
  138487. private _frameTime;
  138488. private _captureRenderTime;
  138489. private _renderTime;
  138490. private _captureInterFrameTime;
  138491. private _interFrameTime;
  138492. private _captureParticlesRenderTime;
  138493. private _particlesRenderTime;
  138494. private _captureSpritesRenderTime;
  138495. private _spritesRenderTime;
  138496. private _capturePhysicsTime;
  138497. private _physicsTime;
  138498. private _captureAnimationsTime;
  138499. private _animationsTime;
  138500. private _captureCameraRenderTime;
  138501. private _cameraRenderTime;
  138502. private _onBeforeActiveMeshesEvaluationObserver;
  138503. private _onAfterActiveMeshesEvaluationObserver;
  138504. private _onBeforeRenderTargetsRenderObserver;
  138505. private _onAfterRenderTargetsRenderObserver;
  138506. private _onAfterRenderObserver;
  138507. private _onBeforeDrawPhaseObserver;
  138508. private _onAfterDrawPhaseObserver;
  138509. private _onBeforeAnimationsObserver;
  138510. private _onBeforeParticlesRenderingObserver;
  138511. private _onAfterParticlesRenderingObserver;
  138512. private _onBeforeSpritesRenderingObserver;
  138513. private _onAfterSpritesRenderingObserver;
  138514. private _onBeforePhysicsObserver;
  138515. private _onAfterPhysicsObserver;
  138516. private _onAfterAnimationsObserver;
  138517. private _onBeforeCameraRenderObserver;
  138518. private _onAfterCameraRenderObserver;
  138519. /**
  138520. * Gets the perf counter used for active meshes evaluation time
  138521. */
  138522. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138523. /**
  138524. * Gets the active meshes evaluation time capture status
  138525. */
  138526. get captureActiveMeshesEvaluationTime(): boolean;
  138527. /**
  138528. * Enable or disable the active meshes evaluation time capture
  138529. */
  138530. set captureActiveMeshesEvaluationTime(value: boolean);
  138531. /**
  138532. * Gets the perf counter used for render targets render time
  138533. */
  138534. get renderTargetsRenderTimeCounter(): PerfCounter;
  138535. /**
  138536. * Gets the render targets render time capture status
  138537. */
  138538. get captureRenderTargetsRenderTime(): boolean;
  138539. /**
  138540. * Enable or disable the render targets render time capture
  138541. */
  138542. set captureRenderTargetsRenderTime(value: boolean);
  138543. /**
  138544. * Gets the perf counter used for particles render time
  138545. */
  138546. get particlesRenderTimeCounter(): PerfCounter;
  138547. /**
  138548. * Gets the particles render time capture status
  138549. */
  138550. get captureParticlesRenderTime(): boolean;
  138551. /**
  138552. * Enable or disable the particles render time capture
  138553. */
  138554. set captureParticlesRenderTime(value: boolean);
  138555. /**
  138556. * Gets the perf counter used for sprites render time
  138557. */
  138558. get spritesRenderTimeCounter(): PerfCounter;
  138559. /**
  138560. * Gets the sprites render time capture status
  138561. */
  138562. get captureSpritesRenderTime(): boolean;
  138563. /**
  138564. * Enable or disable the sprites render time capture
  138565. */
  138566. set captureSpritesRenderTime(value: boolean);
  138567. /**
  138568. * Gets the perf counter used for physics time
  138569. */
  138570. get physicsTimeCounter(): PerfCounter;
  138571. /**
  138572. * Gets the physics time capture status
  138573. */
  138574. get capturePhysicsTime(): boolean;
  138575. /**
  138576. * Enable or disable the physics time capture
  138577. */
  138578. set capturePhysicsTime(value: boolean);
  138579. /**
  138580. * Gets the perf counter used for animations time
  138581. */
  138582. get animationsTimeCounter(): PerfCounter;
  138583. /**
  138584. * Gets the animations time capture status
  138585. */
  138586. get captureAnimationsTime(): boolean;
  138587. /**
  138588. * Enable or disable the animations time capture
  138589. */
  138590. set captureAnimationsTime(value: boolean);
  138591. /**
  138592. * Gets the perf counter used for frame time capture
  138593. */
  138594. get frameTimeCounter(): PerfCounter;
  138595. /**
  138596. * Gets the frame time capture status
  138597. */
  138598. get captureFrameTime(): boolean;
  138599. /**
  138600. * Enable or disable the frame time capture
  138601. */
  138602. set captureFrameTime(value: boolean);
  138603. /**
  138604. * Gets the perf counter used for inter-frames time capture
  138605. */
  138606. get interFrameTimeCounter(): PerfCounter;
  138607. /**
  138608. * Gets the inter-frames time capture status
  138609. */
  138610. get captureInterFrameTime(): boolean;
  138611. /**
  138612. * Enable or disable the inter-frames time capture
  138613. */
  138614. set captureInterFrameTime(value: boolean);
  138615. /**
  138616. * Gets the perf counter used for render time capture
  138617. */
  138618. get renderTimeCounter(): PerfCounter;
  138619. /**
  138620. * Gets the render time capture status
  138621. */
  138622. get captureRenderTime(): boolean;
  138623. /**
  138624. * Enable or disable the render time capture
  138625. */
  138626. set captureRenderTime(value: boolean);
  138627. /**
  138628. * Gets the perf counter used for camera render time capture
  138629. */
  138630. get cameraRenderTimeCounter(): PerfCounter;
  138631. /**
  138632. * Gets the camera render time capture status
  138633. */
  138634. get captureCameraRenderTime(): boolean;
  138635. /**
  138636. * Enable or disable the camera render time capture
  138637. */
  138638. set captureCameraRenderTime(value: boolean);
  138639. /**
  138640. * Gets the perf counter used for draw calls
  138641. */
  138642. get drawCallsCounter(): PerfCounter;
  138643. /**
  138644. * Instantiates a new scene instrumentation.
  138645. * This class can be used to get instrumentation data from a Babylon engine
  138646. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138647. * @param scene Defines the scene to instrument
  138648. */
  138649. constructor(
  138650. /**
  138651. * Defines the scene to instrument
  138652. */
  138653. scene: Scene);
  138654. /**
  138655. * Dispose and release associated resources.
  138656. */
  138657. dispose(): void;
  138658. }
  138659. }
  138660. declare module BABYLON {
  138661. /** @hidden */
  138662. export var glowMapGenerationPixelShader: {
  138663. name: string;
  138664. shader: string;
  138665. };
  138666. }
  138667. declare module BABYLON {
  138668. /** @hidden */
  138669. export var glowMapGenerationVertexShader: {
  138670. name: string;
  138671. shader: string;
  138672. };
  138673. }
  138674. declare module BABYLON {
  138675. /**
  138676. * Effect layer options. This helps customizing the behaviour
  138677. * of the effect layer.
  138678. */
  138679. export interface IEffectLayerOptions {
  138680. /**
  138681. * Multiplication factor apply to the canvas size to compute the render target size
  138682. * used to generated the objects (the smaller the faster).
  138683. */
  138684. mainTextureRatio: number;
  138685. /**
  138686. * Enforces a fixed size texture to ensure effect stability across devices.
  138687. */
  138688. mainTextureFixedSize?: number;
  138689. /**
  138690. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138691. */
  138692. alphaBlendingMode: number;
  138693. /**
  138694. * The camera attached to the layer.
  138695. */
  138696. camera: Nullable<Camera>;
  138697. /**
  138698. * The rendering group to draw the layer in.
  138699. */
  138700. renderingGroupId: number;
  138701. }
  138702. /**
  138703. * The effect layer Helps adding post process effect blended with the main pass.
  138704. *
  138705. * This can be for instance use to generate glow or higlight effects on the scene.
  138706. *
  138707. * The effect layer class can not be used directly and is intented to inherited from to be
  138708. * customized per effects.
  138709. */
  138710. export abstract class EffectLayer {
  138711. private _vertexBuffers;
  138712. private _indexBuffer;
  138713. private _cachedDefines;
  138714. private _effectLayerMapGenerationEffect;
  138715. private _effectLayerOptions;
  138716. private _mergeEffect;
  138717. protected _scene: Scene;
  138718. protected _engine: Engine;
  138719. protected _maxSize: number;
  138720. protected _mainTextureDesiredSize: ISize;
  138721. protected _mainTexture: RenderTargetTexture;
  138722. protected _shouldRender: boolean;
  138723. protected _postProcesses: PostProcess[];
  138724. protected _textures: BaseTexture[];
  138725. protected _emissiveTextureAndColor: {
  138726. texture: Nullable<BaseTexture>;
  138727. color: Color4;
  138728. };
  138729. /**
  138730. * The name of the layer
  138731. */
  138732. name: string;
  138733. /**
  138734. * The clear color of the texture used to generate the glow map.
  138735. */
  138736. neutralColor: Color4;
  138737. /**
  138738. * Specifies whether the highlight layer is enabled or not.
  138739. */
  138740. isEnabled: boolean;
  138741. /**
  138742. * Gets the camera attached to the layer.
  138743. */
  138744. get camera(): Nullable<Camera>;
  138745. /**
  138746. * Gets the rendering group id the layer should render in.
  138747. */
  138748. get renderingGroupId(): number;
  138749. set renderingGroupId(renderingGroupId: number);
  138750. /**
  138751. * An event triggered when the effect layer has been disposed.
  138752. */
  138753. onDisposeObservable: Observable<EffectLayer>;
  138754. /**
  138755. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138756. */
  138757. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138758. /**
  138759. * An event triggered when the generated texture is being merged in the scene.
  138760. */
  138761. onBeforeComposeObservable: Observable<EffectLayer>;
  138762. /**
  138763. * An event triggered when the mesh is rendered into the effect render target.
  138764. */
  138765. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138766. /**
  138767. * An event triggered after the mesh has been rendered into the effect render target.
  138768. */
  138769. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138770. /**
  138771. * An event triggered when the generated texture has been merged in the scene.
  138772. */
  138773. onAfterComposeObservable: Observable<EffectLayer>;
  138774. /**
  138775. * An event triggered when the efffect layer changes its size.
  138776. */
  138777. onSizeChangedObservable: Observable<EffectLayer>;
  138778. /** @hidden */
  138779. static _SceneComponentInitialization: (scene: Scene) => void;
  138780. /**
  138781. * Instantiates a new effect Layer and references it in the scene.
  138782. * @param name The name of the layer
  138783. * @param scene The scene to use the layer in
  138784. */
  138785. constructor(
  138786. /** The Friendly of the effect in the scene */
  138787. name: string, scene: Scene);
  138788. /**
  138789. * Get the effect name of the layer.
  138790. * @return The effect name
  138791. */
  138792. abstract getEffectName(): string;
  138793. /**
  138794. * Checks for the readiness of the element composing the layer.
  138795. * @param subMesh the mesh to check for
  138796. * @param useInstances specify whether or not to use instances to render the mesh
  138797. * @return true if ready otherwise, false
  138798. */
  138799. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138800. /**
  138801. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138802. * @returns true if the effect requires stencil during the main canvas render pass.
  138803. */
  138804. abstract needStencil(): boolean;
  138805. /**
  138806. * Create the merge effect. This is the shader use to blit the information back
  138807. * to the main canvas at the end of the scene rendering.
  138808. * @returns The effect containing the shader used to merge the effect on the main canvas
  138809. */
  138810. protected abstract _createMergeEffect(): Effect;
  138811. /**
  138812. * Creates the render target textures and post processes used in the effect layer.
  138813. */
  138814. protected abstract _createTextureAndPostProcesses(): void;
  138815. /**
  138816. * Implementation specific of rendering the generating effect on the main canvas.
  138817. * @param effect The effect used to render through
  138818. */
  138819. protected abstract _internalRender(effect: Effect): void;
  138820. /**
  138821. * Sets the required values for both the emissive texture and and the main color.
  138822. */
  138823. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138824. /**
  138825. * Free any resources and references associated to a mesh.
  138826. * Internal use
  138827. * @param mesh The mesh to free.
  138828. */
  138829. abstract _disposeMesh(mesh: Mesh): void;
  138830. /**
  138831. * Serializes this layer (Glow or Highlight for example)
  138832. * @returns a serialized layer object
  138833. */
  138834. abstract serialize?(): any;
  138835. /**
  138836. * Initializes the effect layer with the required options.
  138837. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138838. */
  138839. protected _init(options: Partial<IEffectLayerOptions>): void;
  138840. /**
  138841. * Generates the index buffer of the full screen quad blending to the main canvas.
  138842. */
  138843. private _generateIndexBuffer;
  138844. /**
  138845. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138846. */
  138847. private _generateVertexBuffer;
  138848. /**
  138849. * Sets the main texture desired size which is the closest power of two
  138850. * of the engine canvas size.
  138851. */
  138852. private _setMainTextureSize;
  138853. /**
  138854. * Creates the main texture for the effect layer.
  138855. */
  138856. protected _createMainTexture(): void;
  138857. /**
  138858. * Adds specific effects defines.
  138859. * @param defines The defines to add specifics to.
  138860. */
  138861. protected _addCustomEffectDefines(defines: string[]): void;
  138862. /**
  138863. * Checks for the readiness of the element composing the layer.
  138864. * @param subMesh the mesh to check for
  138865. * @param useInstances specify whether or not to use instances to render the mesh
  138866. * @param emissiveTexture the associated emissive texture used to generate the glow
  138867. * @return true if ready otherwise, false
  138868. */
  138869. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138870. /**
  138871. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138872. */
  138873. render(): void;
  138874. /**
  138875. * Determine if a given mesh will be used in the current effect.
  138876. * @param mesh mesh to test
  138877. * @returns true if the mesh will be used
  138878. */
  138879. hasMesh(mesh: AbstractMesh): boolean;
  138880. /**
  138881. * Returns true if the layer contains information to display, otherwise false.
  138882. * @returns true if the glow layer should be rendered
  138883. */
  138884. shouldRender(): boolean;
  138885. /**
  138886. * Returns true if the mesh should render, otherwise false.
  138887. * @param mesh The mesh to render
  138888. * @returns true if it should render otherwise false
  138889. */
  138890. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138891. /**
  138892. * Returns true if the mesh can be rendered, otherwise false.
  138893. * @param mesh The mesh to render
  138894. * @param material The material used on the mesh
  138895. * @returns true if it can be rendered otherwise false
  138896. */
  138897. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138898. /**
  138899. * Returns true if the mesh should render, otherwise false.
  138900. * @param mesh The mesh to render
  138901. * @returns true if it should render otherwise false
  138902. */
  138903. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138904. /**
  138905. * Renders the submesh passed in parameter to the generation map.
  138906. */
  138907. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138908. /**
  138909. * Defines whether the current material of the mesh should be use to render the effect.
  138910. * @param mesh defines the current mesh to render
  138911. */
  138912. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138913. /**
  138914. * Rebuild the required buffers.
  138915. * @hidden Internal use only.
  138916. */
  138917. _rebuild(): void;
  138918. /**
  138919. * Dispose only the render target textures and post process.
  138920. */
  138921. private _disposeTextureAndPostProcesses;
  138922. /**
  138923. * Dispose the highlight layer and free resources.
  138924. */
  138925. dispose(): void;
  138926. /**
  138927. * Gets the class name of the effect layer
  138928. * @returns the string with the class name of the effect layer
  138929. */
  138930. getClassName(): string;
  138931. /**
  138932. * Creates an effect layer from parsed effect layer data
  138933. * @param parsedEffectLayer defines effect layer data
  138934. * @param scene defines the current scene
  138935. * @param rootUrl defines the root URL containing the effect layer information
  138936. * @returns a parsed effect Layer
  138937. */
  138938. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138939. }
  138940. }
  138941. declare module BABYLON {
  138942. interface AbstractScene {
  138943. /**
  138944. * The list of effect layers (highlights/glow) added to the scene
  138945. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138946. * @see https://doc.babylonjs.com/how_to/glow_layer
  138947. */
  138948. effectLayers: Array<EffectLayer>;
  138949. /**
  138950. * Removes the given effect layer from this scene.
  138951. * @param toRemove defines the effect layer to remove
  138952. * @returns the index of the removed effect layer
  138953. */
  138954. removeEffectLayer(toRemove: EffectLayer): number;
  138955. /**
  138956. * Adds the given effect layer to this scene
  138957. * @param newEffectLayer defines the effect layer to add
  138958. */
  138959. addEffectLayer(newEffectLayer: EffectLayer): void;
  138960. }
  138961. /**
  138962. * Defines the layer scene component responsible to manage any effect layers
  138963. * in a given scene.
  138964. */
  138965. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138966. /**
  138967. * The component name helpfull to identify the component in the list of scene components.
  138968. */
  138969. readonly name: string;
  138970. /**
  138971. * The scene the component belongs to.
  138972. */
  138973. scene: Scene;
  138974. private _engine;
  138975. private _renderEffects;
  138976. private _needStencil;
  138977. private _previousStencilState;
  138978. /**
  138979. * Creates a new instance of the component for the given scene
  138980. * @param scene Defines the scene to register the component in
  138981. */
  138982. constructor(scene: Scene);
  138983. /**
  138984. * Registers the component in a given scene
  138985. */
  138986. register(): void;
  138987. /**
  138988. * Rebuilds the elements related to this component in case of
  138989. * context lost for instance.
  138990. */
  138991. rebuild(): void;
  138992. /**
  138993. * Serializes the component data to the specified json object
  138994. * @param serializationObject The object to serialize to
  138995. */
  138996. serialize(serializationObject: any): void;
  138997. /**
  138998. * Adds all the elements from the container to the scene
  138999. * @param container the container holding the elements
  139000. */
  139001. addFromContainer(container: AbstractScene): void;
  139002. /**
  139003. * Removes all the elements in the container from the scene
  139004. * @param container contains the elements to remove
  139005. * @param dispose if the removed element should be disposed (default: false)
  139006. */
  139007. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139008. /**
  139009. * Disposes the component and the associated ressources.
  139010. */
  139011. dispose(): void;
  139012. private _isReadyForMesh;
  139013. private _renderMainTexture;
  139014. private _setStencil;
  139015. private _setStencilBack;
  139016. private _draw;
  139017. private _drawCamera;
  139018. private _drawRenderingGroup;
  139019. }
  139020. }
  139021. declare module BABYLON {
  139022. /** @hidden */
  139023. export var glowMapMergePixelShader: {
  139024. name: string;
  139025. shader: string;
  139026. };
  139027. }
  139028. declare module BABYLON {
  139029. /** @hidden */
  139030. export var glowMapMergeVertexShader: {
  139031. name: string;
  139032. shader: string;
  139033. };
  139034. }
  139035. declare module BABYLON {
  139036. interface AbstractScene {
  139037. /**
  139038. * Return a the first highlight layer of the scene with a given name.
  139039. * @param name The name of the highlight layer to look for.
  139040. * @return The highlight layer if found otherwise null.
  139041. */
  139042. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139043. }
  139044. /**
  139045. * Glow layer options. This helps customizing the behaviour
  139046. * of the glow layer.
  139047. */
  139048. export interface IGlowLayerOptions {
  139049. /**
  139050. * Multiplication factor apply to the canvas size to compute the render target size
  139051. * used to generated the glowing objects (the smaller the faster).
  139052. */
  139053. mainTextureRatio: number;
  139054. /**
  139055. * Enforces a fixed size texture to ensure resize independant blur.
  139056. */
  139057. mainTextureFixedSize?: number;
  139058. /**
  139059. * How big is the kernel of the blur texture.
  139060. */
  139061. blurKernelSize: number;
  139062. /**
  139063. * The camera attached to the layer.
  139064. */
  139065. camera: Nullable<Camera>;
  139066. /**
  139067. * Enable MSAA by chosing the number of samples.
  139068. */
  139069. mainTextureSamples?: number;
  139070. /**
  139071. * The rendering group to draw the layer in.
  139072. */
  139073. renderingGroupId: number;
  139074. }
  139075. /**
  139076. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139077. *
  139078. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139079. *
  139080. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139081. */
  139082. export class GlowLayer extends EffectLayer {
  139083. /**
  139084. * Effect Name of the layer.
  139085. */
  139086. static readonly EffectName: string;
  139087. /**
  139088. * The default blur kernel size used for the glow.
  139089. */
  139090. static DefaultBlurKernelSize: number;
  139091. /**
  139092. * The default texture size ratio used for the glow.
  139093. */
  139094. static DefaultTextureRatio: number;
  139095. /**
  139096. * Sets the kernel size of the blur.
  139097. */
  139098. set blurKernelSize(value: number);
  139099. /**
  139100. * Gets the kernel size of the blur.
  139101. */
  139102. get blurKernelSize(): number;
  139103. /**
  139104. * Sets the glow intensity.
  139105. */
  139106. set intensity(value: number);
  139107. /**
  139108. * Gets the glow intensity.
  139109. */
  139110. get intensity(): number;
  139111. private _options;
  139112. private _intensity;
  139113. private _horizontalBlurPostprocess1;
  139114. private _verticalBlurPostprocess1;
  139115. private _horizontalBlurPostprocess2;
  139116. private _verticalBlurPostprocess2;
  139117. private _blurTexture1;
  139118. private _blurTexture2;
  139119. private _postProcesses1;
  139120. private _postProcesses2;
  139121. private _includedOnlyMeshes;
  139122. private _excludedMeshes;
  139123. private _meshesUsingTheirOwnMaterials;
  139124. /**
  139125. * Callback used to let the user override the color selection on a per mesh basis
  139126. */
  139127. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139128. /**
  139129. * Callback used to let the user override the texture selection on a per mesh basis
  139130. */
  139131. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139132. /**
  139133. * Instantiates a new glow Layer and references it to the scene.
  139134. * @param name The name of the layer
  139135. * @param scene The scene to use the layer in
  139136. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139137. */
  139138. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139139. /**
  139140. * Get the effect name of the layer.
  139141. * @return The effect name
  139142. */
  139143. getEffectName(): string;
  139144. /**
  139145. * Create the merge effect. This is the shader use to blit the information back
  139146. * to the main canvas at the end of the scene rendering.
  139147. */
  139148. protected _createMergeEffect(): Effect;
  139149. /**
  139150. * Creates the render target textures and post processes used in the glow layer.
  139151. */
  139152. protected _createTextureAndPostProcesses(): void;
  139153. /**
  139154. * Checks for the readiness of the element composing the layer.
  139155. * @param subMesh the mesh to check for
  139156. * @param useInstances specify wether or not to use instances to render the mesh
  139157. * @param emissiveTexture the associated emissive texture used to generate the glow
  139158. * @return true if ready otherwise, false
  139159. */
  139160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139161. /**
  139162. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139163. */
  139164. needStencil(): boolean;
  139165. /**
  139166. * Returns true if the mesh can be rendered, otherwise false.
  139167. * @param mesh The mesh to render
  139168. * @param material The material used on the mesh
  139169. * @returns true if it can be rendered otherwise false
  139170. */
  139171. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139172. /**
  139173. * Implementation specific of rendering the generating effect on the main canvas.
  139174. * @param effect The effect used to render through
  139175. */
  139176. protected _internalRender(effect: Effect): void;
  139177. /**
  139178. * Sets the required values for both the emissive texture and and the main color.
  139179. */
  139180. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139181. /**
  139182. * Returns true if the mesh should render, otherwise false.
  139183. * @param mesh The mesh to render
  139184. * @returns true if it should render otherwise false
  139185. */
  139186. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139187. /**
  139188. * Adds specific effects defines.
  139189. * @param defines The defines to add specifics to.
  139190. */
  139191. protected _addCustomEffectDefines(defines: string[]): void;
  139192. /**
  139193. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139194. * @param mesh The mesh to exclude from the glow layer
  139195. */
  139196. addExcludedMesh(mesh: Mesh): void;
  139197. /**
  139198. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139199. * @param mesh The mesh to remove
  139200. */
  139201. removeExcludedMesh(mesh: Mesh): void;
  139202. /**
  139203. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139204. * @param mesh The mesh to include in the glow layer
  139205. */
  139206. addIncludedOnlyMesh(mesh: Mesh): void;
  139207. /**
  139208. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139209. * @param mesh The mesh to remove
  139210. */
  139211. removeIncludedOnlyMesh(mesh: Mesh): void;
  139212. /**
  139213. * Determine if a given mesh will be used in the glow layer
  139214. * @param mesh The mesh to test
  139215. * @returns true if the mesh will be highlighted by the current glow layer
  139216. */
  139217. hasMesh(mesh: AbstractMesh): boolean;
  139218. /**
  139219. * Defines whether the current material of the mesh should be use to render the effect.
  139220. * @param mesh defines the current mesh to render
  139221. */
  139222. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139223. /**
  139224. * Add a mesh to be rendered through its own material and not with emissive only.
  139225. * @param mesh The mesh for which we need to use its material
  139226. */
  139227. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139228. /**
  139229. * Remove a mesh from being rendered through its own material and not with emissive only.
  139230. * @param mesh The mesh for which we need to not use its material
  139231. */
  139232. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139233. /**
  139234. * Free any resources and references associated to a mesh.
  139235. * Internal use
  139236. * @param mesh The mesh to free.
  139237. * @hidden
  139238. */
  139239. _disposeMesh(mesh: Mesh): void;
  139240. /**
  139241. * Gets the class name of the effect layer
  139242. * @returns the string with the class name of the effect layer
  139243. */
  139244. getClassName(): string;
  139245. /**
  139246. * Serializes this glow layer
  139247. * @returns a serialized glow layer object
  139248. */
  139249. serialize(): any;
  139250. /**
  139251. * Creates a Glow Layer from parsed glow layer data
  139252. * @param parsedGlowLayer defines glow layer data
  139253. * @param scene defines the current scene
  139254. * @param rootUrl defines the root URL containing the glow layer information
  139255. * @returns a parsed Glow Layer
  139256. */
  139257. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139258. }
  139259. }
  139260. declare module BABYLON {
  139261. /** @hidden */
  139262. export var glowBlurPostProcessPixelShader: {
  139263. name: string;
  139264. shader: string;
  139265. };
  139266. }
  139267. declare module BABYLON {
  139268. interface AbstractScene {
  139269. /**
  139270. * Return a the first highlight layer of the scene with a given name.
  139271. * @param name The name of the highlight layer to look for.
  139272. * @return The highlight layer if found otherwise null.
  139273. */
  139274. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139275. }
  139276. /**
  139277. * Highlight layer options. This helps customizing the behaviour
  139278. * of the highlight layer.
  139279. */
  139280. export interface IHighlightLayerOptions {
  139281. /**
  139282. * Multiplication factor apply to the canvas size to compute the render target size
  139283. * used to generated the glowing objects (the smaller the faster).
  139284. */
  139285. mainTextureRatio: number;
  139286. /**
  139287. * Enforces a fixed size texture to ensure resize independant blur.
  139288. */
  139289. mainTextureFixedSize?: number;
  139290. /**
  139291. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139292. * of the picture to blur (the smaller the faster).
  139293. */
  139294. blurTextureSizeRatio: number;
  139295. /**
  139296. * How big in texel of the blur texture is the vertical blur.
  139297. */
  139298. blurVerticalSize: number;
  139299. /**
  139300. * How big in texel of the blur texture is the horizontal blur.
  139301. */
  139302. blurHorizontalSize: number;
  139303. /**
  139304. * Alpha blending mode used to apply the blur. Default is combine.
  139305. */
  139306. alphaBlendingMode: number;
  139307. /**
  139308. * The camera attached to the layer.
  139309. */
  139310. camera: Nullable<Camera>;
  139311. /**
  139312. * Should we display highlight as a solid stroke?
  139313. */
  139314. isStroke?: boolean;
  139315. /**
  139316. * The rendering group to draw the layer in.
  139317. */
  139318. renderingGroupId: number;
  139319. }
  139320. /**
  139321. * The highlight layer Helps adding a glow effect around a mesh.
  139322. *
  139323. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139324. * glowy meshes to your scene.
  139325. *
  139326. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139327. */
  139328. export class HighlightLayer extends EffectLayer {
  139329. name: string;
  139330. /**
  139331. * Effect Name of the highlight layer.
  139332. */
  139333. static readonly EffectName: string;
  139334. /**
  139335. * The neutral color used during the preparation of the glow effect.
  139336. * This is black by default as the blend operation is a blend operation.
  139337. */
  139338. static NeutralColor: Color4;
  139339. /**
  139340. * Stencil value used for glowing meshes.
  139341. */
  139342. static GlowingMeshStencilReference: number;
  139343. /**
  139344. * Stencil value used for the other meshes in the scene.
  139345. */
  139346. static NormalMeshStencilReference: number;
  139347. /**
  139348. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139349. */
  139350. innerGlow: boolean;
  139351. /**
  139352. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139353. */
  139354. outerGlow: boolean;
  139355. /**
  139356. * Specifies the horizontal size of the blur.
  139357. */
  139358. set blurHorizontalSize(value: number);
  139359. /**
  139360. * Specifies the vertical size of the blur.
  139361. */
  139362. set blurVerticalSize(value: number);
  139363. /**
  139364. * Gets the horizontal size of the blur.
  139365. */
  139366. get blurHorizontalSize(): number;
  139367. /**
  139368. * Gets the vertical size of the blur.
  139369. */
  139370. get blurVerticalSize(): number;
  139371. /**
  139372. * An event triggered when the highlight layer is being blurred.
  139373. */
  139374. onBeforeBlurObservable: Observable<HighlightLayer>;
  139375. /**
  139376. * An event triggered when the highlight layer has been blurred.
  139377. */
  139378. onAfterBlurObservable: Observable<HighlightLayer>;
  139379. private _instanceGlowingMeshStencilReference;
  139380. private _options;
  139381. private _downSamplePostprocess;
  139382. private _horizontalBlurPostprocess;
  139383. private _verticalBlurPostprocess;
  139384. private _blurTexture;
  139385. private _meshes;
  139386. private _excludedMeshes;
  139387. /**
  139388. * Instantiates a new highlight Layer and references it to the scene..
  139389. * @param name The name of the layer
  139390. * @param scene The scene to use the layer in
  139391. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139392. */
  139393. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139394. /**
  139395. * Get the effect name of the layer.
  139396. * @return The effect name
  139397. */
  139398. getEffectName(): string;
  139399. /**
  139400. * Create the merge effect. This is the shader use to blit the information back
  139401. * to the main canvas at the end of the scene rendering.
  139402. */
  139403. protected _createMergeEffect(): Effect;
  139404. /**
  139405. * Creates the render target textures and post processes used in the highlight layer.
  139406. */
  139407. protected _createTextureAndPostProcesses(): void;
  139408. /**
  139409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139410. */
  139411. needStencil(): boolean;
  139412. /**
  139413. * Checks for the readiness of the element composing the layer.
  139414. * @param subMesh the mesh to check for
  139415. * @param useInstances specify wether or not to use instances to render the mesh
  139416. * @param emissiveTexture the associated emissive texture used to generate the glow
  139417. * @return true if ready otherwise, false
  139418. */
  139419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139420. /**
  139421. * Implementation specific of rendering the generating effect on the main canvas.
  139422. * @param effect The effect used to render through
  139423. */
  139424. protected _internalRender(effect: Effect): void;
  139425. /**
  139426. * Returns true if the layer contains information to display, otherwise false.
  139427. */
  139428. shouldRender(): boolean;
  139429. /**
  139430. * Returns true if the mesh should render, otherwise false.
  139431. * @param mesh The mesh to render
  139432. * @returns true if it should render otherwise false
  139433. */
  139434. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139435. /**
  139436. * Returns true if the mesh can be rendered, otherwise false.
  139437. * @param mesh The mesh to render
  139438. * @param material The material used on the mesh
  139439. * @returns true if it can be rendered otherwise false
  139440. */
  139441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139442. /**
  139443. * Adds specific effects defines.
  139444. * @param defines The defines to add specifics to.
  139445. */
  139446. protected _addCustomEffectDefines(defines: string[]): void;
  139447. /**
  139448. * Sets the required values for both the emissive texture and and the main color.
  139449. */
  139450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139451. /**
  139452. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139453. * @param mesh The mesh to exclude from the highlight layer
  139454. */
  139455. addExcludedMesh(mesh: Mesh): void;
  139456. /**
  139457. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139458. * @param mesh The mesh to highlight
  139459. */
  139460. removeExcludedMesh(mesh: Mesh): void;
  139461. /**
  139462. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139463. * @param mesh mesh to test
  139464. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139465. */
  139466. hasMesh(mesh: AbstractMesh): boolean;
  139467. /**
  139468. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139469. * @param mesh The mesh to highlight
  139470. * @param color The color of the highlight
  139471. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139472. */
  139473. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139474. /**
  139475. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139476. * @param mesh The mesh to highlight
  139477. */
  139478. removeMesh(mesh: Mesh): void;
  139479. /**
  139480. * Remove all the meshes currently referenced in the highlight layer
  139481. */
  139482. removeAllMeshes(): void;
  139483. /**
  139484. * Force the stencil to the normal expected value for none glowing parts
  139485. */
  139486. private _defaultStencilReference;
  139487. /**
  139488. * Free any resources and references associated to a mesh.
  139489. * Internal use
  139490. * @param mesh The mesh to free.
  139491. * @hidden
  139492. */
  139493. _disposeMesh(mesh: Mesh): void;
  139494. /**
  139495. * Dispose the highlight layer and free resources.
  139496. */
  139497. dispose(): void;
  139498. /**
  139499. * Gets the class name of the effect layer
  139500. * @returns the string with the class name of the effect layer
  139501. */
  139502. getClassName(): string;
  139503. /**
  139504. * Serializes this Highlight layer
  139505. * @returns a serialized Highlight layer object
  139506. */
  139507. serialize(): any;
  139508. /**
  139509. * Creates a Highlight layer from parsed Highlight layer data
  139510. * @param parsedHightlightLayer defines the Highlight layer data
  139511. * @param scene defines the current scene
  139512. * @param rootUrl defines the root URL containing the Highlight layer information
  139513. * @returns a parsed Highlight layer
  139514. */
  139515. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139516. }
  139517. }
  139518. declare module BABYLON {
  139519. interface AbstractScene {
  139520. /**
  139521. * The list of layers (background and foreground) of the scene
  139522. */
  139523. layers: Array<Layer>;
  139524. }
  139525. /**
  139526. * Defines the layer scene component responsible to manage any layers
  139527. * in a given scene.
  139528. */
  139529. export class LayerSceneComponent implements ISceneComponent {
  139530. /**
  139531. * The component name helpfull to identify the component in the list of scene components.
  139532. */
  139533. readonly name: string;
  139534. /**
  139535. * The scene the component belongs to.
  139536. */
  139537. scene: Scene;
  139538. private _engine;
  139539. /**
  139540. * Creates a new instance of the component for the given scene
  139541. * @param scene Defines the scene to register the component in
  139542. */
  139543. constructor(scene: Scene);
  139544. /**
  139545. * Registers the component in a given scene
  139546. */
  139547. register(): void;
  139548. /**
  139549. * Rebuilds the elements related to this component in case of
  139550. * context lost for instance.
  139551. */
  139552. rebuild(): void;
  139553. /**
  139554. * Disposes the component and the associated ressources.
  139555. */
  139556. dispose(): void;
  139557. private _draw;
  139558. private _drawCameraPredicate;
  139559. private _drawCameraBackground;
  139560. private _drawCameraForeground;
  139561. private _drawRenderTargetPredicate;
  139562. private _drawRenderTargetBackground;
  139563. private _drawRenderTargetForeground;
  139564. /**
  139565. * Adds all the elements from the container to the scene
  139566. * @param container the container holding the elements
  139567. */
  139568. addFromContainer(container: AbstractScene): void;
  139569. /**
  139570. * Removes all the elements in the container from the scene
  139571. * @param container contains the elements to remove
  139572. * @param dispose if the removed element should be disposed (default: false)
  139573. */
  139574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139575. }
  139576. }
  139577. declare module BABYLON {
  139578. /** @hidden */
  139579. export var layerPixelShader: {
  139580. name: string;
  139581. shader: string;
  139582. };
  139583. }
  139584. declare module BABYLON {
  139585. /** @hidden */
  139586. export var layerVertexShader: {
  139587. name: string;
  139588. shader: string;
  139589. };
  139590. }
  139591. declare module BABYLON {
  139592. /**
  139593. * This represents a full screen 2d layer.
  139594. * This can be useful to display a picture in the background of your scene for instance.
  139595. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139596. */
  139597. export class Layer {
  139598. /**
  139599. * Define the name of the layer.
  139600. */
  139601. name: string;
  139602. /**
  139603. * Define the texture the layer should display.
  139604. */
  139605. texture: Nullable<Texture>;
  139606. /**
  139607. * Is the layer in background or foreground.
  139608. */
  139609. isBackground: boolean;
  139610. /**
  139611. * Define the color of the layer (instead of texture).
  139612. */
  139613. color: Color4;
  139614. /**
  139615. * Define the scale of the layer in order to zoom in out of the texture.
  139616. */
  139617. scale: Vector2;
  139618. /**
  139619. * Define an offset for the layer in order to shift the texture.
  139620. */
  139621. offset: Vector2;
  139622. /**
  139623. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139624. */
  139625. alphaBlendingMode: number;
  139626. /**
  139627. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139628. * Alpha test will not mix with the background color in case of transparency.
  139629. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139630. */
  139631. alphaTest: boolean;
  139632. /**
  139633. * Define a mask to restrict the layer to only some of the scene cameras.
  139634. */
  139635. layerMask: number;
  139636. /**
  139637. * Define the list of render target the layer is visible into.
  139638. */
  139639. renderTargetTextures: RenderTargetTexture[];
  139640. /**
  139641. * Define if the layer is only used in renderTarget or if it also
  139642. * renders in the main frame buffer of the canvas.
  139643. */
  139644. renderOnlyInRenderTargetTextures: boolean;
  139645. private _scene;
  139646. private _vertexBuffers;
  139647. private _indexBuffer;
  139648. private _effect;
  139649. private _previousDefines;
  139650. /**
  139651. * An event triggered when the layer is disposed.
  139652. */
  139653. onDisposeObservable: Observable<Layer>;
  139654. private _onDisposeObserver;
  139655. /**
  139656. * Back compatibility with callback before the onDisposeObservable existed.
  139657. * The set callback will be triggered when the layer has been disposed.
  139658. */
  139659. set onDispose(callback: () => void);
  139660. /**
  139661. * An event triggered before rendering the scene
  139662. */
  139663. onBeforeRenderObservable: Observable<Layer>;
  139664. private _onBeforeRenderObserver;
  139665. /**
  139666. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139667. * The set callback will be triggered just before rendering the layer.
  139668. */
  139669. set onBeforeRender(callback: () => void);
  139670. /**
  139671. * An event triggered after rendering the scene
  139672. */
  139673. onAfterRenderObservable: Observable<Layer>;
  139674. private _onAfterRenderObserver;
  139675. /**
  139676. * Back compatibility with callback before the onAfterRenderObservable existed.
  139677. * The set callback will be triggered just after rendering the layer.
  139678. */
  139679. set onAfterRender(callback: () => void);
  139680. /**
  139681. * Instantiates a new layer.
  139682. * This represents a full screen 2d layer.
  139683. * This can be useful to display a picture in the background of your scene for instance.
  139684. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139685. * @param name Define the name of the layer in the scene
  139686. * @param imgUrl Define the url of the texture to display in the layer
  139687. * @param scene Define the scene the layer belongs to
  139688. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139689. * @param color Defines a color for the layer
  139690. */
  139691. constructor(
  139692. /**
  139693. * Define the name of the layer.
  139694. */
  139695. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139696. private _createIndexBuffer;
  139697. /** @hidden */
  139698. _rebuild(): void;
  139699. /**
  139700. * Renders the layer in the scene.
  139701. */
  139702. render(): void;
  139703. /**
  139704. * Disposes and releases the associated ressources.
  139705. */
  139706. dispose(): void;
  139707. }
  139708. }
  139709. declare module BABYLON {
  139710. /** @hidden */
  139711. export var lensFlarePixelShader: {
  139712. name: string;
  139713. shader: string;
  139714. };
  139715. }
  139716. declare module BABYLON {
  139717. /** @hidden */
  139718. export var lensFlareVertexShader: {
  139719. name: string;
  139720. shader: string;
  139721. };
  139722. }
  139723. declare module BABYLON {
  139724. /**
  139725. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139726. * It is usually composed of several `lensFlare`.
  139727. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139728. */
  139729. export class LensFlareSystem {
  139730. /**
  139731. * Define the name of the lens flare system
  139732. */
  139733. name: string;
  139734. /**
  139735. * List of lens flares used in this system.
  139736. */
  139737. lensFlares: LensFlare[];
  139738. /**
  139739. * Define a limit from the border the lens flare can be visible.
  139740. */
  139741. borderLimit: number;
  139742. /**
  139743. * Define a viewport border we do not want to see the lens flare in.
  139744. */
  139745. viewportBorder: number;
  139746. /**
  139747. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139748. */
  139749. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139750. /**
  139751. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139752. */
  139753. layerMask: number;
  139754. /**
  139755. * Define the id of the lens flare system in the scene.
  139756. * (equal to name by default)
  139757. */
  139758. id: string;
  139759. private _scene;
  139760. private _emitter;
  139761. private _vertexBuffers;
  139762. private _indexBuffer;
  139763. private _effect;
  139764. private _positionX;
  139765. private _positionY;
  139766. private _isEnabled;
  139767. /** @hidden */
  139768. static _SceneComponentInitialization: (scene: Scene) => void;
  139769. /**
  139770. * Instantiates a lens flare system.
  139771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139772. * It is usually composed of several `lensFlare`.
  139773. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139774. * @param name Define the name of the lens flare system in the scene
  139775. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139776. * @param scene Define the scene the lens flare system belongs to
  139777. */
  139778. constructor(
  139779. /**
  139780. * Define the name of the lens flare system
  139781. */
  139782. name: string, emitter: any, scene: Scene);
  139783. /**
  139784. * Define if the lens flare system is enabled.
  139785. */
  139786. get isEnabled(): boolean;
  139787. set isEnabled(value: boolean);
  139788. /**
  139789. * Get the scene the effects belongs to.
  139790. * @returns the scene holding the lens flare system
  139791. */
  139792. getScene(): Scene;
  139793. /**
  139794. * Get the emitter of the lens flare system.
  139795. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139796. * @returns the emitter of the lens flare system
  139797. */
  139798. getEmitter(): any;
  139799. /**
  139800. * Set the emitter of the lens flare system.
  139801. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139802. * @param newEmitter Define the new emitter of the system
  139803. */
  139804. setEmitter(newEmitter: any): void;
  139805. /**
  139806. * Get the lens flare system emitter position.
  139807. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139808. * @returns the position
  139809. */
  139810. getEmitterPosition(): Vector3;
  139811. /**
  139812. * @hidden
  139813. */
  139814. computeEffectivePosition(globalViewport: Viewport): boolean;
  139815. /** @hidden */
  139816. _isVisible(): boolean;
  139817. /**
  139818. * @hidden
  139819. */
  139820. render(): boolean;
  139821. /**
  139822. * Dispose and release the lens flare with its associated resources.
  139823. */
  139824. dispose(): void;
  139825. /**
  139826. * Parse a lens flare system from a JSON repressentation
  139827. * @param parsedLensFlareSystem Define the JSON to parse
  139828. * @param scene Define the scene the parsed system should be instantiated in
  139829. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139830. * @returns the parsed system
  139831. */
  139832. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139833. /**
  139834. * Serialize the current Lens Flare System into a JSON representation.
  139835. * @returns the serialized JSON
  139836. */
  139837. serialize(): any;
  139838. }
  139839. }
  139840. declare module BABYLON {
  139841. /**
  139842. * This represents one of the lens effect in a `lensFlareSystem`.
  139843. * It controls one of the indiviual texture used in the effect.
  139844. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139845. */
  139846. export class LensFlare {
  139847. /**
  139848. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139849. */
  139850. size: number;
  139851. /**
  139852. * 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.
  139853. */
  139854. position: number;
  139855. /**
  139856. * Define the lens color.
  139857. */
  139858. color: Color3;
  139859. /**
  139860. * Define the lens texture.
  139861. */
  139862. texture: Nullable<Texture>;
  139863. /**
  139864. * Define the alpha mode to render this particular lens.
  139865. */
  139866. alphaMode: number;
  139867. private _system;
  139868. /**
  139869. * Creates a new Lens Flare.
  139870. * This represents one of the lens effect in a `lensFlareSystem`.
  139871. * It controls one of the indiviual texture used in the effect.
  139872. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139873. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139874. * @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.
  139875. * @param color Define the lens color
  139876. * @param imgUrl Define the lens texture url
  139877. * @param system Define the `lensFlareSystem` this flare is part of
  139878. * @returns The newly created Lens Flare
  139879. */
  139880. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139881. /**
  139882. * Instantiates a new Lens Flare.
  139883. * This represents one of the lens effect in a `lensFlareSystem`.
  139884. * It controls one of the indiviual texture used in the effect.
  139885. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139886. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139887. * @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.
  139888. * @param color Define the lens color
  139889. * @param imgUrl Define the lens texture url
  139890. * @param system Define the `lensFlareSystem` this flare is part of
  139891. */
  139892. constructor(
  139893. /**
  139894. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139895. */
  139896. size: number,
  139897. /**
  139898. * 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.
  139899. */
  139900. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139901. /**
  139902. * Dispose and release the lens flare with its associated resources.
  139903. */
  139904. dispose(): void;
  139905. }
  139906. }
  139907. declare module BABYLON {
  139908. interface AbstractScene {
  139909. /**
  139910. * The list of lens flare system added to the scene
  139911. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139912. */
  139913. lensFlareSystems: Array<LensFlareSystem>;
  139914. /**
  139915. * Removes the given lens flare system from this scene.
  139916. * @param toRemove The lens flare system to remove
  139917. * @returns The index of the removed lens flare system
  139918. */
  139919. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139920. /**
  139921. * Adds the given lens flare system to this scene
  139922. * @param newLensFlareSystem The lens flare system to add
  139923. */
  139924. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139925. /**
  139926. * Gets a lens flare system using its name
  139927. * @param name defines the name to look for
  139928. * @returns the lens flare system or null if not found
  139929. */
  139930. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139931. /**
  139932. * Gets a lens flare system using its id
  139933. * @param id defines the id to look for
  139934. * @returns the lens flare system or null if not found
  139935. */
  139936. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139937. }
  139938. /**
  139939. * Defines the lens flare scene component responsible to manage any lens flares
  139940. * in a given scene.
  139941. */
  139942. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139943. /**
  139944. * The component name helpfull to identify the component in the list of scene components.
  139945. */
  139946. readonly name: string;
  139947. /**
  139948. * The scene the component belongs to.
  139949. */
  139950. scene: Scene;
  139951. /**
  139952. * Creates a new instance of the component for the given scene
  139953. * @param scene Defines the scene to register the component in
  139954. */
  139955. constructor(scene: Scene);
  139956. /**
  139957. * Registers the component in a given scene
  139958. */
  139959. register(): void;
  139960. /**
  139961. * Rebuilds the elements related to this component in case of
  139962. * context lost for instance.
  139963. */
  139964. rebuild(): void;
  139965. /**
  139966. * Adds all the elements from the container to the scene
  139967. * @param container the container holding the elements
  139968. */
  139969. addFromContainer(container: AbstractScene): void;
  139970. /**
  139971. * Removes all the elements in the container from the scene
  139972. * @param container contains the elements to remove
  139973. * @param dispose if the removed element should be disposed (default: false)
  139974. */
  139975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139976. /**
  139977. * Serializes the component data to the specified json object
  139978. * @param serializationObject The object to serialize to
  139979. */
  139980. serialize(serializationObject: any): void;
  139981. /**
  139982. * Disposes the component and the associated ressources.
  139983. */
  139984. dispose(): void;
  139985. private _draw;
  139986. }
  139987. }
  139988. declare module BABYLON {
  139989. /** @hidden */
  139990. export var depthPixelShader: {
  139991. name: string;
  139992. shader: string;
  139993. };
  139994. }
  139995. declare module BABYLON {
  139996. /** @hidden */
  139997. export var depthVertexShader: {
  139998. name: string;
  139999. shader: string;
  140000. };
  140001. }
  140002. declare module BABYLON {
  140003. /**
  140004. * This represents a depth renderer in Babylon.
  140005. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140006. */
  140007. export class DepthRenderer {
  140008. private _scene;
  140009. private _depthMap;
  140010. private _effect;
  140011. private readonly _storeNonLinearDepth;
  140012. private readonly _clearColor;
  140013. /** Get if the depth renderer is using packed depth or not */
  140014. readonly isPacked: boolean;
  140015. private _cachedDefines;
  140016. private _camera;
  140017. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140018. enabled: boolean;
  140019. /**
  140020. * Specifiess that the depth renderer will only be used within
  140021. * the camera it is created for.
  140022. * This can help forcing its rendering during the camera processing.
  140023. */
  140024. useOnlyInActiveCamera: boolean;
  140025. /** @hidden */
  140026. static _SceneComponentInitialization: (scene: Scene) => void;
  140027. /**
  140028. * Instantiates a depth renderer
  140029. * @param scene The scene the renderer belongs to
  140030. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140031. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140032. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140033. */
  140034. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140035. /**
  140036. * Creates the depth rendering effect and checks if the effect is ready.
  140037. * @param subMesh The submesh to be used to render the depth map of
  140038. * @param useInstances If multiple world instances should be used
  140039. * @returns if the depth renderer is ready to render the depth map
  140040. */
  140041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140042. /**
  140043. * Gets the texture which the depth map will be written to.
  140044. * @returns The depth map texture
  140045. */
  140046. getDepthMap(): RenderTargetTexture;
  140047. /**
  140048. * Disposes of the depth renderer.
  140049. */
  140050. dispose(): void;
  140051. }
  140052. }
  140053. declare module BABYLON {
  140054. /** @hidden */
  140055. export var minmaxReduxPixelShader: {
  140056. name: string;
  140057. shader: string;
  140058. };
  140059. }
  140060. declare module BABYLON {
  140061. /**
  140062. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140063. * and maximum values from all values of the texture.
  140064. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140065. * The source values are read from the red channel of the texture.
  140066. */
  140067. export class MinMaxReducer {
  140068. /**
  140069. * Observable triggered when the computation has been performed
  140070. */
  140071. onAfterReductionPerformed: Observable<{
  140072. min: number;
  140073. max: number;
  140074. }>;
  140075. protected _camera: Camera;
  140076. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140077. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140078. protected _postProcessManager: PostProcessManager;
  140079. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140080. protected _forceFullscreenViewport: boolean;
  140081. /**
  140082. * Creates a min/max reducer
  140083. * @param camera The camera to use for the post processes
  140084. */
  140085. constructor(camera: Camera);
  140086. /**
  140087. * Gets the texture used to read the values from.
  140088. */
  140089. get sourceTexture(): Nullable<RenderTargetTexture>;
  140090. /**
  140091. * Sets the source texture to read the values from.
  140092. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140093. * because in such textures '1' value must not be taken into account to compute the maximum
  140094. * as this value is used to clear the texture.
  140095. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140096. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140097. * @param depthRedux Indicates if the texture is a depth texture or not
  140098. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140099. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140100. */
  140101. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140102. /**
  140103. * Defines the refresh rate of the computation.
  140104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140105. */
  140106. get refreshRate(): number;
  140107. set refreshRate(value: number);
  140108. protected _activated: boolean;
  140109. /**
  140110. * Gets the activation status of the reducer
  140111. */
  140112. get activated(): boolean;
  140113. /**
  140114. * Activates the reduction computation.
  140115. * When activated, the observers registered in onAfterReductionPerformed are
  140116. * called after the compuation is performed
  140117. */
  140118. activate(): void;
  140119. /**
  140120. * Deactivates the reduction computation.
  140121. */
  140122. deactivate(): void;
  140123. /**
  140124. * Disposes the min/max reducer
  140125. * @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.
  140126. */
  140127. dispose(disposeAll?: boolean): void;
  140128. }
  140129. }
  140130. declare module BABYLON {
  140131. /**
  140132. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140133. */
  140134. export class DepthReducer extends MinMaxReducer {
  140135. private _depthRenderer;
  140136. private _depthRendererId;
  140137. /**
  140138. * Gets the depth renderer used for the computation.
  140139. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140140. */
  140141. get depthRenderer(): Nullable<DepthRenderer>;
  140142. /**
  140143. * Creates a depth reducer
  140144. * @param camera The camera used to render the depth texture
  140145. */
  140146. constructor(camera: Camera);
  140147. /**
  140148. * Sets the depth renderer to use to generate the depth map
  140149. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140150. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140151. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140152. */
  140153. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140154. /** @hidden */
  140155. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140156. /**
  140157. * Activates the reduction computation.
  140158. * When activated, the observers registered in onAfterReductionPerformed are
  140159. * called after the compuation is performed
  140160. */
  140161. activate(): void;
  140162. /**
  140163. * Deactivates the reduction computation.
  140164. */
  140165. deactivate(): void;
  140166. /**
  140167. * Disposes the depth reducer
  140168. * @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.
  140169. */
  140170. dispose(disposeAll?: boolean): void;
  140171. }
  140172. }
  140173. declare module BABYLON {
  140174. /**
  140175. * A CSM implementation allowing casting shadows on large scenes.
  140176. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140177. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140178. */
  140179. export class CascadedShadowGenerator extends ShadowGenerator {
  140180. private static readonly frustumCornersNDCSpace;
  140181. /**
  140182. * Name of the CSM class
  140183. */
  140184. static CLASSNAME: string;
  140185. /**
  140186. * Defines the default number of cascades used by the CSM.
  140187. */
  140188. static readonly DEFAULT_CASCADES_COUNT: number;
  140189. /**
  140190. * Defines the minimum number of cascades used by the CSM.
  140191. */
  140192. static readonly MIN_CASCADES_COUNT: number;
  140193. /**
  140194. * Defines the maximum number of cascades used by the CSM.
  140195. */
  140196. static readonly MAX_CASCADES_COUNT: number;
  140197. protected _validateFilter(filter: number): number;
  140198. /**
  140199. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140200. */
  140201. penumbraDarkness: number;
  140202. private _numCascades;
  140203. /**
  140204. * Gets or set the number of cascades used by the CSM.
  140205. */
  140206. get numCascades(): number;
  140207. set numCascades(value: number);
  140208. /**
  140209. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140210. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140211. */
  140212. stabilizeCascades: boolean;
  140213. private _freezeShadowCastersBoundingInfo;
  140214. private _freezeShadowCastersBoundingInfoObservable;
  140215. /**
  140216. * Enables or disables the shadow casters bounding info computation.
  140217. * If your shadow casters don't move, you can disable this feature.
  140218. * If it is enabled, the bounding box computation is done every frame.
  140219. */
  140220. get freezeShadowCastersBoundingInfo(): boolean;
  140221. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140222. private _scbiMin;
  140223. private _scbiMax;
  140224. protected _computeShadowCastersBoundingInfo(): void;
  140225. protected _shadowCastersBoundingInfo: BoundingInfo;
  140226. /**
  140227. * Gets or sets the shadow casters bounding info.
  140228. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140229. * so that the system won't overwrite the bounds you provide
  140230. */
  140231. get shadowCastersBoundingInfo(): BoundingInfo;
  140232. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140233. protected _breaksAreDirty: boolean;
  140234. protected _minDistance: number;
  140235. protected _maxDistance: number;
  140236. /**
  140237. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140238. *
  140239. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140240. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140241. * @param min minimal distance for the breaks (default to 0.)
  140242. * @param max maximal distance for the breaks (default to 1.)
  140243. */
  140244. setMinMaxDistance(min: number, max: number): void;
  140245. /** Gets the minimal distance used in the cascade break computation */
  140246. get minDistance(): number;
  140247. /** Gets the maximal distance used in the cascade break computation */
  140248. get maxDistance(): number;
  140249. /**
  140250. * Gets the class name of that object
  140251. * @returns "CascadedShadowGenerator"
  140252. */
  140253. getClassName(): string;
  140254. private _cascadeMinExtents;
  140255. private _cascadeMaxExtents;
  140256. /**
  140257. * Gets a cascade minimum extents
  140258. * @param cascadeIndex index of the cascade
  140259. * @returns the minimum cascade extents
  140260. */
  140261. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140262. /**
  140263. * Gets a cascade maximum extents
  140264. * @param cascadeIndex index of the cascade
  140265. * @returns the maximum cascade extents
  140266. */
  140267. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140268. private _cascades;
  140269. private _currentLayer;
  140270. private _viewSpaceFrustumsZ;
  140271. private _viewMatrices;
  140272. private _projectionMatrices;
  140273. private _transformMatrices;
  140274. private _transformMatricesAsArray;
  140275. private _frustumLengths;
  140276. private _lightSizeUVCorrection;
  140277. private _depthCorrection;
  140278. private _frustumCornersWorldSpace;
  140279. private _frustumCenter;
  140280. private _shadowCameraPos;
  140281. private _shadowMaxZ;
  140282. /**
  140283. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140284. * It defaults to camera.maxZ
  140285. */
  140286. get shadowMaxZ(): number;
  140287. /**
  140288. * Sets the shadow max z distance.
  140289. */
  140290. set shadowMaxZ(value: number);
  140291. protected _debug: boolean;
  140292. /**
  140293. * Gets or sets the debug flag.
  140294. * When enabled, the cascades are materialized by different colors on the screen.
  140295. */
  140296. get debug(): boolean;
  140297. set debug(dbg: boolean);
  140298. private _depthClamp;
  140299. /**
  140300. * Gets or sets the depth clamping value.
  140301. *
  140302. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140303. * to account for the shadow casters far away.
  140304. *
  140305. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140306. */
  140307. get depthClamp(): boolean;
  140308. set depthClamp(value: boolean);
  140309. private _cascadeBlendPercentage;
  140310. /**
  140311. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140312. * It defaults to 0.1 (10% blending).
  140313. */
  140314. get cascadeBlendPercentage(): number;
  140315. set cascadeBlendPercentage(value: number);
  140316. private _lambda;
  140317. /**
  140318. * Gets or set the lambda parameter.
  140319. * This parameter is used to split the camera frustum and create the cascades.
  140320. * 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.
  140321. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140322. */
  140323. get lambda(): number;
  140324. set lambda(value: number);
  140325. /**
  140326. * Gets the view matrix corresponding to a given cascade
  140327. * @param cascadeNum cascade to retrieve the view matrix from
  140328. * @returns the cascade view matrix
  140329. */
  140330. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140331. /**
  140332. * Gets the projection matrix corresponding to a given cascade
  140333. * @param cascadeNum cascade to retrieve the projection matrix from
  140334. * @returns the cascade projection matrix
  140335. */
  140336. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140337. /**
  140338. * Gets the transformation matrix corresponding to a given cascade
  140339. * @param cascadeNum cascade to retrieve the transformation matrix from
  140340. * @returns the cascade transformation matrix
  140341. */
  140342. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140343. private _depthRenderer;
  140344. /**
  140345. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140346. *
  140347. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140348. *
  140349. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140350. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140351. * @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
  140352. */
  140353. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140354. private _depthReducer;
  140355. private _autoCalcDepthBounds;
  140356. /**
  140357. * Gets or sets the autoCalcDepthBounds property.
  140358. *
  140359. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140360. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140361. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140362. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140363. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140364. */
  140365. get autoCalcDepthBounds(): boolean;
  140366. set autoCalcDepthBounds(value: boolean);
  140367. /**
  140368. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140369. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140370. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140371. * for setting the refresh rate on the renderer yourself!
  140372. */
  140373. get autoCalcDepthBoundsRefreshRate(): number;
  140374. set autoCalcDepthBoundsRefreshRate(value: number);
  140375. /**
  140376. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140377. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140378. * you change the camera near/far planes!
  140379. */
  140380. splitFrustum(): void;
  140381. private _splitFrustum;
  140382. private _computeMatrices;
  140383. private _computeFrustumInWorldSpace;
  140384. private _computeCascadeFrustum;
  140385. /**
  140386. * Support test.
  140387. */
  140388. static get IsSupported(): boolean;
  140389. /** @hidden */
  140390. static _SceneComponentInitialization: (scene: Scene) => void;
  140391. /**
  140392. * Creates a Cascaded Shadow Generator object.
  140393. * A ShadowGenerator is the required tool to use the shadows.
  140394. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140395. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140396. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140397. * @param light The directional light object generating the shadows.
  140398. * @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.
  140399. */
  140400. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140401. protected _initializeGenerator(): void;
  140402. protected _createTargetRenderTexture(): void;
  140403. protected _initializeShadowMap(): void;
  140404. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140405. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140406. /**
  140407. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140408. * @param defines Defines of the material we want to update
  140409. * @param lightIndex Index of the light in the enabled light list of the material
  140410. */
  140411. prepareDefines(defines: any, lightIndex: number): void;
  140412. /**
  140413. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140414. * defined in the generator but impacting the effect).
  140415. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140416. * @param effect The effect we are binfing the information for
  140417. */
  140418. bindShadowLight(lightIndex: string, effect: Effect): void;
  140419. /**
  140420. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140421. * (eq to view projection * shadow projection matrices)
  140422. * @returns The transform matrix used to create the shadow map
  140423. */
  140424. getTransformMatrix(): Matrix;
  140425. /**
  140426. * Disposes the ShadowGenerator.
  140427. * Returns nothing.
  140428. */
  140429. dispose(): void;
  140430. /**
  140431. * Serializes the shadow generator setup to a json object.
  140432. * @returns The serialized JSON object
  140433. */
  140434. serialize(): any;
  140435. /**
  140436. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140437. * @param parsedShadowGenerator The JSON object to parse
  140438. * @param scene The scene to create the shadow map for
  140439. * @returns The parsed shadow generator
  140440. */
  140441. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140442. }
  140443. }
  140444. declare module BABYLON {
  140445. /**
  140446. * Defines the shadow generator component responsible to manage any shadow generators
  140447. * in a given scene.
  140448. */
  140449. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140450. /**
  140451. * The component name helpfull to identify the component in the list of scene components.
  140452. */
  140453. readonly name: string;
  140454. /**
  140455. * The scene the component belongs to.
  140456. */
  140457. scene: Scene;
  140458. /**
  140459. * Creates a new instance of the component for the given scene
  140460. * @param scene Defines the scene to register the component in
  140461. */
  140462. constructor(scene: Scene);
  140463. /**
  140464. * Registers the component in a given scene
  140465. */
  140466. register(): void;
  140467. /**
  140468. * Rebuilds the elements related to this component in case of
  140469. * context lost for instance.
  140470. */
  140471. rebuild(): void;
  140472. /**
  140473. * Serializes the component data to the specified json object
  140474. * @param serializationObject The object to serialize to
  140475. */
  140476. serialize(serializationObject: any): void;
  140477. /**
  140478. * Adds all the elements from the container to the scene
  140479. * @param container the container holding the elements
  140480. */
  140481. addFromContainer(container: AbstractScene): void;
  140482. /**
  140483. * Removes all the elements in the container from the scene
  140484. * @param container contains the elements to remove
  140485. * @param dispose if the removed element should be disposed (default: false)
  140486. */
  140487. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140488. /**
  140489. * Rebuilds the elements related to this component in case of
  140490. * context lost for instance.
  140491. */
  140492. dispose(): void;
  140493. private _gatherRenderTargets;
  140494. }
  140495. }
  140496. declare module BABYLON {
  140497. /**
  140498. * A point light is a light defined by an unique point in world space.
  140499. * The light is emitted in every direction from this point.
  140500. * A good example of a point light is a standard light bulb.
  140501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140502. */
  140503. export class PointLight extends ShadowLight {
  140504. private _shadowAngle;
  140505. /**
  140506. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140507. * This specifies what angle the shadow will use to be created.
  140508. *
  140509. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140510. */
  140511. get shadowAngle(): number;
  140512. /**
  140513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140514. * This specifies what angle the shadow will use to be created.
  140515. *
  140516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140517. */
  140518. set shadowAngle(value: number);
  140519. /**
  140520. * Gets the direction if it has been set.
  140521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140522. */
  140523. get direction(): Vector3;
  140524. /**
  140525. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140526. */
  140527. set direction(value: Vector3);
  140528. /**
  140529. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140530. * A PointLight emits the light in every direction.
  140531. * It can cast shadows.
  140532. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140533. * ```javascript
  140534. * var pointLight = new PointLight("pl", camera.position, scene);
  140535. * ```
  140536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140537. * @param name The light friendly name
  140538. * @param position The position of the point light in the scene
  140539. * @param scene The scene the lights belongs to
  140540. */
  140541. constructor(name: string, position: Vector3, scene: Scene);
  140542. /**
  140543. * Returns the string "PointLight"
  140544. * @returns the class name
  140545. */
  140546. getClassName(): string;
  140547. /**
  140548. * Returns the integer 0.
  140549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140550. */
  140551. getTypeID(): number;
  140552. /**
  140553. * Specifies wether or not the shadowmap should be a cube texture.
  140554. * @returns true if the shadowmap needs to be a cube texture.
  140555. */
  140556. needCube(): boolean;
  140557. /**
  140558. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140559. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140560. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140561. */
  140562. getShadowDirection(faceIndex?: number): Vector3;
  140563. /**
  140564. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140565. * - fov = PI / 2
  140566. * - aspect ratio : 1.0
  140567. * - z-near and far equal to the active camera minZ and maxZ.
  140568. * Returns the PointLight.
  140569. */
  140570. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140571. protected _buildUniformLayout(): void;
  140572. /**
  140573. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140574. * @param effect The effect to update
  140575. * @param lightIndex The index of the light in the effect to update
  140576. * @returns The point light
  140577. */
  140578. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140580. /**
  140581. * Prepares the list of defines specific to the light type.
  140582. * @param defines the list of defines
  140583. * @param lightIndex defines the index of the light for the effect
  140584. */
  140585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140586. }
  140587. }
  140588. declare module BABYLON {
  140589. /**
  140590. * Header information of HDR texture files.
  140591. */
  140592. export interface HDRInfo {
  140593. /**
  140594. * The height of the texture in pixels.
  140595. */
  140596. height: number;
  140597. /**
  140598. * The width of the texture in pixels.
  140599. */
  140600. width: number;
  140601. /**
  140602. * The index of the beginning of the data in the binary file.
  140603. */
  140604. dataPosition: number;
  140605. }
  140606. /**
  140607. * This groups tools to convert HDR texture to native colors array.
  140608. */
  140609. export class HDRTools {
  140610. private static Ldexp;
  140611. private static Rgbe2float;
  140612. private static readStringLine;
  140613. /**
  140614. * Reads header information from an RGBE texture stored in a native array.
  140615. * More information on this format are available here:
  140616. * https://en.wikipedia.org/wiki/RGBE_image_format
  140617. *
  140618. * @param uint8array The binary file stored in native array.
  140619. * @return The header information.
  140620. */
  140621. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140622. /**
  140623. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140624. * This RGBE texture needs to store the information as a panorama.
  140625. *
  140626. * More information on this format are available here:
  140627. * https://en.wikipedia.org/wiki/RGBE_image_format
  140628. *
  140629. * @param buffer The binary file stored in an array buffer.
  140630. * @param size The expected size of the extracted cubemap.
  140631. * @return The Cube Map information.
  140632. */
  140633. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140634. /**
  140635. * Returns the pixels data extracted from an RGBE texture.
  140636. * This pixels will be stored left to right up to down in the R G B order in one array.
  140637. *
  140638. * More information on this format are available here:
  140639. * https://en.wikipedia.org/wiki/RGBE_image_format
  140640. *
  140641. * @param uint8array The binary file stored in an array buffer.
  140642. * @param hdrInfo The header information of the file.
  140643. * @return The pixels data in RGB right to left up to down order.
  140644. */
  140645. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140646. private static RGBE_ReadPixels_RLE;
  140647. private static RGBE_ReadPixels_NOT_RLE;
  140648. }
  140649. }
  140650. declare module BABYLON {
  140651. /**
  140652. * Effect Render Options
  140653. */
  140654. export interface IEffectRendererOptions {
  140655. /**
  140656. * Defines the vertices positions.
  140657. */
  140658. positions?: number[];
  140659. /**
  140660. * Defines the indices.
  140661. */
  140662. indices?: number[];
  140663. }
  140664. /**
  140665. * Helper class to render one or more effects.
  140666. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140667. */
  140668. export class EffectRenderer {
  140669. private engine;
  140670. private static _DefaultOptions;
  140671. private _vertexBuffers;
  140672. private _indexBuffer;
  140673. private _fullscreenViewport;
  140674. /**
  140675. * Creates an effect renderer
  140676. * @param engine the engine to use for rendering
  140677. * @param options defines the options of the effect renderer
  140678. */
  140679. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140680. /**
  140681. * Sets the current viewport in normalized coordinates 0-1
  140682. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140683. */
  140684. setViewport(viewport?: Viewport): void;
  140685. /**
  140686. * Binds the embedded attributes buffer to the effect.
  140687. * @param effect Defines the effect to bind the attributes for
  140688. */
  140689. bindBuffers(effect: Effect): void;
  140690. /**
  140691. * Sets the current effect wrapper to use during draw.
  140692. * The effect needs to be ready before calling this api.
  140693. * This also sets the default full screen position attribute.
  140694. * @param effectWrapper Defines the effect to draw with
  140695. */
  140696. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140697. /**
  140698. * Restores engine states
  140699. */
  140700. restoreStates(): void;
  140701. /**
  140702. * Draws a full screen quad.
  140703. */
  140704. draw(): void;
  140705. private isRenderTargetTexture;
  140706. /**
  140707. * renders one or more effects to a specified texture
  140708. * @param effectWrapper the effect to renderer
  140709. * @param outputTexture texture to draw to, if null it will render to the screen.
  140710. */
  140711. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140712. /**
  140713. * Disposes of the effect renderer
  140714. */
  140715. dispose(): void;
  140716. }
  140717. /**
  140718. * Options to create an EffectWrapper
  140719. */
  140720. interface EffectWrapperCreationOptions {
  140721. /**
  140722. * Engine to use to create the effect
  140723. */
  140724. engine: ThinEngine;
  140725. /**
  140726. * Fragment shader for the effect
  140727. */
  140728. fragmentShader: string;
  140729. /**
  140730. * Use the shader store instead of direct source code
  140731. */
  140732. useShaderStore?: boolean;
  140733. /**
  140734. * Vertex shader for the effect
  140735. */
  140736. vertexShader?: string;
  140737. /**
  140738. * Attributes to use in the shader
  140739. */
  140740. attributeNames?: Array<string>;
  140741. /**
  140742. * Uniforms to use in the shader
  140743. */
  140744. uniformNames?: Array<string>;
  140745. /**
  140746. * Texture sampler names to use in the shader
  140747. */
  140748. samplerNames?: Array<string>;
  140749. /**
  140750. * Defines to use in the shader
  140751. */
  140752. defines?: Array<string>;
  140753. /**
  140754. * Callback when effect is compiled
  140755. */
  140756. onCompiled?: Nullable<(effect: Effect) => void>;
  140757. /**
  140758. * The friendly name of the effect displayed in Spector.
  140759. */
  140760. name?: string;
  140761. }
  140762. /**
  140763. * Wraps an effect to be used for rendering
  140764. */
  140765. export class EffectWrapper {
  140766. /**
  140767. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140768. */
  140769. onApplyObservable: Observable<{}>;
  140770. /**
  140771. * The underlying effect
  140772. */
  140773. effect: Effect;
  140774. /**
  140775. * Creates an effect to be renderer
  140776. * @param creationOptions options to create the effect
  140777. */
  140778. constructor(creationOptions: EffectWrapperCreationOptions);
  140779. /**
  140780. * Disposes of the effect wrapper
  140781. */
  140782. dispose(): void;
  140783. }
  140784. }
  140785. declare module BABYLON {
  140786. /** @hidden */
  140787. export var hdrFilteringVertexShader: {
  140788. name: string;
  140789. shader: string;
  140790. };
  140791. }
  140792. declare module BABYLON {
  140793. /** @hidden */
  140794. export var hdrFilteringPixelShader: {
  140795. name: string;
  140796. shader: string;
  140797. };
  140798. }
  140799. declare module BABYLON {
  140800. /**
  140801. * Options for texture filtering
  140802. */
  140803. interface IHDRFilteringOptions {
  140804. /**
  140805. * Scales pixel intensity for the input HDR map.
  140806. */
  140807. hdrScale?: number;
  140808. /**
  140809. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140810. */
  140811. quality?: number;
  140812. }
  140813. /**
  140814. * Filters HDR maps to get correct renderings of PBR reflections
  140815. */
  140816. export class HDRFiltering {
  140817. private _engine;
  140818. private _effectRenderer;
  140819. private _effectWrapper;
  140820. private _lodGenerationOffset;
  140821. private _lodGenerationScale;
  140822. /**
  140823. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140824. * you care about baking speed.
  140825. */
  140826. quality: number;
  140827. /**
  140828. * Scales pixel intensity for the input HDR map.
  140829. */
  140830. hdrScale: number;
  140831. /**
  140832. * Instantiates HDR filter for reflection maps
  140833. *
  140834. * @param engine Thin engine
  140835. * @param options Options
  140836. */
  140837. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140838. private _createRenderTarget;
  140839. private _prefilterInternal;
  140840. private _createEffect;
  140841. /**
  140842. * Get a value indicating if the filter is ready to be used
  140843. * @param texture Texture to filter
  140844. * @returns true if the filter is ready
  140845. */
  140846. isReady(texture: BaseTexture): boolean;
  140847. /**
  140848. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140849. * Prefiltering will be invoked at the end of next rendering pass.
  140850. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140851. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140852. * @param texture Texture to filter
  140853. * @param onFinished Callback when filtering is done
  140854. * @return Promise called when prefiltering is done
  140855. */
  140856. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140857. }
  140858. }
  140859. declare module BABYLON {
  140860. /**
  140861. * This represents a texture coming from an HDR input.
  140862. *
  140863. * The only supported format is currently panorama picture stored in RGBE format.
  140864. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140865. */
  140866. export class HDRCubeTexture extends BaseTexture {
  140867. private static _facesMapping;
  140868. private _generateHarmonics;
  140869. private _noMipmap;
  140870. private _prefilterOnLoad;
  140871. private _textureMatrix;
  140872. private _size;
  140873. private _onLoad;
  140874. private _onError;
  140875. /**
  140876. * The texture URL.
  140877. */
  140878. url: string;
  140879. protected _isBlocking: boolean;
  140880. /**
  140881. * Sets wether or not the texture is blocking during loading.
  140882. */
  140883. set isBlocking(value: boolean);
  140884. /**
  140885. * Gets wether or not the texture is blocking during loading.
  140886. */
  140887. get isBlocking(): boolean;
  140888. protected _rotationY: number;
  140889. /**
  140890. * Sets texture matrix rotation angle around Y axis in radians.
  140891. */
  140892. set rotationY(value: number);
  140893. /**
  140894. * Gets texture matrix rotation angle around Y axis radians.
  140895. */
  140896. get rotationY(): number;
  140897. /**
  140898. * Gets or sets the center of the bounding box associated with the cube texture
  140899. * It must define where the camera used to render the texture was set
  140900. */
  140901. boundingBoxPosition: Vector3;
  140902. private _boundingBoxSize;
  140903. /**
  140904. * Gets or sets the size of the bounding box associated with the cube texture
  140905. * When defined, the cubemap will switch to local mode
  140906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140907. * @example https://www.babylonjs-playground.com/#RNASML
  140908. */
  140909. set boundingBoxSize(value: Vector3);
  140910. get boundingBoxSize(): Vector3;
  140911. /**
  140912. * Instantiates an HDRTexture from the following parameters.
  140913. *
  140914. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140915. * @param sceneOrEngine The scene or engine the texture will be used in
  140916. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140917. * @param noMipmap Forces to not generate the mipmap if true
  140918. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140919. * @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)
  140920. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140921. */
  140922. 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>);
  140923. /**
  140924. * Get the current class name of the texture useful for serialization or dynamic coding.
  140925. * @returns "HDRCubeTexture"
  140926. */
  140927. getClassName(): string;
  140928. /**
  140929. * Occurs when the file is raw .hdr file.
  140930. */
  140931. private loadTexture;
  140932. clone(): HDRCubeTexture;
  140933. delayLoad(): void;
  140934. /**
  140935. * Get the texture reflection matrix used to rotate/transform the reflection.
  140936. * @returns the reflection matrix
  140937. */
  140938. getReflectionTextureMatrix(): Matrix;
  140939. /**
  140940. * Set the texture reflection matrix used to rotate/transform the reflection.
  140941. * @param value Define the reflection matrix to set
  140942. */
  140943. setReflectionTextureMatrix(value: Matrix): void;
  140944. /**
  140945. * Parses a JSON representation of an HDR Texture in order to create the texture
  140946. * @param parsedTexture Define the JSON representation
  140947. * @param scene Define the scene the texture should be created in
  140948. * @param rootUrl Define the root url in case we need to load relative dependencies
  140949. * @returns the newly created texture after parsing
  140950. */
  140951. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140952. serialize(): any;
  140953. }
  140954. }
  140955. declare module BABYLON {
  140956. /**
  140957. * Class used to control physics engine
  140958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140959. */
  140960. export class PhysicsEngine implements IPhysicsEngine {
  140961. private _physicsPlugin;
  140962. /**
  140963. * Global value used to control the smallest number supported by the simulation
  140964. */
  140965. static Epsilon: number;
  140966. private _impostors;
  140967. private _joints;
  140968. private _subTimeStep;
  140969. /**
  140970. * Gets the gravity vector used by the simulation
  140971. */
  140972. gravity: Vector3;
  140973. /**
  140974. * Factory used to create the default physics plugin.
  140975. * @returns The default physics plugin
  140976. */
  140977. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140978. /**
  140979. * Creates a new Physics Engine
  140980. * @param gravity defines the gravity vector used by the simulation
  140981. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140982. */
  140983. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140984. /**
  140985. * Sets the gravity vector used by the simulation
  140986. * @param gravity defines the gravity vector to use
  140987. */
  140988. setGravity(gravity: Vector3): void;
  140989. /**
  140990. * Set the time step of the physics engine.
  140991. * Default is 1/60.
  140992. * To slow it down, enter 1/600 for example.
  140993. * To speed it up, 1/30
  140994. * @param newTimeStep defines the new timestep to apply to this world.
  140995. */
  140996. setTimeStep(newTimeStep?: number): void;
  140997. /**
  140998. * Get the time step of the physics engine.
  140999. * @returns the current time step
  141000. */
  141001. getTimeStep(): number;
  141002. /**
  141003. * Set the sub time step of the physics engine.
  141004. * Default is 0 meaning there is no sub steps
  141005. * To increase physics resolution precision, set a small value (like 1 ms)
  141006. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141007. */
  141008. setSubTimeStep(subTimeStep?: number): void;
  141009. /**
  141010. * Get the sub time step of the physics engine.
  141011. * @returns the current sub time step
  141012. */
  141013. getSubTimeStep(): number;
  141014. /**
  141015. * Release all resources
  141016. */
  141017. dispose(): void;
  141018. /**
  141019. * Gets the name of the current physics plugin
  141020. * @returns the name of the plugin
  141021. */
  141022. getPhysicsPluginName(): string;
  141023. /**
  141024. * Adding a new impostor for the impostor tracking.
  141025. * This will be done by the impostor itself.
  141026. * @param impostor the impostor to add
  141027. */
  141028. addImpostor(impostor: PhysicsImpostor): void;
  141029. /**
  141030. * Remove an impostor from the engine.
  141031. * This impostor and its mesh will not longer be updated by the physics engine.
  141032. * @param impostor the impostor to remove
  141033. */
  141034. removeImpostor(impostor: PhysicsImpostor): void;
  141035. /**
  141036. * Add a joint to the physics engine
  141037. * @param mainImpostor defines the main impostor to which the joint is added.
  141038. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141039. * @param joint defines the joint that will connect both impostors.
  141040. */
  141041. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141042. /**
  141043. * Removes a joint from the simulation
  141044. * @param mainImpostor defines the impostor used with the joint
  141045. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141046. * @param joint defines the joint to remove
  141047. */
  141048. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141049. /**
  141050. * Called by the scene. No need to call it.
  141051. * @param delta defines the timespam between frames
  141052. */
  141053. _step(delta: number): void;
  141054. /**
  141055. * Gets the current plugin used to run the simulation
  141056. * @returns current plugin
  141057. */
  141058. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141059. /**
  141060. * Gets the list of physic impostors
  141061. * @returns an array of PhysicsImpostor
  141062. */
  141063. getImpostors(): Array<PhysicsImpostor>;
  141064. /**
  141065. * Gets the impostor for a physics enabled object
  141066. * @param object defines the object impersonated by the impostor
  141067. * @returns the PhysicsImpostor or null if not found
  141068. */
  141069. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141070. /**
  141071. * Gets the impostor for a physics body object
  141072. * @param body defines physics body used by the impostor
  141073. * @returns the PhysicsImpostor or null if not found
  141074. */
  141075. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141076. /**
  141077. * Does a raycast in the physics world
  141078. * @param from when should the ray start?
  141079. * @param to when should the ray end?
  141080. * @returns PhysicsRaycastResult
  141081. */
  141082. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141083. }
  141084. }
  141085. declare module BABYLON {
  141086. /** @hidden */
  141087. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141088. private _useDeltaForWorldStep;
  141089. world: any;
  141090. name: string;
  141091. private _physicsMaterials;
  141092. private _fixedTimeStep;
  141093. private _cannonRaycastResult;
  141094. private _raycastResult;
  141095. private _physicsBodysToRemoveAfterStep;
  141096. private _firstFrame;
  141097. BJSCANNON: any;
  141098. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141099. setGravity(gravity: Vector3): void;
  141100. setTimeStep(timeStep: number): void;
  141101. getTimeStep(): number;
  141102. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141103. private _removeMarkedPhysicsBodiesFromWorld;
  141104. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141105. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141106. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141107. private _processChildMeshes;
  141108. removePhysicsBody(impostor: PhysicsImpostor): void;
  141109. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141110. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141111. private _addMaterial;
  141112. private _checkWithEpsilon;
  141113. private _createShape;
  141114. private _createHeightmap;
  141115. private _minus90X;
  141116. private _plus90X;
  141117. private _tmpPosition;
  141118. private _tmpDeltaPosition;
  141119. private _tmpUnityRotation;
  141120. private _updatePhysicsBodyTransformation;
  141121. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141122. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141123. isSupported(): boolean;
  141124. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141125. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141126. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141127. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141128. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141129. getBodyMass(impostor: PhysicsImpostor): number;
  141130. getBodyFriction(impostor: PhysicsImpostor): number;
  141131. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141132. getBodyRestitution(impostor: PhysicsImpostor): number;
  141133. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141134. sleepBody(impostor: PhysicsImpostor): void;
  141135. wakeUpBody(impostor: PhysicsImpostor): void;
  141136. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141137. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141138. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141139. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141140. getRadius(impostor: PhysicsImpostor): number;
  141141. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141142. dispose(): void;
  141143. private _extendNamespace;
  141144. /**
  141145. * Does a raycast in the physics world
  141146. * @param from when should the ray start?
  141147. * @param to when should the ray end?
  141148. * @returns PhysicsRaycastResult
  141149. */
  141150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141151. }
  141152. }
  141153. declare module BABYLON {
  141154. /** @hidden */
  141155. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141156. private _useDeltaForWorldStep;
  141157. world: any;
  141158. name: string;
  141159. BJSOIMO: any;
  141160. private _raycastResult;
  141161. private _fixedTimeStep;
  141162. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141163. setGravity(gravity: Vector3): void;
  141164. setTimeStep(timeStep: number): void;
  141165. getTimeStep(): number;
  141166. private _tmpImpostorsArray;
  141167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141171. private _tmpPositionVector;
  141172. removePhysicsBody(impostor: PhysicsImpostor): void;
  141173. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141174. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141175. isSupported(): boolean;
  141176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141183. getBodyMass(impostor: PhysicsImpostor): number;
  141184. getBodyFriction(impostor: PhysicsImpostor): number;
  141185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141186. getBodyRestitution(impostor: PhysicsImpostor): number;
  141187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141188. sleepBody(impostor: PhysicsImpostor): void;
  141189. wakeUpBody(impostor: PhysicsImpostor): void;
  141190. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141191. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141192. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141193. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141194. getRadius(impostor: PhysicsImpostor): number;
  141195. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141196. dispose(): void;
  141197. /**
  141198. * Does a raycast in the physics world
  141199. * @param from when should the ray start?
  141200. * @param to when should the ray end?
  141201. * @returns PhysicsRaycastResult
  141202. */
  141203. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141204. }
  141205. }
  141206. declare module BABYLON {
  141207. /**
  141208. * AmmoJS Physics plugin
  141209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141210. * @see https://github.com/kripken/ammo.js/
  141211. */
  141212. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141213. private _useDeltaForWorldStep;
  141214. /**
  141215. * Reference to the Ammo library
  141216. */
  141217. bjsAMMO: any;
  141218. /**
  141219. * Created ammoJS world which physics bodies are added to
  141220. */
  141221. world: any;
  141222. /**
  141223. * Name of the plugin
  141224. */
  141225. name: string;
  141226. private _timeStep;
  141227. private _fixedTimeStep;
  141228. private _maxSteps;
  141229. private _tmpQuaternion;
  141230. private _tmpAmmoTransform;
  141231. private _tmpAmmoQuaternion;
  141232. private _tmpAmmoConcreteContactResultCallback;
  141233. private _collisionConfiguration;
  141234. private _dispatcher;
  141235. private _overlappingPairCache;
  141236. private _solver;
  141237. private _softBodySolver;
  141238. private _tmpAmmoVectorA;
  141239. private _tmpAmmoVectorB;
  141240. private _tmpAmmoVectorC;
  141241. private _tmpAmmoVectorD;
  141242. private _tmpContactCallbackResult;
  141243. private _tmpAmmoVectorRCA;
  141244. private _tmpAmmoVectorRCB;
  141245. private _raycastResult;
  141246. private static readonly DISABLE_COLLISION_FLAG;
  141247. private static readonly KINEMATIC_FLAG;
  141248. private static readonly DISABLE_DEACTIVATION_FLAG;
  141249. /**
  141250. * Initializes the ammoJS plugin
  141251. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141252. * @param ammoInjection can be used to inject your own ammo reference
  141253. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141254. */
  141255. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141256. /**
  141257. * Sets the gravity of the physics world (m/(s^2))
  141258. * @param gravity Gravity to set
  141259. */
  141260. setGravity(gravity: Vector3): void;
  141261. /**
  141262. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141263. * @param timeStep timestep to use in seconds
  141264. */
  141265. setTimeStep(timeStep: number): void;
  141266. /**
  141267. * 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)
  141268. * @param fixedTimeStep fixedTimeStep to use in seconds
  141269. */
  141270. setFixedTimeStep(fixedTimeStep: number): void;
  141271. /**
  141272. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141273. * @param maxSteps the maximum number of steps by the physics engine per frame
  141274. */
  141275. setMaxSteps(maxSteps: number): void;
  141276. /**
  141277. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141278. * @returns the current timestep in seconds
  141279. */
  141280. getTimeStep(): number;
  141281. /**
  141282. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141283. */
  141284. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141285. private _isImpostorInContact;
  141286. private _isImpostorPairInContact;
  141287. private _stepSimulation;
  141288. /**
  141289. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141290. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141291. * After the step the babylon meshes are set to the position of the physics imposters
  141292. * @param delta amount of time to step forward
  141293. * @param impostors array of imposters to update before/after the step
  141294. */
  141295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141296. /**
  141297. * Update babylon mesh to match physics world object
  141298. * @param impostor imposter to match
  141299. */
  141300. private _afterSoftStep;
  141301. /**
  141302. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141303. * @param impostor imposter to match
  141304. */
  141305. private _ropeStep;
  141306. /**
  141307. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141308. * @param impostor imposter to match
  141309. */
  141310. private _softbodyOrClothStep;
  141311. private _tmpMatrix;
  141312. /**
  141313. * Applies an impulse on the imposter
  141314. * @param impostor imposter to apply impulse to
  141315. * @param force amount of force to be applied to the imposter
  141316. * @param contactPoint the location to apply the impulse on the imposter
  141317. */
  141318. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141319. /**
  141320. * Applies a force on the imposter
  141321. * @param impostor imposter to apply force
  141322. * @param force amount of force to be applied to the imposter
  141323. * @param contactPoint the location to apply the force on the imposter
  141324. */
  141325. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141326. /**
  141327. * Creates a physics body using the plugin
  141328. * @param impostor the imposter to create the physics body on
  141329. */
  141330. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141331. /**
  141332. * Removes the physics body from the imposter and disposes of the body's memory
  141333. * @param impostor imposter to remove the physics body from
  141334. */
  141335. removePhysicsBody(impostor: PhysicsImpostor): void;
  141336. /**
  141337. * Generates a joint
  141338. * @param impostorJoint the imposter joint to create the joint with
  141339. */
  141340. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141341. /**
  141342. * Removes a joint
  141343. * @param impostorJoint the imposter joint to remove the joint from
  141344. */
  141345. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141346. private _addMeshVerts;
  141347. /**
  141348. * Initialise the soft body vertices to match its object's (mesh) vertices
  141349. * Softbody vertices (nodes) are in world space and to match this
  141350. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141351. * @param impostor to create the softbody for
  141352. */
  141353. private _softVertexData;
  141354. /**
  141355. * Create an impostor's soft body
  141356. * @param impostor to create the softbody for
  141357. */
  141358. private _createSoftbody;
  141359. /**
  141360. * Create cloth for an impostor
  141361. * @param impostor to create the softbody for
  141362. */
  141363. private _createCloth;
  141364. /**
  141365. * Create rope for an impostor
  141366. * @param impostor to create the softbody for
  141367. */
  141368. private _createRope;
  141369. /**
  141370. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141371. * @param impostor to create the custom physics shape for
  141372. */
  141373. private _createCustom;
  141374. private _addHullVerts;
  141375. private _createShape;
  141376. /**
  141377. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141378. * @param impostor imposter containing the physics body and babylon object
  141379. */
  141380. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141381. /**
  141382. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141383. * @param impostor imposter containing the physics body and babylon object
  141384. * @param newPosition new position
  141385. * @param newRotation new rotation
  141386. */
  141387. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141388. /**
  141389. * If this plugin is supported
  141390. * @returns true if its supported
  141391. */
  141392. isSupported(): boolean;
  141393. /**
  141394. * Sets the linear velocity of the physics body
  141395. * @param impostor imposter to set the velocity on
  141396. * @param velocity velocity to set
  141397. */
  141398. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141399. /**
  141400. * Sets the angular velocity of the physics body
  141401. * @param impostor imposter to set the velocity on
  141402. * @param velocity velocity to set
  141403. */
  141404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141405. /**
  141406. * gets the linear velocity
  141407. * @param impostor imposter to get linear velocity from
  141408. * @returns linear velocity
  141409. */
  141410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141411. /**
  141412. * gets the angular velocity
  141413. * @param impostor imposter to get angular velocity from
  141414. * @returns angular velocity
  141415. */
  141416. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141417. /**
  141418. * Sets the mass of physics body
  141419. * @param impostor imposter to set the mass on
  141420. * @param mass mass to set
  141421. */
  141422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141423. /**
  141424. * Gets the mass of the physics body
  141425. * @param impostor imposter to get the mass from
  141426. * @returns mass
  141427. */
  141428. getBodyMass(impostor: PhysicsImpostor): number;
  141429. /**
  141430. * Gets friction of the impostor
  141431. * @param impostor impostor to get friction from
  141432. * @returns friction value
  141433. */
  141434. getBodyFriction(impostor: PhysicsImpostor): number;
  141435. /**
  141436. * Sets friction of the impostor
  141437. * @param impostor impostor to set friction on
  141438. * @param friction friction value
  141439. */
  141440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141441. /**
  141442. * Gets restitution of the impostor
  141443. * @param impostor impostor to get restitution from
  141444. * @returns restitution value
  141445. */
  141446. getBodyRestitution(impostor: PhysicsImpostor): number;
  141447. /**
  141448. * Sets resitution of the impostor
  141449. * @param impostor impostor to set resitution on
  141450. * @param restitution resitution value
  141451. */
  141452. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141453. /**
  141454. * Gets pressure inside the impostor
  141455. * @param impostor impostor to get pressure from
  141456. * @returns pressure value
  141457. */
  141458. getBodyPressure(impostor: PhysicsImpostor): number;
  141459. /**
  141460. * Sets pressure inside a soft body impostor
  141461. * Cloth and rope must remain 0 pressure
  141462. * @param impostor impostor to set pressure on
  141463. * @param pressure pressure value
  141464. */
  141465. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141466. /**
  141467. * Gets stiffness of the impostor
  141468. * @param impostor impostor to get stiffness from
  141469. * @returns pressure value
  141470. */
  141471. getBodyStiffness(impostor: PhysicsImpostor): number;
  141472. /**
  141473. * Sets stiffness of the impostor
  141474. * @param impostor impostor to set stiffness on
  141475. * @param stiffness stiffness value from 0 to 1
  141476. */
  141477. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141478. /**
  141479. * Gets velocityIterations of the impostor
  141480. * @param impostor impostor to get velocity iterations from
  141481. * @returns velocityIterations value
  141482. */
  141483. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141484. /**
  141485. * Sets velocityIterations of the impostor
  141486. * @param impostor impostor to set velocity iterations on
  141487. * @param velocityIterations velocityIterations value
  141488. */
  141489. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141490. /**
  141491. * Gets positionIterations of the impostor
  141492. * @param impostor impostor to get position iterations from
  141493. * @returns positionIterations value
  141494. */
  141495. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141496. /**
  141497. * Sets positionIterations of the impostor
  141498. * @param impostor impostor to set position on
  141499. * @param positionIterations positionIterations value
  141500. */
  141501. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141502. /**
  141503. * Append an anchor to a cloth object
  141504. * @param impostor is the cloth impostor to add anchor to
  141505. * @param otherImpostor is the rigid impostor to anchor to
  141506. * @param width ratio across width from 0 to 1
  141507. * @param height ratio up height from 0 to 1
  141508. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141509. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141510. */
  141511. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141512. /**
  141513. * Append an hook to a rope object
  141514. * @param impostor is the rope impostor to add hook to
  141515. * @param otherImpostor is the rigid impostor to hook to
  141516. * @param length ratio along the rope from 0 to 1
  141517. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141518. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141519. */
  141520. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141521. /**
  141522. * Sleeps the physics body and stops it from being active
  141523. * @param impostor impostor to sleep
  141524. */
  141525. sleepBody(impostor: PhysicsImpostor): void;
  141526. /**
  141527. * Activates the physics body
  141528. * @param impostor impostor to activate
  141529. */
  141530. wakeUpBody(impostor: PhysicsImpostor): void;
  141531. /**
  141532. * Updates the distance parameters of the joint
  141533. * @param joint joint to update
  141534. * @param maxDistance maximum distance of the joint
  141535. * @param minDistance minimum distance of the joint
  141536. */
  141537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141538. /**
  141539. * Sets a motor on the joint
  141540. * @param joint joint to set motor on
  141541. * @param speed speed of the motor
  141542. * @param maxForce maximum force of the motor
  141543. * @param motorIndex index of the motor
  141544. */
  141545. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141546. /**
  141547. * Sets the motors limit
  141548. * @param joint joint to set limit on
  141549. * @param upperLimit upper limit
  141550. * @param lowerLimit lower limit
  141551. */
  141552. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141553. /**
  141554. * Syncs the position and rotation of a mesh with the impostor
  141555. * @param mesh mesh to sync
  141556. * @param impostor impostor to update the mesh with
  141557. */
  141558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141559. /**
  141560. * Gets the radius of the impostor
  141561. * @param impostor impostor to get radius from
  141562. * @returns the radius
  141563. */
  141564. getRadius(impostor: PhysicsImpostor): number;
  141565. /**
  141566. * Gets the box size of the impostor
  141567. * @param impostor impostor to get box size from
  141568. * @param result the resulting box size
  141569. */
  141570. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141571. /**
  141572. * Disposes of the impostor
  141573. */
  141574. dispose(): void;
  141575. /**
  141576. * Does a raycast in the physics world
  141577. * @param from when should the ray start?
  141578. * @param to when should the ray end?
  141579. * @returns PhysicsRaycastResult
  141580. */
  141581. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141582. }
  141583. }
  141584. declare module BABYLON {
  141585. interface AbstractScene {
  141586. /**
  141587. * The list of reflection probes added to the scene
  141588. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141589. */
  141590. reflectionProbes: Array<ReflectionProbe>;
  141591. /**
  141592. * Removes the given reflection probe from this scene.
  141593. * @param toRemove The reflection probe to remove
  141594. * @returns The index of the removed reflection probe
  141595. */
  141596. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141597. /**
  141598. * Adds the given reflection probe to this scene.
  141599. * @param newReflectionProbe The reflection probe to add
  141600. */
  141601. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141602. }
  141603. /**
  141604. * Class used to generate realtime reflection / refraction cube textures
  141605. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141606. */
  141607. export class ReflectionProbe {
  141608. /** defines the name of the probe */
  141609. name: string;
  141610. private _scene;
  141611. private _renderTargetTexture;
  141612. private _projectionMatrix;
  141613. private _viewMatrix;
  141614. private _target;
  141615. private _add;
  141616. private _attachedMesh;
  141617. private _invertYAxis;
  141618. /** Gets or sets probe position (center of the cube map) */
  141619. position: Vector3;
  141620. /**
  141621. * Creates a new reflection probe
  141622. * @param name defines the name of the probe
  141623. * @param size defines the texture resolution (for each face)
  141624. * @param scene defines the hosting scene
  141625. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141626. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141627. */
  141628. constructor(
  141629. /** defines the name of the probe */
  141630. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141631. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141632. get samples(): number;
  141633. set samples(value: number);
  141634. /** Gets or sets the refresh rate to use (on every frame by default) */
  141635. get refreshRate(): number;
  141636. set refreshRate(value: number);
  141637. /**
  141638. * Gets the hosting scene
  141639. * @returns a Scene
  141640. */
  141641. getScene(): Scene;
  141642. /** Gets the internal CubeTexture used to render to */
  141643. get cubeTexture(): RenderTargetTexture;
  141644. /** Gets the list of meshes to render */
  141645. get renderList(): Nullable<AbstractMesh[]>;
  141646. /**
  141647. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141648. * @param mesh defines the mesh to attach to
  141649. */
  141650. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141651. /**
  141652. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141653. * @param renderingGroupId The rendering group id corresponding to its index
  141654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141655. */
  141656. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141657. /**
  141658. * Clean all associated resources
  141659. */
  141660. dispose(): void;
  141661. /**
  141662. * Converts the reflection probe information to a readable string for debug purpose.
  141663. * @param fullDetails Supports for multiple levels of logging within scene loading
  141664. * @returns the human readable reflection probe info
  141665. */
  141666. toString(fullDetails?: boolean): string;
  141667. /**
  141668. * Get the class name of the relfection probe.
  141669. * @returns "ReflectionProbe"
  141670. */
  141671. getClassName(): string;
  141672. /**
  141673. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141674. * @returns The JSON representation of the texture
  141675. */
  141676. serialize(): any;
  141677. /**
  141678. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141679. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141680. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141681. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141682. * @returns The parsed reflection probe if successful
  141683. */
  141684. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141685. }
  141686. }
  141687. declare module BABYLON {
  141688. /** @hidden */
  141689. export var _BabylonLoaderRegistered: boolean;
  141690. /**
  141691. * Helps setting up some configuration for the babylon file loader.
  141692. */
  141693. export class BabylonFileLoaderConfiguration {
  141694. /**
  141695. * The loader does not allow injecting custom physix engine into the plugins.
  141696. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141697. * So you could set this variable to your engine import to make it work.
  141698. */
  141699. static LoaderInjectedPhysicsEngine: any;
  141700. }
  141701. }
  141702. declare module BABYLON {
  141703. /**
  141704. * The Physically based simple base material of BJS.
  141705. *
  141706. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141707. * It is used as the base class for both the specGloss and metalRough conventions.
  141708. */
  141709. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141710. /**
  141711. * Number of Simultaneous lights allowed on the material.
  141712. */
  141713. maxSimultaneousLights: number;
  141714. /**
  141715. * If sets to true, disables all the lights affecting the material.
  141716. */
  141717. disableLighting: boolean;
  141718. /**
  141719. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141720. */
  141721. environmentTexture: BaseTexture;
  141722. /**
  141723. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141724. */
  141725. invertNormalMapX: boolean;
  141726. /**
  141727. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141728. */
  141729. invertNormalMapY: boolean;
  141730. /**
  141731. * Normal map used in the model.
  141732. */
  141733. normalTexture: BaseTexture;
  141734. /**
  141735. * Emissivie color used to self-illuminate the model.
  141736. */
  141737. emissiveColor: Color3;
  141738. /**
  141739. * Emissivie texture used to self-illuminate the model.
  141740. */
  141741. emissiveTexture: BaseTexture;
  141742. /**
  141743. * Occlusion Channel Strenght.
  141744. */
  141745. occlusionStrength: number;
  141746. /**
  141747. * Occlusion Texture of the material (adding extra occlusion effects).
  141748. */
  141749. occlusionTexture: BaseTexture;
  141750. /**
  141751. * Defines the alpha limits in alpha test mode.
  141752. */
  141753. alphaCutOff: number;
  141754. /**
  141755. * Gets the current double sided mode.
  141756. */
  141757. get doubleSided(): boolean;
  141758. /**
  141759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141760. */
  141761. set doubleSided(value: boolean);
  141762. /**
  141763. * Stores the pre-calculated light information of a mesh in a texture.
  141764. */
  141765. lightmapTexture: BaseTexture;
  141766. /**
  141767. * If true, the light map contains occlusion information instead of lighting info.
  141768. */
  141769. useLightmapAsShadowmap: boolean;
  141770. /**
  141771. * Instantiates a new PBRMaterial instance.
  141772. *
  141773. * @param name The material name
  141774. * @param scene The scene the material will be use in.
  141775. */
  141776. constructor(name: string, scene: Scene);
  141777. getClassName(): string;
  141778. }
  141779. }
  141780. declare module BABYLON {
  141781. /**
  141782. * The PBR material of BJS following the metal roughness convention.
  141783. *
  141784. * This fits to the PBR convention in the GLTF definition:
  141785. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141786. */
  141787. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141788. /**
  141789. * The base color has two different interpretations depending on the value of metalness.
  141790. * When the material is a metal, the base color is the specific measured reflectance value
  141791. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141792. * of the material.
  141793. */
  141794. baseColor: Color3;
  141795. /**
  141796. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141797. * well as opacity information in the alpha channel.
  141798. */
  141799. baseTexture: BaseTexture;
  141800. /**
  141801. * Specifies the metallic scalar value of the material.
  141802. * Can also be used to scale the metalness values of the metallic texture.
  141803. */
  141804. metallic: number;
  141805. /**
  141806. * Specifies the roughness scalar value of the material.
  141807. * Can also be used to scale the roughness values of the metallic texture.
  141808. */
  141809. roughness: number;
  141810. /**
  141811. * Texture containing both the metallic value in the B channel and the
  141812. * roughness value in the G channel to keep better precision.
  141813. */
  141814. metallicRoughnessTexture: BaseTexture;
  141815. /**
  141816. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141817. *
  141818. * @param name The material name
  141819. * @param scene The scene the material will be use in.
  141820. */
  141821. constructor(name: string, scene: Scene);
  141822. /**
  141823. * Return the currrent class name of the material.
  141824. */
  141825. getClassName(): string;
  141826. /**
  141827. * Makes a duplicate of the current material.
  141828. * @param name - name to use for the new material.
  141829. */
  141830. clone(name: string): PBRMetallicRoughnessMaterial;
  141831. /**
  141832. * Serialize the material to a parsable JSON object.
  141833. */
  141834. serialize(): any;
  141835. /**
  141836. * Parses a JSON object correponding to the serialize function.
  141837. */
  141838. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141839. }
  141840. }
  141841. declare module BABYLON {
  141842. /**
  141843. * The PBR material of BJS following the specular glossiness convention.
  141844. *
  141845. * This fits to the PBR convention in the GLTF definition:
  141846. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141847. */
  141848. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141849. /**
  141850. * Specifies the diffuse color of the material.
  141851. */
  141852. diffuseColor: Color3;
  141853. /**
  141854. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141855. * channel.
  141856. */
  141857. diffuseTexture: BaseTexture;
  141858. /**
  141859. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141860. */
  141861. specularColor: Color3;
  141862. /**
  141863. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141864. */
  141865. glossiness: number;
  141866. /**
  141867. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141868. */
  141869. specularGlossinessTexture: BaseTexture;
  141870. /**
  141871. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141872. *
  141873. * @param name The material name
  141874. * @param scene The scene the material will be use in.
  141875. */
  141876. constructor(name: string, scene: Scene);
  141877. /**
  141878. * Return the currrent class name of the material.
  141879. */
  141880. getClassName(): string;
  141881. /**
  141882. * Makes a duplicate of the current material.
  141883. * @param name - name to use for the new material.
  141884. */
  141885. clone(name: string): PBRSpecularGlossinessMaterial;
  141886. /**
  141887. * Serialize the material to a parsable JSON object.
  141888. */
  141889. serialize(): any;
  141890. /**
  141891. * Parses a JSON object correponding to the serialize function.
  141892. */
  141893. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141894. }
  141895. }
  141896. declare module BABYLON {
  141897. /**
  141898. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141899. * It can help converting any input color in a desired output one. This can then be used to create effects
  141900. * from sepia, black and white to sixties or futuristic rendering...
  141901. *
  141902. * The only supported format is currently 3dl.
  141903. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141904. */
  141905. export class ColorGradingTexture extends BaseTexture {
  141906. /**
  141907. * The texture URL.
  141908. */
  141909. url: string;
  141910. /**
  141911. * Empty line regex stored for GC.
  141912. */
  141913. private static _noneEmptyLineRegex;
  141914. private _textureMatrix;
  141915. private _onLoad;
  141916. /**
  141917. * Instantiates a ColorGradingTexture from the following parameters.
  141918. *
  141919. * @param url The location of the color gradind data (currently only supporting 3dl)
  141920. * @param sceneOrEngine The scene or engine the texture will be used in
  141921. * @param onLoad defines a callback triggered when the texture has been loaded
  141922. */
  141923. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141924. /**
  141925. * Fires the onload event from the constructor if requested.
  141926. */
  141927. private _triggerOnLoad;
  141928. /**
  141929. * Returns the texture matrix used in most of the material.
  141930. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141931. */
  141932. getTextureMatrix(): Matrix;
  141933. /**
  141934. * Occurs when the file being loaded is a .3dl LUT file.
  141935. */
  141936. private load3dlTexture;
  141937. /**
  141938. * Starts the loading process of the texture.
  141939. */
  141940. private loadTexture;
  141941. /**
  141942. * Clones the color gradind texture.
  141943. */
  141944. clone(): ColorGradingTexture;
  141945. /**
  141946. * Called during delayed load for textures.
  141947. */
  141948. delayLoad(): void;
  141949. /**
  141950. * Parses a color grading texture serialized by Babylon.
  141951. * @param parsedTexture The texture information being parsedTexture
  141952. * @param scene The scene to load the texture in
  141953. * @param rootUrl The root url of the data assets to load
  141954. * @return A color gradind texture
  141955. */
  141956. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141957. /**
  141958. * Serializes the LUT texture to json format.
  141959. */
  141960. serialize(): any;
  141961. }
  141962. }
  141963. declare module BABYLON {
  141964. /**
  141965. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141966. */
  141967. export class EquiRectangularCubeTexture extends BaseTexture {
  141968. /** The six faces of the cube. */
  141969. private static _FacesMapping;
  141970. private _noMipmap;
  141971. private _onLoad;
  141972. private _onError;
  141973. /** The size of the cubemap. */
  141974. private _size;
  141975. /** The buffer of the image. */
  141976. private _buffer;
  141977. /** The width of the input image. */
  141978. private _width;
  141979. /** The height of the input image. */
  141980. private _height;
  141981. /** The URL to the image. */
  141982. url: string;
  141983. /**
  141984. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141985. * @param url The location of the image
  141986. * @param scene The scene the texture will be used in
  141987. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141988. * @param noMipmap Forces to not generate the mipmap if true
  141989. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141990. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141991. * @param onLoad — defines a callback called when texture is loaded
  141992. * @param onError — defines a callback called if there is an error
  141993. */
  141994. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141995. /**
  141996. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141997. */
  141998. private loadImage;
  141999. /**
  142000. * Convert the image buffer into a cubemap and create a CubeTexture.
  142001. */
  142002. private loadTexture;
  142003. /**
  142004. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142005. * @param buffer The ArrayBuffer that should be converted.
  142006. * @returns The buffer as Float32Array.
  142007. */
  142008. private getFloat32ArrayFromArrayBuffer;
  142009. /**
  142010. * Get the current class name of the texture useful for serialization or dynamic coding.
  142011. * @returns "EquiRectangularCubeTexture"
  142012. */
  142013. getClassName(): string;
  142014. /**
  142015. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142016. * @returns A clone of the current EquiRectangularCubeTexture.
  142017. */
  142018. clone(): EquiRectangularCubeTexture;
  142019. }
  142020. }
  142021. declare module BABYLON {
  142022. /**
  142023. * Defines the options related to the creation of an HtmlElementTexture
  142024. */
  142025. export interface IHtmlElementTextureOptions {
  142026. /**
  142027. * Defines wether mip maps should be created or not.
  142028. */
  142029. generateMipMaps?: boolean;
  142030. /**
  142031. * Defines the sampling mode of the texture.
  142032. */
  142033. samplingMode?: number;
  142034. /**
  142035. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142036. */
  142037. engine: Nullable<ThinEngine>;
  142038. /**
  142039. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142040. */
  142041. scene: Nullable<Scene>;
  142042. }
  142043. /**
  142044. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142045. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142046. * is automatically managed.
  142047. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142048. * in your application.
  142049. *
  142050. * As the update is not automatic, you need to call them manually.
  142051. */
  142052. export class HtmlElementTexture extends BaseTexture {
  142053. /**
  142054. * The texture URL.
  142055. */
  142056. element: HTMLVideoElement | HTMLCanvasElement;
  142057. private static readonly DefaultOptions;
  142058. private _textureMatrix;
  142059. private _isVideo;
  142060. private _generateMipMaps;
  142061. private _samplingMode;
  142062. /**
  142063. * Instantiates a HtmlElementTexture from the following parameters.
  142064. *
  142065. * @param name Defines the name of the texture
  142066. * @param element Defines the video or canvas the texture is filled with
  142067. * @param options Defines the other none mandatory texture creation options
  142068. */
  142069. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142070. private _createInternalTexture;
  142071. /**
  142072. * Returns the texture matrix used in most of the material.
  142073. */
  142074. getTextureMatrix(): Matrix;
  142075. /**
  142076. * Updates the content of the texture.
  142077. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142078. */
  142079. update(invertY?: Nullable<boolean>): void;
  142080. }
  142081. }
  142082. declare module BABYLON {
  142083. /**
  142084. * Based on jsTGALoader - Javascript loader for TGA file
  142085. * By Vincent Thibault
  142086. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142087. */
  142088. export class TGATools {
  142089. private static _TYPE_INDEXED;
  142090. private static _TYPE_RGB;
  142091. private static _TYPE_GREY;
  142092. private static _TYPE_RLE_INDEXED;
  142093. private static _TYPE_RLE_RGB;
  142094. private static _TYPE_RLE_GREY;
  142095. private static _ORIGIN_MASK;
  142096. private static _ORIGIN_SHIFT;
  142097. private static _ORIGIN_BL;
  142098. private static _ORIGIN_BR;
  142099. private static _ORIGIN_UL;
  142100. private static _ORIGIN_UR;
  142101. /**
  142102. * Gets the header of a TGA file
  142103. * @param data defines the TGA data
  142104. * @returns the header
  142105. */
  142106. static GetTGAHeader(data: Uint8Array): any;
  142107. /**
  142108. * Uploads TGA content to a Babylon Texture
  142109. * @hidden
  142110. */
  142111. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142112. /** @hidden */
  142113. 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;
  142114. /** @hidden */
  142115. 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;
  142116. /** @hidden */
  142117. 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;
  142118. /** @hidden */
  142119. 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;
  142120. /** @hidden */
  142121. 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;
  142122. /** @hidden */
  142123. 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;
  142124. }
  142125. }
  142126. declare module BABYLON {
  142127. /**
  142128. * Implementation of the TGA Texture Loader.
  142129. * @hidden
  142130. */
  142131. export class _TGATextureLoader implements IInternalTextureLoader {
  142132. /**
  142133. * Defines wether the loader supports cascade loading the different faces.
  142134. */
  142135. readonly supportCascades: boolean;
  142136. /**
  142137. * This returns if the loader support the current file information.
  142138. * @param extension defines the file extension of the file being loaded
  142139. * @returns true if the loader can load the specified file
  142140. */
  142141. canLoad(extension: string): boolean;
  142142. /**
  142143. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142144. * @param data contains the texture data
  142145. * @param texture defines the BabylonJS internal texture
  142146. * @param createPolynomials will be true if polynomials have been requested
  142147. * @param onLoad defines the callback to trigger once the texture is ready
  142148. * @param onError defines the callback to trigger in case of error
  142149. */
  142150. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142151. /**
  142152. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142153. * @param data contains the texture data
  142154. * @param texture defines the BabylonJS internal texture
  142155. * @param callback defines the method to call once ready to upload
  142156. */
  142157. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142158. }
  142159. }
  142160. declare module BABYLON {
  142161. /**
  142162. * Info about the .basis files
  142163. */
  142164. class BasisFileInfo {
  142165. /**
  142166. * If the file has alpha
  142167. */
  142168. hasAlpha: boolean;
  142169. /**
  142170. * Info about each image of the basis file
  142171. */
  142172. images: Array<{
  142173. levels: Array<{
  142174. width: number;
  142175. height: number;
  142176. transcodedPixels: ArrayBufferView;
  142177. }>;
  142178. }>;
  142179. }
  142180. /**
  142181. * Result of transcoding a basis file
  142182. */
  142183. class TranscodeResult {
  142184. /**
  142185. * Info about the .basis file
  142186. */
  142187. fileInfo: BasisFileInfo;
  142188. /**
  142189. * Format to use when loading the file
  142190. */
  142191. format: number;
  142192. }
  142193. /**
  142194. * Configuration options for the Basis transcoder
  142195. */
  142196. export class BasisTranscodeConfiguration {
  142197. /**
  142198. * Supported compression formats used to determine the supported output format of the transcoder
  142199. */
  142200. supportedCompressionFormats?: {
  142201. /**
  142202. * etc1 compression format
  142203. */
  142204. etc1?: boolean;
  142205. /**
  142206. * s3tc compression format
  142207. */
  142208. s3tc?: boolean;
  142209. /**
  142210. * pvrtc compression format
  142211. */
  142212. pvrtc?: boolean;
  142213. /**
  142214. * etc2 compression format
  142215. */
  142216. etc2?: boolean;
  142217. };
  142218. /**
  142219. * If mipmap levels should be loaded for transcoded images (Default: true)
  142220. */
  142221. loadMipmapLevels?: boolean;
  142222. /**
  142223. * Index of a single image to load (Default: all images)
  142224. */
  142225. loadSingleImage?: number;
  142226. }
  142227. /**
  142228. * Used to load .Basis files
  142229. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142230. */
  142231. export class BasisTools {
  142232. private static _IgnoreSupportedFormats;
  142233. /**
  142234. * URL to use when loading the basis transcoder
  142235. */
  142236. static JSModuleURL: string;
  142237. /**
  142238. * URL to use when loading the wasm module for the transcoder
  142239. */
  142240. static WasmModuleURL: string;
  142241. /**
  142242. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142243. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142244. * @returns internal format corresponding to the Basis format
  142245. */
  142246. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142247. private static _WorkerPromise;
  142248. private static _Worker;
  142249. private static _actionId;
  142250. private static _CreateWorkerAsync;
  142251. /**
  142252. * Transcodes a loaded image file to compressed pixel data
  142253. * @param data image data to transcode
  142254. * @param config configuration options for the transcoding
  142255. * @returns a promise resulting in the transcoded image
  142256. */
  142257. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142258. /**
  142259. * Loads a texture from the transcode result
  142260. * @param texture texture load to
  142261. * @param transcodeResult the result of transcoding the basis file to load from
  142262. */
  142263. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142264. }
  142265. }
  142266. declare module BABYLON {
  142267. /**
  142268. * Loader for .basis file format
  142269. */
  142270. export class _BasisTextureLoader implements IInternalTextureLoader {
  142271. /**
  142272. * Defines whether the loader supports cascade loading the different faces.
  142273. */
  142274. readonly supportCascades: boolean;
  142275. /**
  142276. * This returns if the loader support the current file information.
  142277. * @param extension defines the file extension of the file being loaded
  142278. * @returns true if the loader can load the specified file
  142279. */
  142280. canLoad(extension: string): boolean;
  142281. /**
  142282. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142283. * @param data contains the texture data
  142284. * @param texture defines the BabylonJS internal texture
  142285. * @param createPolynomials will be true if polynomials have been requested
  142286. * @param onLoad defines the callback to trigger once the texture is ready
  142287. * @param onError defines the callback to trigger in case of error
  142288. */
  142289. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142290. /**
  142291. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142292. * @param data contains the texture data
  142293. * @param texture defines the BabylonJS internal texture
  142294. * @param callback defines the method to call once ready to upload
  142295. */
  142296. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142297. }
  142298. }
  142299. declare module BABYLON {
  142300. /**
  142301. * Defines the basic options interface of a TexturePacker Frame
  142302. */
  142303. export interface ITexturePackerFrame {
  142304. /**
  142305. * The frame ID
  142306. */
  142307. id: number;
  142308. /**
  142309. * The frames Scale
  142310. */
  142311. scale: Vector2;
  142312. /**
  142313. * The Frames offset
  142314. */
  142315. offset: Vector2;
  142316. }
  142317. /**
  142318. * This is a support class for frame Data on texture packer sets.
  142319. */
  142320. export class TexturePackerFrame implements ITexturePackerFrame {
  142321. /**
  142322. * The frame ID
  142323. */
  142324. id: number;
  142325. /**
  142326. * The frames Scale
  142327. */
  142328. scale: Vector2;
  142329. /**
  142330. * The Frames offset
  142331. */
  142332. offset: Vector2;
  142333. /**
  142334. * Initializes a texture package frame.
  142335. * @param id The numerical frame identifier
  142336. * @param scale Scalar Vector2 for UV frame
  142337. * @param offset Vector2 for the frame position in UV units.
  142338. * @returns TexturePackerFrame
  142339. */
  142340. constructor(id: number, scale: Vector2, offset: Vector2);
  142341. }
  142342. }
  142343. declare module BABYLON {
  142344. /**
  142345. * Defines the basic options interface of a TexturePacker
  142346. */
  142347. export interface ITexturePackerOptions {
  142348. /**
  142349. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142350. */
  142351. map?: string[];
  142352. /**
  142353. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142354. */
  142355. uvsIn?: string;
  142356. /**
  142357. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142358. */
  142359. uvsOut?: string;
  142360. /**
  142361. * number representing the layout style. Defaults to LAYOUT_STRIP
  142362. */
  142363. layout?: number;
  142364. /**
  142365. * number of columns if using custom column count layout(2). This defaults to 4.
  142366. */
  142367. colnum?: number;
  142368. /**
  142369. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142370. */
  142371. updateInputMeshes?: boolean;
  142372. /**
  142373. * boolean flag to dispose all the source textures. Defaults to true.
  142374. */
  142375. disposeSources?: boolean;
  142376. /**
  142377. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142378. */
  142379. fillBlanks?: boolean;
  142380. /**
  142381. * string value representing the context fill style color. Defaults to 'black'.
  142382. */
  142383. customFillColor?: string;
  142384. /**
  142385. * Width and Height Value of each Frame in the TexturePacker Sets
  142386. */
  142387. frameSize?: number;
  142388. /**
  142389. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142390. */
  142391. paddingRatio?: number;
  142392. /**
  142393. * Number that declares the fill method for the padding gutter.
  142394. */
  142395. paddingMode?: number;
  142396. /**
  142397. * If in SUBUV_COLOR padding mode what color to use.
  142398. */
  142399. paddingColor?: Color3 | Color4;
  142400. }
  142401. /**
  142402. * Defines the basic interface of a TexturePacker JSON File
  142403. */
  142404. export interface ITexturePackerJSON {
  142405. /**
  142406. * The frame ID
  142407. */
  142408. name: string;
  142409. /**
  142410. * The base64 channel data
  142411. */
  142412. sets: any;
  142413. /**
  142414. * The options of the Packer
  142415. */
  142416. options: ITexturePackerOptions;
  142417. /**
  142418. * The frame data of the Packer
  142419. */
  142420. frames: Array<number>;
  142421. }
  142422. /**
  142423. * This is a support class that generates a series of packed texture sets.
  142424. * @see https://doc.babylonjs.com/babylon101/materials
  142425. */
  142426. export class TexturePacker {
  142427. /** Packer Layout Constant 0 */
  142428. static readonly LAYOUT_STRIP: number;
  142429. /** Packer Layout Constant 1 */
  142430. static readonly LAYOUT_POWER2: number;
  142431. /** Packer Layout Constant 2 */
  142432. static readonly LAYOUT_COLNUM: number;
  142433. /** Packer Layout Constant 0 */
  142434. static readonly SUBUV_WRAP: number;
  142435. /** Packer Layout Constant 1 */
  142436. static readonly SUBUV_EXTEND: number;
  142437. /** Packer Layout Constant 2 */
  142438. static readonly SUBUV_COLOR: number;
  142439. /** The Name of the Texture Package */
  142440. name: string;
  142441. /** The scene scope of the TexturePacker */
  142442. scene: Scene;
  142443. /** The Meshes to target */
  142444. meshes: AbstractMesh[];
  142445. /** Arguments passed with the Constructor */
  142446. options: ITexturePackerOptions;
  142447. /** The promise that is started upon initialization */
  142448. promise: Nullable<Promise<TexturePacker | string>>;
  142449. /** The Container object for the channel sets that are generated */
  142450. sets: object;
  142451. /** The Container array for the frames that are generated */
  142452. frames: TexturePackerFrame[];
  142453. /** The expected number of textures the system is parsing. */
  142454. private _expecting;
  142455. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142456. private _paddingValue;
  142457. /**
  142458. * Initializes a texture package series from an array of meshes or a single mesh.
  142459. * @param name The name of the package
  142460. * @param meshes The target meshes to compose the package from
  142461. * @param options The arguments that texture packer should follow while building.
  142462. * @param scene The scene which the textures are scoped to.
  142463. * @returns TexturePacker
  142464. */
  142465. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142466. /**
  142467. * Starts the package process
  142468. * @param resolve The promises resolution function
  142469. * @returns TexturePacker
  142470. */
  142471. private _createFrames;
  142472. /**
  142473. * Calculates the Size of the Channel Sets
  142474. * @returns Vector2
  142475. */
  142476. private _calculateSize;
  142477. /**
  142478. * Calculates the UV data for the frames.
  142479. * @param baseSize the base frameSize
  142480. * @param padding the base frame padding
  142481. * @param dtSize size of the Dynamic Texture for that channel
  142482. * @param dtUnits is 1/dtSize
  142483. * @param update flag to update the input meshes
  142484. */
  142485. private _calculateMeshUVFrames;
  142486. /**
  142487. * Calculates the frames Offset.
  142488. * @param index of the frame
  142489. * @returns Vector2
  142490. */
  142491. private _getFrameOffset;
  142492. /**
  142493. * Updates a Mesh to the frame data
  142494. * @param mesh that is the target
  142495. * @param frameID or the frame index
  142496. */
  142497. private _updateMeshUV;
  142498. /**
  142499. * Updates a Meshes materials to use the texture packer channels
  142500. * @param m is the mesh to target
  142501. * @param force all channels on the packer to be set.
  142502. */
  142503. private _updateTextureReferences;
  142504. /**
  142505. * Public method to set a Mesh to a frame
  142506. * @param m that is the target
  142507. * @param frameID or the frame index
  142508. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142509. */
  142510. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142511. /**
  142512. * Starts the async promise to compile the texture packer.
  142513. * @returns Promise<void>
  142514. */
  142515. processAsync(): Promise<void>;
  142516. /**
  142517. * Disposes all textures associated with this packer
  142518. */
  142519. dispose(): void;
  142520. /**
  142521. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142522. * @param imageType is the image type to use.
  142523. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142524. */
  142525. download(imageType?: string, quality?: number): void;
  142526. /**
  142527. * Public method to load a texturePacker JSON file.
  142528. * @param data of the JSON file in string format.
  142529. */
  142530. updateFromJSON(data: string): void;
  142531. }
  142532. }
  142533. declare module BABYLON {
  142534. /**
  142535. * 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.
  142536. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142537. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142538. */
  142539. export class CustomProceduralTexture extends ProceduralTexture {
  142540. private _animate;
  142541. private _time;
  142542. private _config;
  142543. private _texturePath;
  142544. /**
  142545. * Instantiates a new Custom Procedural Texture.
  142546. * 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.
  142547. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142548. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142549. * @param name Define the name of the texture
  142550. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142551. * @param size Define the size of the texture to create
  142552. * @param scene Define the scene the texture belongs to
  142553. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142554. * @param generateMipMaps Define if the texture should creates mip maps or not
  142555. */
  142556. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142557. private _loadJson;
  142558. /**
  142559. * Is the texture ready to be used ? (rendered at least once)
  142560. * @returns true if ready, otherwise, false.
  142561. */
  142562. isReady(): boolean;
  142563. /**
  142564. * Render the texture to its associated render target.
  142565. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142566. */
  142567. render(useCameraPostProcess?: boolean): void;
  142568. /**
  142569. * Update the list of dependant textures samplers in the shader.
  142570. */
  142571. updateTextures(): void;
  142572. /**
  142573. * Update the uniform values of the procedural texture in the shader.
  142574. */
  142575. updateShaderUniforms(): void;
  142576. /**
  142577. * Define if the texture animates or not.
  142578. */
  142579. get animate(): boolean;
  142580. set animate(value: boolean);
  142581. }
  142582. }
  142583. declare module BABYLON {
  142584. /** @hidden */
  142585. export var noisePixelShader: {
  142586. name: string;
  142587. shader: string;
  142588. };
  142589. }
  142590. declare module BABYLON {
  142591. /**
  142592. * Class used to generate noise procedural textures
  142593. */
  142594. export class NoiseProceduralTexture extends ProceduralTexture {
  142595. /** Gets or sets the start time (default is 0) */
  142596. time: number;
  142597. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142598. brightness: number;
  142599. /** Defines the number of octaves to process */
  142600. octaves: number;
  142601. /** Defines the level of persistence (0.8 by default) */
  142602. persistence: number;
  142603. /** Gets or sets animation speed factor (default is 1) */
  142604. animationSpeedFactor: number;
  142605. /**
  142606. * Creates a new NoiseProceduralTexture
  142607. * @param name defines the name fo the texture
  142608. * @param size defines the size of the texture (default is 256)
  142609. * @param scene defines the hosting scene
  142610. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142611. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142612. */
  142613. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142614. private _updateShaderUniforms;
  142615. protected _getDefines(): string;
  142616. /** Generate the current state of the procedural texture */
  142617. render(useCameraPostProcess?: boolean): void;
  142618. /**
  142619. * Serializes this noise procedural texture
  142620. * @returns a serialized noise procedural texture object
  142621. */
  142622. serialize(): any;
  142623. /**
  142624. * Clone the texture.
  142625. * @returns the cloned texture
  142626. */
  142627. clone(): NoiseProceduralTexture;
  142628. /**
  142629. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142630. * @param parsedTexture defines parsed texture data
  142631. * @param scene defines the current scene
  142632. * @param rootUrl defines the root URL containing noise procedural texture information
  142633. * @returns a parsed NoiseProceduralTexture
  142634. */
  142635. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142636. }
  142637. }
  142638. declare module BABYLON {
  142639. /**
  142640. * Raw cube texture where the raw buffers are passed in
  142641. */
  142642. export class RawCubeTexture extends CubeTexture {
  142643. /**
  142644. * Creates a cube texture where the raw buffers are passed in.
  142645. * @param scene defines the scene the texture is attached to
  142646. * @param data defines the array of data to use to create each face
  142647. * @param size defines the size of the textures
  142648. * @param format defines the format of the data
  142649. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142650. * @param generateMipMaps defines if the engine should generate the mip levels
  142651. * @param invertY defines if data must be stored with Y axis inverted
  142652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142653. * @param compression defines the compression used (null by default)
  142654. */
  142655. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142656. /**
  142657. * Updates the raw cube texture.
  142658. * @param data defines the data to store
  142659. * @param format defines the data format
  142660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142661. * @param invertY defines if data must be stored with Y axis inverted
  142662. * @param compression defines the compression used (null by default)
  142663. * @param level defines which level of the texture to update
  142664. */
  142665. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142666. /**
  142667. * Updates a raw cube texture with RGBD encoded data.
  142668. * @param data defines the array of data [mipmap][face] to use to create each face
  142669. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142672. * @returns a promsie that resolves when the operation is complete
  142673. */
  142674. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142675. /**
  142676. * Clones the raw cube texture.
  142677. * @return a new cube texture
  142678. */
  142679. clone(): CubeTexture;
  142680. /** @hidden */
  142681. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142682. }
  142683. }
  142684. declare module BABYLON {
  142685. /**
  142686. * Class used to store 2D array textures containing user data
  142687. */
  142688. export class RawTexture2DArray extends Texture {
  142689. /** Gets or sets the texture format to use */
  142690. format: number;
  142691. /**
  142692. * Create a new RawTexture2DArray
  142693. * @param data defines the data of the texture
  142694. * @param width defines the width of the texture
  142695. * @param height defines the height of the texture
  142696. * @param depth defines the number of layers of the texture
  142697. * @param format defines the texture format to use
  142698. * @param scene defines the hosting scene
  142699. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142700. * @param invertY defines if texture must be stored with Y axis inverted
  142701. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142702. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142703. */
  142704. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142705. /** Gets or sets the texture format to use */
  142706. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142707. /**
  142708. * Update the texture with new data
  142709. * @param data defines the data to store in the texture
  142710. */
  142711. update(data: ArrayBufferView): void;
  142712. }
  142713. }
  142714. declare module BABYLON {
  142715. /**
  142716. * Class used to store 3D textures containing user data
  142717. */
  142718. export class RawTexture3D extends Texture {
  142719. /** Gets or sets the texture format to use */
  142720. format: number;
  142721. /**
  142722. * Create a new RawTexture3D
  142723. * @param data defines the data of the texture
  142724. * @param width defines the width of the texture
  142725. * @param height defines the height of the texture
  142726. * @param depth defines the depth of the texture
  142727. * @param format defines the texture format to use
  142728. * @param scene defines the hosting scene
  142729. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142730. * @param invertY defines if texture must be stored with Y axis inverted
  142731. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142732. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142733. */
  142734. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142735. /** Gets or sets the texture format to use */
  142736. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142737. /**
  142738. * Update the texture with new data
  142739. * @param data defines the data to store in the texture
  142740. */
  142741. update(data: ArrayBufferView): void;
  142742. }
  142743. }
  142744. declare module BABYLON {
  142745. /**
  142746. * Creates a refraction texture used by refraction channel of the standard material.
  142747. * It is like a mirror but to see through a material.
  142748. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142749. */
  142750. export class RefractionTexture extends RenderTargetTexture {
  142751. /**
  142752. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142753. * 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.
  142754. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142755. */
  142756. refractionPlane: Plane;
  142757. /**
  142758. * Define how deep under the surface we should see.
  142759. */
  142760. depth: number;
  142761. /**
  142762. * Creates a refraction texture used by refraction channel of the standard material.
  142763. * It is like a mirror but to see through a material.
  142764. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142765. * @param name Define the texture name
  142766. * @param size Define the size of the underlying texture
  142767. * @param scene Define the scene the refraction belongs to
  142768. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142769. */
  142770. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142771. /**
  142772. * Clone the refraction texture.
  142773. * @returns the cloned texture
  142774. */
  142775. clone(): RefractionTexture;
  142776. /**
  142777. * Serialize the texture to a JSON representation you could use in Parse later on
  142778. * @returns the serialized JSON representation
  142779. */
  142780. serialize(): any;
  142781. }
  142782. }
  142783. declare module BABYLON {
  142784. /**
  142785. * Block used to add support for vertex skinning (bones)
  142786. */
  142787. export class BonesBlock extends NodeMaterialBlock {
  142788. /**
  142789. * Creates a new BonesBlock
  142790. * @param name defines the block name
  142791. */
  142792. constructor(name: string);
  142793. /**
  142794. * Initialize the block and prepare the context for build
  142795. * @param state defines the state that will be used for the build
  142796. */
  142797. initialize(state: NodeMaterialBuildState): void;
  142798. /**
  142799. * Gets the current class name
  142800. * @returns the class name
  142801. */
  142802. getClassName(): string;
  142803. /**
  142804. * Gets the matrix indices input component
  142805. */
  142806. get matricesIndices(): NodeMaterialConnectionPoint;
  142807. /**
  142808. * Gets the matrix weights input component
  142809. */
  142810. get matricesWeights(): NodeMaterialConnectionPoint;
  142811. /**
  142812. * Gets the extra matrix indices input component
  142813. */
  142814. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142815. /**
  142816. * Gets the extra matrix weights input component
  142817. */
  142818. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142819. /**
  142820. * Gets the world input component
  142821. */
  142822. get world(): NodeMaterialConnectionPoint;
  142823. /**
  142824. * Gets the output component
  142825. */
  142826. get output(): NodeMaterialConnectionPoint;
  142827. autoConfigure(material: NodeMaterial): void;
  142828. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142831. protected _buildBlock(state: NodeMaterialBuildState): this;
  142832. }
  142833. }
  142834. declare module BABYLON {
  142835. /**
  142836. * Block used to add support for instances
  142837. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142838. */
  142839. export class InstancesBlock extends NodeMaterialBlock {
  142840. /**
  142841. * Creates a new InstancesBlock
  142842. * @param name defines the block name
  142843. */
  142844. constructor(name: string);
  142845. /**
  142846. * Gets the current class name
  142847. * @returns the class name
  142848. */
  142849. getClassName(): string;
  142850. /**
  142851. * Gets the first world row input component
  142852. */
  142853. get world0(): NodeMaterialConnectionPoint;
  142854. /**
  142855. * Gets the second world row input component
  142856. */
  142857. get world1(): NodeMaterialConnectionPoint;
  142858. /**
  142859. * Gets the third world row input component
  142860. */
  142861. get world2(): NodeMaterialConnectionPoint;
  142862. /**
  142863. * Gets the forth world row input component
  142864. */
  142865. get world3(): NodeMaterialConnectionPoint;
  142866. /**
  142867. * Gets the world input component
  142868. */
  142869. get world(): NodeMaterialConnectionPoint;
  142870. /**
  142871. * Gets the output component
  142872. */
  142873. get output(): NodeMaterialConnectionPoint;
  142874. /**
  142875. * Gets the isntanceID component
  142876. */
  142877. get instanceID(): NodeMaterialConnectionPoint;
  142878. autoConfigure(material: NodeMaterial): void;
  142879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142880. protected _buildBlock(state: NodeMaterialBuildState): this;
  142881. }
  142882. }
  142883. declare module BABYLON {
  142884. /**
  142885. * Block used to add morph targets support to vertex shader
  142886. */
  142887. export class MorphTargetsBlock extends NodeMaterialBlock {
  142888. private _repeatableContentAnchor;
  142889. /**
  142890. * Create a new MorphTargetsBlock
  142891. * @param name defines the block name
  142892. */
  142893. constructor(name: string);
  142894. /**
  142895. * Gets the current class name
  142896. * @returns the class name
  142897. */
  142898. getClassName(): string;
  142899. /**
  142900. * Gets the position input component
  142901. */
  142902. get position(): NodeMaterialConnectionPoint;
  142903. /**
  142904. * Gets the normal input component
  142905. */
  142906. get normal(): NodeMaterialConnectionPoint;
  142907. /**
  142908. * Gets the tangent input component
  142909. */
  142910. get tangent(): NodeMaterialConnectionPoint;
  142911. /**
  142912. * Gets the tangent input component
  142913. */
  142914. get uv(): NodeMaterialConnectionPoint;
  142915. /**
  142916. * Gets the position output component
  142917. */
  142918. get positionOutput(): NodeMaterialConnectionPoint;
  142919. /**
  142920. * Gets the normal output component
  142921. */
  142922. get normalOutput(): NodeMaterialConnectionPoint;
  142923. /**
  142924. * Gets the tangent output component
  142925. */
  142926. get tangentOutput(): NodeMaterialConnectionPoint;
  142927. /**
  142928. * Gets the tangent output component
  142929. */
  142930. get uvOutput(): NodeMaterialConnectionPoint;
  142931. initialize(state: NodeMaterialBuildState): void;
  142932. autoConfigure(material: NodeMaterial): void;
  142933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142935. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142936. protected _buildBlock(state: NodeMaterialBuildState): this;
  142937. }
  142938. }
  142939. declare module BABYLON {
  142940. /**
  142941. * Block used to get data information from a light
  142942. */
  142943. export class LightInformationBlock extends NodeMaterialBlock {
  142944. private _lightDataUniformName;
  142945. private _lightColorUniformName;
  142946. private _lightTypeDefineName;
  142947. /**
  142948. * Gets or sets the light associated with this block
  142949. */
  142950. light: Nullable<Light>;
  142951. /**
  142952. * Creates a new LightInformationBlock
  142953. * @param name defines the block name
  142954. */
  142955. constructor(name: string);
  142956. /**
  142957. * Gets the current class name
  142958. * @returns the class name
  142959. */
  142960. getClassName(): string;
  142961. /**
  142962. * Gets the world position input component
  142963. */
  142964. get worldPosition(): NodeMaterialConnectionPoint;
  142965. /**
  142966. * Gets the direction output component
  142967. */
  142968. get direction(): NodeMaterialConnectionPoint;
  142969. /**
  142970. * Gets the direction output component
  142971. */
  142972. get color(): NodeMaterialConnectionPoint;
  142973. /**
  142974. * Gets the direction output component
  142975. */
  142976. get intensity(): NodeMaterialConnectionPoint;
  142977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142979. protected _buildBlock(state: NodeMaterialBuildState): this;
  142980. serialize(): any;
  142981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142982. }
  142983. }
  142984. declare module BABYLON {
  142985. /**
  142986. * Block used to add image processing support to fragment shader
  142987. */
  142988. export class ImageProcessingBlock extends NodeMaterialBlock {
  142989. /**
  142990. * Create a new ImageProcessingBlock
  142991. * @param name defines the block name
  142992. */
  142993. constructor(name: string);
  142994. /**
  142995. * Gets the current class name
  142996. * @returns the class name
  142997. */
  142998. getClassName(): string;
  142999. /**
  143000. * Gets the color input component
  143001. */
  143002. get color(): NodeMaterialConnectionPoint;
  143003. /**
  143004. * Gets the output component
  143005. */
  143006. get output(): NodeMaterialConnectionPoint;
  143007. /**
  143008. * Initialize the block and prepare the context for build
  143009. * @param state defines the state that will be used for the build
  143010. */
  143011. initialize(state: NodeMaterialBuildState): void;
  143012. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143015. protected _buildBlock(state: NodeMaterialBuildState): this;
  143016. }
  143017. }
  143018. declare module BABYLON {
  143019. /**
  143020. * Block used to pertub normals based on a normal map
  143021. */
  143022. export class PerturbNormalBlock extends NodeMaterialBlock {
  143023. private _tangentSpaceParameterName;
  143024. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143025. invertX: boolean;
  143026. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143027. invertY: boolean;
  143028. /**
  143029. * Create a new PerturbNormalBlock
  143030. * @param name defines the block name
  143031. */
  143032. constructor(name: string);
  143033. /**
  143034. * Gets the current class name
  143035. * @returns the class name
  143036. */
  143037. getClassName(): string;
  143038. /**
  143039. * Gets the world position input component
  143040. */
  143041. get worldPosition(): NodeMaterialConnectionPoint;
  143042. /**
  143043. * Gets the world normal input component
  143044. */
  143045. get worldNormal(): NodeMaterialConnectionPoint;
  143046. /**
  143047. * Gets the world tangent input component
  143048. */
  143049. get worldTangent(): NodeMaterialConnectionPoint;
  143050. /**
  143051. * Gets the uv input component
  143052. */
  143053. get uv(): NodeMaterialConnectionPoint;
  143054. /**
  143055. * Gets the normal map color input component
  143056. */
  143057. get normalMapColor(): NodeMaterialConnectionPoint;
  143058. /**
  143059. * Gets the strength input component
  143060. */
  143061. get strength(): NodeMaterialConnectionPoint;
  143062. /**
  143063. * Gets the output component
  143064. */
  143065. get output(): NodeMaterialConnectionPoint;
  143066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143068. autoConfigure(material: NodeMaterial): void;
  143069. protected _buildBlock(state: NodeMaterialBuildState): this;
  143070. protected _dumpPropertiesCode(): string;
  143071. serialize(): any;
  143072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143073. }
  143074. }
  143075. declare module BABYLON {
  143076. /**
  143077. * Block used to discard a pixel if a value is smaller than a cutoff
  143078. */
  143079. export class DiscardBlock extends NodeMaterialBlock {
  143080. /**
  143081. * Create a new DiscardBlock
  143082. * @param name defines the block name
  143083. */
  143084. constructor(name: string);
  143085. /**
  143086. * Gets the current class name
  143087. * @returns the class name
  143088. */
  143089. getClassName(): string;
  143090. /**
  143091. * Gets the color input component
  143092. */
  143093. get value(): NodeMaterialConnectionPoint;
  143094. /**
  143095. * Gets the cutoff input component
  143096. */
  143097. get cutoff(): NodeMaterialConnectionPoint;
  143098. protected _buildBlock(state: NodeMaterialBuildState): this;
  143099. }
  143100. }
  143101. declare module BABYLON {
  143102. /**
  143103. * Block used to test if the fragment shader is front facing
  143104. */
  143105. export class FrontFacingBlock extends NodeMaterialBlock {
  143106. /**
  143107. * Creates a new FrontFacingBlock
  143108. * @param name defines the block name
  143109. */
  143110. constructor(name: string);
  143111. /**
  143112. * Gets the current class name
  143113. * @returns the class name
  143114. */
  143115. getClassName(): string;
  143116. /**
  143117. * Gets the output component
  143118. */
  143119. get output(): NodeMaterialConnectionPoint;
  143120. protected _buildBlock(state: NodeMaterialBuildState): this;
  143121. }
  143122. }
  143123. declare module BABYLON {
  143124. /**
  143125. * Block used to get the derivative value on x and y of a given input
  143126. */
  143127. export class DerivativeBlock extends NodeMaterialBlock {
  143128. /**
  143129. * Create a new DerivativeBlock
  143130. * @param name defines the block name
  143131. */
  143132. constructor(name: string);
  143133. /**
  143134. * Gets the current class name
  143135. * @returns the class name
  143136. */
  143137. getClassName(): string;
  143138. /**
  143139. * Gets the input component
  143140. */
  143141. get input(): NodeMaterialConnectionPoint;
  143142. /**
  143143. * Gets the derivative output on x
  143144. */
  143145. get dx(): NodeMaterialConnectionPoint;
  143146. /**
  143147. * Gets the derivative output on y
  143148. */
  143149. get dy(): NodeMaterialConnectionPoint;
  143150. protected _buildBlock(state: NodeMaterialBuildState): this;
  143151. }
  143152. }
  143153. declare module BABYLON {
  143154. /**
  143155. * Block used to make gl_FragCoord available
  143156. */
  143157. export class FragCoordBlock extends NodeMaterialBlock {
  143158. /**
  143159. * Creates a new FragCoordBlock
  143160. * @param name defines the block name
  143161. */
  143162. constructor(name: string);
  143163. /**
  143164. * Gets the current class name
  143165. * @returns the class name
  143166. */
  143167. getClassName(): string;
  143168. /**
  143169. * Gets the xy component
  143170. */
  143171. get xy(): NodeMaterialConnectionPoint;
  143172. /**
  143173. * Gets the xyz component
  143174. */
  143175. get xyz(): NodeMaterialConnectionPoint;
  143176. /**
  143177. * Gets the xyzw component
  143178. */
  143179. get xyzw(): NodeMaterialConnectionPoint;
  143180. /**
  143181. * Gets the x component
  143182. */
  143183. get x(): NodeMaterialConnectionPoint;
  143184. /**
  143185. * Gets the y component
  143186. */
  143187. get y(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the z component
  143190. */
  143191. get z(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the w component
  143194. */
  143195. get output(): NodeMaterialConnectionPoint;
  143196. protected writeOutputs(state: NodeMaterialBuildState): string;
  143197. protected _buildBlock(state: NodeMaterialBuildState): this;
  143198. }
  143199. }
  143200. declare module BABYLON {
  143201. /**
  143202. * Block used to get the screen sizes
  143203. */
  143204. export class ScreenSizeBlock extends NodeMaterialBlock {
  143205. private _varName;
  143206. private _scene;
  143207. /**
  143208. * Creates a new ScreenSizeBlock
  143209. * @param name defines the block name
  143210. */
  143211. constructor(name: string);
  143212. /**
  143213. * Gets the current class name
  143214. * @returns the class name
  143215. */
  143216. getClassName(): string;
  143217. /**
  143218. * Gets the xy component
  143219. */
  143220. get xy(): NodeMaterialConnectionPoint;
  143221. /**
  143222. * Gets the x component
  143223. */
  143224. get x(): NodeMaterialConnectionPoint;
  143225. /**
  143226. * Gets the y component
  143227. */
  143228. get y(): NodeMaterialConnectionPoint;
  143229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143230. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143231. protected _buildBlock(state: NodeMaterialBuildState): this;
  143232. }
  143233. }
  143234. declare module BABYLON {
  143235. /**
  143236. * Block used to add support for scene fog
  143237. */
  143238. export class FogBlock extends NodeMaterialBlock {
  143239. private _fogDistanceName;
  143240. private _fogParameters;
  143241. /**
  143242. * Create a new FogBlock
  143243. * @param name defines the block name
  143244. */
  143245. constructor(name: string);
  143246. /**
  143247. * Gets the current class name
  143248. * @returns the class name
  143249. */
  143250. getClassName(): string;
  143251. /**
  143252. * Gets the world position input component
  143253. */
  143254. get worldPosition(): NodeMaterialConnectionPoint;
  143255. /**
  143256. * Gets the view input component
  143257. */
  143258. get view(): NodeMaterialConnectionPoint;
  143259. /**
  143260. * Gets the color input component
  143261. */
  143262. get input(): NodeMaterialConnectionPoint;
  143263. /**
  143264. * Gets the fog color input component
  143265. */
  143266. get fogColor(): NodeMaterialConnectionPoint;
  143267. /**
  143268. * Gets the output component
  143269. */
  143270. get output(): NodeMaterialConnectionPoint;
  143271. autoConfigure(material: NodeMaterial): void;
  143272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143274. protected _buildBlock(state: NodeMaterialBuildState): this;
  143275. }
  143276. }
  143277. declare module BABYLON {
  143278. /**
  143279. * Block used to add light in the fragment shader
  143280. */
  143281. export class LightBlock extends NodeMaterialBlock {
  143282. private _lightId;
  143283. /**
  143284. * Gets or sets the light associated with this block
  143285. */
  143286. light: Nullable<Light>;
  143287. /**
  143288. * Create a new LightBlock
  143289. * @param name defines the block name
  143290. */
  143291. constructor(name: string);
  143292. /**
  143293. * Gets the current class name
  143294. * @returns the class name
  143295. */
  143296. getClassName(): string;
  143297. /**
  143298. * Gets the world position input component
  143299. */
  143300. get worldPosition(): NodeMaterialConnectionPoint;
  143301. /**
  143302. * Gets the world normal input component
  143303. */
  143304. get worldNormal(): NodeMaterialConnectionPoint;
  143305. /**
  143306. * Gets the camera (or eye) position component
  143307. */
  143308. get cameraPosition(): NodeMaterialConnectionPoint;
  143309. /**
  143310. * Gets the glossiness component
  143311. */
  143312. get glossiness(): NodeMaterialConnectionPoint;
  143313. /**
  143314. * Gets the glossinness power component
  143315. */
  143316. get glossPower(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the diffuse color component
  143319. */
  143320. get diffuseColor(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the specular color component
  143323. */
  143324. get specularColor(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the diffuse output component
  143327. */
  143328. get diffuseOutput(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the specular output component
  143331. */
  143332. get specularOutput(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the shadow output component
  143335. */
  143336. get shadow(): NodeMaterialConnectionPoint;
  143337. autoConfigure(material: NodeMaterial): void;
  143338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143339. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143341. private _injectVertexCode;
  143342. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143343. serialize(): any;
  143344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143345. }
  143346. }
  143347. declare module BABYLON {
  143348. /**
  143349. * Block used to read a reflection texture from a sampler
  143350. */
  143351. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143352. /**
  143353. * Create a new ReflectionTextureBlock
  143354. * @param name defines the block name
  143355. */
  143356. constructor(name: string);
  143357. /**
  143358. * Gets the current class name
  143359. * @returns the class name
  143360. */
  143361. getClassName(): string;
  143362. /**
  143363. * Gets the world position input component
  143364. */
  143365. get position(): NodeMaterialConnectionPoint;
  143366. /**
  143367. * Gets the world position input component
  143368. */
  143369. get worldPosition(): NodeMaterialConnectionPoint;
  143370. /**
  143371. * Gets the world normal input component
  143372. */
  143373. get worldNormal(): NodeMaterialConnectionPoint;
  143374. /**
  143375. * Gets the world input component
  143376. */
  143377. get world(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the camera (or eye) position component
  143380. */
  143381. get cameraPosition(): NodeMaterialConnectionPoint;
  143382. /**
  143383. * Gets the view input component
  143384. */
  143385. get view(): NodeMaterialConnectionPoint;
  143386. /**
  143387. * Gets the rgb output component
  143388. */
  143389. get rgb(): NodeMaterialConnectionPoint;
  143390. /**
  143391. * Gets the rgba output component
  143392. */
  143393. get rgba(): NodeMaterialConnectionPoint;
  143394. /**
  143395. * Gets the r output component
  143396. */
  143397. get r(): NodeMaterialConnectionPoint;
  143398. /**
  143399. * Gets the g output component
  143400. */
  143401. get g(): NodeMaterialConnectionPoint;
  143402. /**
  143403. * Gets the b output component
  143404. */
  143405. get b(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the a output component
  143408. */
  143409. get a(): NodeMaterialConnectionPoint;
  143410. autoConfigure(material: NodeMaterial): void;
  143411. protected _buildBlock(state: NodeMaterialBuildState): this;
  143412. }
  143413. }
  143414. declare module BABYLON {
  143415. /**
  143416. * Block used to add 2 vectors
  143417. */
  143418. export class AddBlock extends NodeMaterialBlock {
  143419. /**
  143420. * Creates a new AddBlock
  143421. * @param name defines the block name
  143422. */
  143423. constructor(name: string);
  143424. /**
  143425. * Gets the current class name
  143426. * @returns the class name
  143427. */
  143428. getClassName(): string;
  143429. /**
  143430. * Gets the left operand input component
  143431. */
  143432. get left(): NodeMaterialConnectionPoint;
  143433. /**
  143434. * Gets the right operand input component
  143435. */
  143436. get right(): NodeMaterialConnectionPoint;
  143437. /**
  143438. * Gets the output component
  143439. */
  143440. get output(): NodeMaterialConnectionPoint;
  143441. protected _buildBlock(state: NodeMaterialBuildState): this;
  143442. }
  143443. }
  143444. declare module BABYLON {
  143445. /**
  143446. * Block used to scale a vector by a float
  143447. */
  143448. export class ScaleBlock extends NodeMaterialBlock {
  143449. /**
  143450. * Creates a new ScaleBlock
  143451. * @param name defines the block name
  143452. */
  143453. constructor(name: string);
  143454. /**
  143455. * Gets the current class name
  143456. * @returns the class name
  143457. */
  143458. getClassName(): string;
  143459. /**
  143460. * Gets the input component
  143461. */
  143462. get input(): NodeMaterialConnectionPoint;
  143463. /**
  143464. * Gets the factor input component
  143465. */
  143466. get factor(): NodeMaterialConnectionPoint;
  143467. /**
  143468. * Gets the output component
  143469. */
  143470. get output(): NodeMaterialConnectionPoint;
  143471. protected _buildBlock(state: NodeMaterialBuildState): this;
  143472. }
  143473. }
  143474. declare module BABYLON {
  143475. /**
  143476. * Block used to clamp a float
  143477. */
  143478. export class ClampBlock extends NodeMaterialBlock {
  143479. /** Gets or sets the minimum range */
  143480. minimum: number;
  143481. /** Gets or sets the maximum range */
  143482. maximum: number;
  143483. /**
  143484. * Creates a new ClampBlock
  143485. * @param name defines the block name
  143486. */
  143487. constructor(name: string);
  143488. /**
  143489. * Gets the current class name
  143490. * @returns the class name
  143491. */
  143492. getClassName(): string;
  143493. /**
  143494. * Gets the value input component
  143495. */
  143496. get value(): NodeMaterialConnectionPoint;
  143497. /**
  143498. * Gets the output component
  143499. */
  143500. get output(): NodeMaterialConnectionPoint;
  143501. protected _buildBlock(state: NodeMaterialBuildState): this;
  143502. protected _dumpPropertiesCode(): string;
  143503. serialize(): any;
  143504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143505. }
  143506. }
  143507. declare module BABYLON {
  143508. /**
  143509. * Block used to apply a cross product between 2 vectors
  143510. */
  143511. export class CrossBlock extends NodeMaterialBlock {
  143512. /**
  143513. * Creates a new CrossBlock
  143514. * @param name defines the block name
  143515. */
  143516. constructor(name: string);
  143517. /**
  143518. * Gets the current class name
  143519. * @returns the class name
  143520. */
  143521. getClassName(): string;
  143522. /**
  143523. * Gets the left operand input component
  143524. */
  143525. get left(): NodeMaterialConnectionPoint;
  143526. /**
  143527. * Gets the right operand input component
  143528. */
  143529. get right(): NodeMaterialConnectionPoint;
  143530. /**
  143531. * Gets the output component
  143532. */
  143533. get output(): NodeMaterialConnectionPoint;
  143534. protected _buildBlock(state: NodeMaterialBuildState): this;
  143535. }
  143536. }
  143537. declare module BABYLON {
  143538. /**
  143539. * Block used to apply a dot product between 2 vectors
  143540. */
  143541. export class DotBlock extends NodeMaterialBlock {
  143542. /**
  143543. * Creates a new DotBlock
  143544. * @param name defines the block name
  143545. */
  143546. constructor(name: string);
  143547. /**
  143548. * Gets the current class name
  143549. * @returns the class name
  143550. */
  143551. getClassName(): string;
  143552. /**
  143553. * Gets the left operand input component
  143554. */
  143555. get left(): NodeMaterialConnectionPoint;
  143556. /**
  143557. * Gets the right operand input component
  143558. */
  143559. get right(): NodeMaterialConnectionPoint;
  143560. /**
  143561. * Gets the output component
  143562. */
  143563. get output(): NodeMaterialConnectionPoint;
  143564. protected _buildBlock(state: NodeMaterialBuildState): this;
  143565. }
  143566. }
  143567. declare module BABYLON {
  143568. /**
  143569. * Block used to normalize a vector
  143570. */
  143571. export class NormalizeBlock extends NodeMaterialBlock {
  143572. /**
  143573. * Creates a new NormalizeBlock
  143574. * @param name defines the block name
  143575. */
  143576. constructor(name: string);
  143577. /**
  143578. * Gets the current class name
  143579. * @returns the class name
  143580. */
  143581. getClassName(): string;
  143582. /**
  143583. * Gets the input component
  143584. */
  143585. get input(): NodeMaterialConnectionPoint;
  143586. /**
  143587. * Gets the output component
  143588. */
  143589. get output(): NodeMaterialConnectionPoint;
  143590. protected _buildBlock(state: NodeMaterialBuildState): this;
  143591. }
  143592. }
  143593. declare module BABYLON {
  143594. /**
  143595. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143596. */
  143597. export class ColorMergerBlock extends NodeMaterialBlock {
  143598. /**
  143599. * Create a new ColorMergerBlock
  143600. * @param name defines the block name
  143601. */
  143602. constructor(name: string);
  143603. /**
  143604. * Gets the current class name
  143605. * @returns the class name
  143606. */
  143607. getClassName(): string;
  143608. /**
  143609. * Gets the rgb component (input)
  143610. */
  143611. get rgbIn(): NodeMaterialConnectionPoint;
  143612. /**
  143613. * Gets the r component (input)
  143614. */
  143615. get r(): NodeMaterialConnectionPoint;
  143616. /**
  143617. * Gets the g component (input)
  143618. */
  143619. get g(): NodeMaterialConnectionPoint;
  143620. /**
  143621. * Gets the b component (input)
  143622. */
  143623. get b(): NodeMaterialConnectionPoint;
  143624. /**
  143625. * Gets the a component (input)
  143626. */
  143627. get a(): NodeMaterialConnectionPoint;
  143628. /**
  143629. * Gets the rgba component (output)
  143630. */
  143631. get rgba(): NodeMaterialConnectionPoint;
  143632. /**
  143633. * Gets the rgb component (output)
  143634. */
  143635. get rgbOut(): NodeMaterialConnectionPoint;
  143636. /**
  143637. * Gets the rgb component (output)
  143638. * @deprecated Please use rgbOut instead.
  143639. */
  143640. get rgb(): NodeMaterialConnectionPoint;
  143641. protected _buildBlock(state: NodeMaterialBuildState): this;
  143642. }
  143643. }
  143644. declare module BABYLON {
  143645. /**
  143646. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143647. */
  143648. export class VectorSplitterBlock extends NodeMaterialBlock {
  143649. /**
  143650. * Create a new VectorSplitterBlock
  143651. * @param name defines the block name
  143652. */
  143653. constructor(name: string);
  143654. /**
  143655. * Gets the current class name
  143656. * @returns the class name
  143657. */
  143658. getClassName(): string;
  143659. /**
  143660. * Gets the xyzw component (input)
  143661. */
  143662. get xyzw(): NodeMaterialConnectionPoint;
  143663. /**
  143664. * Gets the xyz component (input)
  143665. */
  143666. get xyzIn(): NodeMaterialConnectionPoint;
  143667. /**
  143668. * Gets the xy component (input)
  143669. */
  143670. get xyIn(): NodeMaterialConnectionPoint;
  143671. /**
  143672. * Gets the xyz component (output)
  143673. */
  143674. get xyzOut(): NodeMaterialConnectionPoint;
  143675. /**
  143676. * Gets the xy component (output)
  143677. */
  143678. get xyOut(): NodeMaterialConnectionPoint;
  143679. /**
  143680. * Gets the x component (output)
  143681. */
  143682. get x(): NodeMaterialConnectionPoint;
  143683. /**
  143684. * Gets the y component (output)
  143685. */
  143686. get y(): NodeMaterialConnectionPoint;
  143687. /**
  143688. * Gets the z component (output)
  143689. */
  143690. get z(): NodeMaterialConnectionPoint;
  143691. /**
  143692. * Gets the w component (output)
  143693. */
  143694. get w(): NodeMaterialConnectionPoint;
  143695. protected _inputRename(name: string): string;
  143696. protected _outputRename(name: string): string;
  143697. protected _buildBlock(state: NodeMaterialBuildState): this;
  143698. }
  143699. }
  143700. declare module BABYLON {
  143701. /**
  143702. * Block used to lerp between 2 values
  143703. */
  143704. export class LerpBlock extends NodeMaterialBlock {
  143705. /**
  143706. * Creates a new LerpBlock
  143707. * @param name defines the block name
  143708. */
  143709. constructor(name: string);
  143710. /**
  143711. * Gets the current class name
  143712. * @returns the class name
  143713. */
  143714. getClassName(): string;
  143715. /**
  143716. * Gets the left operand input component
  143717. */
  143718. get left(): NodeMaterialConnectionPoint;
  143719. /**
  143720. * Gets the right operand input component
  143721. */
  143722. get right(): NodeMaterialConnectionPoint;
  143723. /**
  143724. * Gets the gradient operand input component
  143725. */
  143726. get gradient(): NodeMaterialConnectionPoint;
  143727. /**
  143728. * Gets the output component
  143729. */
  143730. get output(): NodeMaterialConnectionPoint;
  143731. protected _buildBlock(state: NodeMaterialBuildState): this;
  143732. }
  143733. }
  143734. declare module BABYLON {
  143735. /**
  143736. * Block used to divide 2 vectors
  143737. */
  143738. export class DivideBlock extends NodeMaterialBlock {
  143739. /**
  143740. * Creates a new DivideBlock
  143741. * @param name defines the block name
  143742. */
  143743. constructor(name: string);
  143744. /**
  143745. * Gets the current class name
  143746. * @returns the class name
  143747. */
  143748. getClassName(): string;
  143749. /**
  143750. * Gets the left operand input component
  143751. */
  143752. get left(): NodeMaterialConnectionPoint;
  143753. /**
  143754. * Gets the right operand input component
  143755. */
  143756. get right(): NodeMaterialConnectionPoint;
  143757. /**
  143758. * Gets the output component
  143759. */
  143760. get output(): NodeMaterialConnectionPoint;
  143761. protected _buildBlock(state: NodeMaterialBuildState): this;
  143762. }
  143763. }
  143764. declare module BABYLON {
  143765. /**
  143766. * Block used to subtract 2 vectors
  143767. */
  143768. export class SubtractBlock extends NodeMaterialBlock {
  143769. /**
  143770. * Creates a new SubtractBlock
  143771. * @param name defines the block name
  143772. */
  143773. constructor(name: string);
  143774. /**
  143775. * Gets the current class name
  143776. * @returns the class name
  143777. */
  143778. getClassName(): string;
  143779. /**
  143780. * Gets the left operand input component
  143781. */
  143782. get left(): NodeMaterialConnectionPoint;
  143783. /**
  143784. * Gets the right operand input component
  143785. */
  143786. get right(): NodeMaterialConnectionPoint;
  143787. /**
  143788. * Gets the output component
  143789. */
  143790. get output(): NodeMaterialConnectionPoint;
  143791. protected _buildBlock(state: NodeMaterialBuildState): this;
  143792. }
  143793. }
  143794. declare module BABYLON {
  143795. /**
  143796. * Block used to step a value
  143797. */
  143798. export class StepBlock extends NodeMaterialBlock {
  143799. /**
  143800. * Creates a new StepBlock
  143801. * @param name defines the block name
  143802. */
  143803. constructor(name: string);
  143804. /**
  143805. * Gets the current class name
  143806. * @returns the class name
  143807. */
  143808. getClassName(): string;
  143809. /**
  143810. * Gets the value operand input component
  143811. */
  143812. get value(): NodeMaterialConnectionPoint;
  143813. /**
  143814. * Gets the edge operand input component
  143815. */
  143816. get edge(): NodeMaterialConnectionPoint;
  143817. /**
  143818. * Gets the output component
  143819. */
  143820. get output(): NodeMaterialConnectionPoint;
  143821. protected _buildBlock(state: NodeMaterialBuildState): this;
  143822. }
  143823. }
  143824. declare module BABYLON {
  143825. /**
  143826. * Block used to get the opposite (1 - x) of a value
  143827. */
  143828. export class OneMinusBlock extends NodeMaterialBlock {
  143829. /**
  143830. * Creates a new OneMinusBlock
  143831. * @param name defines the block name
  143832. */
  143833. constructor(name: string);
  143834. /**
  143835. * Gets the current class name
  143836. * @returns the class name
  143837. */
  143838. getClassName(): string;
  143839. /**
  143840. * Gets the input component
  143841. */
  143842. get input(): NodeMaterialConnectionPoint;
  143843. /**
  143844. * Gets the output component
  143845. */
  143846. get output(): NodeMaterialConnectionPoint;
  143847. protected _buildBlock(state: NodeMaterialBuildState): this;
  143848. }
  143849. }
  143850. declare module BABYLON {
  143851. /**
  143852. * Block used to get the view direction
  143853. */
  143854. export class ViewDirectionBlock extends NodeMaterialBlock {
  143855. /**
  143856. * Creates a new ViewDirectionBlock
  143857. * @param name defines the block name
  143858. */
  143859. constructor(name: string);
  143860. /**
  143861. * Gets the current class name
  143862. * @returns the class name
  143863. */
  143864. getClassName(): string;
  143865. /**
  143866. * Gets the world position component
  143867. */
  143868. get worldPosition(): NodeMaterialConnectionPoint;
  143869. /**
  143870. * Gets the camera position component
  143871. */
  143872. get cameraPosition(): NodeMaterialConnectionPoint;
  143873. /**
  143874. * Gets the output component
  143875. */
  143876. get output(): NodeMaterialConnectionPoint;
  143877. autoConfigure(material: NodeMaterial): void;
  143878. protected _buildBlock(state: NodeMaterialBuildState): this;
  143879. }
  143880. }
  143881. declare module BABYLON {
  143882. /**
  143883. * Block used to compute fresnel value
  143884. */
  143885. export class FresnelBlock extends NodeMaterialBlock {
  143886. /**
  143887. * Create a new FresnelBlock
  143888. * @param name defines the block name
  143889. */
  143890. constructor(name: string);
  143891. /**
  143892. * Gets the current class name
  143893. * @returns the class name
  143894. */
  143895. getClassName(): string;
  143896. /**
  143897. * Gets the world normal input component
  143898. */
  143899. get worldNormal(): NodeMaterialConnectionPoint;
  143900. /**
  143901. * Gets the view direction input component
  143902. */
  143903. get viewDirection(): NodeMaterialConnectionPoint;
  143904. /**
  143905. * Gets the bias input component
  143906. */
  143907. get bias(): NodeMaterialConnectionPoint;
  143908. /**
  143909. * Gets the camera (or eye) position component
  143910. */
  143911. get power(): NodeMaterialConnectionPoint;
  143912. /**
  143913. * Gets the fresnel output component
  143914. */
  143915. get fresnel(): NodeMaterialConnectionPoint;
  143916. autoConfigure(material: NodeMaterial): void;
  143917. protected _buildBlock(state: NodeMaterialBuildState): this;
  143918. }
  143919. }
  143920. declare module BABYLON {
  143921. /**
  143922. * Block used to get the max of 2 values
  143923. */
  143924. export class MaxBlock extends NodeMaterialBlock {
  143925. /**
  143926. * Creates a new MaxBlock
  143927. * @param name defines the block name
  143928. */
  143929. constructor(name: string);
  143930. /**
  143931. * Gets the current class name
  143932. * @returns the class name
  143933. */
  143934. getClassName(): string;
  143935. /**
  143936. * Gets the left operand input component
  143937. */
  143938. get left(): NodeMaterialConnectionPoint;
  143939. /**
  143940. * Gets the right operand input component
  143941. */
  143942. get right(): NodeMaterialConnectionPoint;
  143943. /**
  143944. * Gets the output component
  143945. */
  143946. get output(): NodeMaterialConnectionPoint;
  143947. protected _buildBlock(state: NodeMaterialBuildState): this;
  143948. }
  143949. }
  143950. declare module BABYLON {
  143951. /**
  143952. * Block used to get the min of 2 values
  143953. */
  143954. export class MinBlock extends NodeMaterialBlock {
  143955. /**
  143956. * Creates a new MinBlock
  143957. * @param name defines the block name
  143958. */
  143959. constructor(name: string);
  143960. /**
  143961. * Gets the current class name
  143962. * @returns the class name
  143963. */
  143964. getClassName(): string;
  143965. /**
  143966. * Gets the left operand input component
  143967. */
  143968. get left(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the right operand input component
  143971. */
  143972. get right(): NodeMaterialConnectionPoint;
  143973. /**
  143974. * Gets the output component
  143975. */
  143976. get output(): NodeMaterialConnectionPoint;
  143977. protected _buildBlock(state: NodeMaterialBuildState): this;
  143978. }
  143979. }
  143980. declare module BABYLON {
  143981. /**
  143982. * Block used to get the distance between 2 values
  143983. */
  143984. export class DistanceBlock extends NodeMaterialBlock {
  143985. /**
  143986. * Creates a new DistanceBlock
  143987. * @param name defines the block name
  143988. */
  143989. constructor(name: string);
  143990. /**
  143991. * Gets the current class name
  143992. * @returns the class name
  143993. */
  143994. getClassName(): string;
  143995. /**
  143996. * Gets the left operand input component
  143997. */
  143998. get left(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the right operand input component
  144001. */
  144002. get right(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the output component
  144005. */
  144006. get output(): NodeMaterialConnectionPoint;
  144007. protected _buildBlock(state: NodeMaterialBuildState): this;
  144008. }
  144009. }
  144010. declare module BABYLON {
  144011. /**
  144012. * Block used to get the length of a vector
  144013. */
  144014. export class LengthBlock extends NodeMaterialBlock {
  144015. /**
  144016. * Creates a new LengthBlock
  144017. * @param name defines the block name
  144018. */
  144019. constructor(name: string);
  144020. /**
  144021. * Gets the current class name
  144022. * @returns the class name
  144023. */
  144024. getClassName(): string;
  144025. /**
  144026. * Gets the value input component
  144027. */
  144028. get value(): NodeMaterialConnectionPoint;
  144029. /**
  144030. * Gets the output component
  144031. */
  144032. get output(): NodeMaterialConnectionPoint;
  144033. protected _buildBlock(state: NodeMaterialBuildState): this;
  144034. }
  144035. }
  144036. declare module BABYLON {
  144037. /**
  144038. * Block used to get negative version of a value (i.e. x * -1)
  144039. */
  144040. export class NegateBlock extends NodeMaterialBlock {
  144041. /**
  144042. * Creates a new NegateBlock
  144043. * @param name defines the block name
  144044. */
  144045. constructor(name: string);
  144046. /**
  144047. * Gets the current class name
  144048. * @returns the class name
  144049. */
  144050. getClassName(): string;
  144051. /**
  144052. * Gets the value input component
  144053. */
  144054. get value(): NodeMaterialConnectionPoint;
  144055. /**
  144056. * Gets the output component
  144057. */
  144058. get output(): NodeMaterialConnectionPoint;
  144059. protected _buildBlock(state: NodeMaterialBuildState): this;
  144060. }
  144061. }
  144062. declare module BABYLON {
  144063. /**
  144064. * Block used to get the value of the first parameter raised to the power of the second
  144065. */
  144066. export class PowBlock extends NodeMaterialBlock {
  144067. /**
  144068. * Creates a new PowBlock
  144069. * @param name defines the block name
  144070. */
  144071. constructor(name: string);
  144072. /**
  144073. * Gets the current class name
  144074. * @returns the class name
  144075. */
  144076. getClassName(): string;
  144077. /**
  144078. * Gets the value operand input component
  144079. */
  144080. get value(): NodeMaterialConnectionPoint;
  144081. /**
  144082. * Gets the power operand input component
  144083. */
  144084. get power(): NodeMaterialConnectionPoint;
  144085. /**
  144086. * Gets the output component
  144087. */
  144088. get output(): NodeMaterialConnectionPoint;
  144089. protected _buildBlock(state: NodeMaterialBuildState): this;
  144090. }
  144091. }
  144092. declare module BABYLON {
  144093. /**
  144094. * Block used to get a random number
  144095. */
  144096. export class RandomNumberBlock extends NodeMaterialBlock {
  144097. /**
  144098. * Creates a new RandomNumberBlock
  144099. * @param name defines the block name
  144100. */
  144101. constructor(name: string);
  144102. /**
  144103. * Gets the current class name
  144104. * @returns the class name
  144105. */
  144106. getClassName(): string;
  144107. /**
  144108. * Gets the seed input component
  144109. */
  144110. get seed(): NodeMaterialConnectionPoint;
  144111. /**
  144112. * Gets the output component
  144113. */
  144114. get output(): NodeMaterialConnectionPoint;
  144115. protected _buildBlock(state: NodeMaterialBuildState): this;
  144116. }
  144117. }
  144118. declare module BABYLON {
  144119. /**
  144120. * Block used to compute arc tangent of 2 values
  144121. */
  144122. export class ArcTan2Block extends NodeMaterialBlock {
  144123. /**
  144124. * Creates a new ArcTan2Block
  144125. * @param name defines the block name
  144126. */
  144127. constructor(name: string);
  144128. /**
  144129. * Gets the current class name
  144130. * @returns the class name
  144131. */
  144132. getClassName(): string;
  144133. /**
  144134. * Gets the x operand input component
  144135. */
  144136. get x(): NodeMaterialConnectionPoint;
  144137. /**
  144138. * Gets the y operand input component
  144139. */
  144140. get y(): NodeMaterialConnectionPoint;
  144141. /**
  144142. * Gets the output component
  144143. */
  144144. get output(): NodeMaterialConnectionPoint;
  144145. protected _buildBlock(state: NodeMaterialBuildState): this;
  144146. }
  144147. }
  144148. declare module BABYLON {
  144149. /**
  144150. * Block used to smooth step a value
  144151. */
  144152. export class SmoothStepBlock extends NodeMaterialBlock {
  144153. /**
  144154. * Creates a new SmoothStepBlock
  144155. * @param name defines the block name
  144156. */
  144157. constructor(name: string);
  144158. /**
  144159. * Gets the current class name
  144160. * @returns the class name
  144161. */
  144162. getClassName(): string;
  144163. /**
  144164. * Gets the value operand input component
  144165. */
  144166. get value(): NodeMaterialConnectionPoint;
  144167. /**
  144168. * Gets the first edge operand input component
  144169. */
  144170. get edge0(): NodeMaterialConnectionPoint;
  144171. /**
  144172. * Gets the second edge operand input component
  144173. */
  144174. get edge1(): NodeMaterialConnectionPoint;
  144175. /**
  144176. * Gets the output component
  144177. */
  144178. get output(): NodeMaterialConnectionPoint;
  144179. protected _buildBlock(state: NodeMaterialBuildState): this;
  144180. }
  144181. }
  144182. declare module BABYLON {
  144183. /**
  144184. * Block used to get the reciprocal (1 / x) of a value
  144185. */
  144186. export class ReciprocalBlock extends NodeMaterialBlock {
  144187. /**
  144188. * Creates a new ReciprocalBlock
  144189. * @param name defines the block name
  144190. */
  144191. constructor(name: string);
  144192. /**
  144193. * Gets the current class name
  144194. * @returns the class name
  144195. */
  144196. getClassName(): string;
  144197. /**
  144198. * Gets the input component
  144199. */
  144200. get input(): NodeMaterialConnectionPoint;
  144201. /**
  144202. * Gets the output component
  144203. */
  144204. get output(): NodeMaterialConnectionPoint;
  144205. protected _buildBlock(state: NodeMaterialBuildState): this;
  144206. }
  144207. }
  144208. declare module BABYLON {
  144209. /**
  144210. * Block used to replace a color by another one
  144211. */
  144212. export class ReplaceColorBlock extends NodeMaterialBlock {
  144213. /**
  144214. * Creates a new ReplaceColorBlock
  144215. * @param name defines the block name
  144216. */
  144217. constructor(name: string);
  144218. /**
  144219. * Gets the current class name
  144220. * @returns the class name
  144221. */
  144222. getClassName(): string;
  144223. /**
  144224. * Gets the value input component
  144225. */
  144226. get value(): NodeMaterialConnectionPoint;
  144227. /**
  144228. * Gets the reference input component
  144229. */
  144230. get reference(): NodeMaterialConnectionPoint;
  144231. /**
  144232. * Gets the distance input component
  144233. */
  144234. get distance(): NodeMaterialConnectionPoint;
  144235. /**
  144236. * Gets the replacement input component
  144237. */
  144238. get replacement(): NodeMaterialConnectionPoint;
  144239. /**
  144240. * Gets the output component
  144241. */
  144242. get output(): NodeMaterialConnectionPoint;
  144243. protected _buildBlock(state: NodeMaterialBuildState): this;
  144244. }
  144245. }
  144246. declare module BABYLON {
  144247. /**
  144248. * Block used to posterize a value
  144249. * @see https://en.wikipedia.org/wiki/Posterization
  144250. */
  144251. export class PosterizeBlock extends NodeMaterialBlock {
  144252. /**
  144253. * Creates a new PosterizeBlock
  144254. * @param name defines the block name
  144255. */
  144256. constructor(name: string);
  144257. /**
  144258. * Gets the current class name
  144259. * @returns the class name
  144260. */
  144261. getClassName(): string;
  144262. /**
  144263. * Gets the value input component
  144264. */
  144265. get value(): NodeMaterialConnectionPoint;
  144266. /**
  144267. * Gets the steps input component
  144268. */
  144269. get steps(): NodeMaterialConnectionPoint;
  144270. /**
  144271. * Gets the output component
  144272. */
  144273. get output(): NodeMaterialConnectionPoint;
  144274. protected _buildBlock(state: NodeMaterialBuildState): this;
  144275. }
  144276. }
  144277. declare module BABYLON {
  144278. /**
  144279. * Operations supported by the Wave block
  144280. */
  144281. export enum WaveBlockKind {
  144282. /** SawTooth */
  144283. SawTooth = 0,
  144284. /** Square */
  144285. Square = 1,
  144286. /** Triangle */
  144287. Triangle = 2
  144288. }
  144289. /**
  144290. * Block used to apply wave operation to floats
  144291. */
  144292. export class WaveBlock extends NodeMaterialBlock {
  144293. /**
  144294. * Gets or sets the kibnd of wave to be applied by the block
  144295. */
  144296. kind: WaveBlockKind;
  144297. /**
  144298. * Creates a new WaveBlock
  144299. * @param name defines the block name
  144300. */
  144301. constructor(name: string);
  144302. /**
  144303. * Gets the current class name
  144304. * @returns the class name
  144305. */
  144306. getClassName(): string;
  144307. /**
  144308. * Gets the input component
  144309. */
  144310. get input(): NodeMaterialConnectionPoint;
  144311. /**
  144312. * Gets the output component
  144313. */
  144314. get output(): NodeMaterialConnectionPoint;
  144315. protected _buildBlock(state: NodeMaterialBuildState): this;
  144316. serialize(): any;
  144317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144318. }
  144319. }
  144320. declare module BABYLON {
  144321. /**
  144322. * Class used to store a color step for the GradientBlock
  144323. */
  144324. export class GradientBlockColorStep {
  144325. private _step;
  144326. /**
  144327. * Gets value indicating which step this color is associated with (between 0 and 1)
  144328. */
  144329. get step(): number;
  144330. /**
  144331. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144332. */
  144333. set step(val: number);
  144334. private _color;
  144335. /**
  144336. * Gets the color associated with this step
  144337. */
  144338. get color(): Color3;
  144339. /**
  144340. * Sets the color associated with this step
  144341. */
  144342. set color(val: Color3);
  144343. /**
  144344. * Creates a new GradientBlockColorStep
  144345. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144346. * @param color defines the color associated with this step
  144347. */
  144348. constructor(step: number, color: Color3);
  144349. }
  144350. /**
  144351. * Block used to return a color from a gradient based on an input value between 0 and 1
  144352. */
  144353. export class GradientBlock extends NodeMaterialBlock {
  144354. /**
  144355. * Gets or sets the list of color steps
  144356. */
  144357. colorSteps: GradientBlockColorStep[];
  144358. /** Gets an observable raised when the value is changed */
  144359. onValueChangedObservable: Observable<GradientBlock>;
  144360. /** calls observable when the value is changed*/
  144361. colorStepsUpdated(): void;
  144362. /**
  144363. * Creates a new GradientBlock
  144364. * @param name defines the block name
  144365. */
  144366. constructor(name: string);
  144367. /**
  144368. * Gets the current class name
  144369. * @returns the class name
  144370. */
  144371. getClassName(): string;
  144372. /**
  144373. * Gets the gradient input component
  144374. */
  144375. get gradient(): NodeMaterialConnectionPoint;
  144376. /**
  144377. * Gets the output component
  144378. */
  144379. get output(): NodeMaterialConnectionPoint;
  144380. private _writeColorConstant;
  144381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144382. serialize(): any;
  144383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144384. protected _dumpPropertiesCode(): string;
  144385. }
  144386. }
  144387. declare module BABYLON {
  144388. /**
  144389. * Block used to normalize lerp between 2 values
  144390. */
  144391. export class NLerpBlock extends NodeMaterialBlock {
  144392. /**
  144393. * Creates a new NLerpBlock
  144394. * @param name defines the block name
  144395. */
  144396. constructor(name: string);
  144397. /**
  144398. * Gets the current class name
  144399. * @returns the class name
  144400. */
  144401. getClassName(): string;
  144402. /**
  144403. * Gets the left operand input component
  144404. */
  144405. get left(): NodeMaterialConnectionPoint;
  144406. /**
  144407. * Gets the right operand input component
  144408. */
  144409. get right(): NodeMaterialConnectionPoint;
  144410. /**
  144411. * Gets the gradient operand input component
  144412. */
  144413. get gradient(): NodeMaterialConnectionPoint;
  144414. /**
  144415. * Gets the output component
  144416. */
  144417. get output(): NodeMaterialConnectionPoint;
  144418. protected _buildBlock(state: NodeMaterialBuildState): this;
  144419. }
  144420. }
  144421. declare module BABYLON {
  144422. /**
  144423. * block used to Generate a Worley Noise 3D Noise Pattern
  144424. */
  144425. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144426. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144427. manhattanDistance: boolean;
  144428. /**
  144429. * Creates a new WorleyNoise3DBlock
  144430. * @param name defines the block name
  144431. */
  144432. constructor(name: string);
  144433. /**
  144434. * Gets the current class name
  144435. * @returns the class name
  144436. */
  144437. getClassName(): string;
  144438. /**
  144439. * Gets the seed input component
  144440. */
  144441. get seed(): NodeMaterialConnectionPoint;
  144442. /**
  144443. * Gets the jitter input component
  144444. */
  144445. get jitter(): NodeMaterialConnectionPoint;
  144446. /**
  144447. * Gets the output component
  144448. */
  144449. get output(): NodeMaterialConnectionPoint;
  144450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144451. /**
  144452. * Exposes the properties to the UI?
  144453. */
  144454. protected _dumpPropertiesCode(): string;
  144455. /**
  144456. * Exposes the properties to the Seralize?
  144457. */
  144458. serialize(): any;
  144459. /**
  144460. * Exposes the properties to the deseralize?
  144461. */
  144462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144463. }
  144464. }
  144465. declare module BABYLON {
  144466. /**
  144467. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144468. */
  144469. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144470. /**
  144471. * Creates a new SimplexPerlin3DBlock
  144472. * @param name defines the block name
  144473. */
  144474. constructor(name: string);
  144475. /**
  144476. * Gets the current class name
  144477. * @returns the class name
  144478. */
  144479. getClassName(): string;
  144480. /**
  144481. * Gets the seed operand input component
  144482. */
  144483. get seed(): NodeMaterialConnectionPoint;
  144484. /**
  144485. * Gets the output component
  144486. */
  144487. get output(): NodeMaterialConnectionPoint;
  144488. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144489. }
  144490. }
  144491. declare module BABYLON {
  144492. /**
  144493. * Block used to blend normals
  144494. */
  144495. export class NormalBlendBlock extends NodeMaterialBlock {
  144496. /**
  144497. * Creates a new NormalBlendBlock
  144498. * @param name defines the block name
  144499. */
  144500. constructor(name: string);
  144501. /**
  144502. * Gets the current class name
  144503. * @returns the class name
  144504. */
  144505. getClassName(): string;
  144506. /**
  144507. * Gets the first input component
  144508. */
  144509. get normalMap0(): NodeMaterialConnectionPoint;
  144510. /**
  144511. * Gets the second input component
  144512. */
  144513. get normalMap1(): NodeMaterialConnectionPoint;
  144514. /**
  144515. * Gets the output component
  144516. */
  144517. get output(): NodeMaterialConnectionPoint;
  144518. protected _buildBlock(state: NodeMaterialBuildState): this;
  144519. }
  144520. }
  144521. declare module BABYLON {
  144522. /**
  144523. * Block used to rotate a 2d vector by a given angle
  144524. */
  144525. export class Rotate2dBlock extends NodeMaterialBlock {
  144526. /**
  144527. * Creates a new Rotate2dBlock
  144528. * @param name defines the block name
  144529. */
  144530. constructor(name: string);
  144531. /**
  144532. * Gets the current class name
  144533. * @returns the class name
  144534. */
  144535. getClassName(): string;
  144536. /**
  144537. * Gets the input vector
  144538. */
  144539. get input(): NodeMaterialConnectionPoint;
  144540. /**
  144541. * Gets the input angle
  144542. */
  144543. get angle(): NodeMaterialConnectionPoint;
  144544. /**
  144545. * Gets the output component
  144546. */
  144547. get output(): NodeMaterialConnectionPoint;
  144548. autoConfigure(material: NodeMaterial): void;
  144549. protected _buildBlock(state: NodeMaterialBuildState): this;
  144550. }
  144551. }
  144552. declare module BABYLON {
  144553. /**
  144554. * Block used to get the reflected vector from a direction and a normal
  144555. */
  144556. export class ReflectBlock extends NodeMaterialBlock {
  144557. /**
  144558. * Creates a new ReflectBlock
  144559. * @param name defines the block name
  144560. */
  144561. constructor(name: string);
  144562. /**
  144563. * Gets the current class name
  144564. * @returns the class name
  144565. */
  144566. getClassName(): string;
  144567. /**
  144568. * Gets the incident component
  144569. */
  144570. get incident(): NodeMaterialConnectionPoint;
  144571. /**
  144572. * Gets the normal component
  144573. */
  144574. get normal(): NodeMaterialConnectionPoint;
  144575. /**
  144576. * Gets the output component
  144577. */
  144578. get output(): NodeMaterialConnectionPoint;
  144579. protected _buildBlock(state: NodeMaterialBuildState): this;
  144580. }
  144581. }
  144582. declare module BABYLON {
  144583. /**
  144584. * Block used to get the refracted vector from a direction and a normal
  144585. */
  144586. export class RefractBlock extends NodeMaterialBlock {
  144587. /**
  144588. * Creates a new RefractBlock
  144589. * @param name defines the block name
  144590. */
  144591. constructor(name: string);
  144592. /**
  144593. * Gets the current class name
  144594. * @returns the class name
  144595. */
  144596. getClassName(): string;
  144597. /**
  144598. * Gets the incident component
  144599. */
  144600. get incident(): NodeMaterialConnectionPoint;
  144601. /**
  144602. * Gets the normal component
  144603. */
  144604. get normal(): NodeMaterialConnectionPoint;
  144605. /**
  144606. * Gets the index of refraction component
  144607. */
  144608. get ior(): NodeMaterialConnectionPoint;
  144609. /**
  144610. * Gets the output component
  144611. */
  144612. get output(): NodeMaterialConnectionPoint;
  144613. protected _buildBlock(state: NodeMaterialBuildState): this;
  144614. }
  144615. }
  144616. declare module BABYLON {
  144617. /**
  144618. * Block used to desaturate a color
  144619. */
  144620. export class DesaturateBlock extends NodeMaterialBlock {
  144621. /**
  144622. * Creates a new DesaturateBlock
  144623. * @param name defines the block name
  144624. */
  144625. constructor(name: string);
  144626. /**
  144627. * Gets the current class name
  144628. * @returns the class name
  144629. */
  144630. getClassName(): string;
  144631. /**
  144632. * Gets the color operand input component
  144633. */
  144634. get color(): NodeMaterialConnectionPoint;
  144635. /**
  144636. * Gets the level operand input component
  144637. */
  144638. get level(): NodeMaterialConnectionPoint;
  144639. /**
  144640. * Gets the output component
  144641. */
  144642. get output(): NodeMaterialConnectionPoint;
  144643. protected _buildBlock(state: NodeMaterialBuildState): this;
  144644. }
  144645. }
  144646. declare module BABYLON {
  144647. /**
  144648. * Block used to implement the ambient occlusion module of the PBR material
  144649. */
  144650. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144651. /**
  144652. * Create a new AmbientOcclusionBlock
  144653. * @param name defines the block name
  144654. */
  144655. constructor(name: string);
  144656. /**
  144657. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144658. */
  144659. useAmbientInGrayScale: boolean;
  144660. /**
  144661. * Initialize the block and prepare the context for build
  144662. * @param state defines the state that will be used for the build
  144663. */
  144664. initialize(state: NodeMaterialBuildState): void;
  144665. /**
  144666. * Gets the current class name
  144667. * @returns the class name
  144668. */
  144669. getClassName(): string;
  144670. /**
  144671. * Gets the texture input component
  144672. */
  144673. get texture(): NodeMaterialConnectionPoint;
  144674. /**
  144675. * Gets the texture intensity component
  144676. */
  144677. get intensity(): NodeMaterialConnectionPoint;
  144678. /**
  144679. * Gets the direct light intensity input component
  144680. */
  144681. get directLightIntensity(): NodeMaterialConnectionPoint;
  144682. /**
  144683. * Gets the ambient occlusion object output component
  144684. */
  144685. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144686. /**
  144687. * Gets the main code of the block (fragment side)
  144688. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144689. * @returns the shader code
  144690. */
  144691. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144693. protected _buildBlock(state: NodeMaterialBuildState): this;
  144694. protected _dumpPropertiesCode(): string;
  144695. serialize(): any;
  144696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144697. }
  144698. }
  144699. declare module BABYLON {
  144700. /**
  144701. * Block used to implement the reflection module of the PBR material
  144702. */
  144703. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144704. /** @hidden */
  144705. _defineLODReflectionAlpha: string;
  144706. /** @hidden */
  144707. _defineLinearSpecularReflection: string;
  144708. private _vEnvironmentIrradianceName;
  144709. /** @hidden */
  144710. _vReflectionMicrosurfaceInfosName: string;
  144711. /** @hidden */
  144712. _vReflectionInfosName: string;
  144713. /** @hidden */
  144714. _vReflectionFilteringInfoName: string;
  144715. private _scene;
  144716. /**
  144717. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144718. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144719. * It's less burden on the user side in the editor part.
  144720. */
  144721. /** @hidden */
  144722. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144723. /** @hidden */
  144724. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144725. /** @hidden */
  144726. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144727. /**
  144728. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144729. * diffuse part of the IBL.
  144730. */
  144731. useSphericalHarmonics: boolean;
  144732. /**
  144733. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144734. */
  144735. forceIrradianceInFragment: boolean;
  144736. /**
  144737. * Create a new ReflectionBlock
  144738. * @param name defines the block name
  144739. */
  144740. constructor(name: string);
  144741. /**
  144742. * Gets the current class name
  144743. * @returns the class name
  144744. */
  144745. getClassName(): string;
  144746. /**
  144747. * Gets the position input component
  144748. */
  144749. get position(): NodeMaterialConnectionPoint;
  144750. /**
  144751. * Gets the world position input component
  144752. */
  144753. get worldPosition(): NodeMaterialConnectionPoint;
  144754. /**
  144755. * Gets the world normal input component
  144756. */
  144757. get worldNormal(): NodeMaterialConnectionPoint;
  144758. /**
  144759. * Gets the world input component
  144760. */
  144761. get world(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the camera (or eye) position component
  144764. */
  144765. get cameraPosition(): NodeMaterialConnectionPoint;
  144766. /**
  144767. * Gets the view input component
  144768. */
  144769. get view(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the color input component
  144772. */
  144773. get color(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the reflection object output component
  144776. */
  144777. get reflection(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144780. */
  144781. get hasTexture(): boolean;
  144782. /**
  144783. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144784. */
  144785. get reflectionColor(): string;
  144786. protected _getTexture(): Nullable<BaseTexture>;
  144787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144789. /**
  144790. * Gets the code to inject in the vertex shader
  144791. * @param state current state of the node material building
  144792. * @returns the shader code
  144793. */
  144794. handleVertexSide(state: NodeMaterialBuildState): string;
  144795. /**
  144796. * Gets the main code of the block (fragment side)
  144797. * @param state current state of the node material building
  144798. * @param normalVarName name of the existing variable corresponding to the normal
  144799. * @returns the shader code
  144800. */
  144801. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144802. protected _buildBlock(state: NodeMaterialBuildState): this;
  144803. protected _dumpPropertiesCode(): string;
  144804. serialize(): any;
  144805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144806. }
  144807. }
  144808. declare module BABYLON {
  144809. /**
  144810. * Block used to implement the sheen module of the PBR material
  144811. */
  144812. export class SheenBlock extends NodeMaterialBlock {
  144813. /**
  144814. * Create a new SheenBlock
  144815. * @param name defines the block name
  144816. */
  144817. constructor(name: string);
  144818. /**
  144819. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144820. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144821. * making it easier to setup and tweak the effect
  144822. */
  144823. albedoScaling: boolean;
  144824. /**
  144825. * Defines if the sheen is linked to the sheen color.
  144826. */
  144827. linkSheenWithAlbedo: boolean;
  144828. /**
  144829. * Initialize the block and prepare the context for build
  144830. * @param state defines the state that will be used for the build
  144831. */
  144832. initialize(state: NodeMaterialBuildState): void;
  144833. /**
  144834. * Gets the current class name
  144835. * @returns the class name
  144836. */
  144837. getClassName(): string;
  144838. /**
  144839. * Gets the intensity input component
  144840. */
  144841. get intensity(): NodeMaterialConnectionPoint;
  144842. /**
  144843. * Gets the color input component
  144844. */
  144845. get color(): NodeMaterialConnectionPoint;
  144846. /**
  144847. * Gets the roughness input component
  144848. */
  144849. get roughness(): NodeMaterialConnectionPoint;
  144850. /**
  144851. * Gets the sheen object output component
  144852. */
  144853. get sheen(): NodeMaterialConnectionPoint;
  144854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144855. /**
  144856. * Gets the main code of the block (fragment side)
  144857. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144858. * @returns the shader code
  144859. */
  144860. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144861. protected _buildBlock(state: NodeMaterialBuildState): this;
  144862. protected _dumpPropertiesCode(): string;
  144863. serialize(): any;
  144864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144865. }
  144866. }
  144867. declare module BABYLON {
  144868. /**
  144869. * Block used to implement the reflectivity module of the PBR material
  144870. */
  144871. export class ReflectivityBlock extends NodeMaterialBlock {
  144872. private _metallicReflectanceColor;
  144873. private _metallicF0Factor;
  144874. /** @hidden */
  144875. _vMetallicReflectanceFactorsName: string;
  144876. /**
  144877. * The property below is set by the main PBR block prior to calling methods of this class.
  144878. */
  144879. /** @hidden */
  144880. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144881. /**
  144882. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144883. */
  144884. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144885. /**
  144886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144887. */
  144888. useMetallnessFromMetallicTextureBlue: boolean;
  144889. /**
  144890. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144891. */
  144892. useRoughnessFromMetallicTextureAlpha: boolean;
  144893. /**
  144894. * Specifies if the metallic texture contains the roughness information in its green channel.
  144895. */
  144896. useRoughnessFromMetallicTextureGreen: boolean;
  144897. /**
  144898. * Create a new ReflectivityBlock
  144899. * @param name defines the block name
  144900. */
  144901. constructor(name: string);
  144902. /**
  144903. * Initialize the block and prepare the context for build
  144904. * @param state defines the state that will be used for the build
  144905. */
  144906. initialize(state: NodeMaterialBuildState): void;
  144907. /**
  144908. * Gets the current class name
  144909. * @returns the class name
  144910. */
  144911. getClassName(): string;
  144912. /**
  144913. * Gets the metallic input component
  144914. */
  144915. get metallic(): NodeMaterialConnectionPoint;
  144916. /**
  144917. * Gets the roughness input component
  144918. */
  144919. get roughness(): NodeMaterialConnectionPoint;
  144920. /**
  144921. * Gets the texture input component
  144922. */
  144923. get texture(): NodeMaterialConnectionPoint;
  144924. /**
  144925. * Gets the reflectivity object output component
  144926. */
  144927. get reflectivity(): NodeMaterialConnectionPoint;
  144928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144929. /**
  144930. * Gets the main code of the block (fragment side)
  144931. * @param state current state of the node material building
  144932. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144933. * @returns the shader code
  144934. */
  144935. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144937. protected _buildBlock(state: NodeMaterialBuildState): this;
  144938. protected _dumpPropertiesCode(): string;
  144939. serialize(): any;
  144940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144941. }
  144942. }
  144943. declare module BABYLON {
  144944. /**
  144945. * Block used to implement the anisotropy module of the PBR material
  144946. */
  144947. export class AnisotropyBlock extends NodeMaterialBlock {
  144948. /**
  144949. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144950. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144951. * It's less burden on the user side in the editor part.
  144952. */
  144953. /** @hidden */
  144954. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144955. /** @hidden */
  144956. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144957. /**
  144958. * Create a new AnisotropyBlock
  144959. * @param name defines the block name
  144960. */
  144961. constructor(name: string);
  144962. /**
  144963. * Initialize the block and prepare the context for build
  144964. * @param state defines the state that will be used for the build
  144965. */
  144966. initialize(state: NodeMaterialBuildState): void;
  144967. /**
  144968. * Gets the current class name
  144969. * @returns the class name
  144970. */
  144971. getClassName(): string;
  144972. /**
  144973. * Gets the intensity input component
  144974. */
  144975. get intensity(): NodeMaterialConnectionPoint;
  144976. /**
  144977. * Gets the direction input component
  144978. */
  144979. get direction(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the texture input component
  144982. */
  144983. get texture(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the uv input component
  144986. */
  144987. get uv(): NodeMaterialConnectionPoint;
  144988. /**
  144989. * Gets the worldTangent input component
  144990. */
  144991. get worldTangent(): NodeMaterialConnectionPoint;
  144992. /**
  144993. * Gets the anisotropy object output component
  144994. */
  144995. get anisotropy(): NodeMaterialConnectionPoint;
  144996. private _generateTBNSpace;
  144997. /**
  144998. * Gets the main code of the block (fragment side)
  144999. * @param state current state of the node material building
  145000. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145001. * @returns the shader code
  145002. */
  145003. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145005. protected _buildBlock(state: NodeMaterialBuildState): this;
  145006. }
  145007. }
  145008. declare module BABYLON {
  145009. /**
  145010. * Block used to implement the clear coat module of the PBR material
  145011. */
  145012. export class ClearCoatBlock extends NodeMaterialBlock {
  145013. private _scene;
  145014. /**
  145015. * Create a new ClearCoatBlock
  145016. * @param name defines the block name
  145017. */
  145018. constructor(name: string);
  145019. /**
  145020. * Initialize the block and prepare the context for build
  145021. * @param state defines the state that will be used for the build
  145022. */
  145023. initialize(state: NodeMaterialBuildState): void;
  145024. /**
  145025. * Gets the current class name
  145026. * @returns the class name
  145027. */
  145028. getClassName(): string;
  145029. /**
  145030. * Gets the intensity input component
  145031. */
  145032. get intensity(): NodeMaterialConnectionPoint;
  145033. /**
  145034. * Gets the roughness input component
  145035. */
  145036. get roughness(): NodeMaterialConnectionPoint;
  145037. /**
  145038. * Gets the ior input component
  145039. */
  145040. get ior(): NodeMaterialConnectionPoint;
  145041. /**
  145042. * Gets the texture input component
  145043. */
  145044. get texture(): NodeMaterialConnectionPoint;
  145045. /**
  145046. * Gets the bump texture input component
  145047. */
  145048. get bumpTexture(): NodeMaterialConnectionPoint;
  145049. /**
  145050. * Gets the uv input component
  145051. */
  145052. get uv(): NodeMaterialConnectionPoint;
  145053. /**
  145054. * Gets the tint color input component
  145055. */
  145056. get tintColor(): NodeMaterialConnectionPoint;
  145057. /**
  145058. * Gets the tint "at distance" input component
  145059. */
  145060. get tintAtDistance(): NodeMaterialConnectionPoint;
  145061. /**
  145062. * Gets the tint thickness input component
  145063. */
  145064. get tintThickness(): NodeMaterialConnectionPoint;
  145065. /**
  145066. * Gets the world tangent input component
  145067. */
  145068. get worldTangent(): NodeMaterialConnectionPoint;
  145069. /**
  145070. * Gets the clear coat object output component
  145071. */
  145072. get clearcoat(): NodeMaterialConnectionPoint;
  145073. autoConfigure(material: NodeMaterial): void;
  145074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145076. private _generateTBNSpace;
  145077. /**
  145078. * Gets the main code of the block (fragment side)
  145079. * @param state current state of the node material building
  145080. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145081. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145082. * @param worldPosVarName name of the variable holding the world position
  145083. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145084. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145085. * @param worldNormalVarName name of the variable holding the world normal
  145086. * @returns the shader code
  145087. */
  145088. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145089. protected _buildBlock(state: NodeMaterialBuildState): this;
  145090. }
  145091. }
  145092. declare module BABYLON {
  145093. /**
  145094. * Block used to implement the sub surface module of the PBR material
  145095. */
  145096. export class SubSurfaceBlock extends NodeMaterialBlock {
  145097. /**
  145098. * Create a new SubSurfaceBlock
  145099. * @param name defines the block name
  145100. */
  145101. constructor(name: string);
  145102. /**
  145103. * Stores the intensity of the different subsurface effects in the thickness texture.
  145104. * * the green channel is the translucency intensity.
  145105. * * the blue channel is the scattering intensity.
  145106. * * the alpha channel is the refraction intensity.
  145107. */
  145108. useMaskFromThicknessTexture: boolean;
  145109. /**
  145110. * Initialize the block and prepare the context for build
  145111. * @param state defines the state that will be used for the build
  145112. */
  145113. initialize(state: NodeMaterialBuildState): void;
  145114. /**
  145115. * Gets the current class name
  145116. * @returns the class name
  145117. */
  145118. getClassName(): string;
  145119. /**
  145120. * Gets the min thickness input component
  145121. */
  145122. get minThickness(): NodeMaterialConnectionPoint;
  145123. /**
  145124. * Gets the max thickness input component
  145125. */
  145126. get maxThickness(): NodeMaterialConnectionPoint;
  145127. /**
  145128. * Gets the thickness texture component
  145129. */
  145130. get thicknessTexture(): NodeMaterialConnectionPoint;
  145131. /**
  145132. * Gets the tint color input component
  145133. */
  145134. get tintColor(): NodeMaterialConnectionPoint;
  145135. /**
  145136. * Gets the translucency intensity input component
  145137. */
  145138. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145139. /**
  145140. * Gets the translucency diffusion distance input component
  145141. */
  145142. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145143. /**
  145144. * Gets the refraction object parameters
  145145. */
  145146. get refraction(): NodeMaterialConnectionPoint;
  145147. /**
  145148. * Gets the sub surface object output component
  145149. */
  145150. get subsurface(): NodeMaterialConnectionPoint;
  145151. autoConfigure(material: NodeMaterial): void;
  145152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145153. /**
  145154. * Gets the main code of the block (fragment side)
  145155. * @param state current state of the node material building
  145156. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145157. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145158. * @param worldPosVarName name of the variable holding the world position
  145159. * @returns the shader code
  145160. */
  145161. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145162. protected _buildBlock(state: NodeMaterialBuildState): this;
  145163. }
  145164. }
  145165. declare module BABYLON {
  145166. /**
  145167. * Block used to implement the PBR metallic/roughness model
  145168. */
  145169. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145170. /**
  145171. * Gets or sets the light associated with this block
  145172. */
  145173. light: Nullable<Light>;
  145174. private _lightId;
  145175. private _scene;
  145176. private _environmentBRDFTexture;
  145177. private _environmentBrdfSamplerName;
  145178. private _vNormalWName;
  145179. private _invertNormalName;
  145180. /**
  145181. * Create a new ReflectionBlock
  145182. * @param name defines the block name
  145183. */
  145184. constructor(name: string);
  145185. /**
  145186. * Intensity of the direct lights e.g. the four lights available in your scene.
  145187. * This impacts both the direct diffuse and specular highlights.
  145188. */
  145189. directIntensity: number;
  145190. /**
  145191. * Intensity of the environment e.g. how much the environment will light the object
  145192. * either through harmonics for rough material or through the refelction for shiny ones.
  145193. */
  145194. environmentIntensity: number;
  145195. /**
  145196. * This is a special control allowing the reduction of the specular highlights coming from the
  145197. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145198. */
  145199. specularIntensity: number;
  145200. /**
  145201. * Defines the falloff type used in this material.
  145202. * It by default is Physical.
  145203. */
  145204. lightFalloff: number;
  145205. /**
  145206. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145207. */
  145208. useAlphaFromAlbedoTexture: boolean;
  145209. /**
  145210. * Specifies that alpha test should be used
  145211. */
  145212. useAlphaTest: boolean;
  145213. /**
  145214. * Defines the alpha limits in alpha test mode.
  145215. */
  145216. alphaTestCutoff: number;
  145217. /**
  145218. * Specifies that alpha blending should be used
  145219. */
  145220. useAlphaBlending: boolean;
  145221. /**
  145222. * Defines if the alpha value should be determined via the rgb values.
  145223. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145224. */
  145225. opacityRGB: boolean;
  145226. /**
  145227. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145228. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145229. */
  145230. useRadianceOverAlpha: boolean;
  145231. /**
  145232. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145233. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145234. */
  145235. useSpecularOverAlpha: boolean;
  145236. /**
  145237. * Enables specular anti aliasing in the PBR shader.
  145238. * It will both interacts on the Geometry for analytical and IBL lighting.
  145239. * It also prefilter the roughness map based on the bump values.
  145240. */
  145241. enableSpecularAntiAliasing: boolean;
  145242. /**
  145243. * Enables realtime filtering on the texture.
  145244. */
  145245. realTimeFiltering: boolean;
  145246. /**
  145247. * Quality switch for realtime filtering
  145248. */
  145249. realTimeFilteringQuality: number;
  145250. /**
  145251. * Defines if the material uses energy conservation.
  145252. */
  145253. useEnergyConservation: boolean;
  145254. /**
  145255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145256. * too much the area relying on ambient texture to define their ambient occlusion.
  145257. */
  145258. useRadianceOcclusion: boolean;
  145259. /**
  145260. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145261. * makes the reflect vector face the model (under horizon).
  145262. */
  145263. useHorizonOcclusion: boolean;
  145264. /**
  145265. * If set to true, no lighting calculations will be applied.
  145266. */
  145267. unlit: boolean;
  145268. /**
  145269. * Force normal to face away from face.
  145270. */
  145271. forceNormalForward: boolean;
  145272. /**
  145273. * Defines the material debug mode.
  145274. * It helps seeing only some components of the material while troubleshooting.
  145275. */
  145276. debugMode: number;
  145277. /**
  145278. * Specify from where on screen the debug mode should start.
  145279. * The value goes from -1 (full screen) to 1 (not visible)
  145280. * It helps with side by side comparison against the final render
  145281. * This defaults to 0
  145282. */
  145283. debugLimit: number;
  145284. /**
  145285. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145286. * You can use the factor to better multiply the final value.
  145287. */
  145288. debugFactor: number;
  145289. /**
  145290. * Initialize the block and prepare the context for build
  145291. * @param state defines the state that will be used for the build
  145292. */
  145293. initialize(state: NodeMaterialBuildState): void;
  145294. /**
  145295. * Gets the current class name
  145296. * @returns the class name
  145297. */
  145298. getClassName(): string;
  145299. /**
  145300. * Gets the world position input component
  145301. */
  145302. get worldPosition(): NodeMaterialConnectionPoint;
  145303. /**
  145304. * Gets the world normal input component
  145305. */
  145306. get worldNormal(): NodeMaterialConnectionPoint;
  145307. /**
  145308. * Gets the perturbed normal input component
  145309. */
  145310. get perturbedNormal(): NodeMaterialConnectionPoint;
  145311. /**
  145312. * Gets the camera position input component
  145313. */
  145314. get cameraPosition(): NodeMaterialConnectionPoint;
  145315. /**
  145316. * Gets the base color input component
  145317. */
  145318. get baseColor(): NodeMaterialConnectionPoint;
  145319. /**
  145320. * Gets the opacity texture input component
  145321. */
  145322. get opacityTexture(): NodeMaterialConnectionPoint;
  145323. /**
  145324. * Gets the ambient color input component
  145325. */
  145326. get ambientColor(): NodeMaterialConnectionPoint;
  145327. /**
  145328. * Gets the reflectivity object parameters
  145329. */
  145330. get reflectivity(): NodeMaterialConnectionPoint;
  145331. /**
  145332. * Gets the ambient occlusion object parameters
  145333. */
  145334. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the reflection object parameters
  145337. */
  145338. get reflection(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the sheen object parameters
  145341. */
  145342. get sheen(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the clear coat object parameters
  145345. */
  145346. get clearcoat(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the sub surface object parameters
  145349. */
  145350. get subsurface(): NodeMaterialConnectionPoint;
  145351. /**
  145352. * Gets the anisotropy object parameters
  145353. */
  145354. get anisotropy(): NodeMaterialConnectionPoint;
  145355. /**
  145356. * Gets the ambient output component
  145357. */
  145358. get ambient(): NodeMaterialConnectionPoint;
  145359. /**
  145360. * Gets the diffuse output component
  145361. */
  145362. get diffuse(): NodeMaterialConnectionPoint;
  145363. /**
  145364. * Gets the specular output component
  145365. */
  145366. get specular(): NodeMaterialConnectionPoint;
  145367. /**
  145368. * Gets the sheen output component
  145369. */
  145370. get sheenDir(): NodeMaterialConnectionPoint;
  145371. /**
  145372. * Gets the clear coat output component
  145373. */
  145374. get clearcoatDir(): NodeMaterialConnectionPoint;
  145375. /**
  145376. * Gets the indirect diffuse output component
  145377. */
  145378. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145379. /**
  145380. * Gets the indirect specular output component
  145381. */
  145382. get specularIndirect(): NodeMaterialConnectionPoint;
  145383. /**
  145384. * Gets the indirect sheen output component
  145385. */
  145386. get sheenIndirect(): NodeMaterialConnectionPoint;
  145387. /**
  145388. * Gets the indirect clear coat output component
  145389. */
  145390. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the refraction output component
  145393. */
  145394. get refraction(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the global lighting output component
  145397. */
  145398. get lighting(): NodeMaterialConnectionPoint;
  145399. /**
  145400. * Gets the shadow output component
  145401. */
  145402. get shadow(): NodeMaterialConnectionPoint;
  145403. /**
  145404. * Gets the alpha output component
  145405. */
  145406. get alpha(): NodeMaterialConnectionPoint;
  145407. autoConfigure(material: NodeMaterial): void;
  145408. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145409. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145411. private _injectVertexCode;
  145412. /**
  145413. * Gets the code corresponding to the albedo/opacity module
  145414. * @returns the shader code
  145415. */
  145416. getAlbedoOpacityCode(): string;
  145417. protected _buildBlock(state: NodeMaterialBuildState): this;
  145418. protected _dumpPropertiesCode(): string;
  145419. serialize(): any;
  145420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145421. }
  145422. }
  145423. declare module BABYLON {
  145424. /**
  145425. * Block used to compute value of one parameter modulo another
  145426. */
  145427. export class ModBlock extends NodeMaterialBlock {
  145428. /**
  145429. * Creates a new ModBlock
  145430. * @param name defines the block name
  145431. */
  145432. constructor(name: string);
  145433. /**
  145434. * Gets the current class name
  145435. * @returns the class name
  145436. */
  145437. getClassName(): string;
  145438. /**
  145439. * Gets the left operand input component
  145440. */
  145441. get left(): NodeMaterialConnectionPoint;
  145442. /**
  145443. * Gets the right operand input component
  145444. */
  145445. get right(): NodeMaterialConnectionPoint;
  145446. /**
  145447. * Gets the output component
  145448. */
  145449. get output(): NodeMaterialConnectionPoint;
  145450. protected _buildBlock(state: NodeMaterialBuildState): this;
  145451. }
  145452. }
  145453. declare module BABYLON {
  145454. /**
  145455. * Configuration for Draco compression
  145456. */
  145457. export interface IDracoCompressionConfiguration {
  145458. /**
  145459. * Configuration for the decoder.
  145460. */
  145461. decoder: {
  145462. /**
  145463. * The url to the WebAssembly module.
  145464. */
  145465. wasmUrl?: string;
  145466. /**
  145467. * The url to the WebAssembly binary.
  145468. */
  145469. wasmBinaryUrl?: string;
  145470. /**
  145471. * The url to the fallback JavaScript module.
  145472. */
  145473. fallbackUrl?: string;
  145474. };
  145475. }
  145476. /**
  145477. * Draco compression (https://google.github.io/draco/)
  145478. *
  145479. * This class wraps the Draco module.
  145480. *
  145481. * **Encoder**
  145482. *
  145483. * The encoder is not currently implemented.
  145484. *
  145485. * **Decoder**
  145486. *
  145487. * 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.
  145488. *
  145489. * To update the configuration, use the following code:
  145490. * ```javascript
  145491. * DracoCompression.Configuration = {
  145492. * decoder: {
  145493. * wasmUrl: "<url to the WebAssembly library>",
  145494. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145495. * fallbackUrl: "<url to the fallback JavaScript library>",
  145496. * }
  145497. * };
  145498. * ```
  145499. *
  145500. * 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.
  145501. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145502. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145503. *
  145504. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145505. * ```javascript
  145506. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145507. * ```
  145508. *
  145509. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145510. */
  145511. export class DracoCompression implements IDisposable {
  145512. private _workerPoolPromise?;
  145513. private _decoderModulePromise?;
  145514. /**
  145515. * The configuration. Defaults to the following urls:
  145516. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145517. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145518. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145519. */
  145520. static Configuration: IDracoCompressionConfiguration;
  145521. /**
  145522. * Returns true if the decoder configuration is available.
  145523. */
  145524. static get DecoderAvailable(): boolean;
  145525. /**
  145526. * Default number of workers to create when creating the draco compression object.
  145527. */
  145528. static DefaultNumWorkers: number;
  145529. private static GetDefaultNumWorkers;
  145530. private static _Default;
  145531. /**
  145532. * Default instance for the draco compression object.
  145533. */
  145534. static get Default(): DracoCompression;
  145535. /**
  145536. * Constructor
  145537. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145538. */
  145539. constructor(numWorkers?: number);
  145540. /**
  145541. * Stop all async operations and release resources.
  145542. */
  145543. dispose(): void;
  145544. /**
  145545. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145546. * @returns a promise that resolves when ready
  145547. */
  145548. whenReadyAsync(): Promise<void>;
  145549. /**
  145550. * Decode Draco compressed mesh data to vertex data.
  145551. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145552. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145553. * @returns A promise that resolves with the decoded vertex data
  145554. */
  145555. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145556. [kind: string]: number;
  145557. }): Promise<VertexData>;
  145558. }
  145559. }
  145560. declare module BABYLON {
  145561. /**
  145562. * Class for building Constructive Solid Geometry
  145563. */
  145564. export class CSG {
  145565. private polygons;
  145566. /**
  145567. * The world matrix
  145568. */
  145569. matrix: Matrix;
  145570. /**
  145571. * Stores the position
  145572. */
  145573. position: Vector3;
  145574. /**
  145575. * Stores the rotation
  145576. */
  145577. rotation: Vector3;
  145578. /**
  145579. * Stores the rotation quaternion
  145580. */
  145581. rotationQuaternion: Nullable<Quaternion>;
  145582. /**
  145583. * Stores the scaling vector
  145584. */
  145585. scaling: Vector3;
  145586. /**
  145587. * Convert the Mesh to CSG
  145588. * @param mesh The Mesh to convert to CSG
  145589. * @returns A new CSG from the Mesh
  145590. */
  145591. static FromMesh(mesh: Mesh): CSG;
  145592. /**
  145593. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145594. * @param polygons Polygons used to construct a CSG solid
  145595. */
  145596. private static FromPolygons;
  145597. /**
  145598. * Clones, or makes a deep copy, of the CSG
  145599. * @returns A new CSG
  145600. */
  145601. clone(): CSG;
  145602. /**
  145603. * Unions this CSG with another CSG
  145604. * @param csg The CSG to union against this CSG
  145605. * @returns The unioned CSG
  145606. */
  145607. union(csg: CSG): CSG;
  145608. /**
  145609. * Unions this CSG with another CSG in place
  145610. * @param csg The CSG to union against this CSG
  145611. */
  145612. unionInPlace(csg: CSG): void;
  145613. /**
  145614. * Subtracts this CSG with another CSG
  145615. * @param csg The CSG to subtract against this CSG
  145616. * @returns A new CSG
  145617. */
  145618. subtract(csg: CSG): CSG;
  145619. /**
  145620. * Subtracts this CSG with another CSG in place
  145621. * @param csg The CSG to subtact against this CSG
  145622. */
  145623. subtractInPlace(csg: CSG): void;
  145624. /**
  145625. * Intersect this CSG with another CSG
  145626. * @param csg The CSG to intersect against this CSG
  145627. * @returns A new CSG
  145628. */
  145629. intersect(csg: CSG): CSG;
  145630. /**
  145631. * Intersects this CSG with another CSG in place
  145632. * @param csg The CSG to intersect against this CSG
  145633. */
  145634. intersectInPlace(csg: CSG): void;
  145635. /**
  145636. * Return a new CSG solid with solid and empty space switched. This solid is
  145637. * not modified.
  145638. * @returns A new CSG solid with solid and empty space switched
  145639. */
  145640. inverse(): CSG;
  145641. /**
  145642. * Inverses the CSG in place
  145643. */
  145644. inverseInPlace(): void;
  145645. /**
  145646. * This is used to keep meshes transformations so they can be restored
  145647. * when we build back a Babylon Mesh
  145648. * NB : All CSG operations are performed in world coordinates
  145649. * @param csg The CSG to copy the transform attributes from
  145650. * @returns This CSG
  145651. */
  145652. copyTransformAttributes(csg: CSG): CSG;
  145653. /**
  145654. * Build Raw mesh from CSG
  145655. * Coordinates here are in world space
  145656. * @param name The name of the mesh geometry
  145657. * @param scene The Scene
  145658. * @param keepSubMeshes Specifies if the submeshes should be kept
  145659. * @returns A new Mesh
  145660. */
  145661. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145662. /**
  145663. * Build Mesh from CSG taking material and transforms into account
  145664. * @param name The name of the Mesh
  145665. * @param material The material of the Mesh
  145666. * @param scene The Scene
  145667. * @param keepSubMeshes Specifies if submeshes should be kept
  145668. * @returns The new Mesh
  145669. */
  145670. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145671. }
  145672. }
  145673. declare module BABYLON {
  145674. /**
  145675. * Class used to create a trail following a mesh
  145676. */
  145677. export class TrailMesh extends Mesh {
  145678. private _generator;
  145679. private _autoStart;
  145680. private _running;
  145681. private _diameter;
  145682. private _length;
  145683. private _sectionPolygonPointsCount;
  145684. private _sectionVectors;
  145685. private _sectionNormalVectors;
  145686. private _beforeRenderObserver;
  145687. /**
  145688. * @constructor
  145689. * @param name The value used by scene.getMeshByName() to do a lookup.
  145690. * @param generator The mesh or transform node to generate a trail.
  145691. * @param scene The scene to add this mesh to.
  145692. * @param diameter Diameter of trailing mesh. Default is 1.
  145693. * @param length Length of trailing mesh. Default is 60.
  145694. * @param autoStart Automatically start trailing mesh. Default true.
  145695. */
  145696. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145697. /**
  145698. * "TrailMesh"
  145699. * @returns "TrailMesh"
  145700. */
  145701. getClassName(): string;
  145702. private _createMesh;
  145703. /**
  145704. * Start trailing mesh.
  145705. */
  145706. start(): void;
  145707. /**
  145708. * Stop trailing mesh.
  145709. */
  145710. stop(): void;
  145711. /**
  145712. * Update trailing mesh geometry.
  145713. */
  145714. update(): void;
  145715. /**
  145716. * Returns a new TrailMesh object.
  145717. * @param name is a string, the name given to the new mesh
  145718. * @param newGenerator use new generator object for cloned trail mesh
  145719. * @returns a new mesh
  145720. */
  145721. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145722. /**
  145723. * Serializes this trail mesh
  145724. * @param serializationObject object to write serialization to
  145725. */
  145726. serialize(serializationObject: any): void;
  145727. /**
  145728. * Parses a serialized trail mesh
  145729. * @param parsedMesh the serialized mesh
  145730. * @param scene the scene to create the trail mesh in
  145731. * @returns the created trail mesh
  145732. */
  145733. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145734. }
  145735. }
  145736. declare module BABYLON {
  145737. /**
  145738. * Class containing static functions to help procedurally build meshes
  145739. */
  145740. export class TiledBoxBuilder {
  145741. /**
  145742. * Creates a box mesh
  145743. * 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)
  145744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145748. * @param name defines the name of the mesh
  145749. * @param options defines the options used to create the mesh
  145750. * @param scene defines the hosting scene
  145751. * @returns the box mesh
  145752. */
  145753. static CreateTiledBox(name: string, options: {
  145754. pattern?: number;
  145755. width?: number;
  145756. height?: number;
  145757. depth?: number;
  145758. tileSize?: number;
  145759. tileWidth?: number;
  145760. tileHeight?: number;
  145761. alignHorizontal?: number;
  145762. alignVertical?: number;
  145763. faceUV?: Vector4[];
  145764. faceColors?: Color4[];
  145765. sideOrientation?: number;
  145766. updatable?: boolean;
  145767. }, scene?: Nullable<Scene>): Mesh;
  145768. }
  145769. }
  145770. declare module BABYLON {
  145771. /**
  145772. * Class containing static functions to help procedurally build meshes
  145773. */
  145774. export class TorusKnotBuilder {
  145775. /**
  145776. * Creates a torus knot mesh
  145777. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145778. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145779. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145780. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145784. * @param name defines the name of the mesh
  145785. * @param options defines the options used to create the mesh
  145786. * @param scene defines the hosting scene
  145787. * @returns the torus knot mesh
  145788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145789. */
  145790. static CreateTorusKnot(name: string, options: {
  145791. radius?: number;
  145792. tube?: number;
  145793. radialSegments?: number;
  145794. tubularSegments?: number;
  145795. p?: number;
  145796. q?: number;
  145797. updatable?: boolean;
  145798. sideOrientation?: number;
  145799. frontUVs?: Vector4;
  145800. backUVs?: Vector4;
  145801. }, scene: any): Mesh;
  145802. }
  145803. }
  145804. declare module BABYLON {
  145805. /**
  145806. * Polygon
  145807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145808. */
  145809. export class Polygon {
  145810. /**
  145811. * Creates a rectangle
  145812. * @param xmin bottom X coord
  145813. * @param ymin bottom Y coord
  145814. * @param xmax top X coord
  145815. * @param ymax top Y coord
  145816. * @returns points that make the resulting rectation
  145817. */
  145818. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145819. /**
  145820. * Creates a circle
  145821. * @param radius radius of circle
  145822. * @param cx scale in x
  145823. * @param cy scale in y
  145824. * @param numberOfSides number of sides that make up the circle
  145825. * @returns points that make the resulting circle
  145826. */
  145827. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145828. /**
  145829. * Creates a polygon from input string
  145830. * @param input Input polygon data
  145831. * @returns the parsed points
  145832. */
  145833. static Parse(input: string): Vector2[];
  145834. /**
  145835. * Starts building a polygon from x and y coordinates
  145836. * @param x x coordinate
  145837. * @param y y coordinate
  145838. * @returns the started path2
  145839. */
  145840. static StartingAt(x: number, y: number): Path2;
  145841. }
  145842. /**
  145843. * Builds a polygon
  145844. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145845. */
  145846. export class PolygonMeshBuilder {
  145847. private _points;
  145848. private _outlinepoints;
  145849. private _holes;
  145850. private _name;
  145851. private _scene;
  145852. private _epoints;
  145853. private _eholes;
  145854. private _addToepoint;
  145855. /**
  145856. * Babylon reference to the earcut plugin.
  145857. */
  145858. bjsEarcut: any;
  145859. /**
  145860. * Creates a PolygonMeshBuilder
  145861. * @param name name of the builder
  145862. * @param contours Path of the polygon
  145863. * @param scene scene to add to when creating the mesh
  145864. * @param earcutInjection can be used to inject your own earcut reference
  145865. */
  145866. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145867. /**
  145868. * Adds a whole within the polygon
  145869. * @param hole Array of points defining the hole
  145870. * @returns this
  145871. */
  145872. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145873. /**
  145874. * Creates the polygon
  145875. * @param updatable If the mesh should be updatable
  145876. * @param depth The depth of the mesh created
  145877. * @returns the created mesh
  145878. */
  145879. build(updatable?: boolean, depth?: number): Mesh;
  145880. /**
  145881. * Creates the polygon
  145882. * @param depth The depth of the mesh created
  145883. * @returns the created VertexData
  145884. */
  145885. buildVertexData(depth?: number): VertexData;
  145886. /**
  145887. * Adds a side to the polygon
  145888. * @param positions points that make the polygon
  145889. * @param normals normals of the polygon
  145890. * @param uvs uvs of the polygon
  145891. * @param indices indices of the polygon
  145892. * @param bounds bounds of the polygon
  145893. * @param points points of the polygon
  145894. * @param depth depth of the polygon
  145895. * @param flip flip of the polygon
  145896. */
  145897. private addSide;
  145898. }
  145899. }
  145900. declare module BABYLON {
  145901. /**
  145902. * Class containing static functions to help procedurally build meshes
  145903. */
  145904. export class PolygonBuilder {
  145905. /**
  145906. * Creates a polygon mesh
  145907. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145908. * * 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
  145909. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145912. * * Remember you can only change the shape positions, not their number when updating a polygon
  145913. * @param name defines the name of the mesh
  145914. * @param options defines the options used to create the mesh
  145915. * @param scene defines the hosting scene
  145916. * @param earcutInjection can be used to inject your own earcut reference
  145917. * @returns the polygon mesh
  145918. */
  145919. static CreatePolygon(name: string, options: {
  145920. shape: Vector3[];
  145921. holes?: Vector3[][];
  145922. depth?: number;
  145923. faceUV?: Vector4[];
  145924. faceColors?: Color4[];
  145925. updatable?: boolean;
  145926. sideOrientation?: number;
  145927. frontUVs?: Vector4;
  145928. backUVs?: Vector4;
  145929. wrap?: boolean;
  145930. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145931. /**
  145932. * Creates an extruded polygon mesh, with depth in the Y direction.
  145933. * * 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)
  145934. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145935. * @param name defines the name of the mesh
  145936. * @param options defines the options used to create the mesh
  145937. * @param scene defines the hosting scene
  145938. * @param earcutInjection can be used to inject your own earcut reference
  145939. * @returns the polygon mesh
  145940. */
  145941. static ExtrudePolygon(name: string, options: {
  145942. shape: Vector3[];
  145943. holes?: Vector3[][];
  145944. depth?: number;
  145945. faceUV?: Vector4[];
  145946. faceColors?: Color4[];
  145947. updatable?: boolean;
  145948. sideOrientation?: number;
  145949. frontUVs?: Vector4;
  145950. backUVs?: Vector4;
  145951. wrap?: boolean;
  145952. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145953. }
  145954. }
  145955. declare module BABYLON {
  145956. /**
  145957. * Class containing static functions to help procedurally build meshes
  145958. */
  145959. export class LatheBuilder {
  145960. /**
  145961. * Creates lathe mesh.
  145962. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145963. * * 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
  145964. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145965. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145966. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145967. * * 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
  145968. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145969. * * 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
  145970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145974. * @param name defines the name of the mesh
  145975. * @param options defines the options used to create the mesh
  145976. * @param scene defines the hosting scene
  145977. * @returns the lathe mesh
  145978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145979. */
  145980. static CreateLathe(name: string, options: {
  145981. shape: Vector3[];
  145982. radius?: number;
  145983. tessellation?: number;
  145984. clip?: number;
  145985. arc?: number;
  145986. closed?: boolean;
  145987. updatable?: boolean;
  145988. sideOrientation?: number;
  145989. frontUVs?: Vector4;
  145990. backUVs?: Vector4;
  145991. cap?: number;
  145992. invertUV?: boolean;
  145993. }, scene?: Nullable<Scene>): Mesh;
  145994. }
  145995. }
  145996. declare module BABYLON {
  145997. /**
  145998. * Class containing static functions to help procedurally build meshes
  145999. */
  146000. export class TiledPlaneBuilder {
  146001. /**
  146002. * Creates a tiled plane mesh
  146003. * * The parameter `pattern` will, depending on value, do nothing or
  146004. * * * flip (reflect about central vertical) alternate tiles across and up
  146005. * * * flip every tile on alternate rows
  146006. * * * rotate (180 degs) alternate tiles across and up
  146007. * * * rotate every tile on alternate rows
  146008. * * * flip and rotate alternate tiles across and up
  146009. * * * flip and rotate every tile on alternate rows
  146010. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146011. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146014. * * 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)
  146015. * * 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)
  146016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146017. * @param name defines the name of the mesh
  146018. * @param options defines the options used to create the mesh
  146019. * @param scene defines the hosting scene
  146020. * @returns the box mesh
  146021. */
  146022. static CreateTiledPlane(name: string, options: {
  146023. pattern?: number;
  146024. tileSize?: number;
  146025. tileWidth?: number;
  146026. tileHeight?: number;
  146027. size?: number;
  146028. width?: number;
  146029. height?: number;
  146030. alignHorizontal?: number;
  146031. alignVertical?: number;
  146032. sideOrientation?: number;
  146033. frontUVs?: Vector4;
  146034. backUVs?: Vector4;
  146035. updatable?: boolean;
  146036. }, scene?: Nullable<Scene>): Mesh;
  146037. }
  146038. }
  146039. declare module BABYLON {
  146040. /**
  146041. * Class containing static functions to help procedurally build meshes
  146042. */
  146043. export class TubeBuilder {
  146044. /**
  146045. * Creates a tube mesh.
  146046. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146047. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146048. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146049. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146050. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146051. * * 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)
  146052. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146053. * * 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
  146054. * * 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
  146055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146059. * @param name defines the name of the mesh
  146060. * @param options defines the options used to create the mesh
  146061. * @param scene defines the hosting scene
  146062. * @returns the tube mesh
  146063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146064. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146065. */
  146066. static CreateTube(name: string, options: {
  146067. path: Vector3[];
  146068. radius?: number;
  146069. tessellation?: number;
  146070. radiusFunction?: {
  146071. (i: number, distance: number): number;
  146072. };
  146073. cap?: number;
  146074. arc?: number;
  146075. updatable?: boolean;
  146076. sideOrientation?: number;
  146077. frontUVs?: Vector4;
  146078. backUVs?: Vector4;
  146079. instance?: Mesh;
  146080. invertUV?: boolean;
  146081. }, scene?: Nullable<Scene>): Mesh;
  146082. }
  146083. }
  146084. declare module BABYLON {
  146085. /**
  146086. * Class containing static functions to help procedurally build meshes
  146087. */
  146088. export class IcoSphereBuilder {
  146089. /**
  146090. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146091. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146092. * * 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`)
  146093. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146094. * * 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
  146095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146098. * @param name defines the name of the mesh
  146099. * @param options defines the options used to create the mesh
  146100. * @param scene defines the hosting scene
  146101. * @returns the icosahedron mesh
  146102. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146103. */
  146104. static CreateIcoSphere(name: string, options: {
  146105. radius?: number;
  146106. radiusX?: number;
  146107. radiusY?: number;
  146108. radiusZ?: number;
  146109. flat?: boolean;
  146110. subdivisions?: number;
  146111. sideOrientation?: number;
  146112. frontUVs?: Vector4;
  146113. backUVs?: Vector4;
  146114. updatable?: boolean;
  146115. }, scene?: Nullable<Scene>): Mesh;
  146116. }
  146117. }
  146118. declare module BABYLON {
  146119. /**
  146120. * Class containing static functions to help procedurally build meshes
  146121. */
  146122. export class DecalBuilder {
  146123. /**
  146124. * Creates a decal mesh.
  146125. * 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
  146126. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146127. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146128. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146129. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146130. * @param name defines the name of the mesh
  146131. * @param sourceMesh defines the mesh where the decal must be applied
  146132. * @param options defines the options used to create the mesh
  146133. * @param scene defines the hosting scene
  146134. * @returns the decal mesh
  146135. * @see https://doc.babylonjs.com/how_to/decals
  146136. */
  146137. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146138. position?: Vector3;
  146139. normal?: Vector3;
  146140. size?: Vector3;
  146141. angle?: number;
  146142. }): Mesh;
  146143. }
  146144. }
  146145. declare module BABYLON {
  146146. /**
  146147. * Class containing static functions to help procedurally build meshes
  146148. */
  146149. export class MeshBuilder {
  146150. /**
  146151. * Creates a box mesh
  146152. * * The parameter `size` sets the size (float) of each box side (default 1)
  146153. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146154. * * 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)
  146155. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146159. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146160. * @param name defines the name of the mesh
  146161. * @param options defines the options used to create the mesh
  146162. * @param scene defines the hosting scene
  146163. * @returns the box mesh
  146164. */
  146165. static CreateBox(name: string, options: {
  146166. size?: number;
  146167. width?: number;
  146168. height?: number;
  146169. depth?: number;
  146170. faceUV?: Vector4[];
  146171. faceColors?: Color4[];
  146172. sideOrientation?: number;
  146173. frontUVs?: Vector4;
  146174. backUVs?: Vector4;
  146175. wrap?: boolean;
  146176. topBaseAt?: number;
  146177. bottomBaseAt?: number;
  146178. updatable?: boolean;
  146179. }, scene?: Nullable<Scene>): Mesh;
  146180. /**
  146181. * Creates a tiled box mesh
  146182. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146184. * @param name defines the name of the mesh
  146185. * @param options defines the options used to create the mesh
  146186. * @param scene defines the hosting scene
  146187. * @returns the tiled box mesh
  146188. */
  146189. static CreateTiledBox(name: string, options: {
  146190. pattern?: number;
  146191. size?: number;
  146192. width?: number;
  146193. height?: number;
  146194. depth: number;
  146195. tileSize?: number;
  146196. tileWidth?: number;
  146197. tileHeight?: number;
  146198. faceUV?: Vector4[];
  146199. faceColors?: Color4[];
  146200. alignHorizontal?: number;
  146201. alignVertical?: number;
  146202. sideOrientation?: number;
  146203. updatable?: boolean;
  146204. }, scene?: Nullable<Scene>): Mesh;
  146205. /**
  146206. * Creates a sphere mesh
  146207. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146208. * * 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`)
  146209. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146210. * * 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
  146211. * * 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)
  146212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146215. * @param name defines the name of the mesh
  146216. * @param options defines the options used to create the mesh
  146217. * @param scene defines the hosting scene
  146218. * @returns the sphere mesh
  146219. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146220. */
  146221. static CreateSphere(name: string, options: {
  146222. segments?: number;
  146223. diameter?: number;
  146224. diameterX?: number;
  146225. diameterY?: number;
  146226. diameterZ?: number;
  146227. arc?: number;
  146228. slice?: number;
  146229. sideOrientation?: number;
  146230. frontUVs?: Vector4;
  146231. backUVs?: Vector4;
  146232. updatable?: boolean;
  146233. }, scene?: Nullable<Scene>): Mesh;
  146234. /**
  146235. * Creates a plane polygonal mesh. By default, this is a disc
  146236. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146237. * * 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
  146238. * * 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
  146239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146242. * @param name defines the name of the mesh
  146243. * @param options defines the options used to create the mesh
  146244. * @param scene defines the hosting scene
  146245. * @returns the plane polygonal mesh
  146246. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146247. */
  146248. static CreateDisc(name: string, options: {
  146249. radius?: number;
  146250. tessellation?: number;
  146251. arc?: number;
  146252. updatable?: boolean;
  146253. sideOrientation?: number;
  146254. frontUVs?: Vector4;
  146255. backUVs?: Vector4;
  146256. }, scene?: Nullable<Scene>): Mesh;
  146257. /**
  146258. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146259. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146260. * * 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`)
  146261. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146262. * * 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
  146263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146266. * @param name defines the name of the mesh
  146267. * @param options defines the options used to create the mesh
  146268. * @param scene defines the hosting scene
  146269. * @returns the icosahedron mesh
  146270. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146271. */
  146272. static CreateIcoSphere(name: string, options: {
  146273. radius?: number;
  146274. radiusX?: number;
  146275. radiusY?: number;
  146276. radiusZ?: number;
  146277. flat?: boolean;
  146278. subdivisions?: number;
  146279. sideOrientation?: number;
  146280. frontUVs?: Vector4;
  146281. backUVs?: Vector4;
  146282. updatable?: boolean;
  146283. }, scene?: Nullable<Scene>): Mesh;
  146284. /**
  146285. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146286. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146287. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146288. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146289. * * 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
  146290. * * 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
  146291. * * 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
  146292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146295. * * 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
  146296. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146297. * * 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
  146298. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146300. * @param name defines the name of the mesh
  146301. * @param options defines the options used to create the mesh
  146302. * @param scene defines the hosting scene
  146303. * @returns the ribbon mesh
  146304. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146306. */
  146307. static CreateRibbon(name: string, options: {
  146308. pathArray: Vector3[][];
  146309. closeArray?: boolean;
  146310. closePath?: boolean;
  146311. offset?: number;
  146312. updatable?: boolean;
  146313. sideOrientation?: number;
  146314. frontUVs?: Vector4;
  146315. backUVs?: Vector4;
  146316. instance?: Mesh;
  146317. invertUV?: boolean;
  146318. uvs?: Vector2[];
  146319. colors?: Color4[];
  146320. }, scene?: Nullable<Scene>): Mesh;
  146321. /**
  146322. * Creates a cylinder or a cone mesh
  146323. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146324. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146325. * * 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.
  146326. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146327. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146328. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146329. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146330. * * 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).
  146331. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146332. * * 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).
  146333. * * 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
  146334. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146335. * * 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
  146336. * * 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.
  146337. * * If `enclose` is false, a ring surface is one element.
  146338. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146339. * * 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
  146340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146343. * @param name defines the name of the mesh
  146344. * @param options defines the options used to create the mesh
  146345. * @param scene defines the hosting scene
  146346. * @returns the cylinder mesh
  146347. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146348. */
  146349. static CreateCylinder(name: string, options: {
  146350. height?: number;
  146351. diameterTop?: number;
  146352. diameterBottom?: number;
  146353. diameter?: number;
  146354. tessellation?: number;
  146355. subdivisions?: number;
  146356. arc?: number;
  146357. faceColors?: Color4[];
  146358. faceUV?: Vector4[];
  146359. updatable?: boolean;
  146360. hasRings?: boolean;
  146361. enclose?: boolean;
  146362. cap?: number;
  146363. sideOrientation?: number;
  146364. frontUVs?: Vector4;
  146365. backUVs?: Vector4;
  146366. }, scene?: Nullable<Scene>): Mesh;
  146367. /**
  146368. * Creates a torus mesh
  146369. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146370. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146371. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146375. * @param name defines the name of the mesh
  146376. * @param options defines the options used to create the mesh
  146377. * @param scene defines the hosting scene
  146378. * @returns the torus mesh
  146379. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146380. */
  146381. static CreateTorus(name: string, options: {
  146382. diameter?: number;
  146383. thickness?: number;
  146384. tessellation?: number;
  146385. updatable?: boolean;
  146386. sideOrientation?: number;
  146387. frontUVs?: Vector4;
  146388. backUVs?: Vector4;
  146389. }, scene?: Nullable<Scene>): Mesh;
  146390. /**
  146391. * Creates a torus knot mesh
  146392. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146393. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146394. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146395. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146399. * @param name defines the name of the mesh
  146400. * @param options defines the options used to create the mesh
  146401. * @param scene defines the hosting scene
  146402. * @returns the torus knot mesh
  146403. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146404. */
  146405. static CreateTorusKnot(name: string, options: {
  146406. radius?: number;
  146407. tube?: number;
  146408. radialSegments?: number;
  146409. tubularSegments?: number;
  146410. p?: number;
  146411. q?: number;
  146412. updatable?: boolean;
  146413. sideOrientation?: number;
  146414. frontUVs?: Vector4;
  146415. backUVs?: Vector4;
  146416. }, scene?: Nullable<Scene>): Mesh;
  146417. /**
  146418. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146419. * * 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
  146420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146421. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146422. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146423. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146425. * * 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
  146426. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146429. * @param name defines the name of the new line system
  146430. * @param options defines the options used to create the line system
  146431. * @param scene defines the hosting scene
  146432. * @returns a new line system mesh
  146433. */
  146434. static CreateLineSystem(name: string, options: {
  146435. lines: Vector3[][];
  146436. updatable?: boolean;
  146437. instance?: Nullable<LinesMesh>;
  146438. colors?: Nullable<Color4[][]>;
  146439. useVertexAlpha?: boolean;
  146440. }, scene: Nullable<Scene>): LinesMesh;
  146441. /**
  146442. * Creates a line mesh
  146443. * 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
  146444. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146445. * * The parameter `points` is an array successive Vector3
  146446. * * 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
  146447. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146448. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146449. * * When updating an instance, remember that only point positions can change, not the number of points
  146450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146452. * @param name defines the name of the new line system
  146453. * @param options defines the options used to create the line system
  146454. * @param scene defines the hosting scene
  146455. * @returns a new line mesh
  146456. */
  146457. static CreateLines(name: string, options: {
  146458. points: Vector3[];
  146459. updatable?: boolean;
  146460. instance?: Nullable<LinesMesh>;
  146461. colors?: Color4[];
  146462. useVertexAlpha?: boolean;
  146463. }, scene?: Nullable<Scene>): LinesMesh;
  146464. /**
  146465. * Creates a dashed line mesh
  146466. * * 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
  146467. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146468. * * The parameter `points` is an array successive Vector3
  146469. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146470. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146471. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146472. * * 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
  146473. * * When updating an instance, remember that only point positions can change, not the number of points
  146474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146475. * @param name defines the name of the mesh
  146476. * @param options defines the options used to create the mesh
  146477. * @param scene defines the hosting scene
  146478. * @returns the dashed line mesh
  146479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146480. */
  146481. static CreateDashedLines(name: string, options: {
  146482. points: Vector3[];
  146483. dashSize?: number;
  146484. gapSize?: number;
  146485. dashNb?: number;
  146486. updatable?: boolean;
  146487. instance?: LinesMesh;
  146488. }, scene?: Nullable<Scene>): LinesMesh;
  146489. /**
  146490. * 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.
  146491. * * 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.
  146492. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146493. * * 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.
  146494. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146495. * * 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
  146496. * * 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
  146497. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146502. * @param name defines the name of the mesh
  146503. * @param options defines the options used to create the mesh
  146504. * @param scene defines the hosting scene
  146505. * @returns the extruded shape mesh
  146506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146508. */
  146509. static ExtrudeShape(name: string, options: {
  146510. shape: Vector3[];
  146511. path: Vector3[];
  146512. scale?: number;
  146513. rotation?: number;
  146514. cap?: number;
  146515. updatable?: boolean;
  146516. sideOrientation?: number;
  146517. frontUVs?: Vector4;
  146518. backUVs?: Vector4;
  146519. instance?: Mesh;
  146520. invertUV?: boolean;
  146521. }, scene?: Nullable<Scene>): Mesh;
  146522. /**
  146523. * Creates an custom extruded shape mesh.
  146524. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146525. * * 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.
  146526. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146527. * * 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
  146528. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146529. * * 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
  146530. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146531. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146532. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146533. * * 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
  146534. * * 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
  146535. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146540. * @param name defines the name of the mesh
  146541. * @param options defines the options used to create the mesh
  146542. * @param scene defines the hosting scene
  146543. * @returns the custom extruded shape mesh
  146544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146547. */
  146548. static ExtrudeShapeCustom(name: string, options: {
  146549. shape: Vector3[];
  146550. path: Vector3[];
  146551. scaleFunction?: any;
  146552. rotationFunction?: any;
  146553. ribbonCloseArray?: boolean;
  146554. ribbonClosePath?: boolean;
  146555. cap?: number;
  146556. updatable?: boolean;
  146557. sideOrientation?: number;
  146558. frontUVs?: Vector4;
  146559. backUVs?: Vector4;
  146560. instance?: Mesh;
  146561. invertUV?: boolean;
  146562. }, scene?: Nullable<Scene>): Mesh;
  146563. /**
  146564. * Creates lathe mesh.
  146565. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146566. * * 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
  146567. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146568. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146569. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146570. * * 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
  146571. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146572. * * 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
  146573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146577. * @param name defines the name of the mesh
  146578. * @param options defines the options used to create the mesh
  146579. * @param scene defines the hosting scene
  146580. * @returns the lathe mesh
  146581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146582. */
  146583. static CreateLathe(name: string, options: {
  146584. shape: Vector3[];
  146585. radius?: number;
  146586. tessellation?: number;
  146587. clip?: number;
  146588. arc?: number;
  146589. closed?: boolean;
  146590. updatable?: boolean;
  146591. sideOrientation?: number;
  146592. frontUVs?: Vector4;
  146593. backUVs?: Vector4;
  146594. cap?: number;
  146595. invertUV?: boolean;
  146596. }, scene?: Nullable<Scene>): Mesh;
  146597. /**
  146598. * Creates a tiled plane mesh
  146599. * * You can set a limited pattern arrangement with the tiles
  146600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146603. * @param name defines the name of the mesh
  146604. * @param options defines the options used to create the mesh
  146605. * @param scene defines the hosting scene
  146606. * @returns the plane mesh
  146607. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146608. */
  146609. static CreateTiledPlane(name: string, options: {
  146610. pattern?: number;
  146611. tileSize?: number;
  146612. tileWidth?: number;
  146613. tileHeight?: number;
  146614. size?: number;
  146615. width?: number;
  146616. height?: number;
  146617. alignHorizontal?: number;
  146618. alignVertical?: number;
  146619. sideOrientation?: number;
  146620. frontUVs?: Vector4;
  146621. backUVs?: Vector4;
  146622. updatable?: boolean;
  146623. }, scene?: Nullable<Scene>): Mesh;
  146624. /**
  146625. * Creates a plane mesh
  146626. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146627. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146628. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146632. * @param name defines the name of the mesh
  146633. * @param options defines the options used to create the mesh
  146634. * @param scene defines the hosting scene
  146635. * @returns the plane mesh
  146636. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146637. */
  146638. static CreatePlane(name: string, options: {
  146639. size?: number;
  146640. width?: number;
  146641. height?: number;
  146642. sideOrientation?: number;
  146643. frontUVs?: Vector4;
  146644. backUVs?: Vector4;
  146645. updatable?: boolean;
  146646. sourcePlane?: Plane;
  146647. }, scene?: Nullable<Scene>): Mesh;
  146648. /**
  146649. * Creates a ground mesh
  146650. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146651. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146653. * @param name defines the name of the mesh
  146654. * @param options defines the options used to create the mesh
  146655. * @param scene defines the hosting scene
  146656. * @returns the ground mesh
  146657. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146658. */
  146659. static CreateGround(name: string, options: {
  146660. width?: number;
  146661. height?: number;
  146662. subdivisions?: number;
  146663. subdivisionsX?: number;
  146664. subdivisionsY?: number;
  146665. updatable?: boolean;
  146666. }, scene?: Nullable<Scene>): Mesh;
  146667. /**
  146668. * Creates a tiled ground mesh
  146669. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146670. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146671. * * 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
  146672. * * 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
  146673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146674. * @param name defines the name of the mesh
  146675. * @param options defines the options used to create the mesh
  146676. * @param scene defines the hosting scene
  146677. * @returns the tiled ground mesh
  146678. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146679. */
  146680. static CreateTiledGround(name: string, options: {
  146681. xmin: number;
  146682. zmin: number;
  146683. xmax: number;
  146684. zmax: number;
  146685. subdivisions?: {
  146686. w: number;
  146687. h: number;
  146688. };
  146689. precision?: {
  146690. w: number;
  146691. h: number;
  146692. };
  146693. updatable?: boolean;
  146694. }, scene?: Nullable<Scene>): Mesh;
  146695. /**
  146696. * Creates a ground mesh from a height map
  146697. * * The parameter `url` sets the URL of the height map image resource.
  146698. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146699. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146700. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146701. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146702. * * 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.
  146703. * * 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).
  146704. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146706. * @param name defines the name of the mesh
  146707. * @param url defines the url to the height map
  146708. * @param options defines the options used to create the mesh
  146709. * @param scene defines the hosting scene
  146710. * @returns the ground mesh
  146711. * @see https://doc.babylonjs.com/babylon101/height_map
  146712. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146713. */
  146714. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146715. width?: number;
  146716. height?: number;
  146717. subdivisions?: number;
  146718. minHeight?: number;
  146719. maxHeight?: number;
  146720. colorFilter?: Color3;
  146721. alphaFilter?: number;
  146722. updatable?: boolean;
  146723. onReady?: (mesh: GroundMesh) => void;
  146724. }, scene?: Nullable<Scene>): GroundMesh;
  146725. /**
  146726. * Creates a polygon mesh
  146727. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146728. * * 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
  146729. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146732. * * Remember you can only change the shape positions, not their number when updating a polygon
  146733. * @param name defines the name of the mesh
  146734. * @param options defines the options used to create the mesh
  146735. * @param scene defines the hosting scene
  146736. * @param earcutInjection can be used to inject your own earcut reference
  146737. * @returns the polygon mesh
  146738. */
  146739. static CreatePolygon(name: string, options: {
  146740. shape: Vector3[];
  146741. holes?: Vector3[][];
  146742. depth?: number;
  146743. faceUV?: Vector4[];
  146744. faceColors?: Color4[];
  146745. updatable?: boolean;
  146746. sideOrientation?: number;
  146747. frontUVs?: Vector4;
  146748. backUVs?: Vector4;
  146749. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146750. /**
  146751. * Creates an extruded polygon mesh, with depth in the Y direction.
  146752. * * 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)
  146753. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146754. * @param name defines the name of the mesh
  146755. * @param options defines the options used to create the mesh
  146756. * @param scene defines the hosting scene
  146757. * @param earcutInjection can be used to inject your own earcut reference
  146758. * @returns the polygon mesh
  146759. */
  146760. static ExtrudePolygon(name: string, options: {
  146761. shape: Vector3[];
  146762. holes?: Vector3[][];
  146763. depth?: number;
  146764. faceUV?: Vector4[];
  146765. faceColors?: Color4[];
  146766. updatable?: boolean;
  146767. sideOrientation?: number;
  146768. frontUVs?: Vector4;
  146769. backUVs?: Vector4;
  146770. wrap?: boolean;
  146771. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146772. /**
  146773. * Creates a tube mesh.
  146774. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146775. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146776. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146777. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146778. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146779. * * 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)
  146780. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146781. * * 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
  146782. * * 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
  146783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146787. * @param name defines the name of the mesh
  146788. * @param options defines the options used to create the mesh
  146789. * @param scene defines the hosting scene
  146790. * @returns the tube mesh
  146791. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146792. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146793. */
  146794. static CreateTube(name: string, options: {
  146795. path: Vector3[];
  146796. radius?: number;
  146797. tessellation?: number;
  146798. radiusFunction?: {
  146799. (i: number, distance: number): number;
  146800. };
  146801. cap?: number;
  146802. arc?: number;
  146803. updatable?: boolean;
  146804. sideOrientation?: number;
  146805. frontUVs?: Vector4;
  146806. backUVs?: Vector4;
  146807. instance?: Mesh;
  146808. invertUV?: boolean;
  146809. }, scene?: Nullable<Scene>): Mesh;
  146810. /**
  146811. * Creates a polyhedron mesh
  146812. * * 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
  146813. * * The parameter `size` (positive float, default 1) sets the polygon size
  146814. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146815. * * 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`
  146816. * * 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
  146817. * * 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)`)
  146818. * * 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
  146819. * * 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
  146820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146823. * @param name defines the name of the mesh
  146824. * @param options defines the options used to create the mesh
  146825. * @param scene defines the hosting scene
  146826. * @returns the polyhedron mesh
  146827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146828. */
  146829. static CreatePolyhedron(name: string, options: {
  146830. type?: number;
  146831. size?: number;
  146832. sizeX?: number;
  146833. sizeY?: number;
  146834. sizeZ?: number;
  146835. custom?: any;
  146836. faceUV?: Vector4[];
  146837. faceColors?: Color4[];
  146838. flat?: boolean;
  146839. updatable?: boolean;
  146840. sideOrientation?: number;
  146841. frontUVs?: Vector4;
  146842. backUVs?: Vector4;
  146843. }, scene?: Nullable<Scene>): Mesh;
  146844. /**
  146845. * Creates a decal mesh.
  146846. * 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
  146847. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146848. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146849. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146850. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146851. * @param name defines the name of the mesh
  146852. * @param sourceMesh defines the mesh where the decal must be applied
  146853. * @param options defines the options used to create the mesh
  146854. * @param scene defines the hosting scene
  146855. * @returns the decal mesh
  146856. * @see https://doc.babylonjs.com/how_to/decals
  146857. */
  146858. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146859. position?: Vector3;
  146860. normal?: Vector3;
  146861. size?: Vector3;
  146862. angle?: number;
  146863. }): Mesh;
  146864. /**
  146865. * Creates a Capsule Mesh
  146866. * @param name defines the name of the mesh.
  146867. * @param options the constructors options used to shape the mesh.
  146868. * @param scene defines the scene the mesh is scoped to.
  146869. * @returns the capsule mesh
  146870. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146871. */
  146872. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146873. }
  146874. }
  146875. declare module BABYLON {
  146876. /**
  146877. * A simplifier interface for future simplification implementations
  146878. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146879. */
  146880. export interface ISimplifier {
  146881. /**
  146882. * Simplification of a given mesh according to the given settings.
  146883. * Since this requires computation, it is assumed that the function runs async.
  146884. * @param settings The settings of the simplification, including quality and distance
  146885. * @param successCallback A callback that will be called after the mesh was simplified.
  146886. * @param errorCallback in case of an error, this callback will be called. optional.
  146887. */
  146888. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146889. }
  146890. /**
  146891. * Expected simplification settings.
  146892. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146893. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146894. */
  146895. export interface ISimplificationSettings {
  146896. /**
  146897. * Gets or sets the expected quality
  146898. */
  146899. quality: number;
  146900. /**
  146901. * Gets or sets the distance when this optimized version should be used
  146902. */
  146903. distance: number;
  146904. /**
  146905. * Gets an already optimized mesh
  146906. */
  146907. optimizeMesh?: boolean;
  146908. }
  146909. /**
  146910. * Class used to specify simplification options
  146911. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146912. */
  146913. export class SimplificationSettings implements ISimplificationSettings {
  146914. /** expected quality */
  146915. quality: number;
  146916. /** distance when this optimized version should be used */
  146917. distance: number;
  146918. /** already optimized mesh */
  146919. optimizeMesh?: boolean | undefined;
  146920. /**
  146921. * Creates a SimplificationSettings
  146922. * @param quality expected quality
  146923. * @param distance distance when this optimized version should be used
  146924. * @param optimizeMesh already optimized mesh
  146925. */
  146926. constructor(
  146927. /** expected quality */
  146928. quality: number,
  146929. /** distance when this optimized version should be used */
  146930. distance: number,
  146931. /** already optimized mesh */
  146932. optimizeMesh?: boolean | undefined);
  146933. }
  146934. /**
  146935. * Interface used to define a simplification task
  146936. */
  146937. export interface ISimplificationTask {
  146938. /**
  146939. * Array of settings
  146940. */
  146941. settings: Array<ISimplificationSettings>;
  146942. /**
  146943. * Simplification type
  146944. */
  146945. simplificationType: SimplificationType;
  146946. /**
  146947. * Mesh to simplify
  146948. */
  146949. mesh: Mesh;
  146950. /**
  146951. * Callback called on success
  146952. */
  146953. successCallback?: () => void;
  146954. /**
  146955. * Defines if parallel processing can be used
  146956. */
  146957. parallelProcessing: boolean;
  146958. }
  146959. /**
  146960. * Queue used to order the simplification tasks
  146961. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146962. */
  146963. export class SimplificationQueue {
  146964. private _simplificationArray;
  146965. /**
  146966. * Gets a boolean indicating that the process is still running
  146967. */
  146968. running: boolean;
  146969. /**
  146970. * Creates a new queue
  146971. */
  146972. constructor();
  146973. /**
  146974. * Adds a new simplification task
  146975. * @param task defines a task to add
  146976. */
  146977. addTask(task: ISimplificationTask): void;
  146978. /**
  146979. * Execute next task
  146980. */
  146981. executeNext(): void;
  146982. /**
  146983. * Execute a simplification task
  146984. * @param task defines the task to run
  146985. */
  146986. runSimplification(task: ISimplificationTask): void;
  146987. private getSimplifier;
  146988. }
  146989. /**
  146990. * The implemented types of simplification
  146991. * At the moment only Quadratic Error Decimation is implemented
  146992. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146993. */
  146994. export enum SimplificationType {
  146995. /** Quadratic error decimation */
  146996. QUADRATIC = 0
  146997. }
  146998. /**
  146999. * An implementation of the Quadratic Error simplification algorithm.
  147000. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147001. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147002. * @author RaananW
  147003. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147004. */
  147005. export class QuadraticErrorSimplification implements ISimplifier {
  147006. private _mesh;
  147007. private triangles;
  147008. private vertices;
  147009. private references;
  147010. private _reconstructedMesh;
  147011. /** Gets or sets the number pf sync interations */
  147012. syncIterations: number;
  147013. /** Gets or sets the aggressiveness of the simplifier */
  147014. aggressiveness: number;
  147015. /** Gets or sets the number of allowed iterations for decimation */
  147016. decimationIterations: number;
  147017. /** Gets or sets the espilon to use for bounding box computation */
  147018. boundingBoxEpsilon: number;
  147019. /**
  147020. * Creates a new QuadraticErrorSimplification
  147021. * @param _mesh defines the target mesh
  147022. */
  147023. constructor(_mesh: Mesh);
  147024. /**
  147025. * Simplification of a given mesh according to the given settings.
  147026. * Since this requires computation, it is assumed that the function runs async.
  147027. * @param settings The settings of the simplification, including quality and distance
  147028. * @param successCallback A callback that will be called after the mesh was simplified.
  147029. */
  147030. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147031. private runDecimation;
  147032. private initWithMesh;
  147033. private init;
  147034. private reconstructMesh;
  147035. private initDecimatedMesh;
  147036. private isFlipped;
  147037. private updateTriangles;
  147038. private identifyBorder;
  147039. private updateMesh;
  147040. private vertexError;
  147041. private calculateError;
  147042. }
  147043. }
  147044. declare module BABYLON {
  147045. interface Scene {
  147046. /** @hidden (Backing field) */
  147047. _simplificationQueue: SimplificationQueue;
  147048. /**
  147049. * Gets or sets the simplification queue attached to the scene
  147050. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147051. */
  147052. simplificationQueue: SimplificationQueue;
  147053. }
  147054. interface Mesh {
  147055. /**
  147056. * Simplify the mesh according to the given array of settings.
  147057. * Function will return immediately and will simplify async
  147058. * @param settings a collection of simplification settings
  147059. * @param parallelProcessing should all levels calculate parallel or one after the other
  147060. * @param simplificationType the type of simplification to run
  147061. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147062. * @returns the current mesh
  147063. */
  147064. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147065. }
  147066. /**
  147067. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147068. * created in a scene
  147069. */
  147070. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147071. /**
  147072. * The component name helpfull to identify the component in the list of scene components.
  147073. */
  147074. readonly name: string;
  147075. /**
  147076. * The scene the component belongs to.
  147077. */
  147078. scene: Scene;
  147079. /**
  147080. * Creates a new instance of the component for the given scene
  147081. * @param scene Defines the scene to register the component in
  147082. */
  147083. constructor(scene: Scene);
  147084. /**
  147085. * Registers the component in a given scene
  147086. */
  147087. register(): void;
  147088. /**
  147089. * Rebuilds the elements related to this component in case of
  147090. * context lost for instance.
  147091. */
  147092. rebuild(): void;
  147093. /**
  147094. * Disposes the component and the associated ressources
  147095. */
  147096. dispose(): void;
  147097. private _beforeCameraUpdate;
  147098. }
  147099. }
  147100. declare module BABYLON {
  147101. interface Mesh {
  147102. /**
  147103. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147104. */
  147105. thinInstanceEnablePicking: boolean;
  147106. /**
  147107. * Creates a new thin instance
  147108. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147109. * @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
  147110. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147111. */
  147112. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147113. /**
  147114. * Adds the transformation (matrix) of the current mesh as a thin instance
  147115. * @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
  147116. * @returns the thin instance index number
  147117. */
  147118. thinInstanceAddSelf(refresh: boolean): number;
  147119. /**
  147120. * Registers a custom attribute to be used with thin instances
  147121. * @param kind name of the attribute
  147122. * @param stride size in floats of the attribute
  147123. */
  147124. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147125. /**
  147126. * Sets the matrix of a thin instance
  147127. * @param index index of the thin instance
  147128. * @param matrix matrix to set
  147129. * @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
  147130. */
  147131. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147132. /**
  147133. * Sets the value of a custom attribute for a thin instance
  147134. * @param kind name of the attribute
  147135. * @param index index of the thin instance
  147136. * @param value value to set
  147137. * @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
  147138. */
  147139. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147140. /**
  147141. * 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.
  147142. */
  147143. thinInstanceCount: number;
  147144. /**
  147145. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147146. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147147. * @param buffer buffer to set
  147148. * @param stride size in floats of each value of the buffer
  147149. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147150. */
  147151. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147152. /**
  147153. * Gets the list of world matrices
  147154. * @return an array containing all the world matrices from the thin instances
  147155. */
  147156. thinInstanceGetWorldMatrices(): Matrix[];
  147157. /**
  147158. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147159. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147160. */
  147161. thinInstanceBufferUpdated(kind: string): void;
  147162. /**
  147163. * Applies a partial update to a buffer directly on the GPU
  147164. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  147165. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147166. * @param data the data to set in the GPU buffer
  147167. * @param offset the offset in the GPU buffer where to update the data
  147168. */
  147169. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147170. /**
  147171. * Refreshes the bounding info, taking into account all the thin instances defined
  147172. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147173. */
  147174. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147175. /** @hidden */
  147176. _thinInstanceInitializeUserStorage(): void;
  147177. /** @hidden */
  147178. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147179. /** @hidden */
  147180. _userThinInstanceBuffersStorage: {
  147181. data: {
  147182. [key: string]: Float32Array;
  147183. };
  147184. sizes: {
  147185. [key: string]: number;
  147186. };
  147187. vertexBuffers: {
  147188. [key: string]: Nullable<VertexBuffer>;
  147189. };
  147190. strides: {
  147191. [key: string]: number;
  147192. };
  147193. };
  147194. }
  147195. }
  147196. declare module BABYLON {
  147197. /**
  147198. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147199. */
  147200. export interface INavigationEnginePlugin {
  147201. /**
  147202. * plugin name
  147203. */
  147204. name: string;
  147205. /**
  147206. * Creates a navigation mesh
  147207. * @param meshes array of all the geometry used to compute the navigatio mesh
  147208. * @param parameters bunch of parameters used to filter geometry
  147209. */
  147210. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147211. /**
  147212. * Create a navigation mesh debug mesh
  147213. * @param scene is where the mesh will be added
  147214. * @returns debug display mesh
  147215. */
  147216. createDebugNavMesh(scene: Scene): Mesh;
  147217. /**
  147218. * Get a navigation mesh constrained position, closest to the parameter position
  147219. * @param position world position
  147220. * @returns the closest point to position constrained by the navigation mesh
  147221. */
  147222. getClosestPoint(position: Vector3): Vector3;
  147223. /**
  147224. * Get a navigation mesh constrained position, closest to the parameter position
  147225. * @param position world position
  147226. * @param result output the closest point to position constrained by the navigation mesh
  147227. */
  147228. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147229. /**
  147230. * Get a navigation mesh constrained position, within a particular radius
  147231. * @param position world position
  147232. * @param maxRadius the maximum distance to the constrained world position
  147233. * @returns the closest point to position constrained by the navigation mesh
  147234. */
  147235. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147236. /**
  147237. * Get a navigation mesh constrained position, within a particular radius
  147238. * @param position world position
  147239. * @param maxRadius the maximum distance to the constrained world position
  147240. * @param result output the closest point to position constrained by the navigation mesh
  147241. */
  147242. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147243. /**
  147244. * Compute the final position from a segment made of destination-position
  147245. * @param position world position
  147246. * @param destination world position
  147247. * @returns the resulting point along the navmesh
  147248. */
  147249. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147250. /**
  147251. * Compute the final position from a segment made of destination-position
  147252. * @param position world position
  147253. * @param destination world position
  147254. * @param result output the resulting point along the navmesh
  147255. */
  147256. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147257. /**
  147258. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147259. * @param start world position
  147260. * @param end world position
  147261. * @returns array containing world position composing the path
  147262. */
  147263. computePath(start: Vector3, end: Vector3): Vector3[];
  147264. /**
  147265. * If this plugin is supported
  147266. * @returns true if plugin is supported
  147267. */
  147268. isSupported(): boolean;
  147269. /**
  147270. * Create a new Crowd so you can add agents
  147271. * @param maxAgents the maximum agent count in the crowd
  147272. * @param maxAgentRadius the maximum radius an agent can have
  147273. * @param scene to attach the crowd to
  147274. * @returns the crowd you can add agents to
  147275. */
  147276. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147277. /**
  147278. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147279. * The queries will try to find a solution within those bounds
  147280. * default is (1,1,1)
  147281. * @param extent x,y,z value that define the extent around the queries point of reference
  147282. */
  147283. setDefaultQueryExtent(extent: Vector3): void;
  147284. /**
  147285. * Get the Bounding box extent specified by setDefaultQueryExtent
  147286. * @returns the box extent values
  147287. */
  147288. getDefaultQueryExtent(): Vector3;
  147289. /**
  147290. * build the navmesh from a previously saved state using getNavmeshData
  147291. * @param data the Uint8Array returned by getNavmeshData
  147292. */
  147293. buildFromNavmeshData(data: Uint8Array): void;
  147294. /**
  147295. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147296. * @returns data the Uint8Array that can be saved and reused
  147297. */
  147298. getNavmeshData(): Uint8Array;
  147299. /**
  147300. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147301. * @param result output the box extent values
  147302. */
  147303. getDefaultQueryExtentToRef(result: Vector3): void;
  147304. /**
  147305. * Release all resources
  147306. */
  147307. dispose(): void;
  147308. }
  147309. /**
  147310. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147311. */
  147312. export interface ICrowd {
  147313. /**
  147314. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147315. * You can attach anything to that node. The node position is updated in the scene update tick.
  147316. * @param pos world position that will be constrained by the navigation mesh
  147317. * @param parameters agent parameters
  147318. * @param transform hooked to the agent that will be update by the scene
  147319. * @returns agent index
  147320. */
  147321. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147322. /**
  147323. * Returns the agent position in world space
  147324. * @param index agent index returned by addAgent
  147325. * @returns world space position
  147326. */
  147327. getAgentPosition(index: number): Vector3;
  147328. /**
  147329. * Gets the agent position result in world space
  147330. * @param index agent index returned by addAgent
  147331. * @param result output world space position
  147332. */
  147333. getAgentPositionToRef(index: number, result: Vector3): void;
  147334. /**
  147335. * Gets the agent velocity in world space
  147336. * @param index agent index returned by addAgent
  147337. * @returns world space velocity
  147338. */
  147339. getAgentVelocity(index: number): Vector3;
  147340. /**
  147341. * Gets the agent velocity result in world space
  147342. * @param index agent index returned by addAgent
  147343. * @param result output world space velocity
  147344. */
  147345. getAgentVelocityToRef(index: number, result: Vector3): void;
  147346. /**
  147347. * remove a particular agent previously created
  147348. * @param index agent index returned by addAgent
  147349. */
  147350. removeAgent(index: number): void;
  147351. /**
  147352. * get the list of all agents attached to this crowd
  147353. * @returns list of agent indices
  147354. */
  147355. getAgents(): number[];
  147356. /**
  147357. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147358. * @param deltaTime in seconds
  147359. */
  147360. update(deltaTime: number): void;
  147361. /**
  147362. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147363. * @param index agent index returned by addAgent
  147364. * @param destination targeted world position
  147365. */
  147366. agentGoto(index: number, destination: Vector3): void;
  147367. /**
  147368. * Teleport the agent to a new position
  147369. * @param index agent index returned by addAgent
  147370. * @param destination targeted world position
  147371. */
  147372. agentTeleport(index: number, destination: Vector3): void;
  147373. /**
  147374. * Update agent parameters
  147375. * @param index agent index returned by addAgent
  147376. * @param parameters agent parameters
  147377. */
  147378. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147379. /**
  147380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147381. * The queries will try to find a solution within those bounds
  147382. * default is (1,1,1)
  147383. * @param extent x,y,z value that define the extent around the queries point of reference
  147384. */
  147385. setDefaultQueryExtent(extent: Vector3): void;
  147386. /**
  147387. * Get the Bounding box extent specified by setDefaultQueryExtent
  147388. * @returns the box extent values
  147389. */
  147390. getDefaultQueryExtent(): Vector3;
  147391. /**
  147392. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147393. * @param result output the box extent values
  147394. */
  147395. getDefaultQueryExtentToRef(result: Vector3): void;
  147396. /**
  147397. * Release all resources
  147398. */
  147399. dispose(): void;
  147400. }
  147401. /**
  147402. * Configures an agent
  147403. */
  147404. export interface IAgentParameters {
  147405. /**
  147406. * Agent radius. [Limit: >= 0]
  147407. */
  147408. radius: number;
  147409. /**
  147410. * Agent height. [Limit: > 0]
  147411. */
  147412. height: number;
  147413. /**
  147414. * Maximum allowed acceleration. [Limit: >= 0]
  147415. */
  147416. maxAcceleration: number;
  147417. /**
  147418. * Maximum allowed speed. [Limit: >= 0]
  147419. */
  147420. maxSpeed: number;
  147421. /**
  147422. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147423. */
  147424. collisionQueryRange: number;
  147425. /**
  147426. * The path visibility optimization range. [Limit: > 0]
  147427. */
  147428. pathOptimizationRange: number;
  147429. /**
  147430. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147431. */
  147432. separationWeight: number;
  147433. }
  147434. /**
  147435. * Configures the navigation mesh creation
  147436. */
  147437. export interface INavMeshParameters {
  147438. /**
  147439. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147440. */
  147441. cs: number;
  147442. /**
  147443. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147444. */
  147445. ch: number;
  147446. /**
  147447. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147448. */
  147449. walkableSlopeAngle: number;
  147450. /**
  147451. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147452. * be considered walkable. [Limit: >= 3] [Units: vx]
  147453. */
  147454. walkableHeight: number;
  147455. /**
  147456. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147457. */
  147458. walkableClimb: number;
  147459. /**
  147460. * The distance to erode/shrink the walkable area of the heightfield away from
  147461. * obstructions. [Limit: >=0] [Units: vx]
  147462. */
  147463. walkableRadius: number;
  147464. /**
  147465. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147466. */
  147467. maxEdgeLen: number;
  147468. /**
  147469. * The maximum distance a simplfied contour's border edges should deviate
  147470. * the original raw contour. [Limit: >=0] [Units: vx]
  147471. */
  147472. maxSimplificationError: number;
  147473. /**
  147474. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147475. */
  147476. minRegionArea: number;
  147477. /**
  147478. * Any regions with a span count smaller than this value will, if possible,
  147479. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147480. */
  147481. mergeRegionArea: number;
  147482. /**
  147483. * The maximum number of vertices allowed for polygons generated during the
  147484. * contour to polygon conversion process. [Limit: >= 3]
  147485. */
  147486. maxVertsPerPoly: number;
  147487. /**
  147488. * Sets the sampling distance to use when generating the detail mesh.
  147489. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147490. */
  147491. detailSampleDist: number;
  147492. /**
  147493. * The maximum distance the detail mesh surface should deviate from heightfield
  147494. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147495. */
  147496. detailSampleMaxError: number;
  147497. }
  147498. }
  147499. declare module BABYLON {
  147500. /**
  147501. * RecastJS navigation plugin
  147502. */
  147503. export class RecastJSPlugin implements INavigationEnginePlugin {
  147504. /**
  147505. * Reference to the Recast library
  147506. */
  147507. bjsRECAST: any;
  147508. /**
  147509. * plugin name
  147510. */
  147511. name: string;
  147512. /**
  147513. * the first navmesh created. We might extend this to support multiple navmeshes
  147514. */
  147515. navMesh: any;
  147516. /**
  147517. * Initializes the recastJS plugin
  147518. * @param recastInjection can be used to inject your own recast reference
  147519. */
  147520. constructor(recastInjection?: any);
  147521. /**
  147522. * Creates a navigation mesh
  147523. * @param meshes array of all the geometry used to compute the navigatio mesh
  147524. * @param parameters bunch of parameters used to filter geometry
  147525. */
  147526. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147527. /**
  147528. * Create a navigation mesh debug mesh
  147529. * @param scene is where the mesh will be added
  147530. * @returns debug display mesh
  147531. */
  147532. createDebugNavMesh(scene: Scene): Mesh;
  147533. /**
  147534. * Get a navigation mesh constrained position, closest to the parameter position
  147535. * @param position world position
  147536. * @returns the closest point to position constrained by the navigation mesh
  147537. */
  147538. getClosestPoint(position: Vector3): Vector3;
  147539. /**
  147540. * Get a navigation mesh constrained position, closest to the parameter position
  147541. * @param position world position
  147542. * @param result output the closest point to position constrained by the navigation mesh
  147543. */
  147544. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147545. /**
  147546. * Get a navigation mesh constrained position, within a particular radius
  147547. * @param position world position
  147548. * @param maxRadius the maximum distance to the constrained world position
  147549. * @returns the closest point to position constrained by the navigation mesh
  147550. */
  147551. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147552. /**
  147553. * Get a navigation mesh constrained position, within a particular radius
  147554. * @param position world position
  147555. * @param maxRadius the maximum distance to the constrained world position
  147556. * @param result output the closest point to position constrained by the navigation mesh
  147557. */
  147558. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147559. /**
  147560. * Compute the final position from a segment made of destination-position
  147561. * @param position world position
  147562. * @param destination world position
  147563. * @returns the resulting point along the navmesh
  147564. */
  147565. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147566. /**
  147567. * Compute the final position from a segment made of destination-position
  147568. * @param position world position
  147569. * @param destination world position
  147570. * @param result output the resulting point along the navmesh
  147571. */
  147572. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147573. /**
  147574. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147575. * @param start world position
  147576. * @param end world position
  147577. * @returns array containing world position composing the path
  147578. */
  147579. computePath(start: Vector3, end: Vector3): Vector3[];
  147580. /**
  147581. * Create a new Crowd so you can add agents
  147582. * @param maxAgents the maximum agent count in the crowd
  147583. * @param maxAgentRadius the maximum radius an agent can have
  147584. * @param scene to attach the crowd to
  147585. * @returns the crowd you can add agents to
  147586. */
  147587. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147588. /**
  147589. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147590. * The queries will try to find a solution within those bounds
  147591. * default is (1,1,1)
  147592. * @param extent x,y,z value that define the extent around the queries point of reference
  147593. */
  147594. setDefaultQueryExtent(extent: Vector3): void;
  147595. /**
  147596. * Get the Bounding box extent specified by setDefaultQueryExtent
  147597. * @returns the box extent values
  147598. */
  147599. getDefaultQueryExtent(): Vector3;
  147600. /**
  147601. * build the navmesh from a previously saved state using getNavmeshData
  147602. * @param data the Uint8Array returned by getNavmeshData
  147603. */
  147604. buildFromNavmeshData(data: Uint8Array): void;
  147605. /**
  147606. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147607. * @returns data the Uint8Array that can be saved and reused
  147608. */
  147609. getNavmeshData(): Uint8Array;
  147610. /**
  147611. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147612. * @param result output the box extent values
  147613. */
  147614. getDefaultQueryExtentToRef(result: Vector3): void;
  147615. /**
  147616. * Disposes
  147617. */
  147618. dispose(): void;
  147619. /**
  147620. * If this plugin is supported
  147621. * @returns true if plugin is supported
  147622. */
  147623. isSupported(): boolean;
  147624. }
  147625. /**
  147626. * Recast detour crowd implementation
  147627. */
  147628. export class RecastJSCrowd implements ICrowd {
  147629. /**
  147630. * Recast/detour plugin
  147631. */
  147632. bjsRECASTPlugin: RecastJSPlugin;
  147633. /**
  147634. * Link to the detour crowd
  147635. */
  147636. recastCrowd: any;
  147637. /**
  147638. * One transform per agent
  147639. */
  147640. transforms: TransformNode[];
  147641. /**
  147642. * All agents created
  147643. */
  147644. agents: number[];
  147645. /**
  147646. * Link to the scene is kept to unregister the crowd from the scene
  147647. */
  147648. private _scene;
  147649. /**
  147650. * Observer for crowd updates
  147651. */
  147652. private _onBeforeAnimationsObserver;
  147653. /**
  147654. * Constructor
  147655. * @param plugin recastJS plugin
  147656. * @param maxAgents the maximum agent count in the crowd
  147657. * @param maxAgentRadius the maximum radius an agent can have
  147658. * @param scene to attach the crowd to
  147659. * @returns the crowd you can add agents to
  147660. */
  147661. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147662. /**
  147663. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147664. * You can attach anything to that node. The node position is updated in the scene update tick.
  147665. * @param pos world position that will be constrained by the navigation mesh
  147666. * @param parameters agent parameters
  147667. * @param transform hooked to the agent that will be update by the scene
  147668. * @returns agent index
  147669. */
  147670. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147671. /**
  147672. * Returns the agent position in world space
  147673. * @param index agent index returned by addAgent
  147674. * @returns world space position
  147675. */
  147676. getAgentPosition(index: number): Vector3;
  147677. /**
  147678. * Returns the agent position result in world space
  147679. * @param index agent index returned by addAgent
  147680. * @param result output world space position
  147681. */
  147682. getAgentPositionToRef(index: number, result: Vector3): void;
  147683. /**
  147684. * Returns the agent velocity in world space
  147685. * @param index agent index returned by addAgent
  147686. * @returns world space velocity
  147687. */
  147688. getAgentVelocity(index: number): Vector3;
  147689. /**
  147690. * Returns the agent velocity result in world space
  147691. * @param index agent index returned by addAgent
  147692. * @param result output world space velocity
  147693. */
  147694. getAgentVelocityToRef(index: number, result: Vector3): void;
  147695. /**
  147696. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147697. * @param index agent index returned by addAgent
  147698. * @param destination targeted world position
  147699. */
  147700. agentGoto(index: number, destination: Vector3): void;
  147701. /**
  147702. * Teleport the agent to a new position
  147703. * @param index agent index returned by addAgent
  147704. * @param destination targeted world position
  147705. */
  147706. agentTeleport(index: number, destination: Vector3): void;
  147707. /**
  147708. * Update agent parameters
  147709. * @param index agent index returned by addAgent
  147710. * @param parameters agent parameters
  147711. */
  147712. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147713. /**
  147714. * remove a particular agent previously created
  147715. * @param index agent index returned by addAgent
  147716. */
  147717. removeAgent(index: number): void;
  147718. /**
  147719. * get the list of all agents attached to this crowd
  147720. * @returns list of agent indices
  147721. */
  147722. getAgents(): number[];
  147723. /**
  147724. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147725. * @param deltaTime in seconds
  147726. */
  147727. update(deltaTime: number): void;
  147728. /**
  147729. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147730. * The queries will try to find a solution within those bounds
  147731. * default is (1,1,1)
  147732. * @param extent x,y,z value that define the extent around the queries point of reference
  147733. */
  147734. setDefaultQueryExtent(extent: Vector3): void;
  147735. /**
  147736. * Get the Bounding box extent specified by setDefaultQueryExtent
  147737. * @returns the box extent values
  147738. */
  147739. getDefaultQueryExtent(): Vector3;
  147740. /**
  147741. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147742. * @param result output the box extent values
  147743. */
  147744. getDefaultQueryExtentToRef(result: Vector3): void;
  147745. /**
  147746. * Release all resources
  147747. */
  147748. dispose(): void;
  147749. }
  147750. }
  147751. declare module BABYLON {
  147752. /**
  147753. * Class used to enable access to IndexedDB
  147754. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147755. */
  147756. export class Database implements IOfflineProvider {
  147757. private _callbackManifestChecked;
  147758. private _currentSceneUrl;
  147759. private _db;
  147760. private _enableSceneOffline;
  147761. private _enableTexturesOffline;
  147762. private _manifestVersionFound;
  147763. private _mustUpdateRessources;
  147764. private _hasReachedQuota;
  147765. private _isSupported;
  147766. private _idbFactory;
  147767. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147768. private static IsUASupportingBlobStorage;
  147769. /**
  147770. * Gets a boolean indicating if Database storate is enabled (off by default)
  147771. */
  147772. static IDBStorageEnabled: boolean;
  147773. /**
  147774. * Gets a boolean indicating if scene must be saved in the database
  147775. */
  147776. get enableSceneOffline(): boolean;
  147777. /**
  147778. * Gets a boolean indicating if textures must be saved in the database
  147779. */
  147780. get enableTexturesOffline(): boolean;
  147781. /**
  147782. * Creates a new Database
  147783. * @param urlToScene defines the url to load the scene
  147784. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147785. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147786. */
  147787. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147788. private static _ParseURL;
  147789. private static _ReturnFullUrlLocation;
  147790. private _checkManifestFile;
  147791. /**
  147792. * Open the database and make it available
  147793. * @param successCallback defines the callback to call on success
  147794. * @param errorCallback defines the callback to call on error
  147795. */
  147796. open(successCallback: () => void, errorCallback: () => void): void;
  147797. /**
  147798. * Loads an image from the database
  147799. * @param url defines the url to load from
  147800. * @param image defines the target DOM image
  147801. */
  147802. loadImage(url: string, image: HTMLImageElement): void;
  147803. private _loadImageFromDBAsync;
  147804. private _saveImageIntoDBAsync;
  147805. private _checkVersionFromDB;
  147806. private _loadVersionFromDBAsync;
  147807. private _saveVersionIntoDBAsync;
  147808. /**
  147809. * Loads a file from database
  147810. * @param url defines the URL to load from
  147811. * @param sceneLoaded defines a callback to call on success
  147812. * @param progressCallBack defines a callback to call when progress changed
  147813. * @param errorCallback defines a callback to call on error
  147814. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147815. */
  147816. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147817. private _loadFileAsync;
  147818. private _saveFileAsync;
  147819. /**
  147820. * Validates if xhr data is correct
  147821. * @param xhr defines the request to validate
  147822. * @param dataType defines the expected data type
  147823. * @returns true if data is correct
  147824. */
  147825. private static _ValidateXHRData;
  147826. }
  147827. }
  147828. declare module BABYLON {
  147829. /** @hidden */
  147830. export var gpuUpdateParticlesPixelShader: {
  147831. name: string;
  147832. shader: string;
  147833. };
  147834. }
  147835. declare module BABYLON {
  147836. /** @hidden */
  147837. export var gpuUpdateParticlesVertexShader: {
  147838. name: string;
  147839. shader: string;
  147840. };
  147841. }
  147842. declare module BABYLON {
  147843. /** @hidden */
  147844. export var clipPlaneFragmentDeclaration2: {
  147845. name: string;
  147846. shader: string;
  147847. };
  147848. }
  147849. declare module BABYLON {
  147850. /** @hidden */
  147851. export var gpuRenderParticlesPixelShader: {
  147852. name: string;
  147853. shader: string;
  147854. };
  147855. }
  147856. declare module BABYLON {
  147857. /** @hidden */
  147858. export var clipPlaneVertexDeclaration2: {
  147859. name: string;
  147860. shader: string;
  147861. };
  147862. }
  147863. declare module BABYLON {
  147864. /** @hidden */
  147865. export var gpuRenderParticlesVertexShader: {
  147866. name: string;
  147867. shader: string;
  147868. };
  147869. }
  147870. declare module BABYLON {
  147871. /**
  147872. * This represents a GPU particle system in Babylon
  147873. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147874. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147875. */
  147876. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147877. /**
  147878. * The layer mask we are rendering the particles through.
  147879. */
  147880. layerMask: number;
  147881. private _capacity;
  147882. private _activeCount;
  147883. private _currentActiveCount;
  147884. private _accumulatedCount;
  147885. private _renderEffect;
  147886. private _updateEffect;
  147887. private _buffer0;
  147888. private _buffer1;
  147889. private _spriteBuffer;
  147890. private _updateVAO;
  147891. private _renderVAO;
  147892. private _targetIndex;
  147893. private _sourceBuffer;
  147894. private _targetBuffer;
  147895. private _currentRenderId;
  147896. private _started;
  147897. private _stopped;
  147898. private _timeDelta;
  147899. private _randomTexture;
  147900. private _randomTexture2;
  147901. private _attributesStrideSize;
  147902. private _updateEffectOptions;
  147903. private _randomTextureSize;
  147904. private _actualFrame;
  147905. private _customEffect;
  147906. private readonly _rawTextureWidth;
  147907. /**
  147908. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147909. */
  147910. static get IsSupported(): boolean;
  147911. /**
  147912. * An event triggered when the system is disposed.
  147913. */
  147914. onDisposeObservable: Observable<IParticleSystem>;
  147915. /**
  147916. * Gets the maximum number of particles active at the same time.
  147917. * @returns The max number of active particles.
  147918. */
  147919. getCapacity(): number;
  147920. /**
  147921. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147922. * to override the particles.
  147923. */
  147924. forceDepthWrite: boolean;
  147925. /**
  147926. * Gets or set the number of active particles
  147927. */
  147928. get activeParticleCount(): number;
  147929. set activeParticleCount(value: number);
  147930. private _preWarmDone;
  147931. /**
  147932. * Specifies if the particles are updated in emitter local space or world space.
  147933. */
  147934. isLocal: boolean;
  147935. /** Gets or sets a matrix to use to compute projection */
  147936. defaultProjectionMatrix: Matrix;
  147937. /**
  147938. * Is this system ready to be used/rendered
  147939. * @return true if the system is ready
  147940. */
  147941. isReady(): boolean;
  147942. /**
  147943. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147944. * @returns True if it has been started, otherwise false.
  147945. */
  147946. isStarted(): boolean;
  147947. /**
  147948. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147949. * @returns True if it has been stopped, otherwise false.
  147950. */
  147951. isStopped(): boolean;
  147952. /**
  147953. * Gets a boolean indicating that the system is stopping
  147954. * @returns true if the system is currently stopping
  147955. */
  147956. isStopping(): boolean;
  147957. /**
  147958. * Gets the number of particles active at the same time.
  147959. * @returns The number of active particles.
  147960. */
  147961. getActiveCount(): number;
  147962. /**
  147963. * Starts the particle system and begins to emit
  147964. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147965. */
  147966. start(delay?: number): void;
  147967. /**
  147968. * Stops the particle system.
  147969. */
  147970. stop(): void;
  147971. /**
  147972. * Remove all active particles
  147973. */
  147974. reset(): void;
  147975. /**
  147976. * Returns the string "GPUParticleSystem"
  147977. * @returns a string containing the class name
  147978. */
  147979. getClassName(): string;
  147980. /**
  147981. * Gets the custom effect used to render the particles
  147982. * @param blendMode Blend mode for which the effect should be retrieved
  147983. * @returns The effect
  147984. */
  147985. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147986. /**
  147987. * Sets the custom effect used to render the particles
  147988. * @param effect The effect to set
  147989. * @param blendMode Blend mode for which the effect should be set
  147990. */
  147991. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147992. /** @hidden */
  147993. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147994. /**
  147995. * Observable that will be called just before the particles are drawn
  147996. */
  147997. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147998. /**
  147999. * Gets the name of the particle vertex shader
  148000. */
  148001. get vertexShaderName(): string;
  148002. private _colorGradientsTexture;
  148003. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148004. /**
  148005. * Adds a new color gradient
  148006. * @param gradient defines the gradient to use (between 0 and 1)
  148007. * @param color1 defines the color to affect to the specified gradient
  148008. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148009. * @returns the current particle system
  148010. */
  148011. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148012. private _refreshColorGradient;
  148013. /** Force the system to rebuild all gradients that need to be resync */
  148014. forceRefreshGradients(): void;
  148015. /**
  148016. * Remove a specific color gradient
  148017. * @param gradient defines the gradient to remove
  148018. * @returns the current particle system
  148019. */
  148020. removeColorGradient(gradient: number): GPUParticleSystem;
  148021. private _angularSpeedGradientsTexture;
  148022. private _sizeGradientsTexture;
  148023. private _velocityGradientsTexture;
  148024. private _limitVelocityGradientsTexture;
  148025. private _dragGradientsTexture;
  148026. private _addFactorGradient;
  148027. /**
  148028. * Adds a new size gradient
  148029. * @param gradient defines the gradient to use (between 0 and 1)
  148030. * @param factor defines the size factor to affect to the specified gradient
  148031. * @returns the current particle system
  148032. */
  148033. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148034. /**
  148035. * Remove a specific size gradient
  148036. * @param gradient defines the gradient to remove
  148037. * @returns the current particle system
  148038. */
  148039. removeSizeGradient(gradient: number): GPUParticleSystem;
  148040. private _refreshFactorGradient;
  148041. /**
  148042. * Adds a new angular speed gradient
  148043. * @param gradient defines the gradient to use (between 0 and 1)
  148044. * @param factor defines the angular speed to affect to the specified gradient
  148045. * @returns the current particle system
  148046. */
  148047. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148048. /**
  148049. * Remove a specific angular speed gradient
  148050. * @param gradient defines the gradient to remove
  148051. * @returns the current particle system
  148052. */
  148053. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148054. /**
  148055. * Adds a new velocity gradient
  148056. * @param gradient defines the gradient to use (between 0 and 1)
  148057. * @param factor defines the velocity to affect to the specified gradient
  148058. * @returns the current particle system
  148059. */
  148060. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148061. /**
  148062. * Remove a specific velocity gradient
  148063. * @param gradient defines the gradient to remove
  148064. * @returns the current particle system
  148065. */
  148066. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148067. /**
  148068. * Adds a new limit velocity gradient
  148069. * @param gradient defines the gradient to use (between 0 and 1)
  148070. * @param factor defines the limit velocity value to affect to the specified gradient
  148071. * @returns the current particle system
  148072. */
  148073. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148074. /**
  148075. * Remove a specific limit velocity gradient
  148076. * @param gradient defines the gradient to remove
  148077. * @returns the current particle system
  148078. */
  148079. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148080. /**
  148081. * Adds a new drag gradient
  148082. * @param gradient defines the gradient to use (between 0 and 1)
  148083. * @param factor defines the drag value to affect to the specified gradient
  148084. * @returns the current particle system
  148085. */
  148086. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148087. /**
  148088. * Remove a specific drag gradient
  148089. * @param gradient defines the gradient to remove
  148090. * @returns the current particle system
  148091. */
  148092. removeDragGradient(gradient: number): GPUParticleSystem;
  148093. /**
  148094. * Not supported by GPUParticleSystem
  148095. * @param gradient defines the gradient to use (between 0 and 1)
  148096. * @param factor defines the emit rate value to affect to the specified gradient
  148097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148098. * @returns the current particle system
  148099. */
  148100. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148101. /**
  148102. * Not supported by GPUParticleSystem
  148103. * @param gradient defines the gradient to remove
  148104. * @returns the current particle system
  148105. */
  148106. removeEmitRateGradient(gradient: number): IParticleSystem;
  148107. /**
  148108. * Not supported by GPUParticleSystem
  148109. * @param gradient defines the gradient to use (between 0 and 1)
  148110. * @param factor defines the start size value to affect to the specified gradient
  148111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148112. * @returns the current particle system
  148113. */
  148114. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148115. /**
  148116. * Not supported by GPUParticleSystem
  148117. * @param gradient defines the gradient to remove
  148118. * @returns the current particle system
  148119. */
  148120. removeStartSizeGradient(gradient: number): IParticleSystem;
  148121. /**
  148122. * Not supported by GPUParticleSystem
  148123. * @param gradient defines the gradient to use (between 0 and 1)
  148124. * @param min defines the color remap minimal range
  148125. * @param max defines the color remap maximal range
  148126. * @returns the current particle system
  148127. */
  148128. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148129. /**
  148130. * Not supported by GPUParticleSystem
  148131. * @param gradient defines the gradient to remove
  148132. * @returns the current particle system
  148133. */
  148134. removeColorRemapGradient(): IParticleSystem;
  148135. /**
  148136. * Not supported by GPUParticleSystem
  148137. * @param gradient defines the gradient to use (between 0 and 1)
  148138. * @param min defines the alpha remap minimal range
  148139. * @param max defines the alpha remap maximal range
  148140. * @returns the current particle system
  148141. */
  148142. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148143. /**
  148144. * Not supported by GPUParticleSystem
  148145. * @param gradient defines the gradient to remove
  148146. * @returns the current particle system
  148147. */
  148148. removeAlphaRemapGradient(): IParticleSystem;
  148149. /**
  148150. * Not supported by GPUParticleSystem
  148151. * @param gradient defines the gradient to use (between 0 and 1)
  148152. * @param color defines the color to affect to the specified gradient
  148153. * @returns the current particle system
  148154. */
  148155. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148156. /**
  148157. * Not supported by GPUParticleSystem
  148158. * @param gradient defines the gradient to remove
  148159. * @returns the current particle system
  148160. */
  148161. removeRampGradient(): IParticleSystem;
  148162. /**
  148163. * Not supported by GPUParticleSystem
  148164. * @returns the list of ramp gradients
  148165. */
  148166. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148167. /**
  148168. * Not supported by GPUParticleSystem
  148169. * Gets or sets a boolean indicating that ramp gradients must be used
  148170. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148171. */
  148172. get useRampGradients(): boolean;
  148173. set useRampGradients(value: boolean);
  148174. /**
  148175. * Not supported by GPUParticleSystem
  148176. * @param gradient defines the gradient to use (between 0 and 1)
  148177. * @param factor defines the life time factor to affect to the specified gradient
  148178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148179. * @returns the current particle system
  148180. */
  148181. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148182. /**
  148183. * Not supported by GPUParticleSystem
  148184. * @param gradient defines the gradient to remove
  148185. * @returns the current particle system
  148186. */
  148187. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148188. /**
  148189. * Instantiates a GPU particle system.
  148190. * 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.
  148191. * @param name The name of the particle system
  148192. * @param options The options used to create the system
  148193. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148194. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148195. * @param customEffect a custom effect used to change the way particles are rendered by default
  148196. */
  148197. constructor(name: string, options: Partial<{
  148198. capacity: number;
  148199. randomTextureSize: number;
  148200. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148201. protected _reset(): void;
  148202. private _createUpdateVAO;
  148203. private _createRenderVAO;
  148204. private _initialize;
  148205. /** @hidden */
  148206. _recreateUpdateEffect(): void;
  148207. private _getEffect;
  148208. /**
  148209. * Fill the defines array according to the current settings of the particle system
  148210. * @param defines Array to be updated
  148211. * @param blendMode blend mode to take into account when updating the array
  148212. */
  148213. fillDefines(defines: Array<string>, blendMode?: number): void;
  148214. /**
  148215. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148216. * @param uniforms Uniforms array to fill
  148217. * @param attributes Attributes array to fill
  148218. * @param samplers Samplers array to fill
  148219. */
  148220. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148221. /** @hidden */
  148222. _recreateRenderEffect(): Effect;
  148223. /**
  148224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148225. * @param preWarm defines if we are in the pre-warmimg phase
  148226. */
  148227. animate(preWarm?: boolean): void;
  148228. private _createFactorGradientTexture;
  148229. private _createSizeGradientTexture;
  148230. private _createAngularSpeedGradientTexture;
  148231. private _createVelocityGradientTexture;
  148232. private _createLimitVelocityGradientTexture;
  148233. private _createDragGradientTexture;
  148234. private _createColorGradientTexture;
  148235. /**
  148236. * Renders the particle system in its current state
  148237. * @param preWarm defines if the system should only update the particles but not render them
  148238. * @returns the current number of particles
  148239. */
  148240. render(preWarm?: boolean): number;
  148241. /**
  148242. * Rebuilds the particle system
  148243. */
  148244. rebuild(): void;
  148245. private _releaseBuffers;
  148246. private _releaseVAOs;
  148247. /**
  148248. * Disposes the particle system and free the associated resources
  148249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148250. */
  148251. dispose(disposeTexture?: boolean): void;
  148252. /**
  148253. * Clones the particle system.
  148254. * @param name The name of the cloned object
  148255. * @param newEmitter The new emitter to use
  148256. * @returns the cloned particle system
  148257. */
  148258. clone(name: string, newEmitter: any): GPUParticleSystem;
  148259. /**
  148260. * Serializes the particle system to a JSON object
  148261. * @param serializeTexture defines if the texture must be serialized as well
  148262. * @returns the JSON object
  148263. */
  148264. serialize(serializeTexture?: boolean): any;
  148265. /**
  148266. * Parses a JSON object to create a GPU particle system.
  148267. * @param parsedParticleSystem The JSON object to parse
  148268. * @param sceneOrEngine The scene or the engine to create the particle system in
  148269. * @param rootUrl The root url to use to load external dependencies like texture
  148270. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148271. * @returns the parsed GPU particle system
  148272. */
  148273. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148274. }
  148275. }
  148276. declare module BABYLON {
  148277. /**
  148278. * Represents a set of particle systems working together to create a specific effect
  148279. */
  148280. export class ParticleSystemSet implements IDisposable {
  148281. /**
  148282. * Gets or sets base Assets URL
  148283. */
  148284. static BaseAssetsUrl: string;
  148285. private _emitterCreationOptions;
  148286. private _emitterNode;
  148287. /**
  148288. * Gets the particle system list
  148289. */
  148290. systems: IParticleSystem[];
  148291. /**
  148292. * Gets the emitter node used with this set
  148293. */
  148294. get emitterNode(): Nullable<TransformNode>;
  148295. /**
  148296. * Creates a new emitter mesh as a sphere
  148297. * @param options defines the options used to create the sphere
  148298. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148299. * @param scene defines the hosting scene
  148300. */
  148301. setEmitterAsSphere(options: {
  148302. diameter: number;
  148303. segments: number;
  148304. color: Color3;
  148305. }, renderingGroupId: number, scene: Scene): void;
  148306. /**
  148307. * Starts all particle systems of the set
  148308. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148309. */
  148310. start(emitter?: AbstractMesh): void;
  148311. /**
  148312. * Release all associated resources
  148313. */
  148314. dispose(): void;
  148315. /**
  148316. * Serialize the set into a JSON compatible object
  148317. * @param serializeTexture defines if the texture must be serialized as well
  148318. * @returns a JSON compatible representation of the set
  148319. */
  148320. serialize(serializeTexture?: boolean): any;
  148321. /**
  148322. * Parse a new ParticleSystemSet from a serialized source
  148323. * @param data defines a JSON compatible representation of the set
  148324. * @param scene defines the hosting scene
  148325. * @param gpu defines if we want GPU particles or CPU particles
  148326. * @returns a new ParticleSystemSet
  148327. */
  148328. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148329. }
  148330. }
  148331. declare module BABYLON {
  148332. /**
  148333. * This class is made for on one-liner static method to help creating particle system set.
  148334. */
  148335. export class ParticleHelper {
  148336. /**
  148337. * Gets or sets base Assets URL
  148338. */
  148339. static BaseAssetsUrl: string;
  148340. /** Define the Url to load snippets */
  148341. static SnippetUrl: string;
  148342. /**
  148343. * Create a default particle system that you can tweak
  148344. * @param emitter defines the emitter to use
  148345. * @param capacity defines the system capacity (default is 500 particles)
  148346. * @param scene defines the hosting scene
  148347. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148348. * @returns the new Particle system
  148349. */
  148350. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148351. /**
  148352. * This is the main static method (one-liner) of this helper to create different particle systems
  148353. * @param type This string represents the type to the particle system to create
  148354. * @param scene The scene where the particle system should live
  148355. * @param gpu If the system will use gpu
  148356. * @returns the ParticleSystemSet created
  148357. */
  148358. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148359. /**
  148360. * Static function used to export a particle system to a ParticleSystemSet variable.
  148361. * Please note that the emitter shape is not exported
  148362. * @param systems defines the particle systems to export
  148363. * @returns the created particle system set
  148364. */
  148365. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148366. /**
  148367. * Creates a particle system from a snippet saved in a remote file
  148368. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148369. * @param url defines the url to load from
  148370. * @param scene defines the hosting scene
  148371. * @param gpu If the system will use gpu
  148372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148373. * @returns a promise that will resolve to the new particle system
  148374. */
  148375. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148376. /**
  148377. * Creates a particle system from a snippet saved by the particle system editor
  148378. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148379. * @param scene defines the hosting scene
  148380. * @param gpu If the system will use gpu
  148381. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148382. * @returns a promise that will resolve to the new particle system
  148383. */
  148384. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148385. }
  148386. }
  148387. declare module BABYLON {
  148388. interface Engine {
  148389. /**
  148390. * Create an effect to use with particle systems.
  148391. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148392. * the particle system for which you want to create a custom effect in the last parameter
  148393. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148394. * @param uniformsNames defines a list of attribute names
  148395. * @param samplers defines an array of string used to represent textures
  148396. * @param defines defines the string containing the defines to use to compile the shaders
  148397. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148398. * @param onCompiled defines a function to call when the effect creation is successful
  148399. * @param onError defines a function to call when the effect creation has failed
  148400. * @param particleSystem the particle system you want to create the effect for
  148401. * @returns the new Effect
  148402. */
  148403. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148404. }
  148405. interface Mesh {
  148406. /**
  148407. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148408. * @returns an array of IParticleSystem
  148409. */
  148410. getEmittedParticleSystems(): IParticleSystem[];
  148411. /**
  148412. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148413. * @returns an array of IParticleSystem
  148414. */
  148415. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148416. }
  148417. }
  148418. declare module BABYLON {
  148419. /** Defines the 4 color options */
  148420. export enum PointColor {
  148421. /** color value */
  148422. Color = 2,
  148423. /** uv value */
  148424. UV = 1,
  148425. /** random value */
  148426. Random = 0,
  148427. /** stated value */
  148428. Stated = 3
  148429. }
  148430. /**
  148431. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148432. * 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.
  148433. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148434. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148435. *
  148436. * Full documentation here : TO BE ENTERED
  148437. */
  148438. export class PointsCloudSystem implements IDisposable {
  148439. /**
  148440. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148441. * Example : var p = SPS.particles[i];
  148442. */
  148443. particles: CloudPoint[];
  148444. /**
  148445. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148446. */
  148447. nbParticles: number;
  148448. /**
  148449. * This a counter for your own usage. It's not set by any SPS functions.
  148450. */
  148451. counter: number;
  148452. /**
  148453. * The PCS name. This name is also given to the underlying mesh.
  148454. */
  148455. name: string;
  148456. /**
  148457. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148458. */
  148459. mesh: Mesh;
  148460. /**
  148461. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148462. * Please read :
  148463. */
  148464. vars: any;
  148465. /**
  148466. * @hidden
  148467. */
  148468. _size: number;
  148469. private _scene;
  148470. private _promises;
  148471. private _positions;
  148472. private _indices;
  148473. private _normals;
  148474. private _colors;
  148475. private _uvs;
  148476. private _indices32;
  148477. private _positions32;
  148478. private _colors32;
  148479. private _uvs32;
  148480. private _updatable;
  148481. private _isVisibilityBoxLocked;
  148482. private _alwaysVisible;
  148483. private _groups;
  148484. private _groupCounter;
  148485. private _computeParticleColor;
  148486. private _computeParticleTexture;
  148487. private _computeParticleRotation;
  148488. private _computeBoundingBox;
  148489. private _isReady;
  148490. /**
  148491. * Creates a PCS (Points Cloud System) object
  148492. * @param name (String) is the PCS name, this will be the underlying mesh name
  148493. * @param pointSize (number) is the size for each point
  148494. * @param scene (Scene) is the scene in which the PCS is added
  148495. * @param options defines the options of the PCS e.g.
  148496. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148497. */
  148498. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148499. updatable?: boolean;
  148500. });
  148501. /**
  148502. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148503. * If no points were added to the PCS, the returned mesh is just a single point.
  148504. * @returns a promise for the created mesh
  148505. */
  148506. buildMeshAsync(): Promise<Mesh>;
  148507. /**
  148508. * @hidden
  148509. */
  148510. private _buildMesh;
  148511. private _addParticle;
  148512. private _randomUnitVector;
  148513. private _getColorIndicesForCoord;
  148514. private _setPointsColorOrUV;
  148515. private _colorFromTexture;
  148516. private _calculateDensity;
  148517. /**
  148518. * Adds points to the PCS in random positions within a unit sphere
  148519. * @param nb (positive integer) the number of particles to be created from this model
  148520. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148521. * @returns the number of groups in the system
  148522. */
  148523. addPoints(nb: number, pointFunction?: any): number;
  148524. /**
  148525. * Adds points to the PCS from the surface of the model shape
  148526. * @param mesh is any Mesh object that will be used as a surface model for the points
  148527. * @param nb (positive integer) the number of particles to be created from this model
  148528. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148529. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148530. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148531. * @returns the number of groups in the system
  148532. */
  148533. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148534. /**
  148535. * Adds points to the PCS inside the model shape
  148536. * @param mesh is any Mesh object that will be used as a surface model for the points
  148537. * @param nb (positive integer) the number of particles to be created from this model
  148538. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148539. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148540. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148541. * @returns the number of groups in the system
  148542. */
  148543. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148544. /**
  148545. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148546. * This method calls `updateParticle()` for each particle of the SPS.
  148547. * For an animated SPS, it is usually called within the render loop.
  148548. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148549. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148550. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148551. * @returns the PCS.
  148552. */
  148553. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148554. /**
  148555. * Disposes the PCS.
  148556. */
  148557. dispose(): void;
  148558. /**
  148559. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148560. * doc :
  148561. * @returns the PCS.
  148562. */
  148563. refreshVisibleSize(): PointsCloudSystem;
  148564. /**
  148565. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148566. * @param size the size (float) of the visibility box
  148567. * note : this doesn't lock the PCS mesh bounding box.
  148568. * doc :
  148569. */
  148570. setVisibilityBox(size: number): void;
  148571. /**
  148572. * Gets whether the PCS is always visible or not
  148573. * doc :
  148574. */
  148575. get isAlwaysVisible(): boolean;
  148576. /**
  148577. * Sets the PCS as always visible or not
  148578. * doc :
  148579. */
  148580. set isAlwaysVisible(val: boolean);
  148581. /**
  148582. * Tells to `setParticles()` to compute the particle rotations or not
  148583. * Default value : false. The PCS is faster when it's set to false
  148584. * Note : particle rotations are only applied to parent particles
  148585. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148586. */
  148587. set computeParticleRotation(val: boolean);
  148588. /**
  148589. * Tells to `setParticles()` to compute the particle colors or not.
  148590. * Default value : true. The PCS is faster when it's set to false.
  148591. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148592. */
  148593. set computeParticleColor(val: boolean);
  148594. set computeParticleTexture(val: boolean);
  148595. /**
  148596. * Gets if `setParticles()` computes the particle colors or not.
  148597. * Default value : false. The PCS is faster when it's set to false.
  148598. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148599. */
  148600. get computeParticleColor(): boolean;
  148601. /**
  148602. * Gets if `setParticles()` computes the particle textures or not.
  148603. * Default value : false. The PCS is faster when it's set to false.
  148604. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148605. */
  148606. get computeParticleTexture(): boolean;
  148607. /**
  148608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148609. */
  148610. set computeBoundingBox(val: boolean);
  148611. /**
  148612. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148613. */
  148614. get computeBoundingBox(): boolean;
  148615. /**
  148616. * This function does nothing. It may be overwritten to set all the particle first values.
  148617. * The PCS doesn't call this function, you may have to call it by your own.
  148618. * doc :
  148619. */
  148620. initParticles(): void;
  148621. /**
  148622. * This function does nothing. It may be overwritten to recycle a particle
  148623. * The PCS doesn't call this function, you can to call it
  148624. * doc :
  148625. * @param particle The particle to recycle
  148626. * @returns the recycled particle
  148627. */
  148628. recycleParticle(particle: CloudPoint): CloudPoint;
  148629. /**
  148630. * Updates a particle : this function should be overwritten by the user.
  148631. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148632. * doc :
  148633. * @example : just set a particle position or velocity and recycle conditions
  148634. * @param particle The particle to update
  148635. * @returns the updated particle
  148636. */
  148637. updateParticle(particle: CloudPoint): CloudPoint;
  148638. /**
  148639. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148640. * This does nothing and may be overwritten by the user.
  148641. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148642. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148643. * @param update the boolean update value actually passed to setParticles()
  148644. */
  148645. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148646. /**
  148647. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148648. * This will be passed three parameters.
  148649. * This does nothing and may be overwritten by the user.
  148650. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148651. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148652. * @param update the boolean update value actually passed to setParticles()
  148653. */
  148654. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148655. }
  148656. }
  148657. declare module BABYLON {
  148658. /**
  148659. * Represents one particle of a points cloud system.
  148660. */
  148661. export class CloudPoint {
  148662. /**
  148663. * particle global index
  148664. */
  148665. idx: number;
  148666. /**
  148667. * The color of the particle
  148668. */
  148669. color: Nullable<Color4>;
  148670. /**
  148671. * The world space position of the particle.
  148672. */
  148673. position: Vector3;
  148674. /**
  148675. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148676. */
  148677. rotation: Vector3;
  148678. /**
  148679. * The world space rotation quaternion of the particle.
  148680. */
  148681. rotationQuaternion: Nullable<Quaternion>;
  148682. /**
  148683. * The uv of the particle.
  148684. */
  148685. uv: Nullable<Vector2>;
  148686. /**
  148687. * The current speed of the particle.
  148688. */
  148689. velocity: Vector3;
  148690. /**
  148691. * The pivot point in the particle local space.
  148692. */
  148693. pivot: Vector3;
  148694. /**
  148695. * Must the particle be translated from its pivot point in its local space ?
  148696. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148697. * Default : false
  148698. */
  148699. translateFromPivot: boolean;
  148700. /**
  148701. * Index of this particle in the global "positions" array (Internal use)
  148702. * @hidden
  148703. */
  148704. _pos: number;
  148705. /**
  148706. * @hidden Index of this particle in the global "indices" array (Internal use)
  148707. */
  148708. _ind: number;
  148709. /**
  148710. * Group this particle belongs to
  148711. */
  148712. _group: PointsGroup;
  148713. /**
  148714. * Group id of this particle
  148715. */
  148716. groupId: number;
  148717. /**
  148718. * Index of the particle in its group id (Internal use)
  148719. */
  148720. idxInGroup: number;
  148721. /**
  148722. * @hidden Particle BoundingInfo object (Internal use)
  148723. */
  148724. _boundingInfo: BoundingInfo;
  148725. /**
  148726. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148727. */
  148728. _pcs: PointsCloudSystem;
  148729. /**
  148730. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148731. */
  148732. _stillInvisible: boolean;
  148733. /**
  148734. * @hidden Last computed particle rotation matrix
  148735. */
  148736. _rotationMatrix: number[];
  148737. /**
  148738. * Parent particle Id, if any.
  148739. * Default null.
  148740. */
  148741. parentId: Nullable<number>;
  148742. /**
  148743. * @hidden Internal global position in the PCS.
  148744. */
  148745. _globalPosition: Vector3;
  148746. /**
  148747. * Creates a Point Cloud object.
  148748. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148749. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148750. * @param group (PointsGroup) is the group the particle belongs to
  148751. * @param groupId (integer) is the group identifier in the PCS.
  148752. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148753. * @param pcs defines the PCS it is associated to
  148754. */
  148755. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148756. /**
  148757. * get point size
  148758. */
  148759. get size(): Vector3;
  148760. /**
  148761. * Set point size
  148762. */
  148763. set size(scale: Vector3);
  148764. /**
  148765. * Legacy support, changed quaternion to rotationQuaternion
  148766. */
  148767. get quaternion(): Nullable<Quaternion>;
  148768. /**
  148769. * Legacy support, changed quaternion to rotationQuaternion
  148770. */
  148771. set quaternion(q: Nullable<Quaternion>);
  148772. /**
  148773. * Returns a boolean. True if the particle intersects a mesh, else false
  148774. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148775. * @param target is the object (point or mesh) what the intersection is computed against
  148776. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148777. * @returns true if it intersects
  148778. */
  148779. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148780. /**
  148781. * get the rotation matrix of the particle
  148782. * @hidden
  148783. */
  148784. getRotationMatrix(m: Matrix): void;
  148785. }
  148786. /**
  148787. * Represents a group of points in a points cloud system
  148788. * * PCS internal tool, don't use it manually.
  148789. */
  148790. export class PointsGroup {
  148791. /**
  148792. * The group id
  148793. * @hidden
  148794. */
  148795. groupID: number;
  148796. /**
  148797. * image data for group (internal use)
  148798. * @hidden
  148799. */
  148800. _groupImageData: Nullable<ArrayBufferView>;
  148801. /**
  148802. * Image Width (internal use)
  148803. * @hidden
  148804. */
  148805. _groupImgWidth: number;
  148806. /**
  148807. * Image Height (internal use)
  148808. * @hidden
  148809. */
  148810. _groupImgHeight: number;
  148811. /**
  148812. * Custom position function (internal use)
  148813. * @hidden
  148814. */
  148815. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148816. /**
  148817. * density per facet for surface points
  148818. * @hidden
  148819. */
  148820. _groupDensity: number[];
  148821. /**
  148822. * Only when points are colored by texture carries pointer to texture list array
  148823. * @hidden
  148824. */
  148825. _textureNb: number;
  148826. /**
  148827. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148828. * PCS internal tool, don't use it manually.
  148829. * @hidden
  148830. */
  148831. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148832. }
  148833. }
  148834. declare module BABYLON {
  148835. interface Scene {
  148836. /** @hidden (Backing field) */
  148837. _physicsEngine: Nullable<IPhysicsEngine>;
  148838. /** @hidden */
  148839. _physicsTimeAccumulator: number;
  148840. /**
  148841. * Gets the current physics engine
  148842. * @returns a IPhysicsEngine or null if none attached
  148843. */
  148844. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148845. /**
  148846. * Enables physics to the current scene
  148847. * @param gravity defines the scene's gravity for the physics engine
  148848. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148849. * @return a boolean indicating if the physics engine was initialized
  148850. */
  148851. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148852. /**
  148853. * Disables and disposes the physics engine associated with the scene
  148854. */
  148855. disablePhysicsEngine(): void;
  148856. /**
  148857. * Gets a boolean indicating if there is an active physics engine
  148858. * @returns a boolean indicating if there is an active physics engine
  148859. */
  148860. isPhysicsEnabled(): boolean;
  148861. /**
  148862. * Deletes a physics compound impostor
  148863. * @param compound defines the compound to delete
  148864. */
  148865. deleteCompoundImpostor(compound: any): void;
  148866. /**
  148867. * An event triggered when physic simulation is about to be run
  148868. */
  148869. onBeforePhysicsObservable: Observable<Scene>;
  148870. /**
  148871. * An event triggered when physic simulation has been done
  148872. */
  148873. onAfterPhysicsObservable: Observable<Scene>;
  148874. }
  148875. interface AbstractMesh {
  148876. /** @hidden */
  148877. _physicsImpostor: Nullable<PhysicsImpostor>;
  148878. /**
  148879. * Gets or sets impostor used for physic simulation
  148880. * @see https://doc.babylonjs.com/features/physics_engine
  148881. */
  148882. physicsImpostor: Nullable<PhysicsImpostor>;
  148883. /**
  148884. * Gets the current physics impostor
  148885. * @see https://doc.babylonjs.com/features/physics_engine
  148886. * @returns a physics impostor or null
  148887. */
  148888. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148889. /** Apply a physic impulse to the mesh
  148890. * @param force defines the force to apply
  148891. * @param contactPoint defines where to apply the force
  148892. * @returns the current mesh
  148893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148894. */
  148895. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148896. /**
  148897. * Creates a physic joint between two meshes
  148898. * @param otherMesh defines the other mesh to use
  148899. * @param pivot1 defines the pivot to use on this mesh
  148900. * @param pivot2 defines the pivot to use on the other mesh
  148901. * @param options defines additional options (can be plugin dependent)
  148902. * @returns the current mesh
  148903. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148904. */
  148905. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148906. /** @hidden */
  148907. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148908. }
  148909. /**
  148910. * Defines the physics engine scene component responsible to manage a physics engine
  148911. */
  148912. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148913. /**
  148914. * The component name helpful to identify the component in the list of scene components.
  148915. */
  148916. readonly name: string;
  148917. /**
  148918. * The scene the component belongs to.
  148919. */
  148920. scene: Scene;
  148921. /**
  148922. * Creates a new instance of the component for the given scene
  148923. * @param scene Defines the scene to register the component in
  148924. */
  148925. constructor(scene: Scene);
  148926. /**
  148927. * Registers the component in a given scene
  148928. */
  148929. register(): void;
  148930. /**
  148931. * Rebuilds the elements related to this component in case of
  148932. * context lost for instance.
  148933. */
  148934. rebuild(): void;
  148935. /**
  148936. * Disposes the component and the associated ressources
  148937. */
  148938. dispose(): void;
  148939. }
  148940. }
  148941. declare module BABYLON {
  148942. /**
  148943. * A helper for physics simulations
  148944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148945. */
  148946. export class PhysicsHelper {
  148947. private _scene;
  148948. private _physicsEngine;
  148949. /**
  148950. * Initializes the Physics helper
  148951. * @param scene Babylon.js scene
  148952. */
  148953. constructor(scene: Scene);
  148954. /**
  148955. * Applies a radial explosion impulse
  148956. * @param origin the origin of the explosion
  148957. * @param radiusOrEventOptions the radius or the options of radial explosion
  148958. * @param strength the explosion strength
  148959. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148960. * @returns A physics radial explosion event, or null
  148961. */
  148962. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148963. /**
  148964. * Applies a radial explosion force
  148965. * @param origin the origin of the explosion
  148966. * @param radiusOrEventOptions the radius or the options of radial explosion
  148967. * @param strength the explosion strength
  148968. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148969. * @returns A physics radial explosion event, or null
  148970. */
  148971. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148972. /**
  148973. * Creates a gravitational field
  148974. * @param origin the origin of the explosion
  148975. * @param radiusOrEventOptions the radius or the options of radial explosion
  148976. * @param strength the explosion strength
  148977. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148978. * @returns A physics gravitational field event, or null
  148979. */
  148980. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148981. /**
  148982. * Creates a physics updraft event
  148983. * @param origin the origin of the updraft
  148984. * @param radiusOrEventOptions the radius or the options of the updraft
  148985. * @param strength the strength of the updraft
  148986. * @param height the height of the updraft
  148987. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148988. * @returns A physics updraft event, or null
  148989. */
  148990. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148991. /**
  148992. * Creates a physics vortex event
  148993. * @param origin the of the vortex
  148994. * @param radiusOrEventOptions the radius or the options of the vortex
  148995. * @param strength the strength of the vortex
  148996. * @param height the height of the vortex
  148997. * @returns a Physics vortex event, or null
  148998. * A physics vortex event or null
  148999. */
  149000. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149001. }
  149002. /**
  149003. * Represents a physics radial explosion event
  149004. */
  149005. class PhysicsRadialExplosionEvent {
  149006. private _scene;
  149007. private _options;
  149008. private _sphere;
  149009. private _dataFetched;
  149010. /**
  149011. * Initializes a radial explosioin event
  149012. * @param _scene BabylonJS scene
  149013. * @param _options The options for the vortex event
  149014. */
  149015. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149016. /**
  149017. * Returns the data related to the radial explosion event (sphere).
  149018. * @returns The radial explosion event data
  149019. */
  149020. getData(): PhysicsRadialExplosionEventData;
  149021. /**
  149022. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149023. * @param impostor A physics imposter
  149024. * @param origin the origin of the explosion
  149025. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149026. */
  149027. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149028. /**
  149029. * Triggers affecterd impostors callbacks
  149030. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149031. */
  149032. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149033. /**
  149034. * Disposes the sphere.
  149035. * @param force Specifies if the sphere should be disposed by force
  149036. */
  149037. dispose(force?: boolean): void;
  149038. /*** Helpers ***/
  149039. private _prepareSphere;
  149040. private _intersectsWithSphere;
  149041. }
  149042. /**
  149043. * Represents a gravitational field event
  149044. */
  149045. class PhysicsGravitationalFieldEvent {
  149046. private _physicsHelper;
  149047. private _scene;
  149048. private _origin;
  149049. private _options;
  149050. private _tickCallback;
  149051. private _sphere;
  149052. private _dataFetched;
  149053. /**
  149054. * Initializes the physics gravitational field event
  149055. * @param _physicsHelper A physics helper
  149056. * @param _scene BabylonJS scene
  149057. * @param _origin The origin position of the gravitational field event
  149058. * @param _options The options for the vortex event
  149059. */
  149060. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149061. /**
  149062. * Returns the data related to the gravitational field event (sphere).
  149063. * @returns A gravitational field event
  149064. */
  149065. getData(): PhysicsGravitationalFieldEventData;
  149066. /**
  149067. * Enables the gravitational field.
  149068. */
  149069. enable(): void;
  149070. /**
  149071. * Disables the gravitational field.
  149072. */
  149073. disable(): void;
  149074. /**
  149075. * Disposes the sphere.
  149076. * @param force The force to dispose from the gravitational field event
  149077. */
  149078. dispose(force?: boolean): void;
  149079. private _tick;
  149080. }
  149081. /**
  149082. * Represents a physics updraft event
  149083. */
  149084. class PhysicsUpdraftEvent {
  149085. private _scene;
  149086. private _origin;
  149087. private _options;
  149088. private _physicsEngine;
  149089. private _originTop;
  149090. private _originDirection;
  149091. private _tickCallback;
  149092. private _cylinder;
  149093. private _cylinderPosition;
  149094. private _dataFetched;
  149095. /**
  149096. * Initializes the physics updraft event
  149097. * @param _scene BabylonJS scene
  149098. * @param _origin The origin position of the updraft
  149099. * @param _options The options for the updraft event
  149100. */
  149101. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149102. /**
  149103. * Returns the data related to the updraft event (cylinder).
  149104. * @returns A physics updraft event
  149105. */
  149106. getData(): PhysicsUpdraftEventData;
  149107. /**
  149108. * Enables the updraft.
  149109. */
  149110. enable(): void;
  149111. /**
  149112. * Disables the updraft.
  149113. */
  149114. disable(): void;
  149115. /**
  149116. * Disposes the cylinder.
  149117. * @param force Specifies if the updraft should be disposed by force
  149118. */
  149119. dispose(force?: boolean): void;
  149120. private getImpostorHitData;
  149121. private _tick;
  149122. /*** Helpers ***/
  149123. private _prepareCylinder;
  149124. private _intersectsWithCylinder;
  149125. }
  149126. /**
  149127. * Represents a physics vortex event
  149128. */
  149129. class PhysicsVortexEvent {
  149130. private _scene;
  149131. private _origin;
  149132. private _options;
  149133. private _physicsEngine;
  149134. private _originTop;
  149135. private _tickCallback;
  149136. private _cylinder;
  149137. private _cylinderPosition;
  149138. private _dataFetched;
  149139. /**
  149140. * Initializes the physics vortex event
  149141. * @param _scene The BabylonJS scene
  149142. * @param _origin The origin position of the vortex
  149143. * @param _options The options for the vortex event
  149144. */
  149145. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149146. /**
  149147. * Returns the data related to the vortex event (cylinder).
  149148. * @returns The physics vortex event data
  149149. */
  149150. getData(): PhysicsVortexEventData;
  149151. /**
  149152. * Enables the vortex.
  149153. */
  149154. enable(): void;
  149155. /**
  149156. * Disables the cortex.
  149157. */
  149158. disable(): void;
  149159. /**
  149160. * Disposes the sphere.
  149161. * @param force
  149162. */
  149163. dispose(force?: boolean): void;
  149164. private getImpostorHitData;
  149165. private _tick;
  149166. /*** Helpers ***/
  149167. private _prepareCylinder;
  149168. private _intersectsWithCylinder;
  149169. }
  149170. /**
  149171. * Options fot the radial explosion event
  149172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149173. */
  149174. export class PhysicsRadialExplosionEventOptions {
  149175. /**
  149176. * The radius of the sphere for the radial explosion.
  149177. */
  149178. radius: number;
  149179. /**
  149180. * The strenth of the explosion.
  149181. */
  149182. strength: number;
  149183. /**
  149184. * The strenght of the force in correspondence to the distance of the affected object
  149185. */
  149186. falloff: PhysicsRadialImpulseFalloff;
  149187. /**
  149188. * Sphere options for the radial explosion.
  149189. */
  149190. sphere: {
  149191. segments: number;
  149192. diameter: number;
  149193. };
  149194. /**
  149195. * Sphere options for the radial explosion.
  149196. */
  149197. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149198. }
  149199. /**
  149200. * Options fot the updraft event
  149201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149202. */
  149203. export class PhysicsUpdraftEventOptions {
  149204. /**
  149205. * The radius of the cylinder for the vortex
  149206. */
  149207. radius: number;
  149208. /**
  149209. * The strenth of the updraft.
  149210. */
  149211. strength: number;
  149212. /**
  149213. * The height of the cylinder for the updraft.
  149214. */
  149215. height: number;
  149216. /**
  149217. * The mode for the the updraft.
  149218. */
  149219. updraftMode: PhysicsUpdraftMode;
  149220. }
  149221. /**
  149222. * Options fot the vortex event
  149223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149224. */
  149225. export class PhysicsVortexEventOptions {
  149226. /**
  149227. * The radius of the cylinder for the vortex
  149228. */
  149229. radius: number;
  149230. /**
  149231. * The strenth of the vortex.
  149232. */
  149233. strength: number;
  149234. /**
  149235. * The height of the cylinder for the vortex.
  149236. */
  149237. height: number;
  149238. /**
  149239. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149240. */
  149241. centripetalForceThreshold: number;
  149242. /**
  149243. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149244. */
  149245. centripetalForceMultiplier: number;
  149246. /**
  149247. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149248. */
  149249. centrifugalForceMultiplier: number;
  149250. /**
  149251. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149252. */
  149253. updraftForceMultiplier: number;
  149254. }
  149255. /**
  149256. * The strenght of the force in correspondence to the distance of the affected object
  149257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149258. */
  149259. export enum PhysicsRadialImpulseFalloff {
  149260. /** Defines that impulse is constant in strength across it's whole radius */
  149261. Constant = 0,
  149262. /** Defines that impulse gets weaker if it's further from the origin */
  149263. Linear = 1
  149264. }
  149265. /**
  149266. * The strength of the force in correspondence to the distance of the affected object
  149267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149268. */
  149269. export enum PhysicsUpdraftMode {
  149270. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149271. Center = 0,
  149272. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149273. Perpendicular = 1
  149274. }
  149275. /**
  149276. * Interface for a physics hit data
  149277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149278. */
  149279. export interface PhysicsHitData {
  149280. /**
  149281. * The force applied at the contact point
  149282. */
  149283. force: Vector3;
  149284. /**
  149285. * The contact point
  149286. */
  149287. contactPoint: Vector3;
  149288. /**
  149289. * The distance from the origin to the contact point
  149290. */
  149291. distanceFromOrigin: number;
  149292. }
  149293. /**
  149294. * Interface for radial explosion event data
  149295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149296. */
  149297. export interface PhysicsRadialExplosionEventData {
  149298. /**
  149299. * A sphere used for the radial explosion event
  149300. */
  149301. sphere: Mesh;
  149302. }
  149303. /**
  149304. * Interface for gravitational field event data
  149305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149306. */
  149307. export interface PhysicsGravitationalFieldEventData {
  149308. /**
  149309. * A sphere mesh used for the gravitational field event
  149310. */
  149311. sphere: Mesh;
  149312. }
  149313. /**
  149314. * Interface for updraft event data
  149315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149316. */
  149317. export interface PhysicsUpdraftEventData {
  149318. /**
  149319. * A cylinder used for the updraft event
  149320. */
  149321. cylinder: Mesh;
  149322. }
  149323. /**
  149324. * Interface for vortex event data
  149325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149326. */
  149327. export interface PhysicsVortexEventData {
  149328. /**
  149329. * A cylinder used for the vortex event
  149330. */
  149331. cylinder: Mesh;
  149332. }
  149333. /**
  149334. * Interface for an affected physics impostor
  149335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149336. */
  149337. export interface PhysicsAffectedImpostorWithData {
  149338. /**
  149339. * The impostor affected by the effect
  149340. */
  149341. impostor: PhysicsImpostor;
  149342. /**
  149343. * The data about the hit/horce from the explosion
  149344. */
  149345. hitData: PhysicsHitData;
  149346. }
  149347. }
  149348. declare module BABYLON {
  149349. /** @hidden */
  149350. export var blackAndWhitePixelShader: {
  149351. name: string;
  149352. shader: string;
  149353. };
  149354. }
  149355. declare module BABYLON {
  149356. /**
  149357. * Post process used to render in black and white
  149358. */
  149359. export class BlackAndWhitePostProcess extends PostProcess {
  149360. /**
  149361. * Linear about to convert he result to black and white (default: 1)
  149362. */
  149363. degree: number;
  149364. /**
  149365. * Gets a string identifying the name of the class
  149366. * @returns "BlackAndWhitePostProcess" string
  149367. */
  149368. getClassName(): string;
  149369. /**
  149370. * Creates a black and white post process
  149371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149372. * @param name The name of the effect.
  149373. * @param options The required width/height ratio to downsize to before computing the render pass.
  149374. * @param camera The camera to apply the render pass to.
  149375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149376. * @param engine The engine which the post process will be applied. (default: current engine)
  149377. * @param reusable If the post process can be reused on the same frame. (default: false)
  149378. */
  149379. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149380. /** @hidden */
  149381. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149382. }
  149383. }
  149384. declare module BABYLON {
  149385. /**
  149386. * This represents a set of one or more post processes in Babylon.
  149387. * A post process can be used to apply a shader to a texture after it is rendered.
  149388. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149389. */
  149390. export class PostProcessRenderEffect {
  149391. private _postProcesses;
  149392. private _getPostProcesses;
  149393. private _singleInstance;
  149394. private _cameras;
  149395. private _indicesForCamera;
  149396. /**
  149397. * Name of the effect
  149398. * @hidden
  149399. */
  149400. _name: string;
  149401. /**
  149402. * Instantiates a post process render effect.
  149403. * A post process can be used to apply a shader to a texture after it is rendered.
  149404. * @param engine The engine the effect is tied to
  149405. * @param name The name of the effect
  149406. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149407. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149408. */
  149409. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149410. /**
  149411. * Checks if all the post processes in the effect are supported.
  149412. */
  149413. get isSupported(): boolean;
  149414. /**
  149415. * Updates the current state of the effect
  149416. * @hidden
  149417. */
  149418. _update(): void;
  149419. /**
  149420. * Attaches the effect on cameras
  149421. * @param cameras The camera to attach to.
  149422. * @hidden
  149423. */
  149424. _attachCameras(cameras: Camera): void;
  149425. /**
  149426. * Attaches the effect on cameras
  149427. * @param cameras The camera to attach to.
  149428. * @hidden
  149429. */
  149430. _attachCameras(cameras: Camera[]): void;
  149431. /**
  149432. * Detaches the effect on cameras
  149433. * @param cameras The camera to detatch from.
  149434. * @hidden
  149435. */
  149436. _detachCameras(cameras: Camera): void;
  149437. /**
  149438. * Detatches the effect on cameras
  149439. * @param cameras The camera to detatch from.
  149440. * @hidden
  149441. */
  149442. _detachCameras(cameras: Camera[]): void;
  149443. /**
  149444. * Enables the effect on given cameras
  149445. * @param cameras The camera to enable.
  149446. * @hidden
  149447. */
  149448. _enable(cameras: Camera): void;
  149449. /**
  149450. * Enables the effect on given cameras
  149451. * @param cameras The camera to enable.
  149452. * @hidden
  149453. */
  149454. _enable(cameras: Nullable<Camera[]>): void;
  149455. /**
  149456. * Disables the effect on the given cameras
  149457. * @param cameras The camera to disable.
  149458. * @hidden
  149459. */
  149460. _disable(cameras: Camera): void;
  149461. /**
  149462. * Disables the effect on the given cameras
  149463. * @param cameras The camera to disable.
  149464. * @hidden
  149465. */
  149466. _disable(cameras: Nullable<Camera[]>): void;
  149467. /**
  149468. * Gets a list of the post processes contained in the effect.
  149469. * @param camera The camera to get the post processes on.
  149470. * @returns The list of the post processes in the effect.
  149471. */
  149472. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149473. }
  149474. }
  149475. declare module BABYLON {
  149476. /** @hidden */
  149477. export var extractHighlightsPixelShader: {
  149478. name: string;
  149479. shader: string;
  149480. };
  149481. }
  149482. declare module BABYLON {
  149483. /**
  149484. * 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.
  149485. */
  149486. export class ExtractHighlightsPostProcess extends PostProcess {
  149487. /**
  149488. * The luminance threshold, pixels below this value will be set to black.
  149489. */
  149490. threshold: number;
  149491. /** @hidden */
  149492. _exposure: number;
  149493. /**
  149494. * Post process which has the input texture to be used when performing highlight extraction
  149495. * @hidden
  149496. */
  149497. _inputPostProcess: Nullable<PostProcess>;
  149498. /**
  149499. * Gets a string identifying the name of the class
  149500. * @returns "ExtractHighlightsPostProcess" string
  149501. */
  149502. getClassName(): string;
  149503. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149504. }
  149505. }
  149506. declare module BABYLON {
  149507. /** @hidden */
  149508. export var bloomMergePixelShader: {
  149509. name: string;
  149510. shader: string;
  149511. };
  149512. }
  149513. declare module BABYLON {
  149514. /**
  149515. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149516. */
  149517. export class BloomMergePostProcess extends PostProcess {
  149518. /** Weight of the bloom to be added to the original input. */
  149519. weight: number;
  149520. /**
  149521. * Gets a string identifying the name of the class
  149522. * @returns "BloomMergePostProcess" string
  149523. */
  149524. getClassName(): string;
  149525. /**
  149526. * Creates a new instance of @see BloomMergePostProcess
  149527. * @param name The name of the effect.
  149528. * @param originalFromInput Post process which's input will be used for the merge.
  149529. * @param blurred Blurred highlights post process which's output will be used.
  149530. * @param weight Weight of the bloom to be added to the original input.
  149531. * @param options The required width/height ratio to downsize to before computing the render pass.
  149532. * @param camera The camera to apply the render pass to.
  149533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149534. * @param engine The engine which the post process will be applied. (default: current engine)
  149535. * @param reusable If the post process can be reused on the same frame. (default: false)
  149536. * @param textureType Type of textures used when performing the post process. (default: 0)
  149537. * @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)
  149538. */
  149539. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149540. /** Weight of the bloom to be added to the original input. */
  149541. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149542. }
  149543. }
  149544. declare module BABYLON {
  149545. /**
  149546. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149547. */
  149548. export class BloomEffect extends PostProcessRenderEffect {
  149549. private bloomScale;
  149550. /**
  149551. * @hidden Internal
  149552. */
  149553. _effects: Array<PostProcess>;
  149554. /**
  149555. * @hidden Internal
  149556. */
  149557. _downscale: ExtractHighlightsPostProcess;
  149558. private _blurX;
  149559. private _blurY;
  149560. private _merge;
  149561. /**
  149562. * The luminance threshold to find bright areas of the image to bloom.
  149563. */
  149564. get threshold(): number;
  149565. set threshold(value: number);
  149566. /**
  149567. * The strength of the bloom.
  149568. */
  149569. get weight(): number;
  149570. set weight(value: number);
  149571. /**
  149572. * Specifies the size of the bloom blur kernel, relative to the final output size
  149573. */
  149574. get kernel(): number;
  149575. set kernel(value: number);
  149576. /**
  149577. * Creates a new instance of @see BloomEffect
  149578. * @param scene The scene the effect belongs to.
  149579. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149580. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149581. * @param bloomWeight The the strength of bloom.
  149582. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149583. * @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)
  149584. */
  149585. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149586. /**
  149587. * Disposes each of the internal effects for a given camera.
  149588. * @param camera The camera to dispose the effect on.
  149589. */
  149590. disposeEffects(camera: Camera): void;
  149591. /**
  149592. * @hidden Internal
  149593. */
  149594. _updateEffects(): void;
  149595. /**
  149596. * Internal
  149597. * @returns if all the contained post processes are ready.
  149598. * @hidden
  149599. */
  149600. _isReady(): boolean;
  149601. }
  149602. }
  149603. declare module BABYLON {
  149604. /** @hidden */
  149605. export var chromaticAberrationPixelShader: {
  149606. name: string;
  149607. shader: string;
  149608. };
  149609. }
  149610. declare module BABYLON {
  149611. /**
  149612. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149613. */
  149614. export class ChromaticAberrationPostProcess extends PostProcess {
  149615. /**
  149616. * The amount of seperation of rgb channels (default: 30)
  149617. */
  149618. aberrationAmount: number;
  149619. /**
  149620. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149621. */
  149622. radialIntensity: number;
  149623. /**
  149624. * 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))
  149625. */
  149626. direction: Vector2;
  149627. /**
  149628. * 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))
  149629. */
  149630. centerPosition: Vector2;
  149631. /** The width of the screen to apply the effect on */
  149632. screenWidth: number;
  149633. /** The height of the screen to apply the effect on */
  149634. screenHeight: number;
  149635. /**
  149636. * Gets a string identifying the name of the class
  149637. * @returns "ChromaticAberrationPostProcess" string
  149638. */
  149639. getClassName(): string;
  149640. /**
  149641. * Creates a new instance ChromaticAberrationPostProcess
  149642. * @param name The name of the effect.
  149643. * @param screenWidth The width of the screen to apply the effect on.
  149644. * @param screenHeight The height of the screen to apply the effect on.
  149645. * @param options The required width/height ratio to downsize to before computing the render pass.
  149646. * @param camera The camera to apply the render pass to.
  149647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149648. * @param engine The engine which the post process will be applied. (default: current engine)
  149649. * @param reusable If the post process can be reused on the same frame. (default: false)
  149650. * @param textureType Type of textures used when performing the post process. (default: 0)
  149651. * @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)
  149652. */
  149653. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149654. /** @hidden */
  149655. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149656. }
  149657. }
  149658. declare module BABYLON {
  149659. /** @hidden */
  149660. export var circleOfConfusionPixelShader: {
  149661. name: string;
  149662. shader: string;
  149663. };
  149664. }
  149665. declare module BABYLON {
  149666. /**
  149667. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149668. */
  149669. export class CircleOfConfusionPostProcess extends PostProcess {
  149670. /**
  149671. * 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.
  149672. */
  149673. lensSize: number;
  149674. /**
  149675. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149676. */
  149677. fStop: number;
  149678. /**
  149679. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149680. */
  149681. focusDistance: number;
  149682. /**
  149683. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149684. */
  149685. focalLength: number;
  149686. /**
  149687. * Gets a string identifying the name of the class
  149688. * @returns "CircleOfConfusionPostProcess" string
  149689. */
  149690. getClassName(): string;
  149691. private _depthTexture;
  149692. /**
  149693. * Creates a new instance CircleOfConfusionPostProcess
  149694. * @param name The name of the effect.
  149695. * @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.
  149696. * @param options The required width/height ratio to downsize to before computing the render pass.
  149697. * @param camera The camera to apply the render pass to.
  149698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149699. * @param engine The engine which the post process will be applied. (default: current engine)
  149700. * @param reusable If the post process can be reused on the same frame. (default: false)
  149701. * @param textureType Type of textures used when performing the post process. (default: 0)
  149702. * @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)
  149703. */
  149704. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149705. /**
  149706. * 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.
  149707. */
  149708. set depthTexture(value: RenderTargetTexture);
  149709. }
  149710. }
  149711. declare module BABYLON {
  149712. /** @hidden */
  149713. export var colorCorrectionPixelShader: {
  149714. name: string;
  149715. shader: string;
  149716. };
  149717. }
  149718. declare module BABYLON {
  149719. /**
  149720. *
  149721. * This post-process allows the modification of rendered colors by using
  149722. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149723. *
  149724. * The object needs to be provided an url to a texture containing the color
  149725. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149726. * Use an image editing software to tweak the LUT to match your needs.
  149727. *
  149728. * For an example of a color LUT, see here:
  149729. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149730. * For explanations on color grading, see here:
  149731. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149732. *
  149733. */
  149734. export class ColorCorrectionPostProcess extends PostProcess {
  149735. private _colorTableTexture;
  149736. /**
  149737. * Gets the color table url used to create the LUT texture
  149738. */
  149739. colorTableUrl: string;
  149740. /**
  149741. * Gets a string identifying the name of the class
  149742. * @returns "ColorCorrectionPostProcess" string
  149743. */
  149744. getClassName(): string;
  149745. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149746. /** @hidden */
  149747. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149748. }
  149749. }
  149750. declare module BABYLON {
  149751. /** @hidden */
  149752. export var convolutionPixelShader: {
  149753. name: string;
  149754. shader: string;
  149755. };
  149756. }
  149757. declare module BABYLON {
  149758. /**
  149759. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149760. * input texture to perform effects such as edge detection or sharpening
  149761. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149762. */
  149763. export class ConvolutionPostProcess extends PostProcess {
  149764. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149765. kernel: number[];
  149766. /**
  149767. * Gets a string identifying the name of the class
  149768. * @returns "ConvolutionPostProcess" string
  149769. */
  149770. getClassName(): string;
  149771. /**
  149772. * Creates a new instance ConvolutionPostProcess
  149773. * @param name The name of the effect.
  149774. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149775. * @param options The required width/height ratio to downsize to before computing the render pass.
  149776. * @param camera The camera to apply the render pass to.
  149777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149778. * @param engine The engine which the post process will be applied. (default: current engine)
  149779. * @param reusable If the post process can be reused on the same frame. (default: false)
  149780. * @param textureType Type of textures used when performing the post process. (default: 0)
  149781. */
  149782. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149783. /** @hidden */
  149784. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149785. /**
  149786. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149787. */
  149788. static EdgeDetect0Kernel: number[];
  149789. /**
  149790. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149791. */
  149792. static EdgeDetect1Kernel: number[];
  149793. /**
  149794. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149795. */
  149796. static EdgeDetect2Kernel: number[];
  149797. /**
  149798. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149799. */
  149800. static SharpenKernel: number[];
  149801. /**
  149802. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149803. */
  149804. static EmbossKernel: number[];
  149805. /**
  149806. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149807. */
  149808. static GaussianKernel: number[];
  149809. }
  149810. }
  149811. declare module BABYLON {
  149812. /**
  149813. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149814. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149815. * based on samples that have a large difference in distance than the center pixel.
  149816. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149817. */
  149818. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149819. /**
  149820. * The direction the blur should be applied
  149821. */
  149822. direction: Vector2;
  149823. /**
  149824. * Gets a string identifying the name of the class
  149825. * @returns "DepthOfFieldBlurPostProcess" string
  149826. */
  149827. getClassName(): string;
  149828. /**
  149829. * Creates a new instance CircleOfConfusionPostProcess
  149830. * @param name The name of the effect.
  149831. * @param scene The scene the effect belongs to.
  149832. * @param direction The direction the blur should be applied.
  149833. * @param kernel The size of the kernel used to blur.
  149834. * @param options The required width/height ratio to downsize to before computing the render pass.
  149835. * @param camera The camera to apply the render pass to.
  149836. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149837. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149839. * @param engine The engine which the post process will be applied. (default: current engine)
  149840. * @param reusable If the post process can be reused on the same frame. (default: false)
  149841. * @param textureType Type of textures used when performing the post process. (default: 0)
  149842. * @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)
  149843. */
  149844. 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);
  149845. }
  149846. }
  149847. declare module BABYLON {
  149848. /** @hidden */
  149849. export var depthOfFieldMergePixelShader: {
  149850. name: string;
  149851. shader: string;
  149852. };
  149853. }
  149854. declare module BABYLON {
  149855. /**
  149856. * Options to be set when merging outputs from the default pipeline.
  149857. */
  149858. export class DepthOfFieldMergePostProcessOptions {
  149859. /**
  149860. * The original image to merge on top of
  149861. */
  149862. originalFromInput: PostProcess;
  149863. /**
  149864. * Parameters to perform the merge of the depth of field effect
  149865. */
  149866. depthOfField?: {
  149867. circleOfConfusion: PostProcess;
  149868. blurSteps: Array<PostProcess>;
  149869. };
  149870. /**
  149871. * Parameters to perform the merge of bloom effect
  149872. */
  149873. bloom?: {
  149874. blurred: PostProcess;
  149875. weight: number;
  149876. };
  149877. }
  149878. /**
  149879. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149880. */
  149881. export class DepthOfFieldMergePostProcess extends PostProcess {
  149882. private blurSteps;
  149883. /**
  149884. * Gets a string identifying the name of the class
  149885. * @returns "DepthOfFieldMergePostProcess" string
  149886. */
  149887. getClassName(): string;
  149888. /**
  149889. * Creates a new instance of DepthOfFieldMergePostProcess
  149890. * @param name The name of the effect.
  149891. * @param originalFromInput Post process which's input will be used for the merge.
  149892. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149893. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149894. * @param options The required width/height ratio to downsize to before computing the render pass.
  149895. * @param camera The camera to apply the render pass to.
  149896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149897. * @param engine The engine which the post process will be applied. (default: current engine)
  149898. * @param reusable If the post process can be reused on the same frame. (default: false)
  149899. * @param textureType Type of textures used when performing the post process. (default: 0)
  149900. * @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)
  149901. */
  149902. 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);
  149903. /**
  149904. * Updates the effect with the current post process compile time values and recompiles the shader.
  149905. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149906. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149907. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149908. * @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
  149909. * @param onCompiled Called when the shader has been compiled.
  149910. * @param onError Called if there is an error when compiling a shader.
  149911. */
  149912. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149913. }
  149914. }
  149915. declare module BABYLON {
  149916. /**
  149917. * Specifies the level of max blur that should be applied when using the depth of field effect
  149918. */
  149919. export enum DepthOfFieldEffectBlurLevel {
  149920. /**
  149921. * Subtle blur
  149922. */
  149923. Low = 0,
  149924. /**
  149925. * Medium blur
  149926. */
  149927. Medium = 1,
  149928. /**
  149929. * Large blur
  149930. */
  149931. High = 2
  149932. }
  149933. /**
  149934. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149935. */
  149936. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149937. private _circleOfConfusion;
  149938. /**
  149939. * @hidden Internal, blurs from high to low
  149940. */
  149941. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149942. private _depthOfFieldBlurY;
  149943. private _dofMerge;
  149944. /**
  149945. * @hidden Internal post processes in depth of field effect
  149946. */
  149947. _effects: Array<PostProcess>;
  149948. /**
  149949. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149950. */
  149951. set focalLength(value: number);
  149952. get focalLength(): number;
  149953. /**
  149954. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149955. */
  149956. set fStop(value: number);
  149957. get fStop(): number;
  149958. /**
  149959. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149960. */
  149961. set focusDistance(value: number);
  149962. get focusDistance(): number;
  149963. /**
  149964. * 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.
  149965. */
  149966. set lensSize(value: number);
  149967. get lensSize(): number;
  149968. /**
  149969. * Creates a new instance DepthOfFieldEffect
  149970. * @param scene The scene the effect belongs to.
  149971. * @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.
  149972. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149973. * @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)
  149974. */
  149975. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149976. /**
  149977. * Get the current class name of the current effet
  149978. * @returns "DepthOfFieldEffect"
  149979. */
  149980. getClassName(): string;
  149981. /**
  149982. * 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.
  149983. */
  149984. set depthTexture(value: RenderTargetTexture);
  149985. /**
  149986. * Disposes each of the internal effects for a given camera.
  149987. * @param camera The camera to dispose the effect on.
  149988. */
  149989. disposeEffects(camera: Camera): void;
  149990. /**
  149991. * @hidden Internal
  149992. */
  149993. _updateEffects(): void;
  149994. /**
  149995. * Internal
  149996. * @returns if all the contained post processes are ready.
  149997. * @hidden
  149998. */
  149999. _isReady(): boolean;
  150000. }
  150001. }
  150002. declare module BABYLON {
  150003. /** @hidden */
  150004. export var displayPassPixelShader: {
  150005. name: string;
  150006. shader: string;
  150007. };
  150008. }
  150009. declare module BABYLON {
  150010. /**
  150011. * DisplayPassPostProcess which produces an output the same as it's input
  150012. */
  150013. export class DisplayPassPostProcess extends PostProcess {
  150014. /**
  150015. * Gets a string identifying the name of the class
  150016. * @returns "DisplayPassPostProcess" string
  150017. */
  150018. getClassName(): string;
  150019. /**
  150020. * Creates the DisplayPassPostProcess
  150021. * @param name The name of the effect.
  150022. * @param options The required width/height ratio to downsize to before computing the render pass.
  150023. * @param camera The camera to apply the render pass to.
  150024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150025. * @param engine The engine which the post process will be applied. (default: current engine)
  150026. * @param reusable If the post process can be reused on the same frame. (default: false)
  150027. */
  150028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150029. /** @hidden */
  150030. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150031. }
  150032. }
  150033. declare module BABYLON {
  150034. /** @hidden */
  150035. export var filterPixelShader: {
  150036. name: string;
  150037. shader: string;
  150038. };
  150039. }
  150040. declare module BABYLON {
  150041. /**
  150042. * Applies a kernel filter to the image
  150043. */
  150044. export class FilterPostProcess extends PostProcess {
  150045. /** The matrix to be applied to the image */
  150046. kernelMatrix: Matrix;
  150047. /**
  150048. * Gets a string identifying the name of the class
  150049. * @returns "FilterPostProcess" string
  150050. */
  150051. getClassName(): string;
  150052. /**
  150053. *
  150054. * @param name The name of the effect.
  150055. * @param kernelMatrix The matrix to be applied to the image
  150056. * @param options The required width/height ratio to downsize to before computing the render pass.
  150057. * @param camera The camera to apply the render pass to.
  150058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150059. * @param engine The engine which the post process will be applied. (default: current engine)
  150060. * @param reusable If the post process can be reused on the same frame. (default: false)
  150061. */
  150062. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150063. /** @hidden */
  150064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150065. }
  150066. }
  150067. declare module BABYLON {
  150068. /** @hidden */
  150069. export var fxaaPixelShader: {
  150070. name: string;
  150071. shader: string;
  150072. };
  150073. }
  150074. declare module BABYLON {
  150075. /** @hidden */
  150076. export var fxaaVertexShader: {
  150077. name: string;
  150078. shader: string;
  150079. };
  150080. }
  150081. declare module BABYLON {
  150082. /**
  150083. * Fxaa post process
  150084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150085. */
  150086. export class FxaaPostProcess extends PostProcess {
  150087. /**
  150088. * Gets a string identifying the name of the class
  150089. * @returns "FxaaPostProcess" string
  150090. */
  150091. getClassName(): string;
  150092. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150093. private _getDefines;
  150094. /** @hidden */
  150095. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150096. }
  150097. }
  150098. declare module BABYLON {
  150099. /** @hidden */
  150100. export var grainPixelShader: {
  150101. name: string;
  150102. shader: string;
  150103. };
  150104. }
  150105. declare module BABYLON {
  150106. /**
  150107. * The GrainPostProcess adds noise to the image at mid luminance levels
  150108. */
  150109. export class GrainPostProcess extends PostProcess {
  150110. /**
  150111. * The intensity of the grain added (default: 30)
  150112. */
  150113. intensity: number;
  150114. /**
  150115. * If the grain should be randomized on every frame
  150116. */
  150117. animated: boolean;
  150118. /**
  150119. * Gets a string identifying the name of the class
  150120. * @returns "GrainPostProcess" string
  150121. */
  150122. getClassName(): string;
  150123. /**
  150124. * Creates a new instance of @see GrainPostProcess
  150125. * @param name The name of the effect.
  150126. * @param options The required width/height ratio to downsize to before computing the render pass.
  150127. * @param camera The camera to apply the render pass to.
  150128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150129. * @param engine The engine which the post process will be applied. (default: current engine)
  150130. * @param reusable If the post process can be reused on the same frame. (default: false)
  150131. * @param textureType Type of textures used when performing the post process. (default: 0)
  150132. * @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)
  150133. */
  150134. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150135. /** @hidden */
  150136. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150137. }
  150138. }
  150139. declare module BABYLON {
  150140. /** @hidden */
  150141. export var highlightsPixelShader: {
  150142. name: string;
  150143. shader: string;
  150144. };
  150145. }
  150146. declare module BABYLON {
  150147. /**
  150148. * Extracts highlights from the image
  150149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150150. */
  150151. export class HighlightsPostProcess extends PostProcess {
  150152. /**
  150153. * Gets a string identifying the name of the class
  150154. * @returns "HighlightsPostProcess" string
  150155. */
  150156. getClassName(): string;
  150157. /**
  150158. * Extracts highlights from the image
  150159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150160. * @param name The name of the effect.
  150161. * @param options The required width/height ratio to downsize to before computing the render pass.
  150162. * @param camera The camera to apply the render pass to.
  150163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150164. * @param engine The engine which the post process will be applied. (default: current engine)
  150165. * @param reusable If the post process can be reused on the same frame. (default: false)
  150166. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150167. */
  150168. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150169. }
  150170. }
  150171. declare module BABYLON {
  150172. /** @hidden */
  150173. export var mrtFragmentDeclaration: {
  150174. name: string;
  150175. shader: string;
  150176. };
  150177. }
  150178. declare module BABYLON {
  150179. /** @hidden */
  150180. export var geometryPixelShader: {
  150181. name: string;
  150182. shader: string;
  150183. };
  150184. }
  150185. declare module BABYLON {
  150186. /** @hidden */
  150187. export var geometryVertexShader: {
  150188. name: string;
  150189. shader: string;
  150190. };
  150191. }
  150192. declare module BABYLON {
  150193. /** @hidden */
  150194. interface ISavedTransformationMatrix {
  150195. world: Matrix;
  150196. viewProjection: Matrix;
  150197. }
  150198. /**
  150199. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150200. */
  150201. export class GeometryBufferRenderer {
  150202. /**
  150203. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150204. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150205. */
  150206. static readonly POSITION_TEXTURE_TYPE: number;
  150207. /**
  150208. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150209. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150210. */
  150211. static readonly VELOCITY_TEXTURE_TYPE: number;
  150212. /**
  150213. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150214. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150215. */
  150216. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150217. /**
  150218. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150219. * in order to compute objects velocities when enableVelocity is set to "true"
  150220. * @hidden
  150221. */
  150222. _previousTransformationMatrices: {
  150223. [index: number]: ISavedTransformationMatrix;
  150224. };
  150225. /**
  150226. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150227. * in order to compute objects velocities when enableVelocity is set to "true"
  150228. * @hidden
  150229. */
  150230. _previousBonesTransformationMatrices: {
  150231. [index: number]: Float32Array;
  150232. };
  150233. /**
  150234. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150235. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150236. */
  150237. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150238. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150239. renderTransparentMeshes: boolean;
  150240. private _scene;
  150241. private _resizeObserver;
  150242. private _multiRenderTarget;
  150243. private _ratio;
  150244. private _enablePosition;
  150245. private _enableVelocity;
  150246. private _enableReflectivity;
  150247. private _positionIndex;
  150248. private _velocityIndex;
  150249. private _reflectivityIndex;
  150250. protected _effect: Effect;
  150251. protected _cachedDefines: string;
  150252. /**
  150253. * Set the render list (meshes to be rendered) used in the G buffer.
  150254. */
  150255. set renderList(meshes: Mesh[]);
  150256. /**
  150257. * Gets wether or not G buffer are supported by the running hardware.
  150258. * This requires draw buffer supports
  150259. */
  150260. get isSupported(): boolean;
  150261. /**
  150262. * Returns the index of the given texture type in the G-Buffer textures array
  150263. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150264. * @returns the index of the given texture type in the G-Buffer textures array
  150265. */
  150266. getTextureIndex(textureType: number): number;
  150267. /**
  150268. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150269. */
  150270. get enablePosition(): boolean;
  150271. /**
  150272. * Sets whether or not objects positions are enabled for the G buffer.
  150273. */
  150274. set enablePosition(enable: boolean);
  150275. /**
  150276. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150277. */
  150278. get enableVelocity(): boolean;
  150279. /**
  150280. * Sets wether or not objects velocities are enabled for the G buffer.
  150281. */
  150282. set enableVelocity(enable: boolean);
  150283. /**
  150284. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150285. */
  150286. get enableReflectivity(): boolean;
  150287. /**
  150288. * Sets wether or not objects roughness are enabled for the G buffer.
  150289. */
  150290. set enableReflectivity(enable: boolean);
  150291. /**
  150292. * Gets the scene associated with the buffer.
  150293. */
  150294. get scene(): Scene;
  150295. /**
  150296. * Gets the ratio used by the buffer during its creation.
  150297. * How big is the buffer related to the main canvas.
  150298. */
  150299. get ratio(): number;
  150300. /** @hidden */
  150301. static _SceneComponentInitialization: (scene: Scene) => void;
  150302. /**
  150303. * Creates a new G Buffer for the scene
  150304. * @param scene The scene the buffer belongs to
  150305. * @param ratio How big is the buffer related to the main canvas.
  150306. */
  150307. constructor(scene: Scene, ratio?: number);
  150308. /**
  150309. * Checks wether everything is ready to render a submesh to the G buffer.
  150310. * @param subMesh the submesh to check readiness for
  150311. * @param useInstances is the mesh drawn using instance or not
  150312. * @returns true if ready otherwise false
  150313. */
  150314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150315. /**
  150316. * Gets the current underlying G Buffer.
  150317. * @returns the buffer
  150318. */
  150319. getGBuffer(): MultiRenderTarget;
  150320. /**
  150321. * Gets the number of samples used to render the buffer (anti aliasing).
  150322. */
  150323. get samples(): number;
  150324. /**
  150325. * Sets the number of samples used to render the buffer (anti aliasing).
  150326. */
  150327. set samples(value: number);
  150328. /**
  150329. * Disposes the renderer and frees up associated resources.
  150330. */
  150331. dispose(): void;
  150332. protected _createRenderTargets(): void;
  150333. private _copyBonesTransformationMatrices;
  150334. }
  150335. }
  150336. declare module BABYLON {
  150337. interface Scene {
  150338. /** @hidden (Backing field) */
  150339. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150340. /**
  150341. * Gets or Sets the current geometry buffer associated to the scene.
  150342. */
  150343. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150344. /**
  150345. * Enables a GeometryBufferRender and associates it with the scene
  150346. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150347. * @returns the GeometryBufferRenderer
  150348. */
  150349. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150350. /**
  150351. * Disables the GeometryBufferRender associated with the scene
  150352. */
  150353. disableGeometryBufferRenderer(): void;
  150354. }
  150355. /**
  150356. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150357. * in several rendering techniques.
  150358. */
  150359. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150360. /**
  150361. * The component name helpful to identify the component in the list of scene components.
  150362. */
  150363. readonly name: string;
  150364. /**
  150365. * The scene the component belongs to.
  150366. */
  150367. scene: Scene;
  150368. /**
  150369. * Creates a new instance of the component for the given scene
  150370. * @param scene Defines the scene to register the component in
  150371. */
  150372. constructor(scene: Scene);
  150373. /**
  150374. * Registers the component in a given scene
  150375. */
  150376. register(): void;
  150377. /**
  150378. * Rebuilds the elements related to this component in case of
  150379. * context lost for instance.
  150380. */
  150381. rebuild(): void;
  150382. /**
  150383. * Disposes the component and the associated ressources
  150384. */
  150385. dispose(): void;
  150386. private _gatherRenderTargets;
  150387. }
  150388. }
  150389. declare module BABYLON {
  150390. /** @hidden */
  150391. export var motionBlurPixelShader: {
  150392. name: string;
  150393. shader: string;
  150394. };
  150395. }
  150396. declare module BABYLON {
  150397. /**
  150398. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150399. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150400. * As an example, all you have to do is to create the post-process:
  150401. * var mb = new BABYLON.MotionBlurPostProcess(
  150402. * 'mb', // The name of the effect.
  150403. * scene, // The scene containing the objects to blur according to their velocity.
  150404. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150405. * camera // The camera to apply the render pass to.
  150406. * );
  150407. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150408. */
  150409. export class MotionBlurPostProcess extends PostProcess {
  150410. /**
  150411. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150412. */
  150413. motionStrength: number;
  150414. /**
  150415. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150416. */
  150417. get motionBlurSamples(): number;
  150418. /**
  150419. * Sets the number of iterations to be used for motion blur quality
  150420. */
  150421. set motionBlurSamples(samples: number);
  150422. private _motionBlurSamples;
  150423. private _geometryBufferRenderer;
  150424. /**
  150425. * Gets a string identifying the name of the class
  150426. * @returns "MotionBlurPostProcess" string
  150427. */
  150428. getClassName(): string;
  150429. /**
  150430. * Creates a new instance MotionBlurPostProcess
  150431. * @param name The name of the effect.
  150432. * @param scene The scene containing the objects to blur according to their velocity.
  150433. * @param options The required width/height ratio to downsize to before computing the render pass.
  150434. * @param camera The camera to apply the render pass to.
  150435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150436. * @param engine The engine which the post process will be applied. (default: current engine)
  150437. * @param reusable If the post process can be reused on the same frame. (default: false)
  150438. * @param textureType Type of textures used when performing the post process. (default: 0)
  150439. * @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)
  150440. */
  150441. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150442. /**
  150443. * Excludes the given skinned mesh from computing bones velocities.
  150444. * 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.
  150445. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150446. */
  150447. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150448. /**
  150449. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150450. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150451. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150452. */
  150453. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150454. /**
  150455. * Disposes the post process.
  150456. * @param camera The camera to dispose the post process on.
  150457. */
  150458. dispose(camera?: Camera): void;
  150459. /** @hidden */
  150460. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150461. }
  150462. }
  150463. declare module BABYLON {
  150464. /** @hidden */
  150465. export var refractionPixelShader: {
  150466. name: string;
  150467. shader: string;
  150468. };
  150469. }
  150470. declare module BABYLON {
  150471. /**
  150472. * Post process which applies a refractin texture
  150473. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150474. */
  150475. export class RefractionPostProcess extends PostProcess {
  150476. private _refTexture;
  150477. private _ownRefractionTexture;
  150478. /** the base color of the refraction (used to taint the rendering) */
  150479. color: Color3;
  150480. /** simulated refraction depth */
  150481. depth: number;
  150482. /** the coefficient of the base color (0 to remove base color tainting) */
  150483. colorLevel: number;
  150484. /** Gets the url used to load the refraction texture */
  150485. refractionTextureUrl: string;
  150486. /**
  150487. * Gets or sets the refraction texture
  150488. * Please note that you are responsible for disposing the texture if you set it manually
  150489. */
  150490. get refractionTexture(): Texture;
  150491. set refractionTexture(value: Texture);
  150492. /**
  150493. * Gets a string identifying the name of the class
  150494. * @returns "RefractionPostProcess" string
  150495. */
  150496. getClassName(): string;
  150497. /**
  150498. * Initializes the RefractionPostProcess
  150499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150500. * @param name The name of the effect.
  150501. * @param refractionTextureUrl Url of the refraction texture to use
  150502. * @param color the base color of the refraction (used to taint the rendering)
  150503. * @param depth simulated refraction depth
  150504. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150505. * @param camera The camera to apply the render pass to.
  150506. * @param options The required width/height ratio to downsize to before computing the render pass.
  150507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150508. * @param engine The engine which the post process will be applied. (default: current engine)
  150509. * @param reusable If the post process can be reused on the same frame. (default: false)
  150510. */
  150511. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150512. /**
  150513. * Disposes of the post process
  150514. * @param camera Camera to dispose post process on
  150515. */
  150516. dispose(camera: Camera): void;
  150517. /** @hidden */
  150518. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150519. }
  150520. }
  150521. declare module BABYLON {
  150522. /** @hidden */
  150523. export var sharpenPixelShader: {
  150524. name: string;
  150525. shader: string;
  150526. };
  150527. }
  150528. declare module BABYLON {
  150529. /**
  150530. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150531. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150532. */
  150533. export class SharpenPostProcess extends PostProcess {
  150534. /**
  150535. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150536. */
  150537. colorAmount: number;
  150538. /**
  150539. * How much sharpness should be applied (default: 0.3)
  150540. */
  150541. edgeAmount: number;
  150542. /**
  150543. * Gets a string identifying the name of the class
  150544. * @returns "SharpenPostProcess" string
  150545. */
  150546. getClassName(): string;
  150547. /**
  150548. * Creates a new instance ConvolutionPostProcess
  150549. * @param name The name of the effect.
  150550. * @param options The required width/height ratio to downsize to before computing the render pass.
  150551. * @param camera The camera to apply the render pass to.
  150552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150553. * @param engine The engine which the post process will be applied. (default: current engine)
  150554. * @param reusable If the post process can be reused on the same frame. (default: false)
  150555. * @param textureType Type of textures used when performing the post process. (default: 0)
  150556. * @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)
  150557. */
  150558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150559. /** @hidden */
  150560. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150561. }
  150562. }
  150563. declare module BABYLON {
  150564. /**
  150565. * PostProcessRenderPipeline
  150566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150567. */
  150568. export class PostProcessRenderPipeline {
  150569. private engine;
  150570. private _renderEffects;
  150571. private _renderEffectsForIsolatedPass;
  150572. /**
  150573. * List of inspectable custom properties (used by the Inspector)
  150574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150575. */
  150576. inspectableCustomProperties: IInspectable[];
  150577. /**
  150578. * @hidden
  150579. */
  150580. protected _cameras: Camera[];
  150581. /** @hidden */
  150582. _name: string;
  150583. /**
  150584. * Gets pipeline name
  150585. */
  150586. get name(): string;
  150587. /** Gets the list of attached cameras */
  150588. get cameras(): Camera[];
  150589. /**
  150590. * Initializes a PostProcessRenderPipeline
  150591. * @param engine engine to add the pipeline to
  150592. * @param name name of the pipeline
  150593. */
  150594. constructor(engine: Engine, name: string);
  150595. /**
  150596. * Gets the class name
  150597. * @returns "PostProcessRenderPipeline"
  150598. */
  150599. getClassName(): string;
  150600. /**
  150601. * If all the render effects in the pipeline are supported
  150602. */
  150603. get isSupported(): boolean;
  150604. /**
  150605. * Adds an effect to the pipeline
  150606. * @param renderEffect the effect to add
  150607. */
  150608. addEffect(renderEffect: PostProcessRenderEffect): void;
  150609. /** @hidden */
  150610. _rebuild(): void;
  150611. /** @hidden */
  150612. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150613. /** @hidden */
  150614. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150615. /** @hidden */
  150616. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150617. /** @hidden */
  150618. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150619. /** @hidden */
  150620. _attachCameras(cameras: Camera, unique: boolean): void;
  150621. /** @hidden */
  150622. _attachCameras(cameras: Camera[], unique: boolean): void;
  150623. /** @hidden */
  150624. _detachCameras(cameras: Camera): void;
  150625. /** @hidden */
  150626. _detachCameras(cameras: Nullable<Camera[]>): void;
  150627. /** @hidden */
  150628. _update(): void;
  150629. /** @hidden */
  150630. _reset(): void;
  150631. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150632. /**
  150633. * Sets the required values to the prepass renderer.
  150634. * @param prePassRenderer defines the prepass renderer to setup.
  150635. * @returns true if the pre pass is needed.
  150636. */
  150637. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150638. /**
  150639. * Disposes of the pipeline
  150640. */
  150641. dispose(): void;
  150642. }
  150643. }
  150644. declare module BABYLON {
  150645. /**
  150646. * PostProcessRenderPipelineManager class
  150647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150648. */
  150649. export class PostProcessRenderPipelineManager {
  150650. private _renderPipelines;
  150651. /**
  150652. * Initializes a PostProcessRenderPipelineManager
  150653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150654. */
  150655. constructor();
  150656. /**
  150657. * Gets the list of supported render pipelines
  150658. */
  150659. get supportedPipelines(): PostProcessRenderPipeline[];
  150660. /**
  150661. * Adds a pipeline to the manager
  150662. * @param renderPipeline The pipeline to add
  150663. */
  150664. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150665. /**
  150666. * Attaches a camera to the pipeline
  150667. * @param renderPipelineName The name of the pipeline to attach to
  150668. * @param cameras the camera to attach
  150669. * @param unique if the camera can be attached multiple times to the pipeline
  150670. */
  150671. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150672. /**
  150673. * Detaches a camera from the pipeline
  150674. * @param renderPipelineName The name of the pipeline to detach from
  150675. * @param cameras the camera to detach
  150676. */
  150677. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150678. /**
  150679. * Enables an effect by name on a pipeline
  150680. * @param renderPipelineName the name of the pipeline to enable the effect in
  150681. * @param renderEffectName the name of the effect to enable
  150682. * @param cameras the cameras that the effect should be enabled on
  150683. */
  150684. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150685. /**
  150686. * Disables an effect by name on a pipeline
  150687. * @param renderPipelineName the name of the pipeline to disable the effect in
  150688. * @param renderEffectName the name of the effect to disable
  150689. * @param cameras the cameras that the effect should be disabled on
  150690. */
  150691. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150692. /**
  150693. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150694. */
  150695. update(): void;
  150696. /** @hidden */
  150697. _rebuild(): void;
  150698. /**
  150699. * Disposes of the manager and pipelines
  150700. */
  150701. dispose(): void;
  150702. }
  150703. }
  150704. declare module BABYLON {
  150705. interface Scene {
  150706. /** @hidden (Backing field) */
  150707. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150708. /**
  150709. * Gets the postprocess render pipeline manager
  150710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150711. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150712. */
  150713. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150714. }
  150715. /**
  150716. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150717. */
  150718. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150719. /**
  150720. * The component name helpfull to identify the component in the list of scene components.
  150721. */
  150722. readonly name: string;
  150723. /**
  150724. * The scene the component belongs to.
  150725. */
  150726. scene: Scene;
  150727. /**
  150728. * Creates a new instance of the component for the given scene
  150729. * @param scene Defines the scene to register the component in
  150730. */
  150731. constructor(scene: Scene);
  150732. /**
  150733. * Registers the component in a given scene
  150734. */
  150735. register(): void;
  150736. /**
  150737. * Rebuilds the elements related to this component in case of
  150738. * context lost for instance.
  150739. */
  150740. rebuild(): void;
  150741. /**
  150742. * Disposes the component and the associated ressources
  150743. */
  150744. dispose(): void;
  150745. private _gatherRenderTargets;
  150746. }
  150747. }
  150748. declare module BABYLON {
  150749. /**
  150750. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150751. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150752. */
  150753. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150754. private _scene;
  150755. private _camerasToBeAttached;
  150756. /**
  150757. * ID of the sharpen post process,
  150758. */
  150759. private readonly SharpenPostProcessId;
  150760. /**
  150761. * @ignore
  150762. * ID of the image processing post process;
  150763. */
  150764. readonly ImageProcessingPostProcessId: string;
  150765. /**
  150766. * @ignore
  150767. * ID of the Fast Approximate Anti-Aliasing post process;
  150768. */
  150769. readonly FxaaPostProcessId: string;
  150770. /**
  150771. * ID of the chromatic aberration post process,
  150772. */
  150773. private readonly ChromaticAberrationPostProcessId;
  150774. /**
  150775. * ID of the grain post process
  150776. */
  150777. private readonly GrainPostProcessId;
  150778. /**
  150779. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150780. */
  150781. sharpen: SharpenPostProcess;
  150782. private _sharpenEffect;
  150783. private bloom;
  150784. /**
  150785. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150786. */
  150787. depthOfField: DepthOfFieldEffect;
  150788. /**
  150789. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150790. */
  150791. fxaa: FxaaPostProcess;
  150792. /**
  150793. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150794. */
  150795. imageProcessing: ImageProcessingPostProcess;
  150796. /**
  150797. * Chromatic aberration post process which will shift rgb colors in the image
  150798. */
  150799. chromaticAberration: ChromaticAberrationPostProcess;
  150800. private _chromaticAberrationEffect;
  150801. /**
  150802. * Grain post process which add noise to the image
  150803. */
  150804. grain: GrainPostProcess;
  150805. private _grainEffect;
  150806. /**
  150807. * Glow post process which adds a glow to emissive areas of the image
  150808. */
  150809. private _glowLayer;
  150810. /**
  150811. * Animations which can be used to tweak settings over a period of time
  150812. */
  150813. animations: Animation[];
  150814. private _imageProcessingConfigurationObserver;
  150815. private _sharpenEnabled;
  150816. private _bloomEnabled;
  150817. private _depthOfFieldEnabled;
  150818. private _depthOfFieldBlurLevel;
  150819. private _fxaaEnabled;
  150820. private _imageProcessingEnabled;
  150821. private _defaultPipelineTextureType;
  150822. private _bloomScale;
  150823. private _chromaticAberrationEnabled;
  150824. private _grainEnabled;
  150825. private _buildAllowed;
  150826. /**
  150827. * Gets active scene
  150828. */
  150829. get scene(): Scene;
  150830. /**
  150831. * Enable or disable the sharpen process from the pipeline
  150832. */
  150833. set sharpenEnabled(enabled: boolean);
  150834. get sharpenEnabled(): boolean;
  150835. private _resizeObserver;
  150836. private _hardwareScaleLevel;
  150837. private _bloomKernel;
  150838. /**
  150839. * Specifies the size of the bloom blur kernel, relative to the final output size
  150840. */
  150841. get bloomKernel(): number;
  150842. set bloomKernel(value: number);
  150843. /**
  150844. * Specifies the weight of the bloom in the final rendering
  150845. */
  150846. private _bloomWeight;
  150847. /**
  150848. * Specifies the luma threshold for the area that will be blurred by the bloom
  150849. */
  150850. private _bloomThreshold;
  150851. private _hdr;
  150852. /**
  150853. * The strength of the bloom.
  150854. */
  150855. set bloomWeight(value: number);
  150856. get bloomWeight(): number;
  150857. /**
  150858. * The strength of the bloom.
  150859. */
  150860. set bloomThreshold(value: number);
  150861. get bloomThreshold(): number;
  150862. /**
  150863. * The scale of the bloom, lower value will provide better performance.
  150864. */
  150865. set bloomScale(value: number);
  150866. get bloomScale(): number;
  150867. /**
  150868. * Enable or disable the bloom from the pipeline
  150869. */
  150870. set bloomEnabled(enabled: boolean);
  150871. get bloomEnabled(): boolean;
  150872. private _rebuildBloom;
  150873. /**
  150874. * If the depth of field is enabled.
  150875. */
  150876. get depthOfFieldEnabled(): boolean;
  150877. set depthOfFieldEnabled(enabled: boolean);
  150878. /**
  150879. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150880. */
  150881. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150882. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150883. /**
  150884. * If the anti aliasing is enabled.
  150885. */
  150886. set fxaaEnabled(enabled: boolean);
  150887. get fxaaEnabled(): boolean;
  150888. private _samples;
  150889. /**
  150890. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150891. */
  150892. set samples(sampleCount: number);
  150893. get samples(): number;
  150894. /**
  150895. * If image processing is enabled.
  150896. */
  150897. set imageProcessingEnabled(enabled: boolean);
  150898. get imageProcessingEnabled(): boolean;
  150899. /**
  150900. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150901. */
  150902. set glowLayerEnabled(enabled: boolean);
  150903. get glowLayerEnabled(): boolean;
  150904. /**
  150905. * Gets the glow layer (or null if not defined)
  150906. */
  150907. get glowLayer(): Nullable<GlowLayer>;
  150908. /**
  150909. * Enable or disable the chromaticAberration process from the pipeline
  150910. */
  150911. set chromaticAberrationEnabled(enabled: boolean);
  150912. get chromaticAberrationEnabled(): boolean;
  150913. /**
  150914. * Enable or disable the grain process from the pipeline
  150915. */
  150916. set grainEnabled(enabled: boolean);
  150917. get grainEnabled(): boolean;
  150918. /**
  150919. * @constructor
  150920. * @param name - The rendering pipeline name (default: "")
  150921. * @param hdr - If high dynamic range textures should be used (default: true)
  150922. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150923. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150924. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150925. */
  150926. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150927. /**
  150928. * Get the class name
  150929. * @returns "DefaultRenderingPipeline"
  150930. */
  150931. getClassName(): string;
  150932. /**
  150933. * Force the compilation of the entire pipeline.
  150934. */
  150935. prepare(): void;
  150936. private _hasCleared;
  150937. private _prevPostProcess;
  150938. private _prevPrevPostProcess;
  150939. private _setAutoClearAndTextureSharing;
  150940. private _depthOfFieldSceneObserver;
  150941. private _buildPipeline;
  150942. private _disposePostProcesses;
  150943. /**
  150944. * Adds a camera to the pipeline
  150945. * @param camera the camera to be added
  150946. */
  150947. addCamera(camera: Camera): void;
  150948. /**
  150949. * Removes a camera from the pipeline
  150950. * @param camera the camera to remove
  150951. */
  150952. removeCamera(camera: Camera): void;
  150953. /**
  150954. * Dispose of the pipeline and stop all post processes
  150955. */
  150956. dispose(): void;
  150957. /**
  150958. * Serialize the rendering pipeline (Used when exporting)
  150959. * @returns the serialized object
  150960. */
  150961. serialize(): any;
  150962. /**
  150963. * Parse the serialized pipeline
  150964. * @param source Source pipeline.
  150965. * @param scene The scene to load the pipeline to.
  150966. * @param rootUrl The URL of the serialized pipeline.
  150967. * @returns An instantiated pipeline from the serialized object.
  150968. */
  150969. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150970. }
  150971. }
  150972. declare module BABYLON {
  150973. /** @hidden */
  150974. export var lensHighlightsPixelShader: {
  150975. name: string;
  150976. shader: string;
  150977. };
  150978. }
  150979. declare module BABYLON {
  150980. /** @hidden */
  150981. export var depthOfFieldPixelShader: {
  150982. name: string;
  150983. shader: string;
  150984. };
  150985. }
  150986. declare module BABYLON {
  150987. /**
  150988. * BABYLON.JS Chromatic Aberration GLSL Shader
  150989. * Author: Olivier Guyot
  150990. * Separates very slightly R, G and B colors on the edges of the screen
  150991. * Inspired by Francois Tarlier & Martins Upitis
  150992. */
  150993. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150994. /**
  150995. * @ignore
  150996. * The chromatic aberration PostProcess id in the pipeline
  150997. */
  150998. LensChromaticAberrationEffect: string;
  150999. /**
  151000. * @ignore
  151001. * The highlights enhancing PostProcess id in the pipeline
  151002. */
  151003. HighlightsEnhancingEffect: string;
  151004. /**
  151005. * @ignore
  151006. * The depth-of-field PostProcess id in the pipeline
  151007. */
  151008. LensDepthOfFieldEffect: string;
  151009. private _scene;
  151010. private _depthTexture;
  151011. private _grainTexture;
  151012. private _chromaticAberrationPostProcess;
  151013. private _highlightsPostProcess;
  151014. private _depthOfFieldPostProcess;
  151015. private _edgeBlur;
  151016. private _grainAmount;
  151017. private _chromaticAberration;
  151018. private _distortion;
  151019. private _highlightsGain;
  151020. private _highlightsThreshold;
  151021. private _dofDistance;
  151022. private _dofAperture;
  151023. private _dofDarken;
  151024. private _dofPentagon;
  151025. private _blurNoise;
  151026. /**
  151027. * @constructor
  151028. *
  151029. * Effect parameters are as follow:
  151030. * {
  151031. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151032. * edge_blur: number; // from 0 to x (1 for realism)
  151033. * distortion: number; // from 0 to x (1 for realism)
  151034. * grain_amount: number; // from 0 to 1
  151035. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151036. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151037. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151038. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151039. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151040. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151041. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151042. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151043. * }
  151044. * Note: if an effect parameter is unset, effect is disabled
  151045. *
  151046. * @param name The rendering pipeline name
  151047. * @param parameters - An object containing all parameters (see above)
  151048. * @param scene The scene linked to this pipeline
  151049. * @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)
  151050. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151051. */
  151052. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151053. /**
  151054. * Get the class name
  151055. * @returns "LensRenderingPipeline"
  151056. */
  151057. getClassName(): string;
  151058. /**
  151059. * Gets associated scene
  151060. */
  151061. get scene(): Scene;
  151062. /**
  151063. * Gets or sets the edge blur
  151064. */
  151065. get edgeBlur(): number;
  151066. set edgeBlur(value: number);
  151067. /**
  151068. * Gets or sets the grain amount
  151069. */
  151070. get grainAmount(): number;
  151071. set grainAmount(value: number);
  151072. /**
  151073. * Gets or sets the chromatic aberration amount
  151074. */
  151075. get chromaticAberration(): number;
  151076. set chromaticAberration(value: number);
  151077. /**
  151078. * Gets or sets the depth of field aperture
  151079. */
  151080. get dofAperture(): number;
  151081. set dofAperture(value: number);
  151082. /**
  151083. * Gets or sets the edge distortion
  151084. */
  151085. get edgeDistortion(): number;
  151086. set edgeDistortion(value: number);
  151087. /**
  151088. * Gets or sets the depth of field distortion
  151089. */
  151090. get dofDistortion(): number;
  151091. set dofDistortion(value: number);
  151092. /**
  151093. * Gets or sets the darken out of focus amount
  151094. */
  151095. get darkenOutOfFocus(): number;
  151096. set darkenOutOfFocus(value: number);
  151097. /**
  151098. * Gets or sets a boolean indicating if blur noise is enabled
  151099. */
  151100. get blurNoise(): boolean;
  151101. set blurNoise(value: boolean);
  151102. /**
  151103. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151104. */
  151105. get pentagonBokeh(): boolean;
  151106. set pentagonBokeh(value: boolean);
  151107. /**
  151108. * Gets or sets the highlight grain amount
  151109. */
  151110. get highlightsGain(): number;
  151111. set highlightsGain(value: number);
  151112. /**
  151113. * Gets or sets the highlight threshold
  151114. */
  151115. get highlightsThreshold(): number;
  151116. set highlightsThreshold(value: number);
  151117. /**
  151118. * Sets the amount of blur at the edges
  151119. * @param amount blur amount
  151120. */
  151121. setEdgeBlur(amount: number): void;
  151122. /**
  151123. * Sets edge blur to 0
  151124. */
  151125. disableEdgeBlur(): void;
  151126. /**
  151127. * Sets the amout of grain
  151128. * @param amount Amount of grain
  151129. */
  151130. setGrainAmount(amount: number): void;
  151131. /**
  151132. * Set grain amount to 0
  151133. */
  151134. disableGrain(): void;
  151135. /**
  151136. * Sets the chromatic aberration amount
  151137. * @param amount amount of chromatic aberration
  151138. */
  151139. setChromaticAberration(amount: number): void;
  151140. /**
  151141. * Sets chromatic aberration amount to 0
  151142. */
  151143. disableChromaticAberration(): void;
  151144. /**
  151145. * Sets the EdgeDistortion amount
  151146. * @param amount amount of EdgeDistortion
  151147. */
  151148. setEdgeDistortion(amount: number): void;
  151149. /**
  151150. * Sets edge distortion to 0
  151151. */
  151152. disableEdgeDistortion(): void;
  151153. /**
  151154. * Sets the FocusDistance amount
  151155. * @param amount amount of FocusDistance
  151156. */
  151157. setFocusDistance(amount: number): void;
  151158. /**
  151159. * Disables depth of field
  151160. */
  151161. disableDepthOfField(): void;
  151162. /**
  151163. * Sets the Aperture amount
  151164. * @param amount amount of Aperture
  151165. */
  151166. setAperture(amount: number): void;
  151167. /**
  151168. * Sets the DarkenOutOfFocus amount
  151169. * @param amount amount of DarkenOutOfFocus
  151170. */
  151171. setDarkenOutOfFocus(amount: number): void;
  151172. private _pentagonBokehIsEnabled;
  151173. /**
  151174. * Creates a pentagon bokeh effect
  151175. */
  151176. enablePentagonBokeh(): void;
  151177. /**
  151178. * Disables the pentagon bokeh effect
  151179. */
  151180. disablePentagonBokeh(): void;
  151181. /**
  151182. * Enables noise blur
  151183. */
  151184. enableNoiseBlur(): void;
  151185. /**
  151186. * Disables noise blur
  151187. */
  151188. disableNoiseBlur(): void;
  151189. /**
  151190. * Sets the HighlightsGain amount
  151191. * @param amount amount of HighlightsGain
  151192. */
  151193. setHighlightsGain(amount: number): void;
  151194. /**
  151195. * Sets the HighlightsThreshold amount
  151196. * @param amount amount of HighlightsThreshold
  151197. */
  151198. setHighlightsThreshold(amount: number): void;
  151199. /**
  151200. * Disables highlights
  151201. */
  151202. disableHighlights(): void;
  151203. /**
  151204. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151205. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151206. */
  151207. dispose(disableDepthRender?: boolean): void;
  151208. private _createChromaticAberrationPostProcess;
  151209. private _createHighlightsPostProcess;
  151210. private _createDepthOfFieldPostProcess;
  151211. private _createGrainTexture;
  151212. }
  151213. }
  151214. declare module BABYLON {
  151215. /**
  151216. * Contains all parameters needed for the prepass to perform
  151217. * screen space subsurface scattering
  151218. */
  151219. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151220. /**
  151221. * Is subsurface enabled
  151222. */
  151223. enabled: boolean;
  151224. /**
  151225. * Name of the configuration
  151226. */
  151227. name: string;
  151228. /**
  151229. * Textures that should be present in the MRT for this effect to work
  151230. */
  151231. readonly texturesRequired: number[];
  151232. /**
  151233. * Builds a ssao2 configuration object
  151234. * @param scene The scene
  151235. */
  151236. constructor();
  151237. /**
  151238. * Disposes the configuration
  151239. */
  151240. dispose(): void;
  151241. }
  151242. }
  151243. declare module BABYLON {
  151244. /** @hidden */
  151245. export var ssao2PixelShader: {
  151246. name: string;
  151247. shader: string;
  151248. };
  151249. }
  151250. declare module BABYLON {
  151251. /** @hidden */
  151252. export var ssaoCombinePixelShader: {
  151253. name: string;
  151254. shader: string;
  151255. };
  151256. }
  151257. declare module BABYLON {
  151258. /**
  151259. * Render pipeline to produce ssao effect
  151260. */
  151261. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151262. /**
  151263. * @ignore
  151264. * The PassPostProcess id in the pipeline that contains the original scene color
  151265. */
  151266. SSAOOriginalSceneColorEffect: string;
  151267. /**
  151268. * @ignore
  151269. * The SSAO PostProcess id in the pipeline
  151270. */
  151271. SSAORenderEffect: string;
  151272. /**
  151273. * @ignore
  151274. * The horizontal blur PostProcess id in the pipeline
  151275. */
  151276. SSAOBlurHRenderEffect: string;
  151277. /**
  151278. * @ignore
  151279. * The vertical blur PostProcess id in the pipeline
  151280. */
  151281. SSAOBlurVRenderEffect: string;
  151282. /**
  151283. * @ignore
  151284. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151285. */
  151286. SSAOCombineRenderEffect: string;
  151287. /**
  151288. * The output strength of the SSAO post-process. Default value is 1.0.
  151289. */
  151290. totalStrength: number;
  151291. /**
  151292. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151293. */
  151294. maxZ: number;
  151295. /**
  151296. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151297. */
  151298. minZAspect: number;
  151299. private _samples;
  151300. /**
  151301. * Number of samples used for the SSAO calculations. Default value is 8
  151302. */
  151303. set samples(n: number);
  151304. get samples(): number;
  151305. private _textureSamples;
  151306. /**
  151307. * Number of samples to use for antialiasing
  151308. */
  151309. set textureSamples(n: number);
  151310. get textureSamples(): number;
  151311. /**
  151312. * Force rendering the geometry through geometry buffer
  151313. */
  151314. private _forceGeometryBuffer;
  151315. /**
  151316. * Ratio object used for SSAO ratio and blur ratio
  151317. */
  151318. private _ratio;
  151319. /**
  151320. * Dynamically generated sphere sampler.
  151321. */
  151322. private _sampleSphere;
  151323. private _ssao2PrePassConfiguration;
  151324. /**
  151325. * Blur filter offsets
  151326. */
  151327. private _samplerOffsets;
  151328. private _expensiveBlur;
  151329. /**
  151330. * If bilateral blur should be used
  151331. */
  151332. set expensiveBlur(b: boolean);
  151333. get expensiveBlur(): boolean;
  151334. /**
  151335. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151336. */
  151337. radius: number;
  151338. /**
  151339. * The base color of the SSAO post-process
  151340. * The final result is "base + ssao" between [0, 1]
  151341. */
  151342. base: number;
  151343. /**
  151344. * Support test.
  151345. */
  151346. static get IsSupported(): boolean;
  151347. private _scene;
  151348. private _randomTexture;
  151349. private _originalColorPostProcess;
  151350. private _ssaoPostProcess;
  151351. private _blurHPostProcess;
  151352. private _blurVPostProcess;
  151353. private _ssaoCombinePostProcess;
  151354. private _prePassRenderer;
  151355. /**
  151356. * Gets active scene
  151357. */
  151358. get scene(): Scene;
  151359. /**
  151360. * @constructor
  151361. * @param name The rendering pipeline name
  151362. * @param scene The scene linked to this pipeline
  151363. * @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 }
  151364. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151365. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151366. */
  151367. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151368. /**
  151369. * Get the class name
  151370. * @returns "SSAO2RenderingPipeline"
  151371. */
  151372. getClassName(): string;
  151373. /**
  151374. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151375. */
  151376. dispose(disableGeometryBufferRenderer?: boolean): void;
  151377. private _createBlurPostProcess;
  151378. /** @hidden */
  151379. _rebuild(): void;
  151380. private _bits;
  151381. private _radicalInverse_VdC;
  151382. private _hammersley;
  151383. private _hemisphereSample_uniform;
  151384. private _generateHemisphere;
  151385. private _getDefinesForSSAO;
  151386. private _createSSAOPostProcess;
  151387. private _createSSAOCombinePostProcess;
  151388. private _createRandomTexture;
  151389. /**
  151390. * Serialize the rendering pipeline (Used when exporting)
  151391. * @returns the serialized object
  151392. */
  151393. serialize(): any;
  151394. /**
  151395. * Parse the serialized pipeline
  151396. * @param source Source pipeline.
  151397. * @param scene The scene to load the pipeline to.
  151398. * @param rootUrl The URL of the serialized pipeline.
  151399. * @returns An instantiated pipeline from the serialized object.
  151400. */
  151401. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151402. /**
  151403. * Sets the required values to the prepass renderer.
  151404. * @param prePassRenderer defines the prepass renderer to setup
  151405. * @returns true if the pre pass is needed.
  151406. */
  151407. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151408. }
  151409. }
  151410. declare module BABYLON {
  151411. /** @hidden */
  151412. export var ssaoPixelShader: {
  151413. name: string;
  151414. shader: string;
  151415. };
  151416. }
  151417. declare module BABYLON {
  151418. /**
  151419. * Render pipeline to produce ssao effect
  151420. */
  151421. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151422. /**
  151423. * @ignore
  151424. * The PassPostProcess id in the pipeline that contains the original scene color
  151425. */
  151426. SSAOOriginalSceneColorEffect: string;
  151427. /**
  151428. * @ignore
  151429. * The SSAO PostProcess id in the pipeline
  151430. */
  151431. SSAORenderEffect: string;
  151432. /**
  151433. * @ignore
  151434. * The horizontal blur PostProcess id in the pipeline
  151435. */
  151436. SSAOBlurHRenderEffect: string;
  151437. /**
  151438. * @ignore
  151439. * The vertical blur PostProcess id in the pipeline
  151440. */
  151441. SSAOBlurVRenderEffect: string;
  151442. /**
  151443. * @ignore
  151444. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151445. */
  151446. SSAOCombineRenderEffect: string;
  151447. /**
  151448. * The output strength of the SSAO post-process. Default value is 1.0.
  151449. */
  151450. totalStrength: number;
  151451. /**
  151452. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151453. */
  151454. radius: number;
  151455. /**
  151456. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151457. * Must not be equal to fallOff and superior to fallOff.
  151458. * Default value is 0.0075
  151459. */
  151460. area: number;
  151461. /**
  151462. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151463. * Must not be equal to area and inferior to area.
  151464. * Default value is 0.000001
  151465. */
  151466. fallOff: number;
  151467. /**
  151468. * The base color of the SSAO post-process
  151469. * The final result is "base + ssao" between [0, 1]
  151470. */
  151471. base: number;
  151472. private _scene;
  151473. private _depthTexture;
  151474. private _randomTexture;
  151475. private _originalColorPostProcess;
  151476. private _ssaoPostProcess;
  151477. private _blurHPostProcess;
  151478. private _blurVPostProcess;
  151479. private _ssaoCombinePostProcess;
  151480. private _firstUpdate;
  151481. /**
  151482. * Gets active scene
  151483. */
  151484. get scene(): Scene;
  151485. /**
  151486. * @constructor
  151487. * @param name - The rendering pipeline name
  151488. * @param scene - The scene linked to this pipeline
  151489. * @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 }
  151490. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151491. */
  151492. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151493. /**
  151494. * Get the class name
  151495. * @returns "SSAORenderingPipeline"
  151496. */
  151497. getClassName(): string;
  151498. /**
  151499. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151500. */
  151501. dispose(disableDepthRender?: boolean): void;
  151502. private _createBlurPostProcess;
  151503. /** @hidden */
  151504. _rebuild(): void;
  151505. private _createSSAOPostProcess;
  151506. private _createSSAOCombinePostProcess;
  151507. private _createRandomTexture;
  151508. }
  151509. }
  151510. declare module BABYLON {
  151511. /** @hidden */
  151512. export var screenSpaceReflectionPixelShader: {
  151513. name: string;
  151514. shader: string;
  151515. };
  151516. }
  151517. declare module BABYLON {
  151518. /**
  151519. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151520. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151521. */
  151522. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151523. /**
  151524. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151525. */
  151526. threshold: number;
  151527. /**
  151528. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151529. */
  151530. strength: number;
  151531. /**
  151532. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151533. */
  151534. reflectionSpecularFalloffExponent: number;
  151535. /**
  151536. * 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]
  151537. */
  151538. step: number;
  151539. /**
  151540. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151541. */
  151542. roughnessFactor: number;
  151543. private _geometryBufferRenderer;
  151544. private _enableSmoothReflections;
  151545. private _reflectionSamples;
  151546. private _smoothSteps;
  151547. /**
  151548. * Gets a string identifying the name of the class
  151549. * @returns "ScreenSpaceReflectionPostProcess" string
  151550. */
  151551. getClassName(): string;
  151552. /**
  151553. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151554. * @param name The name of the effect.
  151555. * @param scene The scene containing the objects to calculate reflections.
  151556. * @param options The required width/height ratio to downsize to before computing the render pass.
  151557. * @param camera The camera to apply the render pass to.
  151558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151559. * @param engine The engine which the post process will be applied. (default: current engine)
  151560. * @param reusable If the post process can be reused on the same frame. (default: false)
  151561. * @param textureType Type of textures used when performing the post process. (default: 0)
  151562. * @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)
  151563. */
  151564. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151565. /**
  151566. * Gets wether or not smoothing reflections is enabled.
  151567. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151568. */
  151569. get enableSmoothReflections(): boolean;
  151570. /**
  151571. * Sets wether or not smoothing reflections is enabled.
  151572. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151573. */
  151574. set enableSmoothReflections(enabled: boolean);
  151575. /**
  151576. * Gets the number of samples taken while computing reflections. More samples count is high,
  151577. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151578. */
  151579. get reflectionSamples(): number;
  151580. /**
  151581. * Sets the number of samples taken while computing reflections. More samples count is high,
  151582. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151583. */
  151584. set reflectionSamples(samples: number);
  151585. /**
  151586. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151587. * more the post-process will require GPU power and can generate a drop in FPS.
  151588. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151589. */
  151590. get smoothSteps(): number;
  151591. set smoothSteps(steps: number);
  151592. private _updateEffectDefines;
  151593. /** @hidden */
  151594. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151595. }
  151596. }
  151597. declare module BABYLON {
  151598. /** @hidden */
  151599. export var standardPixelShader: {
  151600. name: string;
  151601. shader: string;
  151602. };
  151603. }
  151604. declare module BABYLON {
  151605. /**
  151606. * Standard rendering pipeline
  151607. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151608. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151609. */
  151610. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151611. /**
  151612. * Public members
  151613. */
  151614. /**
  151615. * Post-process which contains the original scene color before the pipeline applies all the effects
  151616. */
  151617. originalPostProcess: Nullable<PostProcess>;
  151618. /**
  151619. * Post-process used to down scale an image x4
  151620. */
  151621. downSampleX4PostProcess: Nullable<PostProcess>;
  151622. /**
  151623. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151624. */
  151625. brightPassPostProcess: Nullable<PostProcess>;
  151626. /**
  151627. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151628. */
  151629. blurHPostProcesses: PostProcess[];
  151630. /**
  151631. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151632. */
  151633. blurVPostProcesses: PostProcess[];
  151634. /**
  151635. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151636. */
  151637. textureAdderPostProcess: Nullable<PostProcess>;
  151638. /**
  151639. * Post-process used to create volumetric lighting effect
  151640. */
  151641. volumetricLightPostProcess: Nullable<PostProcess>;
  151642. /**
  151643. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151644. */
  151645. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151646. /**
  151647. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151648. */
  151649. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151650. /**
  151651. * Post-process used to merge the volumetric light effect and the real scene color
  151652. */
  151653. volumetricLightMergePostProces: Nullable<PostProcess>;
  151654. /**
  151655. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151656. */
  151657. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151658. /**
  151659. * Base post-process used to calculate the average luminance of the final image for HDR
  151660. */
  151661. luminancePostProcess: Nullable<PostProcess>;
  151662. /**
  151663. * Post-processes used to create down sample post-processes in order to get
  151664. * the average luminance of the final image for HDR
  151665. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151666. */
  151667. luminanceDownSamplePostProcesses: PostProcess[];
  151668. /**
  151669. * Post-process used to create a HDR effect (light adaptation)
  151670. */
  151671. hdrPostProcess: Nullable<PostProcess>;
  151672. /**
  151673. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151674. */
  151675. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151676. /**
  151677. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151678. */
  151679. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151680. /**
  151681. * Post-process used to merge the final HDR post-process and the real scene color
  151682. */
  151683. hdrFinalPostProcess: Nullable<PostProcess>;
  151684. /**
  151685. * Post-process used to create a lens flare effect
  151686. */
  151687. lensFlarePostProcess: Nullable<PostProcess>;
  151688. /**
  151689. * Post-process that merges the result of the lens flare post-process and the real scene color
  151690. */
  151691. lensFlareComposePostProcess: Nullable<PostProcess>;
  151692. /**
  151693. * Post-process used to create a motion blur effect
  151694. */
  151695. motionBlurPostProcess: Nullable<PostProcess>;
  151696. /**
  151697. * Post-process used to create a depth of field effect
  151698. */
  151699. depthOfFieldPostProcess: Nullable<PostProcess>;
  151700. /**
  151701. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151702. */
  151703. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151704. /**
  151705. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151706. */
  151707. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151708. /**
  151709. * Represents the brightness threshold in order to configure the illuminated surfaces
  151710. */
  151711. brightThreshold: number;
  151712. /**
  151713. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151714. */
  151715. blurWidth: number;
  151716. /**
  151717. * Sets if the blur for highlighted surfaces must be only horizontal
  151718. */
  151719. horizontalBlur: boolean;
  151720. /**
  151721. * Gets the overall exposure used by the pipeline
  151722. */
  151723. get exposure(): number;
  151724. /**
  151725. * Sets the overall exposure used by the pipeline
  151726. */
  151727. set exposure(value: number);
  151728. /**
  151729. * Texture used typically to simulate "dirty" on camera lens
  151730. */
  151731. lensTexture: Nullable<Texture>;
  151732. /**
  151733. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151734. */
  151735. volumetricLightCoefficient: number;
  151736. /**
  151737. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151738. */
  151739. volumetricLightPower: number;
  151740. /**
  151741. * Used the set the blur intensity to smooth the volumetric lights
  151742. */
  151743. volumetricLightBlurScale: number;
  151744. /**
  151745. * Light (spot or directional) used to generate the volumetric lights rays
  151746. * The source light must have a shadow generate so the pipeline can get its
  151747. * depth map
  151748. */
  151749. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151750. /**
  151751. * For eye adaptation, represents the minimum luminance the eye can see
  151752. */
  151753. hdrMinimumLuminance: number;
  151754. /**
  151755. * For eye adaptation, represents the decrease luminance speed
  151756. */
  151757. hdrDecreaseRate: number;
  151758. /**
  151759. * For eye adaptation, represents the increase luminance speed
  151760. */
  151761. hdrIncreaseRate: number;
  151762. /**
  151763. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151764. */
  151765. get hdrAutoExposure(): boolean;
  151766. /**
  151767. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151768. */
  151769. set hdrAutoExposure(value: boolean);
  151770. /**
  151771. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151772. */
  151773. lensColorTexture: Nullable<Texture>;
  151774. /**
  151775. * The overall strengh for the lens flare effect
  151776. */
  151777. lensFlareStrength: number;
  151778. /**
  151779. * Dispersion coefficient for lens flare ghosts
  151780. */
  151781. lensFlareGhostDispersal: number;
  151782. /**
  151783. * Main lens flare halo width
  151784. */
  151785. lensFlareHaloWidth: number;
  151786. /**
  151787. * Based on the lens distortion effect, defines how much the lens flare result
  151788. * is distorted
  151789. */
  151790. lensFlareDistortionStrength: number;
  151791. /**
  151792. * Configures the blur intensity used for for lens flare (halo)
  151793. */
  151794. lensFlareBlurWidth: number;
  151795. /**
  151796. * Lens star texture must be used to simulate rays on the flares and is available
  151797. * in the documentation
  151798. */
  151799. lensStarTexture: Nullable<Texture>;
  151800. /**
  151801. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151802. * flare effect by taking account of the dirt texture
  151803. */
  151804. lensFlareDirtTexture: Nullable<Texture>;
  151805. /**
  151806. * Represents the focal length for the depth of field effect
  151807. */
  151808. depthOfFieldDistance: number;
  151809. /**
  151810. * Represents the blur intensity for the blurred part of the depth of field effect
  151811. */
  151812. depthOfFieldBlurWidth: number;
  151813. /**
  151814. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151815. */
  151816. get motionStrength(): number;
  151817. /**
  151818. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151819. */
  151820. set motionStrength(strength: number);
  151821. /**
  151822. * Gets wether or not the motion blur post-process is object based or screen based.
  151823. */
  151824. get objectBasedMotionBlur(): boolean;
  151825. /**
  151826. * Sets wether or not the motion blur post-process should be object based or screen based
  151827. */
  151828. set objectBasedMotionBlur(value: boolean);
  151829. /**
  151830. * List of animations for the pipeline (IAnimatable implementation)
  151831. */
  151832. animations: Animation[];
  151833. /**
  151834. * Private members
  151835. */
  151836. private _scene;
  151837. private _currentDepthOfFieldSource;
  151838. private _basePostProcess;
  151839. private _fixedExposure;
  151840. private _currentExposure;
  151841. private _hdrAutoExposure;
  151842. private _hdrCurrentLuminance;
  151843. private _motionStrength;
  151844. private _isObjectBasedMotionBlur;
  151845. private _floatTextureType;
  151846. private _camerasToBeAttached;
  151847. private _ratio;
  151848. private _bloomEnabled;
  151849. private _depthOfFieldEnabled;
  151850. private _vlsEnabled;
  151851. private _lensFlareEnabled;
  151852. private _hdrEnabled;
  151853. private _motionBlurEnabled;
  151854. private _fxaaEnabled;
  151855. private _screenSpaceReflectionsEnabled;
  151856. private _motionBlurSamples;
  151857. private _volumetricLightStepsCount;
  151858. private _samples;
  151859. /**
  151860. * @ignore
  151861. * Specifies if the bloom pipeline is enabled
  151862. */
  151863. get BloomEnabled(): boolean;
  151864. set BloomEnabled(enabled: boolean);
  151865. /**
  151866. * @ignore
  151867. * Specifies if the depth of field pipeline is enabed
  151868. */
  151869. get DepthOfFieldEnabled(): boolean;
  151870. set DepthOfFieldEnabled(enabled: boolean);
  151871. /**
  151872. * @ignore
  151873. * Specifies if the lens flare pipeline is enabed
  151874. */
  151875. get LensFlareEnabled(): boolean;
  151876. set LensFlareEnabled(enabled: boolean);
  151877. /**
  151878. * @ignore
  151879. * Specifies if the HDR pipeline is enabled
  151880. */
  151881. get HDREnabled(): boolean;
  151882. set HDREnabled(enabled: boolean);
  151883. /**
  151884. * @ignore
  151885. * Specifies if the volumetric lights scattering effect is enabled
  151886. */
  151887. get VLSEnabled(): boolean;
  151888. set VLSEnabled(enabled: boolean);
  151889. /**
  151890. * @ignore
  151891. * Specifies if the motion blur effect is enabled
  151892. */
  151893. get MotionBlurEnabled(): boolean;
  151894. set MotionBlurEnabled(enabled: boolean);
  151895. /**
  151896. * Specifies if anti-aliasing is enabled
  151897. */
  151898. get fxaaEnabled(): boolean;
  151899. set fxaaEnabled(enabled: boolean);
  151900. /**
  151901. * Specifies if screen space reflections are enabled.
  151902. */
  151903. get screenSpaceReflectionsEnabled(): boolean;
  151904. set screenSpaceReflectionsEnabled(enabled: boolean);
  151905. /**
  151906. * Specifies the number of steps used to calculate the volumetric lights
  151907. * Typically in interval [50, 200]
  151908. */
  151909. get volumetricLightStepsCount(): number;
  151910. set volumetricLightStepsCount(count: number);
  151911. /**
  151912. * Specifies the number of samples used for the motion blur effect
  151913. * Typically in interval [16, 64]
  151914. */
  151915. get motionBlurSamples(): number;
  151916. set motionBlurSamples(samples: number);
  151917. /**
  151918. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151919. */
  151920. get samples(): number;
  151921. set samples(sampleCount: number);
  151922. /**
  151923. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151924. * @constructor
  151925. * @param name The rendering pipeline name
  151926. * @param scene The scene linked to this pipeline
  151927. * @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)
  151928. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151929. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151930. */
  151931. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151932. private _buildPipeline;
  151933. private _createDownSampleX4PostProcess;
  151934. private _createBrightPassPostProcess;
  151935. private _createBlurPostProcesses;
  151936. private _createTextureAdderPostProcess;
  151937. private _createVolumetricLightPostProcess;
  151938. private _createLuminancePostProcesses;
  151939. private _createHdrPostProcess;
  151940. private _createLensFlarePostProcess;
  151941. private _createDepthOfFieldPostProcess;
  151942. private _createMotionBlurPostProcess;
  151943. private _getDepthTexture;
  151944. private _disposePostProcesses;
  151945. /**
  151946. * Dispose of the pipeline and stop all post processes
  151947. */
  151948. dispose(): void;
  151949. /**
  151950. * Serialize the rendering pipeline (Used when exporting)
  151951. * @returns the serialized object
  151952. */
  151953. serialize(): any;
  151954. /**
  151955. * Parse the serialized pipeline
  151956. * @param source Source pipeline.
  151957. * @param scene The scene to load the pipeline to.
  151958. * @param rootUrl The URL of the serialized pipeline.
  151959. * @returns An instantiated pipeline from the serialized object.
  151960. */
  151961. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151962. /**
  151963. * Luminance steps
  151964. */
  151965. static LuminanceSteps: number;
  151966. }
  151967. }
  151968. declare module BABYLON {
  151969. /** @hidden */
  151970. export var stereoscopicInterlacePixelShader: {
  151971. name: string;
  151972. shader: string;
  151973. };
  151974. }
  151975. declare module BABYLON {
  151976. /**
  151977. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151978. */
  151979. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151980. private _stepSize;
  151981. private _passedProcess;
  151982. /**
  151983. * Gets a string identifying the name of the class
  151984. * @returns "StereoscopicInterlacePostProcessI" string
  151985. */
  151986. getClassName(): string;
  151987. /**
  151988. * Initializes a StereoscopicInterlacePostProcessI
  151989. * @param name The name of the effect.
  151990. * @param rigCameras The rig cameras to be appled to the post process
  151991. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151992. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151994. * @param engine The engine which the post process will be applied. (default: current engine)
  151995. * @param reusable If the post process can be reused on the same frame. (default: false)
  151996. */
  151997. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151998. }
  151999. /**
  152000. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152001. */
  152002. export class StereoscopicInterlacePostProcess extends PostProcess {
  152003. private _stepSize;
  152004. private _passedProcess;
  152005. /**
  152006. * Gets a string identifying the name of the class
  152007. * @returns "StereoscopicInterlacePostProcess" string
  152008. */
  152009. getClassName(): string;
  152010. /**
  152011. * Initializes a StereoscopicInterlacePostProcess
  152012. * @param name The name of the effect.
  152013. * @param rigCameras The rig cameras to be appled to the post process
  152014. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152016. * @param engine The engine which the post process will be applied. (default: current engine)
  152017. * @param reusable If the post process can be reused on the same frame. (default: false)
  152018. */
  152019. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152020. }
  152021. }
  152022. declare module BABYLON {
  152023. /** @hidden */
  152024. export var tonemapPixelShader: {
  152025. name: string;
  152026. shader: string;
  152027. };
  152028. }
  152029. declare module BABYLON {
  152030. /** Defines operator used for tonemapping */
  152031. export enum TonemappingOperator {
  152032. /** Hable */
  152033. Hable = 0,
  152034. /** Reinhard */
  152035. Reinhard = 1,
  152036. /** HejiDawson */
  152037. HejiDawson = 2,
  152038. /** Photographic */
  152039. Photographic = 3
  152040. }
  152041. /**
  152042. * Defines a post process to apply tone mapping
  152043. */
  152044. export class TonemapPostProcess extends PostProcess {
  152045. private _operator;
  152046. /** Defines the required exposure adjustement */
  152047. exposureAdjustment: number;
  152048. /**
  152049. * Gets a string identifying the name of the class
  152050. * @returns "TonemapPostProcess" string
  152051. */
  152052. getClassName(): string;
  152053. /**
  152054. * Creates a new TonemapPostProcess
  152055. * @param name defines the name of the postprocess
  152056. * @param _operator defines the operator to use
  152057. * @param exposureAdjustment defines the required exposure adjustement
  152058. * @param camera defines the camera to use (can be null)
  152059. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152060. * @param engine defines the hosting engine (can be ignore if camera is set)
  152061. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152062. */
  152063. constructor(name: string, _operator: TonemappingOperator,
  152064. /** Defines the required exposure adjustement */
  152065. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152066. }
  152067. }
  152068. declare module BABYLON {
  152069. /** @hidden */
  152070. export var volumetricLightScatteringPixelShader: {
  152071. name: string;
  152072. shader: string;
  152073. };
  152074. }
  152075. declare module BABYLON {
  152076. /** @hidden */
  152077. export var volumetricLightScatteringPassVertexShader: {
  152078. name: string;
  152079. shader: string;
  152080. };
  152081. }
  152082. declare module BABYLON {
  152083. /** @hidden */
  152084. export var volumetricLightScatteringPassPixelShader: {
  152085. name: string;
  152086. shader: string;
  152087. };
  152088. }
  152089. declare module BABYLON {
  152090. /**
  152091. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152092. */
  152093. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152094. private _volumetricLightScatteringPass;
  152095. private _volumetricLightScatteringRTT;
  152096. private _viewPort;
  152097. private _screenCoordinates;
  152098. private _cachedDefines;
  152099. /**
  152100. * If not undefined, the mesh position is computed from the attached node position
  152101. */
  152102. attachedNode: {
  152103. position: Vector3;
  152104. };
  152105. /**
  152106. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152107. */
  152108. customMeshPosition: Vector3;
  152109. /**
  152110. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152111. */
  152112. useCustomMeshPosition: boolean;
  152113. /**
  152114. * If the post-process should inverse the light scattering direction
  152115. */
  152116. invert: boolean;
  152117. /**
  152118. * The internal mesh used by the post-process
  152119. */
  152120. mesh: Mesh;
  152121. /**
  152122. * @hidden
  152123. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152124. */
  152125. get useDiffuseColor(): boolean;
  152126. set useDiffuseColor(useDiffuseColor: boolean);
  152127. /**
  152128. * Array containing the excluded meshes not rendered in the internal pass
  152129. */
  152130. excludedMeshes: AbstractMesh[];
  152131. /**
  152132. * Controls the overall intensity of the post-process
  152133. */
  152134. exposure: number;
  152135. /**
  152136. * Dissipates each sample's contribution in range [0, 1]
  152137. */
  152138. decay: number;
  152139. /**
  152140. * Controls the overall intensity of each sample
  152141. */
  152142. weight: number;
  152143. /**
  152144. * Controls the density of each sample
  152145. */
  152146. density: number;
  152147. /**
  152148. * @constructor
  152149. * @param name The post-process name
  152150. * @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)
  152151. * @param camera The camera that the post-process will be attached to
  152152. * @param mesh The mesh used to create the light scattering
  152153. * @param samples The post-process quality, default 100
  152154. * @param samplingModeThe post-process filtering mode
  152155. * @param engine The babylon engine
  152156. * @param reusable If the post-process is reusable
  152157. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152158. */
  152159. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152160. /**
  152161. * Returns the string "VolumetricLightScatteringPostProcess"
  152162. * @returns "VolumetricLightScatteringPostProcess"
  152163. */
  152164. getClassName(): string;
  152165. private _isReady;
  152166. /**
  152167. * Sets the new light position for light scattering effect
  152168. * @param position The new custom light position
  152169. */
  152170. setCustomMeshPosition(position: Vector3): void;
  152171. /**
  152172. * Returns the light position for light scattering effect
  152173. * @return Vector3 The custom light position
  152174. */
  152175. getCustomMeshPosition(): Vector3;
  152176. /**
  152177. * Disposes the internal assets and detaches the post-process from the camera
  152178. */
  152179. dispose(camera: Camera): void;
  152180. /**
  152181. * Returns the render target texture used by the post-process
  152182. * @return the render target texture used by the post-process
  152183. */
  152184. getPass(): RenderTargetTexture;
  152185. private _meshExcluded;
  152186. private _createPass;
  152187. private _updateMeshScreenCoordinates;
  152188. /**
  152189. * Creates a default mesh for the Volumeric Light Scattering post-process
  152190. * @param name The mesh name
  152191. * @param scene The scene where to create the mesh
  152192. * @return the default mesh
  152193. */
  152194. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152195. }
  152196. }
  152197. declare module BABYLON {
  152198. /** @hidden */
  152199. export var screenSpaceCurvaturePixelShader: {
  152200. name: string;
  152201. shader: string;
  152202. };
  152203. }
  152204. declare module BABYLON {
  152205. /**
  152206. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152207. */
  152208. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152209. /**
  152210. * Defines how much ridge the curvature effect displays.
  152211. */
  152212. ridge: number;
  152213. /**
  152214. * Defines how much valley the curvature effect displays.
  152215. */
  152216. valley: number;
  152217. private _geometryBufferRenderer;
  152218. /**
  152219. * Gets a string identifying the name of the class
  152220. * @returns "ScreenSpaceCurvaturePostProcess" string
  152221. */
  152222. getClassName(): string;
  152223. /**
  152224. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152225. * @param name The name of the effect.
  152226. * @param scene The scene containing the objects to blur according to their velocity.
  152227. * @param options The required width/height ratio to downsize to before computing the render pass.
  152228. * @param camera The camera to apply the render pass to.
  152229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152230. * @param engine The engine which the post process will be applied. (default: current engine)
  152231. * @param reusable If the post process can be reused on the same frame. (default: false)
  152232. * @param textureType Type of textures used when performing the post process. (default: 0)
  152233. * @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)
  152234. */
  152235. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152236. /**
  152237. * Support test.
  152238. */
  152239. static get IsSupported(): boolean;
  152240. /** @hidden */
  152241. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152242. }
  152243. }
  152244. declare module BABYLON {
  152245. interface Scene {
  152246. /** @hidden (Backing field) */
  152247. _boundingBoxRenderer: BoundingBoxRenderer;
  152248. /** @hidden (Backing field) */
  152249. _forceShowBoundingBoxes: boolean;
  152250. /**
  152251. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152252. */
  152253. forceShowBoundingBoxes: boolean;
  152254. /**
  152255. * Gets the bounding box renderer associated with the scene
  152256. * @returns a BoundingBoxRenderer
  152257. */
  152258. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152259. }
  152260. interface AbstractMesh {
  152261. /** @hidden (Backing field) */
  152262. _showBoundingBox: boolean;
  152263. /**
  152264. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152265. */
  152266. showBoundingBox: boolean;
  152267. }
  152268. /**
  152269. * Component responsible of rendering the bounding box of the meshes in a scene.
  152270. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152271. */
  152272. export class BoundingBoxRenderer implements ISceneComponent {
  152273. /**
  152274. * The component name helpfull to identify the component in the list of scene components.
  152275. */
  152276. readonly name: string;
  152277. /**
  152278. * The scene the component belongs to.
  152279. */
  152280. scene: Scene;
  152281. /**
  152282. * Color of the bounding box lines placed in front of an object
  152283. */
  152284. frontColor: Color3;
  152285. /**
  152286. * Color of the bounding box lines placed behind an object
  152287. */
  152288. backColor: Color3;
  152289. /**
  152290. * Defines if the renderer should show the back lines or not
  152291. */
  152292. showBackLines: boolean;
  152293. /**
  152294. * Observable raised before rendering a bounding box
  152295. */
  152296. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152297. /**
  152298. * Observable raised after rendering a bounding box
  152299. */
  152300. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152301. /**
  152302. * @hidden
  152303. */
  152304. renderList: SmartArray<BoundingBox>;
  152305. private _colorShader;
  152306. private _vertexBuffers;
  152307. private _indexBuffer;
  152308. private _fillIndexBuffer;
  152309. private _fillIndexData;
  152310. /**
  152311. * Instantiates a new bounding box renderer in a scene.
  152312. * @param scene the scene the renderer renders in
  152313. */
  152314. constructor(scene: Scene);
  152315. /**
  152316. * Registers the component in a given scene
  152317. */
  152318. register(): void;
  152319. private _evaluateSubMesh;
  152320. private _activeMesh;
  152321. private _prepareRessources;
  152322. private _createIndexBuffer;
  152323. /**
  152324. * Rebuilds the elements related to this component in case of
  152325. * context lost for instance.
  152326. */
  152327. rebuild(): void;
  152328. /**
  152329. * @hidden
  152330. */
  152331. reset(): void;
  152332. /**
  152333. * Render the bounding boxes of a specific rendering group
  152334. * @param renderingGroupId defines the rendering group to render
  152335. */
  152336. render(renderingGroupId: number): void;
  152337. /**
  152338. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152339. * @param mesh Define the mesh to render the occlusion bounding box for
  152340. */
  152341. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152342. /**
  152343. * Dispose and release the resources attached to this renderer.
  152344. */
  152345. dispose(): void;
  152346. }
  152347. }
  152348. declare module BABYLON {
  152349. interface Scene {
  152350. /** @hidden (Backing field) */
  152351. _depthRenderer: {
  152352. [id: string]: DepthRenderer;
  152353. };
  152354. /**
  152355. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152356. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152357. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152358. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152359. * @returns the created depth renderer
  152360. */
  152361. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152362. /**
  152363. * Disables a depth renderer for a given camera
  152364. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152365. */
  152366. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152367. }
  152368. /**
  152369. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152370. * in several rendering techniques.
  152371. */
  152372. export class DepthRendererSceneComponent implements ISceneComponent {
  152373. /**
  152374. * The component name helpfull to identify the component in the list of scene components.
  152375. */
  152376. readonly name: string;
  152377. /**
  152378. * The scene the component belongs to.
  152379. */
  152380. scene: Scene;
  152381. /**
  152382. * Creates a new instance of the component for the given scene
  152383. * @param scene Defines the scene to register the component in
  152384. */
  152385. constructor(scene: Scene);
  152386. /**
  152387. * Registers the component in a given scene
  152388. */
  152389. register(): void;
  152390. /**
  152391. * Rebuilds the elements related to this component in case of
  152392. * context lost for instance.
  152393. */
  152394. rebuild(): void;
  152395. /**
  152396. * Disposes the component and the associated ressources
  152397. */
  152398. dispose(): void;
  152399. private _gatherRenderTargets;
  152400. private _gatherActiveCameraRenderTargets;
  152401. }
  152402. }
  152403. declare module BABYLON {
  152404. interface AbstractScene {
  152405. /** @hidden (Backing field) */
  152406. _prePassRenderer: Nullable<PrePassRenderer>;
  152407. /**
  152408. * Gets or Sets the current prepass renderer associated to the scene.
  152409. */
  152410. prePassRenderer: Nullable<PrePassRenderer>;
  152411. /**
  152412. * Enables the prepass and associates it with the scene
  152413. * @returns the PrePassRenderer
  152414. */
  152415. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152416. /**
  152417. * Disables the prepass associated with the scene
  152418. */
  152419. disablePrePassRenderer(): void;
  152420. }
  152421. /**
  152422. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152423. * in several rendering techniques.
  152424. */
  152425. export class PrePassRendererSceneComponent implements ISceneComponent {
  152426. /**
  152427. * The component name helpful to identify the component in the list of scene components.
  152428. */
  152429. readonly name: string;
  152430. /**
  152431. * The scene the component belongs to.
  152432. */
  152433. scene: Scene;
  152434. /**
  152435. * Creates a new instance of the component for the given scene
  152436. * @param scene Defines the scene to register the component in
  152437. */
  152438. constructor(scene: Scene);
  152439. /**
  152440. * Registers the component in a given scene
  152441. */
  152442. register(): void;
  152443. private _beforeCameraDraw;
  152444. private _afterCameraDraw;
  152445. private _beforeClearStage;
  152446. /**
  152447. * Rebuilds the elements related to this component in case of
  152448. * context lost for instance.
  152449. */
  152450. rebuild(): void;
  152451. /**
  152452. * Disposes the component and the associated ressources
  152453. */
  152454. dispose(): void;
  152455. }
  152456. }
  152457. declare module BABYLON {
  152458. /** @hidden */
  152459. export var fibonacci: {
  152460. name: string;
  152461. shader: string;
  152462. };
  152463. }
  152464. declare module BABYLON {
  152465. /** @hidden */
  152466. export var diffusionProfile: {
  152467. name: string;
  152468. shader: string;
  152469. };
  152470. }
  152471. declare module BABYLON {
  152472. /** @hidden */
  152473. export var subSurfaceScatteringPixelShader: {
  152474. name: string;
  152475. shader: string;
  152476. };
  152477. }
  152478. declare module BABYLON {
  152479. /**
  152480. * Sub surface scattering post process
  152481. */
  152482. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152483. /**
  152484. * Gets a string identifying the name of the class
  152485. * @returns "SubSurfaceScatteringPostProcess" string
  152486. */
  152487. getClassName(): string;
  152488. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152489. }
  152490. }
  152491. declare module BABYLON {
  152492. /**
  152493. * Contains all parameters needed for the prepass to perform
  152494. * screen space subsurface scattering
  152495. */
  152496. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152497. /** @hidden */
  152498. static _SceneComponentInitialization: (scene: Scene) => void;
  152499. private _ssDiffusionS;
  152500. private _ssFilterRadii;
  152501. private _ssDiffusionD;
  152502. /**
  152503. * Post process to attach for screen space subsurface scattering
  152504. */
  152505. postProcess: SubSurfaceScatteringPostProcess;
  152506. /**
  152507. * Diffusion profile color for subsurface scattering
  152508. */
  152509. get ssDiffusionS(): number[];
  152510. /**
  152511. * Diffusion profile max color channel value for subsurface scattering
  152512. */
  152513. get ssDiffusionD(): number[];
  152514. /**
  152515. * Diffusion profile filter radius for subsurface scattering
  152516. */
  152517. get ssFilterRadii(): number[];
  152518. /**
  152519. * Is subsurface enabled
  152520. */
  152521. enabled: boolean;
  152522. /**
  152523. * Name of the configuration
  152524. */
  152525. name: string;
  152526. /**
  152527. * Diffusion profile colors for subsurface scattering
  152528. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152529. * See ...
  152530. * Note that you can only store up to 5 of them
  152531. */
  152532. ssDiffusionProfileColors: Color3[];
  152533. /**
  152534. * Defines the ratio real world => scene units.
  152535. * Used for subsurface scattering
  152536. */
  152537. metersPerUnit: number;
  152538. /**
  152539. * Textures that should be present in the MRT for this effect to work
  152540. */
  152541. readonly texturesRequired: number[];
  152542. private _scene;
  152543. /**
  152544. * Builds a subsurface configuration object
  152545. * @param scene The scene
  152546. */
  152547. constructor(scene: Scene);
  152548. /**
  152549. * Adds a new diffusion profile.
  152550. * Useful for more realistic subsurface scattering on diverse materials.
  152551. * @param color The color of the diffusion profile. Should be the average color of the material.
  152552. * @return The index of the diffusion profile for the material subsurface configuration
  152553. */
  152554. addDiffusionProfile(color: Color3): number;
  152555. /**
  152556. * Creates the sss post process
  152557. * @return The created post process
  152558. */
  152559. createPostProcess(): SubSurfaceScatteringPostProcess;
  152560. /**
  152561. * Deletes all diffusion profiles.
  152562. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152563. */
  152564. clearAllDiffusionProfiles(): void;
  152565. /**
  152566. * Disposes this object
  152567. */
  152568. dispose(): void;
  152569. /**
  152570. * @hidden
  152571. * https://zero-radiance.github.io/post/sampling-diffusion/
  152572. *
  152573. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152574. * ------------------------------------------------------------------------------------
  152575. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152576. * PDF[r, phi, s] = r * R[r, phi, s]
  152577. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152578. * ------------------------------------------------------------------------------------
  152579. * We importance sample the color channel with the widest scattering distance.
  152580. */
  152581. getDiffusionProfileParameters(color: Color3): number;
  152582. /**
  152583. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152584. * 'u' is the random number (the value of the CDF): [0, 1).
  152585. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152586. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152587. */
  152588. private _sampleBurleyDiffusionProfile;
  152589. }
  152590. }
  152591. declare module BABYLON {
  152592. interface AbstractScene {
  152593. /** @hidden (Backing field) */
  152594. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152595. /**
  152596. * Gets or Sets the current prepass renderer associated to the scene.
  152597. */
  152598. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152599. /**
  152600. * Enables the subsurface effect for prepass
  152601. * @returns the SubSurfaceConfiguration
  152602. */
  152603. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152604. /**
  152605. * Disables the subsurface effect for prepass
  152606. */
  152607. disableSubSurfaceForPrePass(): void;
  152608. }
  152609. /**
  152610. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152611. * in several rendering techniques.
  152612. */
  152613. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152614. /**
  152615. * The component name helpful to identify the component in the list of scene components.
  152616. */
  152617. readonly name: string;
  152618. /**
  152619. * The scene the component belongs to.
  152620. */
  152621. scene: Scene;
  152622. /**
  152623. * Creates a new instance of the component for the given scene
  152624. * @param scene Defines the scene to register the component in
  152625. */
  152626. constructor(scene: Scene);
  152627. /**
  152628. * Registers the component in a given scene
  152629. */
  152630. register(): void;
  152631. /**
  152632. * Serializes the component data to the specified json object
  152633. * @param serializationObject The object to serialize to
  152634. */
  152635. serialize(serializationObject: any): void;
  152636. /**
  152637. * Adds all the elements from the container to the scene
  152638. * @param container the container holding the elements
  152639. */
  152640. addFromContainer(container: AbstractScene): void;
  152641. /**
  152642. * Removes all the elements in the container from the scene
  152643. * @param container contains the elements to remove
  152644. * @param dispose if the removed element should be disposed (default: false)
  152645. */
  152646. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152647. /**
  152648. * Rebuilds the elements related to this component in case of
  152649. * context lost for instance.
  152650. */
  152651. rebuild(): void;
  152652. /**
  152653. * Disposes the component and the associated ressources
  152654. */
  152655. dispose(): void;
  152656. }
  152657. }
  152658. declare module BABYLON {
  152659. /** @hidden */
  152660. export var outlinePixelShader: {
  152661. name: string;
  152662. shader: string;
  152663. };
  152664. }
  152665. declare module BABYLON {
  152666. /** @hidden */
  152667. export var outlineVertexShader: {
  152668. name: string;
  152669. shader: string;
  152670. };
  152671. }
  152672. declare module BABYLON {
  152673. interface Scene {
  152674. /** @hidden */
  152675. _outlineRenderer: OutlineRenderer;
  152676. /**
  152677. * Gets the outline renderer associated with the scene
  152678. * @returns a OutlineRenderer
  152679. */
  152680. getOutlineRenderer(): OutlineRenderer;
  152681. }
  152682. interface AbstractMesh {
  152683. /** @hidden (Backing field) */
  152684. _renderOutline: boolean;
  152685. /**
  152686. * Gets or sets a boolean indicating if the outline must be rendered as well
  152687. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152688. */
  152689. renderOutline: boolean;
  152690. /** @hidden (Backing field) */
  152691. _renderOverlay: boolean;
  152692. /**
  152693. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152694. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152695. */
  152696. renderOverlay: boolean;
  152697. }
  152698. /**
  152699. * This class is responsible to draw bothe outline/overlay of meshes.
  152700. * It should not be used directly but through the available method on mesh.
  152701. */
  152702. export class OutlineRenderer implements ISceneComponent {
  152703. /**
  152704. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152705. */
  152706. private static _StencilReference;
  152707. /**
  152708. * The name of the component. Each component must have a unique name.
  152709. */
  152710. name: string;
  152711. /**
  152712. * The scene the component belongs to.
  152713. */
  152714. scene: Scene;
  152715. /**
  152716. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152717. */
  152718. zOffset: number;
  152719. private _engine;
  152720. private _effect;
  152721. private _cachedDefines;
  152722. private _savedDepthWrite;
  152723. /**
  152724. * Instantiates a new outline renderer. (There could be only one per scene).
  152725. * @param scene Defines the scene it belongs to
  152726. */
  152727. constructor(scene: Scene);
  152728. /**
  152729. * Register the component to one instance of a scene.
  152730. */
  152731. register(): void;
  152732. /**
  152733. * Rebuilds the elements related to this component in case of
  152734. * context lost for instance.
  152735. */
  152736. rebuild(): void;
  152737. /**
  152738. * Disposes the component and the associated ressources.
  152739. */
  152740. dispose(): void;
  152741. /**
  152742. * Renders the outline in the canvas.
  152743. * @param subMesh Defines the sumesh to render
  152744. * @param batch Defines the batch of meshes in case of instances
  152745. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152746. */
  152747. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152748. /**
  152749. * Returns whether or not the outline renderer is ready for a given submesh.
  152750. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152751. * @param subMesh Defines the submesh to check readyness for
  152752. * @param useInstances Defines wheter wee are trying to render instances or not
  152753. * @returns true if ready otherwise false
  152754. */
  152755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152756. private _beforeRenderingMesh;
  152757. private _afterRenderingMesh;
  152758. }
  152759. }
  152760. declare module BABYLON {
  152761. /**
  152762. * Defines the basic options interface of a Sprite Frame Source Size.
  152763. */
  152764. export interface ISpriteJSONSpriteSourceSize {
  152765. /**
  152766. * number of the original width of the Frame
  152767. */
  152768. w: number;
  152769. /**
  152770. * number of the original height of the Frame
  152771. */
  152772. h: number;
  152773. }
  152774. /**
  152775. * Defines the basic options interface of a Sprite Frame Data.
  152776. */
  152777. export interface ISpriteJSONSpriteFrameData {
  152778. /**
  152779. * number of the x offset of the Frame
  152780. */
  152781. x: number;
  152782. /**
  152783. * number of the y offset of the Frame
  152784. */
  152785. y: number;
  152786. /**
  152787. * number of the width of the Frame
  152788. */
  152789. w: number;
  152790. /**
  152791. * number of the height of the Frame
  152792. */
  152793. h: number;
  152794. }
  152795. /**
  152796. * Defines the basic options interface of a JSON Sprite.
  152797. */
  152798. export interface ISpriteJSONSprite {
  152799. /**
  152800. * string name of the Frame
  152801. */
  152802. filename: string;
  152803. /**
  152804. * ISpriteJSONSpriteFrame basic object of the frame data
  152805. */
  152806. frame: ISpriteJSONSpriteFrameData;
  152807. /**
  152808. * boolean to flag is the frame was rotated.
  152809. */
  152810. rotated: boolean;
  152811. /**
  152812. * boolean to flag is the frame was trimmed.
  152813. */
  152814. trimmed: boolean;
  152815. /**
  152816. * ISpriteJSONSpriteFrame basic object of the source data
  152817. */
  152818. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152819. /**
  152820. * ISpriteJSONSpriteFrame basic object of the source data
  152821. */
  152822. sourceSize: ISpriteJSONSpriteSourceSize;
  152823. }
  152824. /**
  152825. * Defines the basic options interface of a JSON atlas.
  152826. */
  152827. export interface ISpriteJSONAtlas {
  152828. /**
  152829. * Array of objects that contain the frame data.
  152830. */
  152831. frames: Array<ISpriteJSONSprite>;
  152832. /**
  152833. * object basic object containing the sprite meta data.
  152834. */
  152835. meta?: object;
  152836. }
  152837. }
  152838. declare module BABYLON {
  152839. /** @hidden */
  152840. export var spriteMapPixelShader: {
  152841. name: string;
  152842. shader: string;
  152843. };
  152844. }
  152845. declare module BABYLON {
  152846. /** @hidden */
  152847. export var spriteMapVertexShader: {
  152848. name: string;
  152849. shader: string;
  152850. };
  152851. }
  152852. declare module BABYLON {
  152853. /**
  152854. * Defines the basic options interface of a SpriteMap
  152855. */
  152856. export interface ISpriteMapOptions {
  152857. /**
  152858. * Vector2 of the number of cells in the grid.
  152859. */
  152860. stageSize?: Vector2;
  152861. /**
  152862. * Vector2 of the size of the output plane in World Units.
  152863. */
  152864. outputSize?: Vector2;
  152865. /**
  152866. * Vector3 of the position of the output plane in World Units.
  152867. */
  152868. outputPosition?: Vector3;
  152869. /**
  152870. * Vector3 of the rotation of the output plane.
  152871. */
  152872. outputRotation?: Vector3;
  152873. /**
  152874. * number of layers that the system will reserve in resources.
  152875. */
  152876. layerCount?: number;
  152877. /**
  152878. * number of max animation frames a single cell will reserve in resources.
  152879. */
  152880. maxAnimationFrames?: number;
  152881. /**
  152882. * number cell index of the base tile when the system compiles.
  152883. */
  152884. baseTile?: number;
  152885. /**
  152886. * boolean flip the sprite after its been repositioned by the framing data.
  152887. */
  152888. flipU?: boolean;
  152889. /**
  152890. * Vector3 scalar of the global RGB values of the SpriteMap.
  152891. */
  152892. colorMultiply?: Vector3;
  152893. }
  152894. /**
  152895. * Defines the IDisposable interface in order to be cleanable from resources.
  152896. */
  152897. export interface ISpriteMap extends IDisposable {
  152898. /**
  152899. * String name of the SpriteMap.
  152900. */
  152901. name: string;
  152902. /**
  152903. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152904. */
  152905. atlasJSON: ISpriteJSONAtlas;
  152906. /**
  152907. * Texture of the SpriteMap.
  152908. */
  152909. spriteSheet: Texture;
  152910. /**
  152911. * The parameters to initialize the SpriteMap with.
  152912. */
  152913. options: ISpriteMapOptions;
  152914. }
  152915. /**
  152916. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152917. */
  152918. export class SpriteMap implements ISpriteMap {
  152919. /** The Name of the spriteMap */
  152920. name: string;
  152921. /** The JSON file with the frame and meta data */
  152922. atlasJSON: ISpriteJSONAtlas;
  152923. /** The systems Sprite Sheet Texture */
  152924. spriteSheet: Texture;
  152925. /** Arguments passed with the Constructor */
  152926. options: ISpriteMapOptions;
  152927. /** Public Sprite Storage array, parsed from atlasJSON */
  152928. sprites: Array<ISpriteJSONSprite>;
  152929. /** Returns the Number of Sprites in the System */
  152930. get spriteCount(): number;
  152931. /** Returns the Position of Output Plane*/
  152932. get position(): Vector3;
  152933. /** Returns the Position of Output Plane*/
  152934. set position(v: Vector3);
  152935. /** Returns the Rotation of Output Plane*/
  152936. get rotation(): Vector3;
  152937. /** Returns the Rotation of Output Plane*/
  152938. set rotation(v: Vector3);
  152939. /** Sets the AnimationMap*/
  152940. get animationMap(): RawTexture;
  152941. /** Sets the AnimationMap*/
  152942. set animationMap(v: RawTexture);
  152943. /** Scene that the SpriteMap was created in */
  152944. private _scene;
  152945. /** Texture Buffer of Float32 that holds tile frame data*/
  152946. private _frameMap;
  152947. /** Texture Buffers of Float32 that holds tileMap data*/
  152948. private _tileMaps;
  152949. /** Texture Buffer of Float32 that holds Animation Data*/
  152950. private _animationMap;
  152951. /** Custom ShaderMaterial Central to the System*/
  152952. private _material;
  152953. /** Custom ShaderMaterial Central to the System*/
  152954. private _output;
  152955. /** Systems Time Ticker*/
  152956. private _time;
  152957. /**
  152958. * Creates a new SpriteMap
  152959. * @param name defines the SpriteMaps Name
  152960. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152961. * @param spriteSheet is the Texture that the Sprites are on.
  152962. * @param options a basic deployment configuration
  152963. * @param scene The Scene that the map is deployed on
  152964. */
  152965. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152966. /**
  152967. * Returns tileID location
  152968. * @returns Vector2 the cell position ID
  152969. */
  152970. getTileID(): Vector2;
  152971. /**
  152972. * Gets the UV location of the mouse over the SpriteMap.
  152973. * @returns Vector2 the UV position of the mouse interaction
  152974. */
  152975. getMousePosition(): Vector2;
  152976. /**
  152977. * Creates the "frame" texture Buffer
  152978. * -------------------------------------
  152979. * Structure of frames
  152980. * "filename": "Falling-Water-2.png",
  152981. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152982. * "rotated": true,
  152983. * "trimmed": true,
  152984. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152985. * "sourceSize": {"w":32,"h":32}
  152986. * @returns RawTexture of the frameMap
  152987. */
  152988. private _createFrameBuffer;
  152989. /**
  152990. * Creates the tileMap texture Buffer
  152991. * @param buffer normally and array of numbers, or a false to generate from scratch
  152992. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152993. * @returns RawTexture of the tileMap
  152994. */
  152995. private _createTileBuffer;
  152996. /**
  152997. * Modifies the data of the tileMaps
  152998. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152999. * @param pos is the iVector2 Coordinates of the Tile
  153000. * @param tile The SpriteIndex of the new Tile
  153001. */
  153002. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153003. /**
  153004. * Creates the animationMap texture Buffer
  153005. * @param buffer normally and array of numbers, or a false to generate from scratch
  153006. * @returns RawTexture of the animationMap
  153007. */
  153008. private _createTileAnimationBuffer;
  153009. /**
  153010. * Modifies the data of the animationMap
  153011. * @param cellID is the Index of the Sprite
  153012. * @param _frame is the target Animation frame
  153013. * @param toCell is the Target Index of the next frame of the animation
  153014. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153015. * @param speed is a global scalar of the time variable on the map.
  153016. */
  153017. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153018. /**
  153019. * Exports the .tilemaps file
  153020. */
  153021. saveTileMaps(): void;
  153022. /**
  153023. * Imports the .tilemaps file
  153024. * @param url of the .tilemaps file
  153025. */
  153026. loadTileMaps(url: string): void;
  153027. /**
  153028. * Release associated resources
  153029. */
  153030. dispose(): void;
  153031. }
  153032. }
  153033. declare module BABYLON {
  153034. /**
  153035. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153036. * @see https://doc.babylonjs.com/babylon101/sprites
  153037. */
  153038. export class SpritePackedManager extends SpriteManager {
  153039. /** defines the packed manager's name */
  153040. name: string;
  153041. /**
  153042. * Creates a new sprite manager from a packed sprite sheet
  153043. * @param name defines the manager's name
  153044. * @param imgUrl defines the sprite sheet url
  153045. * @param capacity defines the maximum allowed number of sprites
  153046. * @param scene defines the hosting scene
  153047. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153048. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153049. * @param samplingMode defines the smapling mode to use with spritesheet
  153050. * @param fromPacked set to true; do not alter
  153051. */
  153052. constructor(
  153053. /** defines the packed manager's name */
  153054. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153055. }
  153056. }
  153057. declare module BABYLON {
  153058. /**
  153059. * Defines the list of states available for a task inside a AssetsManager
  153060. */
  153061. export enum AssetTaskState {
  153062. /**
  153063. * Initialization
  153064. */
  153065. INIT = 0,
  153066. /**
  153067. * Running
  153068. */
  153069. RUNNING = 1,
  153070. /**
  153071. * Done
  153072. */
  153073. DONE = 2,
  153074. /**
  153075. * Error
  153076. */
  153077. ERROR = 3
  153078. }
  153079. /**
  153080. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153081. */
  153082. export abstract class AbstractAssetTask {
  153083. /**
  153084. * Task name
  153085. */ name: string;
  153086. /**
  153087. * Callback called when the task is successful
  153088. */
  153089. onSuccess: (task: any) => void;
  153090. /**
  153091. * Callback called when the task is not successful
  153092. */
  153093. onError: (task: any, message?: string, exception?: any) => void;
  153094. /**
  153095. * Creates a new AssetsManager
  153096. * @param name defines the name of the task
  153097. */
  153098. constructor(
  153099. /**
  153100. * Task name
  153101. */ name: string);
  153102. private _isCompleted;
  153103. private _taskState;
  153104. private _errorObject;
  153105. /**
  153106. * Get if the task is completed
  153107. */
  153108. get isCompleted(): boolean;
  153109. /**
  153110. * Gets the current state of the task
  153111. */
  153112. get taskState(): AssetTaskState;
  153113. /**
  153114. * Gets the current error object (if task is in error)
  153115. */
  153116. get errorObject(): {
  153117. message?: string;
  153118. exception?: any;
  153119. };
  153120. /**
  153121. * Internal only
  153122. * @hidden
  153123. */
  153124. _setErrorObject(message?: string, exception?: any): void;
  153125. /**
  153126. * Execute the current task
  153127. * @param scene defines the scene where you want your assets to be loaded
  153128. * @param onSuccess is a callback called when the task is successfully executed
  153129. * @param onError is a callback called if an error occurs
  153130. */
  153131. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153132. /**
  153133. * Execute the current task
  153134. * @param scene defines the scene where you want your assets to be loaded
  153135. * @param onSuccess is a callback called when the task is successfully executed
  153136. * @param onError is a callback called if an error occurs
  153137. */
  153138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153139. /**
  153140. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153141. * This can be used with failed tasks that have the reason for failure fixed.
  153142. */
  153143. reset(): void;
  153144. private onErrorCallback;
  153145. private onDoneCallback;
  153146. }
  153147. /**
  153148. * Define the interface used by progress events raised during assets loading
  153149. */
  153150. export interface IAssetsProgressEvent {
  153151. /**
  153152. * Defines the number of remaining tasks to process
  153153. */
  153154. remainingCount: number;
  153155. /**
  153156. * Defines the total number of tasks
  153157. */
  153158. totalCount: number;
  153159. /**
  153160. * Defines the task that was just processed
  153161. */
  153162. task: AbstractAssetTask;
  153163. }
  153164. /**
  153165. * Class used to share progress information about assets loading
  153166. */
  153167. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153168. /**
  153169. * Defines the number of remaining tasks to process
  153170. */
  153171. remainingCount: number;
  153172. /**
  153173. * Defines the total number of tasks
  153174. */
  153175. totalCount: number;
  153176. /**
  153177. * Defines the task that was just processed
  153178. */
  153179. task: AbstractAssetTask;
  153180. /**
  153181. * Creates a AssetsProgressEvent
  153182. * @param remainingCount defines the number of remaining tasks to process
  153183. * @param totalCount defines the total number of tasks
  153184. * @param task defines the task that was just processed
  153185. */
  153186. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153187. }
  153188. /**
  153189. * Define a task used by AssetsManager to load assets into a container
  153190. */
  153191. export class ContainerAssetTask extends AbstractAssetTask {
  153192. /**
  153193. * Defines the name of the task
  153194. */
  153195. name: string;
  153196. /**
  153197. * Defines the list of mesh's names you want to load
  153198. */
  153199. meshesNames: any;
  153200. /**
  153201. * Defines the root url to use as a base to load your meshes and associated resources
  153202. */
  153203. rootUrl: string;
  153204. /**
  153205. * Defines the filename or File of the scene to load from
  153206. */
  153207. sceneFilename: string | File;
  153208. /**
  153209. * Get the loaded asset container
  153210. */
  153211. loadedContainer: AssetContainer;
  153212. /**
  153213. * Gets the list of loaded meshes
  153214. */
  153215. loadedMeshes: Array<AbstractMesh>;
  153216. /**
  153217. * Gets the list of loaded particle systems
  153218. */
  153219. loadedParticleSystems: Array<IParticleSystem>;
  153220. /**
  153221. * Gets the list of loaded skeletons
  153222. */
  153223. loadedSkeletons: Array<Skeleton>;
  153224. /**
  153225. * Gets the list of loaded animation groups
  153226. */
  153227. loadedAnimationGroups: Array<AnimationGroup>;
  153228. /**
  153229. * Callback called when the task is successful
  153230. */
  153231. onSuccess: (task: ContainerAssetTask) => void;
  153232. /**
  153233. * Callback called when the task is successful
  153234. */
  153235. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153236. /**
  153237. * Creates a new ContainerAssetTask
  153238. * @param name defines the name of the task
  153239. * @param meshesNames defines the list of mesh's names you want to load
  153240. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153241. * @param sceneFilename defines the filename or File of the scene to load from
  153242. */
  153243. constructor(
  153244. /**
  153245. * Defines the name of the task
  153246. */
  153247. name: string,
  153248. /**
  153249. * Defines the list of mesh's names you want to load
  153250. */
  153251. meshesNames: any,
  153252. /**
  153253. * Defines the root url to use as a base to load your meshes and associated resources
  153254. */
  153255. rootUrl: string,
  153256. /**
  153257. * Defines the filename or File of the scene to load from
  153258. */
  153259. sceneFilename: string | File);
  153260. /**
  153261. * Execute the current task
  153262. * @param scene defines the scene where you want your assets to be loaded
  153263. * @param onSuccess is a callback called when the task is successfully executed
  153264. * @param onError is a callback called if an error occurs
  153265. */
  153266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153267. }
  153268. /**
  153269. * Define a task used by AssetsManager to load meshes
  153270. */
  153271. export class MeshAssetTask extends AbstractAssetTask {
  153272. /**
  153273. * Defines the name of the task
  153274. */
  153275. name: string;
  153276. /**
  153277. * Defines the list of mesh's names you want to load
  153278. */
  153279. meshesNames: any;
  153280. /**
  153281. * Defines the root url to use as a base to load your meshes and associated resources
  153282. */
  153283. rootUrl: string;
  153284. /**
  153285. * Defines the filename or File of the scene to load from
  153286. */
  153287. sceneFilename: string | File;
  153288. /**
  153289. * Gets the list of loaded meshes
  153290. */
  153291. loadedMeshes: Array<AbstractMesh>;
  153292. /**
  153293. * Gets the list of loaded particle systems
  153294. */
  153295. loadedParticleSystems: Array<IParticleSystem>;
  153296. /**
  153297. * Gets the list of loaded skeletons
  153298. */
  153299. loadedSkeletons: Array<Skeleton>;
  153300. /**
  153301. * Gets the list of loaded animation groups
  153302. */
  153303. loadedAnimationGroups: Array<AnimationGroup>;
  153304. /**
  153305. * Callback called when the task is successful
  153306. */
  153307. onSuccess: (task: MeshAssetTask) => void;
  153308. /**
  153309. * Callback called when the task is successful
  153310. */
  153311. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153312. /**
  153313. * Creates a new MeshAssetTask
  153314. * @param name defines the name of the task
  153315. * @param meshesNames defines the list of mesh's names you want to load
  153316. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153317. * @param sceneFilename defines the filename or File of the scene to load from
  153318. */
  153319. constructor(
  153320. /**
  153321. * Defines the name of the task
  153322. */
  153323. name: string,
  153324. /**
  153325. * Defines the list of mesh's names you want to load
  153326. */
  153327. meshesNames: any,
  153328. /**
  153329. * Defines the root url to use as a base to load your meshes and associated resources
  153330. */
  153331. rootUrl: string,
  153332. /**
  153333. * Defines the filename or File of the scene to load from
  153334. */
  153335. sceneFilename: string | File);
  153336. /**
  153337. * Execute the current task
  153338. * @param scene defines the scene where you want your assets to be loaded
  153339. * @param onSuccess is a callback called when the task is successfully executed
  153340. * @param onError is a callback called if an error occurs
  153341. */
  153342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153343. }
  153344. /**
  153345. * Define a task used by AssetsManager to load text content
  153346. */
  153347. export class TextFileAssetTask extends AbstractAssetTask {
  153348. /**
  153349. * Defines the name of the task
  153350. */
  153351. name: string;
  153352. /**
  153353. * Defines the location of the file to load
  153354. */
  153355. url: string;
  153356. /**
  153357. * Gets the loaded text string
  153358. */
  153359. text: string;
  153360. /**
  153361. * Callback called when the task is successful
  153362. */
  153363. onSuccess: (task: TextFileAssetTask) => void;
  153364. /**
  153365. * Callback called when the task is successful
  153366. */
  153367. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153368. /**
  153369. * Creates a new TextFileAssetTask object
  153370. * @param name defines the name of the task
  153371. * @param url defines the location of the file to load
  153372. */
  153373. constructor(
  153374. /**
  153375. * Defines the name of the task
  153376. */
  153377. name: string,
  153378. /**
  153379. * Defines the location of the file to load
  153380. */
  153381. url: string);
  153382. /**
  153383. * Execute the current task
  153384. * @param scene defines the scene where you want your assets to be loaded
  153385. * @param onSuccess is a callback called when the task is successfully executed
  153386. * @param onError is a callback called if an error occurs
  153387. */
  153388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153389. }
  153390. /**
  153391. * Define a task used by AssetsManager to load binary data
  153392. */
  153393. export class BinaryFileAssetTask extends AbstractAssetTask {
  153394. /**
  153395. * Defines the name of the task
  153396. */
  153397. name: string;
  153398. /**
  153399. * Defines the location of the file to load
  153400. */
  153401. url: string;
  153402. /**
  153403. * Gets the lodaded data (as an array buffer)
  153404. */
  153405. data: ArrayBuffer;
  153406. /**
  153407. * Callback called when the task is successful
  153408. */
  153409. onSuccess: (task: BinaryFileAssetTask) => void;
  153410. /**
  153411. * Callback called when the task is successful
  153412. */
  153413. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153414. /**
  153415. * Creates a new BinaryFileAssetTask object
  153416. * @param name defines the name of the new task
  153417. * @param url defines the location of the file to load
  153418. */
  153419. constructor(
  153420. /**
  153421. * Defines the name of the task
  153422. */
  153423. name: string,
  153424. /**
  153425. * Defines the location of the file to load
  153426. */
  153427. url: string);
  153428. /**
  153429. * Execute the current task
  153430. * @param scene defines the scene where you want your assets to be loaded
  153431. * @param onSuccess is a callback called when the task is successfully executed
  153432. * @param onError is a callback called if an error occurs
  153433. */
  153434. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153435. }
  153436. /**
  153437. * Define a task used by AssetsManager to load images
  153438. */
  153439. export class ImageAssetTask extends AbstractAssetTask {
  153440. /**
  153441. * Defines the name of the task
  153442. */
  153443. name: string;
  153444. /**
  153445. * Defines the location of the image to load
  153446. */
  153447. url: string;
  153448. /**
  153449. * Gets the loaded images
  153450. */
  153451. image: HTMLImageElement;
  153452. /**
  153453. * Callback called when the task is successful
  153454. */
  153455. onSuccess: (task: ImageAssetTask) => void;
  153456. /**
  153457. * Callback called when the task is successful
  153458. */
  153459. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153460. /**
  153461. * Creates a new ImageAssetTask
  153462. * @param name defines the name of the task
  153463. * @param url defines the location of the image to load
  153464. */
  153465. constructor(
  153466. /**
  153467. * Defines the name of the task
  153468. */
  153469. name: string,
  153470. /**
  153471. * Defines the location of the image to load
  153472. */
  153473. url: string);
  153474. /**
  153475. * Execute the current task
  153476. * @param scene defines the scene where you want your assets to be loaded
  153477. * @param onSuccess is a callback called when the task is successfully executed
  153478. * @param onError is a callback called if an error occurs
  153479. */
  153480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153481. }
  153482. /**
  153483. * Defines the interface used by texture loading tasks
  153484. */
  153485. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153486. /**
  153487. * Gets the loaded texture
  153488. */
  153489. texture: TEX;
  153490. }
  153491. /**
  153492. * Define a task used by AssetsManager to load 2D textures
  153493. */
  153494. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153495. /**
  153496. * Defines the name of the task
  153497. */
  153498. name: string;
  153499. /**
  153500. * Defines the location of the file to load
  153501. */
  153502. url: string;
  153503. /**
  153504. * Defines if mipmap should not be generated (default is false)
  153505. */
  153506. noMipmap?: boolean | undefined;
  153507. /**
  153508. * Defines if texture must be inverted on Y axis (default is true)
  153509. */
  153510. invertY: boolean;
  153511. /**
  153512. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153513. */
  153514. samplingMode: number;
  153515. /**
  153516. * Gets the loaded texture
  153517. */
  153518. texture: Texture;
  153519. /**
  153520. * Callback called when the task is successful
  153521. */
  153522. onSuccess: (task: TextureAssetTask) => void;
  153523. /**
  153524. * Callback called when the task is successful
  153525. */
  153526. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153527. /**
  153528. * Creates a new TextureAssetTask object
  153529. * @param name defines the name of the task
  153530. * @param url defines the location of the file to load
  153531. * @param noMipmap defines if mipmap should not be generated (default is false)
  153532. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153533. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153534. */
  153535. constructor(
  153536. /**
  153537. * Defines the name of the task
  153538. */
  153539. name: string,
  153540. /**
  153541. * Defines the location of the file to load
  153542. */
  153543. url: string,
  153544. /**
  153545. * Defines if mipmap should not be generated (default is false)
  153546. */
  153547. noMipmap?: boolean | undefined,
  153548. /**
  153549. * Defines if texture must be inverted on Y axis (default is true)
  153550. */
  153551. invertY?: boolean,
  153552. /**
  153553. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153554. */
  153555. samplingMode?: number);
  153556. /**
  153557. * Execute the current task
  153558. * @param scene defines the scene where you want your assets to be loaded
  153559. * @param onSuccess is a callback called when the task is successfully executed
  153560. * @param onError is a callback called if an error occurs
  153561. */
  153562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153563. }
  153564. /**
  153565. * Define a task used by AssetsManager to load cube textures
  153566. */
  153567. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153568. /**
  153569. * Defines the name of the task
  153570. */
  153571. name: string;
  153572. /**
  153573. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153574. */
  153575. url: string;
  153576. /**
  153577. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153578. */
  153579. extensions?: string[] | undefined;
  153580. /**
  153581. * Defines if mipmaps should not be generated (default is false)
  153582. */
  153583. noMipmap?: boolean | undefined;
  153584. /**
  153585. * Defines the explicit list of files (undefined by default)
  153586. */
  153587. files?: string[] | undefined;
  153588. /**
  153589. * Gets the loaded texture
  153590. */
  153591. texture: CubeTexture;
  153592. /**
  153593. * Callback called when the task is successful
  153594. */
  153595. onSuccess: (task: CubeTextureAssetTask) => void;
  153596. /**
  153597. * Callback called when the task is successful
  153598. */
  153599. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153600. /**
  153601. * Creates a new CubeTextureAssetTask
  153602. * @param name defines the name of the task
  153603. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153604. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153605. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153606. * @param files defines the explicit list of files (undefined by default)
  153607. */
  153608. constructor(
  153609. /**
  153610. * Defines the name of the task
  153611. */
  153612. name: string,
  153613. /**
  153614. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153615. */
  153616. url: string,
  153617. /**
  153618. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153619. */
  153620. extensions?: string[] | undefined,
  153621. /**
  153622. * Defines if mipmaps should not be generated (default is false)
  153623. */
  153624. noMipmap?: boolean | undefined,
  153625. /**
  153626. * Defines the explicit list of files (undefined by default)
  153627. */
  153628. files?: string[] | undefined);
  153629. /**
  153630. * Execute the current task
  153631. * @param scene defines the scene where you want your assets to be loaded
  153632. * @param onSuccess is a callback called when the task is successfully executed
  153633. * @param onError is a callback called if an error occurs
  153634. */
  153635. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153636. }
  153637. /**
  153638. * Define a task used by AssetsManager to load HDR cube textures
  153639. */
  153640. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153641. /**
  153642. * Defines the name of the task
  153643. */
  153644. name: string;
  153645. /**
  153646. * Defines the location of the file to load
  153647. */
  153648. url: string;
  153649. /**
  153650. * Defines the desired size (the more it increases the longer the generation will be)
  153651. */
  153652. size: number;
  153653. /**
  153654. * Defines if mipmaps should not be generated (default is false)
  153655. */
  153656. noMipmap: boolean;
  153657. /**
  153658. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153659. */
  153660. generateHarmonics: boolean;
  153661. /**
  153662. * 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)
  153663. */
  153664. gammaSpace: boolean;
  153665. /**
  153666. * Internal Use Only
  153667. */
  153668. reserved: boolean;
  153669. /**
  153670. * Gets the loaded texture
  153671. */
  153672. texture: HDRCubeTexture;
  153673. /**
  153674. * Callback called when the task is successful
  153675. */
  153676. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153677. /**
  153678. * Callback called when the task is successful
  153679. */
  153680. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153681. /**
  153682. * Creates a new HDRCubeTextureAssetTask object
  153683. * @param name defines the name of the task
  153684. * @param url defines the location of the file to load
  153685. * @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.
  153686. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153687. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153688. * @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)
  153689. * @param reserved Internal use only
  153690. */
  153691. constructor(
  153692. /**
  153693. * Defines the name of the task
  153694. */
  153695. name: string,
  153696. /**
  153697. * Defines the location of the file to load
  153698. */
  153699. url: string,
  153700. /**
  153701. * Defines the desired size (the more it increases the longer the generation will be)
  153702. */
  153703. size: number,
  153704. /**
  153705. * Defines if mipmaps should not be generated (default is false)
  153706. */
  153707. noMipmap?: boolean,
  153708. /**
  153709. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153710. */
  153711. generateHarmonics?: boolean,
  153712. /**
  153713. * 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)
  153714. */
  153715. gammaSpace?: boolean,
  153716. /**
  153717. * Internal Use Only
  153718. */
  153719. reserved?: boolean);
  153720. /**
  153721. * Execute the current task
  153722. * @param scene defines the scene where you want your assets to be loaded
  153723. * @param onSuccess is a callback called when the task is successfully executed
  153724. * @param onError is a callback called if an error occurs
  153725. */
  153726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153727. }
  153728. /**
  153729. * Define a task used by AssetsManager to load Equirectangular cube textures
  153730. */
  153731. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153732. /**
  153733. * Defines the name of the task
  153734. */
  153735. name: string;
  153736. /**
  153737. * Defines the location of the file to load
  153738. */
  153739. url: string;
  153740. /**
  153741. * Defines the desired size (the more it increases the longer the generation will be)
  153742. */
  153743. size: number;
  153744. /**
  153745. * Defines if mipmaps should not be generated (default is false)
  153746. */
  153747. noMipmap: boolean;
  153748. /**
  153749. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153750. * but the standard material would require them in Gamma space) (default is true)
  153751. */
  153752. gammaSpace: boolean;
  153753. /**
  153754. * Gets the loaded texture
  153755. */
  153756. texture: EquiRectangularCubeTexture;
  153757. /**
  153758. * Callback called when the task is successful
  153759. */
  153760. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153761. /**
  153762. * Callback called when the task is successful
  153763. */
  153764. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153765. /**
  153766. * Creates a new EquiRectangularCubeTextureAssetTask object
  153767. * @param name defines the name of the task
  153768. * @param url defines the location of the file to load
  153769. * @param size defines the desired size (the more it increases the longer the generation will be)
  153770. * If the size is omitted this implies you are using a preprocessed cubemap.
  153771. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153772. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153773. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153774. * (default is true)
  153775. */
  153776. constructor(
  153777. /**
  153778. * Defines the name of the task
  153779. */
  153780. name: string,
  153781. /**
  153782. * Defines the location of the file to load
  153783. */
  153784. url: string,
  153785. /**
  153786. * Defines the desired size (the more it increases the longer the generation will be)
  153787. */
  153788. size: number,
  153789. /**
  153790. * Defines if mipmaps should not be generated (default is false)
  153791. */
  153792. noMipmap?: boolean,
  153793. /**
  153794. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153795. * but the standard material would require them in Gamma space) (default is true)
  153796. */
  153797. gammaSpace?: boolean);
  153798. /**
  153799. * Execute the current task
  153800. * @param scene defines the scene where you want your assets to be loaded
  153801. * @param onSuccess is a callback called when the task is successfully executed
  153802. * @param onError is a callback called if an error occurs
  153803. */
  153804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153805. }
  153806. /**
  153807. * This class can be used to easily import assets into a scene
  153808. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153809. */
  153810. export class AssetsManager {
  153811. private _scene;
  153812. private _isLoading;
  153813. protected _tasks: AbstractAssetTask[];
  153814. protected _waitingTasksCount: number;
  153815. protected _totalTasksCount: number;
  153816. /**
  153817. * Callback called when all tasks are processed
  153818. */
  153819. onFinish: (tasks: AbstractAssetTask[]) => void;
  153820. /**
  153821. * Callback called when a task is successful
  153822. */
  153823. onTaskSuccess: (task: AbstractAssetTask) => void;
  153824. /**
  153825. * Callback called when a task had an error
  153826. */
  153827. onTaskError: (task: AbstractAssetTask) => void;
  153828. /**
  153829. * Callback called when a task is done (whatever the result is)
  153830. */
  153831. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153832. /**
  153833. * Observable called when all tasks are processed
  153834. */
  153835. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153836. /**
  153837. * Observable called when a task had an error
  153838. */
  153839. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153840. /**
  153841. * Observable called when all tasks were executed
  153842. */
  153843. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153844. /**
  153845. * Observable called when a task is done (whatever the result is)
  153846. */
  153847. onProgressObservable: Observable<IAssetsProgressEvent>;
  153848. /**
  153849. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153850. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153851. */
  153852. useDefaultLoadingScreen: boolean;
  153853. /**
  153854. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153855. * when all assets have been downloaded.
  153856. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153857. */
  153858. autoHideLoadingUI: boolean;
  153859. /**
  153860. * Creates a new AssetsManager
  153861. * @param scene defines the scene to work on
  153862. */
  153863. constructor(scene: Scene);
  153864. /**
  153865. * Add a ContainerAssetTask to the list of active tasks
  153866. * @param taskName defines the name of the new task
  153867. * @param meshesNames defines the name of meshes to load
  153868. * @param rootUrl defines the root url to use to locate files
  153869. * @param sceneFilename defines the filename of the scene file
  153870. * @returns a new ContainerAssetTask object
  153871. */
  153872. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153873. /**
  153874. * Add a MeshAssetTask to the list of active tasks
  153875. * @param taskName defines the name of the new task
  153876. * @param meshesNames defines the name of meshes to load
  153877. * @param rootUrl defines the root url to use to locate files
  153878. * @param sceneFilename defines the filename of the scene file
  153879. * @returns a new MeshAssetTask object
  153880. */
  153881. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153882. /**
  153883. * Add a TextFileAssetTask to the list of active tasks
  153884. * @param taskName defines the name of the new task
  153885. * @param url defines the url of the file to load
  153886. * @returns a new TextFileAssetTask object
  153887. */
  153888. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153889. /**
  153890. * Add a BinaryFileAssetTask to the list of active tasks
  153891. * @param taskName defines the name of the new task
  153892. * @param url defines the url of the file to load
  153893. * @returns a new BinaryFileAssetTask object
  153894. */
  153895. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153896. /**
  153897. * Add a ImageAssetTask to the list of active tasks
  153898. * @param taskName defines the name of the new task
  153899. * @param url defines the url of the file to load
  153900. * @returns a new ImageAssetTask object
  153901. */
  153902. addImageTask(taskName: string, url: string): ImageAssetTask;
  153903. /**
  153904. * Add a TextureAssetTask to the list of active tasks
  153905. * @param taskName defines the name of the new task
  153906. * @param url defines the url of the file to load
  153907. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153908. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153909. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153910. * @returns a new TextureAssetTask object
  153911. */
  153912. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153913. /**
  153914. * Add a CubeTextureAssetTask to the list of active tasks
  153915. * @param taskName defines the name of the new task
  153916. * @param url defines the url of the file to load
  153917. * @param extensions defines the extension to use to load the cube map (can be null)
  153918. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153919. * @param files defines the list of files to load (can be null)
  153920. * @returns a new CubeTextureAssetTask object
  153921. */
  153922. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153923. /**
  153924. *
  153925. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153926. * @param taskName defines the name of the new task
  153927. * @param url defines the url of the file to load
  153928. * @param size defines the size you want for the cubemap (can be null)
  153929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153930. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153931. * @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)
  153932. * @param reserved Internal use only
  153933. * @returns a new HDRCubeTextureAssetTask object
  153934. */
  153935. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153936. /**
  153937. *
  153938. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153939. * @param taskName defines the name of the new task
  153940. * @param url defines the url of the file to load
  153941. * @param size defines the size you want for the cubemap (can be null)
  153942. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153943. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153944. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153945. * @returns a new EquiRectangularCubeTextureAssetTask object
  153946. */
  153947. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153948. /**
  153949. * Remove a task from the assets manager.
  153950. * @param task the task to remove
  153951. */
  153952. removeTask(task: AbstractAssetTask): void;
  153953. private _decreaseWaitingTasksCount;
  153954. private _runTask;
  153955. /**
  153956. * Reset the AssetsManager and remove all tasks
  153957. * @return the current instance of the AssetsManager
  153958. */
  153959. reset(): AssetsManager;
  153960. /**
  153961. * Start the loading process
  153962. * @return the current instance of the AssetsManager
  153963. */
  153964. load(): AssetsManager;
  153965. /**
  153966. * Start the loading process as an async operation
  153967. * @return a promise returning the list of failed tasks
  153968. */
  153969. loadAsync(): Promise<void>;
  153970. }
  153971. }
  153972. declare module BABYLON {
  153973. /**
  153974. * Wrapper class for promise with external resolve and reject.
  153975. */
  153976. export class Deferred<T> {
  153977. /**
  153978. * The promise associated with this deferred object.
  153979. */
  153980. readonly promise: Promise<T>;
  153981. private _resolve;
  153982. private _reject;
  153983. /**
  153984. * The resolve method of the promise associated with this deferred object.
  153985. */
  153986. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153987. /**
  153988. * The reject method of the promise associated with this deferred object.
  153989. */
  153990. get reject(): (reason?: any) => void;
  153991. /**
  153992. * Constructor for this deferred object.
  153993. */
  153994. constructor();
  153995. }
  153996. }
  153997. declare module BABYLON {
  153998. /**
  153999. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154000. */
  154001. export class MeshExploder {
  154002. private _centerMesh;
  154003. private _meshes;
  154004. private _meshesOrigins;
  154005. private _toCenterVectors;
  154006. private _scaledDirection;
  154007. private _newPosition;
  154008. private _centerPosition;
  154009. /**
  154010. * Explodes meshes from a center mesh.
  154011. * @param meshes The meshes to explode.
  154012. * @param centerMesh The mesh to be center of explosion.
  154013. */
  154014. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154015. private _setCenterMesh;
  154016. /**
  154017. * Get class name
  154018. * @returns "MeshExploder"
  154019. */
  154020. getClassName(): string;
  154021. /**
  154022. * "Exploded meshes"
  154023. * @returns Array of meshes with the centerMesh at index 0.
  154024. */
  154025. getMeshes(): Array<Mesh>;
  154026. /**
  154027. * Explodes meshes giving a specific direction
  154028. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154029. */
  154030. explode(direction?: number): void;
  154031. }
  154032. }
  154033. declare module BABYLON {
  154034. /**
  154035. * Class used to help managing file picking and drag'n'drop
  154036. */
  154037. export class FilesInput {
  154038. /**
  154039. * List of files ready to be loaded
  154040. */
  154041. static get FilesToLoad(): {
  154042. [key: string]: File;
  154043. };
  154044. /**
  154045. * Callback called when a file is processed
  154046. */
  154047. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154048. private _engine;
  154049. private _currentScene;
  154050. private _sceneLoadedCallback;
  154051. private _progressCallback;
  154052. private _additionalRenderLoopLogicCallback;
  154053. private _textureLoadingCallback;
  154054. private _startingProcessingFilesCallback;
  154055. private _onReloadCallback;
  154056. private _errorCallback;
  154057. private _elementToMonitor;
  154058. private _sceneFileToLoad;
  154059. private _filesToLoad;
  154060. /**
  154061. * Creates a new FilesInput
  154062. * @param engine defines the rendering engine
  154063. * @param scene defines the hosting scene
  154064. * @param sceneLoadedCallback callback called when scene is loaded
  154065. * @param progressCallback callback called to track progress
  154066. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154067. * @param textureLoadingCallback callback called when a texture is loading
  154068. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154069. * @param onReloadCallback callback called when a reload is requested
  154070. * @param errorCallback callback call if an error occurs
  154071. */
  154072. 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>);
  154073. private _dragEnterHandler;
  154074. private _dragOverHandler;
  154075. private _dropHandler;
  154076. /**
  154077. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154078. * @param elementToMonitor defines the DOM element to track
  154079. */
  154080. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154081. /** Gets the current list of files to load */
  154082. get filesToLoad(): File[];
  154083. /**
  154084. * Release all associated resources
  154085. */
  154086. dispose(): void;
  154087. private renderFunction;
  154088. private drag;
  154089. private drop;
  154090. private _traverseFolder;
  154091. private _processFiles;
  154092. /**
  154093. * Load files from a drop event
  154094. * @param event defines the drop event to use as source
  154095. */
  154096. loadFiles(event: any): void;
  154097. private _processReload;
  154098. /**
  154099. * Reload the current scene from the loaded files
  154100. */
  154101. reload(): void;
  154102. }
  154103. }
  154104. declare module BABYLON {
  154105. /**
  154106. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154107. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154108. */
  154109. export class SceneOptimization {
  154110. /**
  154111. * Defines the priority of this optimization (0 by default which means first in the list)
  154112. */
  154113. priority: number;
  154114. /**
  154115. * Gets a string describing the action executed by the current optimization
  154116. * @returns description string
  154117. */
  154118. getDescription(): string;
  154119. /**
  154120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154121. * @param scene defines the current scene where to apply this optimization
  154122. * @param optimizer defines the current optimizer
  154123. * @returns true if everything that can be done was applied
  154124. */
  154125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154126. /**
  154127. * Creates the SceneOptimization object
  154128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154129. * @param desc defines the description associated with the optimization
  154130. */
  154131. constructor(
  154132. /**
  154133. * Defines the priority of this optimization (0 by default which means first in the list)
  154134. */
  154135. priority?: number);
  154136. }
  154137. /**
  154138. * Defines an optimization used to reduce the size of render target textures
  154139. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154140. */
  154141. export class TextureOptimization extends SceneOptimization {
  154142. /**
  154143. * Defines the priority of this optimization (0 by default which means first in the list)
  154144. */
  154145. priority: number;
  154146. /**
  154147. * 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
  154148. */
  154149. maximumSize: number;
  154150. /**
  154151. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154152. */
  154153. step: number;
  154154. /**
  154155. * Gets a string describing the action executed by the current optimization
  154156. * @returns description string
  154157. */
  154158. getDescription(): string;
  154159. /**
  154160. * Creates the TextureOptimization object
  154161. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154162. * @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
  154163. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154164. */
  154165. constructor(
  154166. /**
  154167. * Defines the priority of this optimization (0 by default which means first in the list)
  154168. */
  154169. priority?: number,
  154170. /**
  154171. * 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
  154172. */
  154173. maximumSize?: number,
  154174. /**
  154175. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154176. */
  154177. step?: number);
  154178. /**
  154179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154180. * @param scene defines the current scene where to apply this optimization
  154181. * @param optimizer defines the current optimizer
  154182. * @returns true if everything that can be done was applied
  154183. */
  154184. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154185. }
  154186. /**
  154187. * Defines an optimization used to increase or decrease the rendering resolution
  154188. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154189. */
  154190. export class HardwareScalingOptimization extends SceneOptimization {
  154191. /**
  154192. * Defines the priority of this optimization (0 by default which means first in the list)
  154193. */
  154194. priority: number;
  154195. /**
  154196. * Defines the maximum scale to use (2 by default)
  154197. */
  154198. maximumScale: number;
  154199. /**
  154200. * Defines the step to use between two passes (0.5 by default)
  154201. */
  154202. step: number;
  154203. private _currentScale;
  154204. private _directionOffset;
  154205. /**
  154206. * Gets a string describing the action executed by the current optimization
  154207. * @return description string
  154208. */
  154209. getDescription(): string;
  154210. /**
  154211. * Creates the HardwareScalingOptimization object
  154212. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154213. * @param maximumScale defines the maximum scale to use (2 by default)
  154214. * @param step defines the step to use between two passes (0.5 by default)
  154215. */
  154216. constructor(
  154217. /**
  154218. * Defines the priority of this optimization (0 by default which means first in the list)
  154219. */
  154220. priority?: number,
  154221. /**
  154222. * Defines the maximum scale to use (2 by default)
  154223. */
  154224. maximumScale?: number,
  154225. /**
  154226. * Defines the step to use between two passes (0.5 by default)
  154227. */
  154228. step?: number);
  154229. /**
  154230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154231. * @param scene defines the current scene where to apply this optimization
  154232. * @param optimizer defines the current optimizer
  154233. * @returns true if everything that can be done was applied
  154234. */
  154235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154236. }
  154237. /**
  154238. * Defines an optimization used to remove shadows
  154239. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154240. */
  154241. export class ShadowsOptimization extends SceneOptimization {
  154242. /**
  154243. * Gets a string describing the action executed by the current optimization
  154244. * @return description string
  154245. */
  154246. getDescription(): string;
  154247. /**
  154248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154249. * @param scene defines the current scene where to apply this optimization
  154250. * @param optimizer defines the current optimizer
  154251. * @returns true if everything that can be done was applied
  154252. */
  154253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154254. }
  154255. /**
  154256. * Defines an optimization used to turn post-processes off
  154257. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154258. */
  154259. export class PostProcessesOptimization extends SceneOptimization {
  154260. /**
  154261. * Gets a string describing the action executed by the current optimization
  154262. * @return description string
  154263. */
  154264. getDescription(): string;
  154265. /**
  154266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154267. * @param scene defines the current scene where to apply this optimization
  154268. * @param optimizer defines the current optimizer
  154269. * @returns true if everything that can be done was applied
  154270. */
  154271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154272. }
  154273. /**
  154274. * Defines an optimization used to turn lens flares off
  154275. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154276. */
  154277. export class LensFlaresOptimization extends SceneOptimization {
  154278. /**
  154279. * Gets a string describing the action executed by the current optimization
  154280. * @return description string
  154281. */
  154282. getDescription(): string;
  154283. /**
  154284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154285. * @param scene defines the current scene where to apply this optimization
  154286. * @param optimizer defines the current optimizer
  154287. * @returns true if everything that can be done was applied
  154288. */
  154289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154290. }
  154291. /**
  154292. * Defines an optimization based on user defined callback.
  154293. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154294. */
  154295. export class CustomOptimization extends SceneOptimization {
  154296. /**
  154297. * Callback called to apply the custom optimization.
  154298. */
  154299. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154300. /**
  154301. * Callback called to get custom description
  154302. */
  154303. onGetDescription: () => string;
  154304. /**
  154305. * Gets a string describing the action executed by the current optimization
  154306. * @returns description string
  154307. */
  154308. getDescription(): string;
  154309. /**
  154310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154311. * @param scene defines the current scene where to apply this optimization
  154312. * @param optimizer defines the current optimizer
  154313. * @returns true if everything that can be done was applied
  154314. */
  154315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154316. }
  154317. /**
  154318. * Defines an optimization used to turn particles off
  154319. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154320. */
  154321. export class ParticlesOptimization extends SceneOptimization {
  154322. /**
  154323. * Gets a string describing the action executed by the current optimization
  154324. * @return description string
  154325. */
  154326. getDescription(): string;
  154327. /**
  154328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154329. * @param scene defines the current scene where to apply this optimization
  154330. * @param optimizer defines the current optimizer
  154331. * @returns true if everything that can be done was applied
  154332. */
  154333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154334. }
  154335. /**
  154336. * Defines an optimization used to turn render targets off
  154337. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154338. */
  154339. export class RenderTargetsOptimization extends SceneOptimization {
  154340. /**
  154341. * Gets a string describing the action executed by the current optimization
  154342. * @return description string
  154343. */
  154344. getDescription(): string;
  154345. /**
  154346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154347. * @param scene defines the current scene where to apply this optimization
  154348. * @param optimizer defines the current optimizer
  154349. * @returns true if everything that can be done was applied
  154350. */
  154351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154352. }
  154353. /**
  154354. * Defines an optimization used to merge meshes with compatible materials
  154355. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154356. */
  154357. export class MergeMeshesOptimization extends SceneOptimization {
  154358. private static _UpdateSelectionTree;
  154359. /**
  154360. * Gets or sets a boolean which defines if optimization octree has to be updated
  154361. */
  154362. static get UpdateSelectionTree(): boolean;
  154363. /**
  154364. * Gets or sets a boolean which defines if optimization octree has to be updated
  154365. */
  154366. static set UpdateSelectionTree(value: boolean);
  154367. /**
  154368. * Gets a string describing the action executed by the current optimization
  154369. * @return description string
  154370. */
  154371. getDescription(): string;
  154372. private _canBeMerged;
  154373. /**
  154374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154375. * @param scene defines the current scene where to apply this optimization
  154376. * @param optimizer defines the current optimizer
  154377. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154378. * @returns true if everything that can be done was applied
  154379. */
  154380. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154381. }
  154382. /**
  154383. * Defines a list of options used by SceneOptimizer
  154384. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154385. */
  154386. export class SceneOptimizerOptions {
  154387. /**
  154388. * Defines the target frame rate to reach (60 by default)
  154389. */
  154390. targetFrameRate: number;
  154391. /**
  154392. * Defines the interval between two checkes (2000ms by default)
  154393. */
  154394. trackerDuration: number;
  154395. /**
  154396. * Gets the list of optimizations to apply
  154397. */
  154398. optimizations: SceneOptimization[];
  154399. /**
  154400. * Creates a new list of options used by SceneOptimizer
  154401. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154402. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154403. */
  154404. constructor(
  154405. /**
  154406. * Defines the target frame rate to reach (60 by default)
  154407. */
  154408. targetFrameRate?: number,
  154409. /**
  154410. * Defines the interval between two checkes (2000ms by default)
  154411. */
  154412. trackerDuration?: number);
  154413. /**
  154414. * Add a new optimization
  154415. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154416. * @returns the current SceneOptimizerOptions
  154417. */
  154418. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154419. /**
  154420. * Add a new custom optimization
  154421. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154422. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154423. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154424. * @returns the current SceneOptimizerOptions
  154425. */
  154426. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154427. /**
  154428. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154429. * @param targetFrameRate defines the target frame rate (60 by default)
  154430. * @returns a SceneOptimizerOptions object
  154431. */
  154432. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154433. /**
  154434. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154435. * @param targetFrameRate defines the target frame rate (60 by default)
  154436. * @returns a SceneOptimizerOptions object
  154437. */
  154438. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154439. /**
  154440. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154441. * @param targetFrameRate defines the target frame rate (60 by default)
  154442. * @returns a SceneOptimizerOptions object
  154443. */
  154444. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154445. }
  154446. /**
  154447. * Class used to run optimizations in order to reach a target frame rate
  154448. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154449. */
  154450. export class SceneOptimizer implements IDisposable {
  154451. private _isRunning;
  154452. private _options;
  154453. private _scene;
  154454. private _currentPriorityLevel;
  154455. private _targetFrameRate;
  154456. private _trackerDuration;
  154457. private _currentFrameRate;
  154458. private _sceneDisposeObserver;
  154459. private _improvementMode;
  154460. /**
  154461. * Defines an observable called when the optimizer reaches the target frame rate
  154462. */
  154463. onSuccessObservable: Observable<SceneOptimizer>;
  154464. /**
  154465. * Defines an observable called when the optimizer enables an optimization
  154466. */
  154467. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154468. /**
  154469. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154470. */
  154471. onFailureObservable: Observable<SceneOptimizer>;
  154472. /**
  154473. * Gets a boolean indicating if the optimizer is in improvement mode
  154474. */
  154475. get isInImprovementMode(): boolean;
  154476. /**
  154477. * Gets the current priority level (0 at start)
  154478. */
  154479. get currentPriorityLevel(): number;
  154480. /**
  154481. * Gets the current frame rate checked by the SceneOptimizer
  154482. */
  154483. get currentFrameRate(): number;
  154484. /**
  154485. * Gets or sets the current target frame rate (60 by default)
  154486. */
  154487. get targetFrameRate(): number;
  154488. /**
  154489. * Gets or sets the current target frame rate (60 by default)
  154490. */
  154491. set targetFrameRate(value: number);
  154492. /**
  154493. * Gets or sets the current interval between two checks (every 2000ms by default)
  154494. */
  154495. get trackerDuration(): number;
  154496. /**
  154497. * Gets or sets the current interval between two checks (every 2000ms by default)
  154498. */
  154499. set trackerDuration(value: number);
  154500. /**
  154501. * Gets the list of active optimizations
  154502. */
  154503. get optimizations(): SceneOptimization[];
  154504. /**
  154505. * Creates a new SceneOptimizer
  154506. * @param scene defines the scene to work on
  154507. * @param options defines the options to use with the SceneOptimizer
  154508. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154509. * @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)
  154510. */
  154511. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154512. /**
  154513. * Stops the current optimizer
  154514. */
  154515. stop(): void;
  154516. /**
  154517. * Reset the optimizer to initial step (current priority level = 0)
  154518. */
  154519. reset(): void;
  154520. /**
  154521. * Start the optimizer. By default it will try to reach a specific framerate
  154522. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154523. */
  154524. start(): void;
  154525. private _checkCurrentState;
  154526. /**
  154527. * Release all resources
  154528. */
  154529. dispose(): void;
  154530. /**
  154531. * Helper function to create a SceneOptimizer with one single line of code
  154532. * @param scene defines the scene to work on
  154533. * @param options defines the options to use with the SceneOptimizer
  154534. * @param onSuccess defines a callback to call on success
  154535. * @param onFailure defines a callback to call on failure
  154536. * @returns the new SceneOptimizer object
  154537. */
  154538. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154539. }
  154540. }
  154541. declare module BABYLON {
  154542. /**
  154543. * Class used to serialize a scene into a string
  154544. */
  154545. export class SceneSerializer {
  154546. /**
  154547. * Clear cache used by a previous serialization
  154548. */
  154549. static ClearCache(): void;
  154550. /**
  154551. * Serialize a scene into a JSON compatible object
  154552. * @param scene defines the scene to serialize
  154553. * @returns a JSON compatible object
  154554. */
  154555. static Serialize(scene: Scene): any;
  154556. /**
  154557. * Serialize a mesh into a JSON compatible object
  154558. * @param toSerialize defines the mesh to serialize
  154559. * @param withParents defines if parents must be serialized as well
  154560. * @param withChildren defines if children must be serialized as well
  154561. * @returns a JSON compatible object
  154562. */
  154563. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154564. }
  154565. }
  154566. declare module BABYLON {
  154567. /**
  154568. * Class used to host texture specific utilities
  154569. */
  154570. export class TextureTools {
  154571. /**
  154572. * Uses the GPU to create a copy texture rescaled at a given size
  154573. * @param texture Texture to copy from
  154574. * @param width defines the desired width
  154575. * @param height defines the desired height
  154576. * @param useBilinearMode defines if bilinear mode has to be used
  154577. * @return the generated texture
  154578. */
  154579. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154580. }
  154581. }
  154582. declare module BABYLON {
  154583. /**
  154584. * This represents the different options available for the video capture.
  154585. */
  154586. export interface VideoRecorderOptions {
  154587. /** Defines the mime type of the video. */
  154588. mimeType: string;
  154589. /** Defines the FPS the video should be recorded at. */
  154590. fps: number;
  154591. /** Defines the chunk size for the recording data. */
  154592. recordChunckSize: number;
  154593. /** The audio tracks to attach to the recording. */
  154594. audioTracks?: MediaStreamTrack[];
  154595. }
  154596. /**
  154597. * This can help with recording videos from BabylonJS.
  154598. * This is based on the available WebRTC functionalities of the browser.
  154599. *
  154600. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154601. */
  154602. export class VideoRecorder {
  154603. private static readonly _defaultOptions;
  154604. /**
  154605. * Returns whether or not the VideoRecorder is available in your browser.
  154606. * @param engine Defines the Babylon Engine.
  154607. * @returns true if supported otherwise false.
  154608. */
  154609. static IsSupported(engine: Engine): boolean;
  154610. private readonly _options;
  154611. private _canvas;
  154612. private _mediaRecorder;
  154613. private _recordedChunks;
  154614. private _fileName;
  154615. private _resolve;
  154616. private _reject;
  154617. /**
  154618. * True when a recording is already in progress.
  154619. */
  154620. get isRecording(): boolean;
  154621. /**
  154622. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154623. * @param engine Defines the BabylonJS Engine you wish to record.
  154624. * @param options Defines options that can be used to customize the capture.
  154625. */
  154626. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154627. /**
  154628. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154629. */
  154630. stopRecording(): void;
  154631. /**
  154632. * Starts recording the canvas for a max duration specified in parameters.
  154633. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154634. * If null no automatic download will start and you can rely on the promise to get the data back.
  154635. * @param maxDuration Defines the maximum recording time in seconds.
  154636. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154637. * @return A promise callback at the end of the recording with the video data in Blob.
  154638. */
  154639. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154640. /**
  154641. * Releases internal resources used during the recording.
  154642. */
  154643. dispose(): void;
  154644. private _handleDataAvailable;
  154645. private _handleError;
  154646. private _handleStop;
  154647. }
  154648. }
  154649. declare module BABYLON {
  154650. /**
  154651. * Class containing a set of static utilities functions for screenshots
  154652. */
  154653. export class ScreenshotTools {
  154654. /**
  154655. * Captures a screenshot of the current rendering
  154656. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154657. * @param engine defines the rendering engine
  154658. * @param camera defines the source camera
  154659. * @param size This parameter can be set to a single number or to an object with the
  154660. * following (optional) properties: precision, width, height. If a single number is passed,
  154661. * it will be used for both width and height. If an object is passed, the screenshot size
  154662. * will be derived from the parameters. The precision property is a multiplier allowing
  154663. * rendering at a higher or lower resolution
  154664. * @param successCallback defines the callback receives a single parameter which contains the
  154665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154666. * src parameter of an <img> to display it
  154667. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154668. * Check your browser for supported MIME types
  154669. */
  154670. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154671. /**
  154672. * Captures a screenshot of the current rendering
  154673. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154674. * @param engine defines the rendering engine
  154675. * @param camera defines the source camera
  154676. * @param size This parameter can be set to a single number or to an object with the
  154677. * following (optional) properties: precision, width, height. If a single number is passed,
  154678. * it will be used for both width and height. If an object is passed, the screenshot size
  154679. * will be derived from the parameters. The precision property is a multiplier allowing
  154680. * rendering at a higher or lower resolution
  154681. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154682. * Check your browser for supported MIME types
  154683. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154684. * to the src parameter of an <img> to display it
  154685. */
  154686. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154687. /**
  154688. * Generates an image screenshot from the specified camera.
  154689. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154690. * @param engine The engine to use for rendering
  154691. * @param camera The camera to use for rendering
  154692. * @param size This parameter can be set to a single number or to an object with the
  154693. * following (optional) properties: precision, width, height. If a single number is passed,
  154694. * it will be used for both width and height. If an object is passed, the screenshot size
  154695. * will be derived from the parameters. The precision property is a multiplier allowing
  154696. * rendering at a higher or lower resolution
  154697. * @param successCallback The callback receives a single parameter which contains the
  154698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154699. * src parameter of an <img> to display it
  154700. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154701. * Check your browser for supported MIME types
  154702. * @param samples Texture samples (default: 1)
  154703. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154704. * @param fileName A name for for the downloaded file.
  154705. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154706. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154707. */
  154708. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  154709. /**
  154710. * Generates an image screenshot from the specified camera.
  154711. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154712. * @param engine The engine to use for rendering
  154713. * @param camera The camera to use for rendering
  154714. * @param size This parameter can be set to a single number or to an object with the
  154715. * following (optional) properties: precision, width, height. If a single number is passed,
  154716. * it will be used for both width and height. If an object is passed, the screenshot size
  154717. * will be derived from the parameters. The precision property is a multiplier allowing
  154718. * rendering at a higher or lower resolution
  154719. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154720. * Check your browser for supported MIME types
  154721. * @param samples Texture samples (default: 1)
  154722. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154723. * @param fileName A name for for the downloaded file.
  154724. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154725. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154726. * to the src parameter of an <img> to display it
  154727. */
  154728. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154729. /**
  154730. * Gets height and width for screenshot size
  154731. * @private
  154732. */
  154733. private static _getScreenshotSize;
  154734. }
  154735. }
  154736. declare module BABYLON {
  154737. /**
  154738. * Interface for a data buffer
  154739. */
  154740. export interface IDataBuffer {
  154741. /**
  154742. * Reads bytes from the data buffer.
  154743. * @param byteOffset The byte offset to read
  154744. * @param byteLength The byte length to read
  154745. * @returns A promise that resolves when the bytes are read
  154746. */
  154747. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154748. /**
  154749. * The byte length of the buffer.
  154750. */
  154751. readonly byteLength: number;
  154752. }
  154753. /**
  154754. * Utility class for reading from a data buffer
  154755. */
  154756. export class DataReader {
  154757. /**
  154758. * The data buffer associated with this data reader.
  154759. */
  154760. readonly buffer: IDataBuffer;
  154761. /**
  154762. * The current byte offset from the beginning of the data buffer.
  154763. */
  154764. byteOffset: number;
  154765. private _dataView;
  154766. private _dataByteOffset;
  154767. /**
  154768. * Constructor
  154769. * @param buffer The buffer to read
  154770. */
  154771. constructor(buffer: IDataBuffer);
  154772. /**
  154773. * Loads the given byte length.
  154774. * @param byteLength The byte length to load
  154775. * @returns A promise that resolves when the load is complete
  154776. */
  154777. loadAsync(byteLength: number): Promise<void>;
  154778. /**
  154779. * Read a unsigned 32-bit integer from the currently loaded data range.
  154780. * @returns The 32-bit integer read
  154781. */
  154782. readUint32(): number;
  154783. /**
  154784. * Read a byte array from the currently loaded data range.
  154785. * @param byteLength The byte length to read
  154786. * @returns The byte array read
  154787. */
  154788. readUint8Array(byteLength: number): Uint8Array;
  154789. /**
  154790. * Read a string from the currently loaded data range.
  154791. * @param byteLength The byte length to read
  154792. * @returns The string read
  154793. */
  154794. readString(byteLength: number): string;
  154795. /**
  154796. * Skips the given byte length the currently loaded data range.
  154797. * @param byteLength The byte length to skip
  154798. */
  154799. skipBytes(byteLength: number): void;
  154800. }
  154801. }
  154802. declare module BABYLON {
  154803. /**
  154804. * Class for storing data to local storage if available or in-memory storage otherwise
  154805. */
  154806. export class DataStorage {
  154807. private static _Storage;
  154808. private static _GetStorage;
  154809. /**
  154810. * Reads a string from the data storage
  154811. * @param key The key to read
  154812. * @param defaultValue The value if the key doesn't exist
  154813. * @returns The string value
  154814. */
  154815. static ReadString(key: string, defaultValue: string): string;
  154816. /**
  154817. * Writes a string to the data storage
  154818. * @param key The key to write
  154819. * @param value The value to write
  154820. */
  154821. static WriteString(key: string, value: string): void;
  154822. /**
  154823. * Reads a boolean from the data storage
  154824. * @param key The key to read
  154825. * @param defaultValue The value if the key doesn't exist
  154826. * @returns The boolean value
  154827. */
  154828. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154829. /**
  154830. * Writes a boolean to the data storage
  154831. * @param key The key to write
  154832. * @param value The value to write
  154833. */
  154834. static WriteBoolean(key: string, value: boolean): void;
  154835. /**
  154836. * Reads a number from the data storage
  154837. * @param key The key to read
  154838. * @param defaultValue The value if the key doesn't exist
  154839. * @returns The number value
  154840. */
  154841. static ReadNumber(key: string, defaultValue: number): number;
  154842. /**
  154843. * Writes a number to the data storage
  154844. * @param key The key to write
  154845. * @param value The value to write
  154846. */
  154847. static WriteNumber(key: string, value: number): void;
  154848. }
  154849. }
  154850. declare module BABYLON {
  154851. /**
  154852. * Class used to record delta files between 2 scene states
  154853. */
  154854. export class SceneRecorder {
  154855. private _trackedScene;
  154856. private _savedJSON;
  154857. /**
  154858. * Track a given scene. This means the current scene state will be considered the original state
  154859. * @param scene defines the scene to track
  154860. */
  154861. track(scene: Scene): void;
  154862. /**
  154863. * Get the delta between current state and original state
  154864. * @returns a string containing the delta
  154865. */
  154866. getDelta(): any;
  154867. private _compareArray;
  154868. private _compareObjects;
  154869. private _compareCollections;
  154870. private static GetShadowGeneratorById;
  154871. /**
  154872. * Apply a given delta to a given scene
  154873. * @param deltaJSON defines the JSON containing the delta
  154874. * @param scene defines the scene to apply the delta to
  154875. */
  154876. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154877. private static _ApplyPropertiesToEntity;
  154878. private static _ApplyDeltaForEntity;
  154879. }
  154880. }
  154881. declare module BABYLON {
  154882. /**
  154883. * A 3D trajectory consisting of an order list of vectors describing a
  154884. * path of motion through 3D space.
  154885. */
  154886. export class Trajectory {
  154887. private _points;
  154888. private readonly _segmentLength;
  154889. /**
  154890. * Serialize to JSON.
  154891. * @returns serialized JSON string
  154892. */
  154893. serialize(): string;
  154894. /**
  154895. * Deserialize from JSON.
  154896. * @param json serialized JSON string
  154897. * @returns deserialized Trajectory
  154898. */
  154899. static Deserialize(json: string): Trajectory;
  154900. /**
  154901. * Create a new empty Trajectory.
  154902. * @param segmentLength radius of discretization for Trajectory points
  154903. */
  154904. constructor(segmentLength?: number);
  154905. /**
  154906. * Get the length of the Trajectory.
  154907. * @returns length of the Trajectory
  154908. */
  154909. getLength(): number;
  154910. /**
  154911. * Append a new point to the Trajectory.
  154912. * NOTE: This implementation has many allocations.
  154913. * @param point point to append to the Trajectory
  154914. */
  154915. add(point: DeepImmutable<Vector3>): void;
  154916. /**
  154917. * Create a new Trajectory with a segment length chosen to make it
  154918. * probable that the new Trajectory will have a specified number of
  154919. * segments. This operation is imprecise.
  154920. * @param targetResolution number of segments desired
  154921. * @returns new Trajectory with approximately the requested number of segments
  154922. */
  154923. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154924. /**
  154925. * Convert Trajectory segments into tokenized representation. This
  154926. * representation is an array of numbers where each nth number is the
  154927. * index of the token which is most similar to the nth segment of the
  154928. * Trajectory.
  154929. * @param tokens list of vectors which serve as discrete tokens
  154930. * @returns list of indices of most similar token per segment
  154931. */
  154932. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154933. private static _forwardDir;
  154934. private static _inverseFromVec;
  154935. private static _upDir;
  154936. private static _fromToVec;
  154937. private static _lookMatrix;
  154938. /**
  154939. * Transform the rotation (i.e., direction) of a segment to isolate
  154940. * the relative transformation represented by the segment. This operation
  154941. * may or may not succeed due to singularities in the equations that define
  154942. * motion relativity in this context.
  154943. * @param priorVec the origin of the prior segment
  154944. * @param fromVec the origin of the current segment
  154945. * @param toVec the destination of the current segment
  154946. * @param result reference to output variable
  154947. * @returns whether or not transformation was successful
  154948. */
  154949. private static _transformSegmentDirToRef;
  154950. private static _bestMatch;
  154951. private static _score;
  154952. private static _bestScore;
  154953. /**
  154954. * Determine which token vector is most similar to the
  154955. * segment vector.
  154956. * @param segment segment vector
  154957. * @param tokens token vector list
  154958. * @returns index of the most similar token to the segment
  154959. */
  154960. private static _tokenizeSegment;
  154961. }
  154962. /**
  154963. * Class representing a set of known, named trajectories to which Trajectories can be
  154964. * added and using which Trajectories can be recognized.
  154965. */
  154966. export class TrajectoryClassifier {
  154967. private _maximumAllowableMatchCost;
  154968. private _vector3Alphabet;
  154969. private _levenshteinAlphabet;
  154970. private _nameToDescribedTrajectory;
  154971. /**
  154972. * Serialize to JSON.
  154973. * @returns JSON serialization
  154974. */
  154975. serialize(): string;
  154976. /**
  154977. * Deserialize from JSON.
  154978. * @param json JSON serialization
  154979. * @returns deserialized TrajectorySet
  154980. */
  154981. static Deserialize(json: string): TrajectoryClassifier;
  154982. /**
  154983. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  154984. * VERY naive, need to be generating these things from known
  154985. * sets. Better version later, probably eliminating this one.
  154986. * @returns auto-generated TrajectorySet
  154987. */
  154988. static Generate(): TrajectoryClassifier;
  154989. private constructor();
  154990. /**
  154991. * Add a new Trajectory to the set with a given name.
  154992. * @param trajectory new Trajectory to be added
  154993. * @param classification name to which to add the Trajectory
  154994. */
  154995. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  154996. /**
  154997. * Remove a known named trajectory and all Trajectories associated with it.
  154998. * @param classification name to remove
  154999. * @returns whether anything was removed
  155000. */
  155001. deleteClassification(classification: string): boolean;
  155002. /**
  155003. * Attempt to recognize a Trajectory from among all the classifications
  155004. * already known to the classifier.
  155005. * @param trajectory Trajectory to be recognized
  155006. * @returns classification of Trajectory if recognized, null otherwise
  155007. */
  155008. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155009. }
  155010. }
  155011. declare module BABYLON {
  155012. /**
  155013. * An interface for all Hit test features
  155014. */
  155015. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155016. /**
  155017. * Triggered when new babylon (transformed) hit test results are available
  155018. */
  155019. onHitTestResultObservable: Observable<T[]>;
  155020. }
  155021. /**
  155022. * Options used for hit testing
  155023. */
  155024. export interface IWebXRLegacyHitTestOptions {
  155025. /**
  155026. * Only test when user interacted with the scene. Default - hit test every frame
  155027. */
  155028. testOnPointerDownOnly?: boolean;
  155029. /**
  155030. * The node to use to transform the local results to world coordinates
  155031. */
  155032. worldParentNode?: TransformNode;
  155033. }
  155034. /**
  155035. * Interface defining the babylon result of raycasting/hit-test
  155036. */
  155037. export interface IWebXRLegacyHitResult {
  155038. /**
  155039. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155040. */
  155041. transformationMatrix: Matrix;
  155042. /**
  155043. * The native hit test result
  155044. */
  155045. xrHitResult: XRHitResult | XRHitTestResult;
  155046. }
  155047. /**
  155048. * The currently-working hit-test module.
  155049. * Hit test (or Ray-casting) is used to interact with the real world.
  155050. * For further information read here - https://github.com/immersive-web/hit-test
  155051. */
  155052. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155053. /**
  155054. * options to use when constructing this feature
  155055. */
  155056. readonly options: IWebXRLegacyHitTestOptions;
  155057. private _direction;
  155058. private _mat;
  155059. private _onSelectEnabled;
  155060. private _origin;
  155061. /**
  155062. * The module's name
  155063. */
  155064. static readonly Name: string;
  155065. /**
  155066. * The (Babylon) version of this module.
  155067. * This is an integer representing the implementation version.
  155068. * This number does not correspond to the WebXR specs version
  155069. */
  155070. static readonly Version: number;
  155071. /**
  155072. * Populated with the last native XR Hit Results
  155073. */
  155074. lastNativeXRHitResults: XRHitResult[];
  155075. /**
  155076. * Triggered when new babylon (transformed) hit test results are available
  155077. */
  155078. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155079. /**
  155080. * Creates a new instance of the (legacy version) hit test feature
  155081. * @param _xrSessionManager an instance of WebXRSessionManager
  155082. * @param options options to use when constructing this feature
  155083. */
  155084. constructor(_xrSessionManager: WebXRSessionManager,
  155085. /**
  155086. * options to use when constructing this feature
  155087. */
  155088. options?: IWebXRLegacyHitTestOptions);
  155089. /**
  155090. * execute a hit test with an XR Ray
  155091. *
  155092. * @param xrSession a native xrSession that will execute this hit test
  155093. * @param xrRay the ray (position and direction) to use for ray-casting
  155094. * @param referenceSpace native XR reference space to use for the hit-test
  155095. * @param filter filter function that will filter the results
  155096. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155097. */
  155098. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155099. /**
  155100. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155101. * @param event the (select) event to use to select with
  155102. * @param referenceSpace the reference space to use for this hit test
  155103. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155104. */
  155105. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155106. /**
  155107. * attach this feature
  155108. * Will usually be called by the features manager
  155109. *
  155110. * @returns true if successful.
  155111. */
  155112. attach(): boolean;
  155113. /**
  155114. * detach this feature.
  155115. * Will usually be called by the features manager
  155116. *
  155117. * @returns true if successful.
  155118. */
  155119. detach(): boolean;
  155120. /**
  155121. * Dispose this feature and all of the resources attached
  155122. */
  155123. dispose(): void;
  155124. protected _onXRFrame(frame: XRFrame): void;
  155125. private _onHitTestResults;
  155126. private _onSelect;
  155127. }
  155128. }
  155129. declare module BABYLON {
  155130. /**
  155131. * Options used for hit testing (version 2)
  155132. */
  155133. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155134. /**
  155135. * Do not create a permanent hit test. Will usually be used when only
  155136. * transient inputs are needed.
  155137. */
  155138. disablePermanentHitTest?: boolean;
  155139. /**
  155140. * Enable transient (for example touch-based) hit test inspections
  155141. */
  155142. enableTransientHitTest?: boolean;
  155143. /**
  155144. * Offset ray for the permanent hit test
  155145. */
  155146. offsetRay?: Vector3;
  155147. /**
  155148. * Offset ray for the transient hit test
  155149. */
  155150. transientOffsetRay?: Vector3;
  155151. /**
  155152. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155153. */
  155154. useReferenceSpace?: boolean;
  155155. /**
  155156. * Override the default entity type(s) of the hit-test result
  155157. */
  155158. entityTypes?: XRHitTestTrackableType[];
  155159. }
  155160. /**
  155161. * Interface defining the babylon result of hit-test
  155162. */
  155163. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155164. /**
  155165. * The input source that generated this hit test (if transient)
  155166. */
  155167. inputSource?: XRInputSource;
  155168. /**
  155169. * Is this a transient hit test
  155170. */
  155171. isTransient?: boolean;
  155172. /**
  155173. * Position of the hit test result
  155174. */
  155175. position: Vector3;
  155176. /**
  155177. * Rotation of the hit test result
  155178. */
  155179. rotationQuaternion: Quaternion;
  155180. /**
  155181. * The native hit test result
  155182. */
  155183. xrHitResult: XRHitTestResult;
  155184. }
  155185. /**
  155186. * The currently-working hit-test module.
  155187. * Hit test (or Ray-casting) is used to interact with the real world.
  155188. * For further information read here - https://github.com/immersive-web/hit-test
  155189. *
  155190. * Tested on chrome (mobile) 80.
  155191. */
  155192. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155193. /**
  155194. * options to use when constructing this feature
  155195. */
  155196. readonly options: IWebXRHitTestOptions;
  155197. private _tmpMat;
  155198. private _tmpPos;
  155199. private _tmpQuat;
  155200. private _transientXrHitTestSource;
  155201. private _xrHitTestSource;
  155202. private initHitTestSource;
  155203. /**
  155204. * The module's name
  155205. */
  155206. static readonly Name: string;
  155207. /**
  155208. * The (Babylon) version of this module.
  155209. * This is an integer representing the implementation version.
  155210. * This number does not correspond to the WebXR specs version
  155211. */
  155212. static readonly Version: number;
  155213. /**
  155214. * When set to true, each hit test will have its own position/rotation objects
  155215. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155216. * the developers will clone them or copy them as they see fit.
  155217. */
  155218. autoCloneTransformation: boolean;
  155219. /**
  155220. * Triggered when new babylon (transformed) hit test results are available
  155221. * Note - this will be called when results come back from the device. It can be an empty array!!
  155222. */
  155223. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155224. /**
  155225. * Use this to temporarily pause hit test checks.
  155226. */
  155227. paused: boolean;
  155228. /**
  155229. * Creates a new instance of the hit test feature
  155230. * @param _xrSessionManager an instance of WebXRSessionManager
  155231. * @param options options to use when constructing this feature
  155232. */
  155233. constructor(_xrSessionManager: WebXRSessionManager,
  155234. /**
  155235. * options to use when constructing this feature
  155236. */
  155237. options?: IWebXRHitTestOptions);
  155238. /**
  155239. * attach this feature
  155240. * Will usually be called by the features manager
  155241. *
  155242. * @returns true if successful.
  155243. */
  155244. attach(): boolean;
  155245. /**
  155246. * detach this feature.
  155247. * Will usually be called by the features manager
  155248. *
  155249. * @returns true if successful.
  155250. */
  155251. detach(): boolean;
  155252. /**
  155253. * Dispose this feature and all of the resources attached
  155254. */
  155255. dispose(): void;
  155256. protected _onXRFrame(frame: XRFrame): void;
  155257. private _processWebXRHitTestResult;
  155258. }
  155259. }
  155260. declare module BABYLON {
  155261. /**
  155262. * Configuration options of the anchor system
  155263. */
  155264. export interface IWebXRAnchorSystemOptions {
  155265. /**
  155266. * a node that will be used to convert local to world coordinates
  155267. */
  155268. worldParentNode?: TransformNode;
  155269. /**
  155270. * If set to true a reference of the created anchors will be kept until the next session starts
  155271. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155272. */
  155273. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155274. }
  155275. /**
  155276. * A babylon container for an XR Anchor
  155277. */
  155278. export interface IWebXRAnchor {
  155279. /**
  155280. * A babylon-assigned ID for this anchor
  155281. */
  155282. id: number;
  155283. /**
  155284. * Transformation matrix to apply to an object attached to this anchor
  155285. */
  155286. transformationMatrix: Matrix;
  155287. /**
  155288. * The native anchor object
  155289. */
  155290. xrAnchor: XRAnchor;
  155291. /**
  155292. * if defined, this object will be constantly updated by the anchor's position and rotation
  155293. */
  155294. attachedNode?: TransformNode;
  155295. }
  155296. /**
  155297. * An implementation of the anchor system for WebXR.
  155298. * For further information see https://github.com/immersive-web/anchors/
  155299. */
  155300. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155301. private _options;
  155302. private _lastFrameDetected;
  155303. private _trackedAnchors;
  155304. private _referenceSpaceForFrameAnchors;
  155305. private _futureAnchors;
  155306. /**
  155307. * The module's name
  155308. */
  155309. static readonly Name: string;
  155310. /**
  155311. * The (Babylon) version of this module.
  155312. * This is an integer representing the implementation version.
  155313. * This number does not correspond to the WebXR specs version
  155314. */
  155315. static readonly Version: number;
  155316. /**
  155317. * Observers registered here will be executed when a new anchor was added to the session
  155318. */
  155319. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155320. /**
  155321. * Observers registered here will be executed when an anchor was removed from the session
  155322. */
  155323. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155324. /**
  155325. * Observers registered here will be executed when an existing anchor updates
  155326. * This can execute N times every frame
  155327. */
  155328. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155329. /**
  155330. * Set the reference space to use for anchor creation, when not using a hit test.
  155331. * Will default to the session's reference space if not defined
  155332. */
  155333. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155334. /**
  155335. * constructs a new anchor system
  155336. * @param _xrSessionManager an instance of WebXRSessionManager
  155337. * @param _options configuration object for this feature
  155338. */
  155339. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155340. private _tmpVector;
  155341. private _tmpQuaternion;
  155342. private _populateTmpTransformation;
  155343. /**
  155344. * Create a new anchor point using a hit test result at a specific point in the scene
  155345. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155346. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155347. *
  155348. * @param hitTestResult The hit test result to use for this anchor creation
  155349. * @param position an optional position offset for this anchor
  155350. * @param rotationQuaternion an optional rotation offset for this anchor
  155351. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155352. */
  155353. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155354. /**
  155355. * Add a new anchor at a specific position and rotation
  155356. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155357. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155358. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155359. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155360. *
  155361. * @param position the position in which to add an anchor
  155362. * @param rotationQuaternion an optional rotation for the anchor transformation
  155363. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155364. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155365. */
  155366. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155367. /**
  155368. * detach this feature.
  155369. * Will usually be called by the features manager
  155370. *
  155371. * @returns true if successful.
  155372. */
  155373. detach(): boolean;
  155374. /**
  155375. * Dispose this feature and all of the resources attached
  155376. */
  155377. dispose(): void;
  155378. protected _onXRFrame(frame: XRFrame): void;
  155379. /**
  155380. * avoiding using Array.find for global support.
  155381. * @param xrAnchor the plane to find in the array
  155382. */
  155383. private _findIndexInAnchorArray;
  155384. private _updateAnchorWithXRFrame;
  155385. private _createAnchorAtTransformation;
  155386. }
  155387. }
  155388. declare module BABYLON {
  155389. /**
  155390. * Options used in the plane detector module
  155391. */
  155392. export interface IWebXRPlaneDetectorOptions {
  155393. /**
  155394. * The node to use to transform the local results to world coordinates
  155395. */
  155396. worldParentNode?: TransformNode;
  155397. /**
  155398. * If set to true a reference of the created planes will be kept until the next session starts
  155399. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155400. */
  155401. doNotRemovePlanesOnSessionEnded?: boolean;
  155402. }
  155403. /**
  155404. * A babylon interface for a WebXR plane.
  155405. * A Plane is actually a polygon, built from N points in space
  155406. *
  155407. * Supported in chrome 79, not supported in canary 81 ATM
  155408. */
  155409. export interface IWebXRPlane {
  155410. /**
  155411. * a babylon-assigned ID for this polygon
  155412. */
  155413. id: number;
  155414. /**
  155415. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155416. */
  155417. polygonDefinition: Array<Vector3>;
  155418. /**
  155419. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155420. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155421. */
  155422. transformationMatrix: Matrix;
  155423. /**
  155424. * the native xr-plane object
  155425. */
  155426. xrPlane: XRPlane;
  155427. }
  155428. /**
  155429. * The plane detector is used to detect planes in the real world when in AR
  155430. * For more information see https://github.com/immersive-web/real-world-geometry/
  155431. */
  155432. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155433. private _options;
  155434. private _detectedPlanes;
  155435. private _enabled;
  155436. private _lastFrameDetected;
  155437. /**
  155438. * The module's name
  155439. */
  155440. static readonly Name: string;
  155441. /**
  155442. * The (Babylon) version of this module.
  155443. * This is an integer representing the implementation version.
  155444. * This number does not correspond to the WebXR specs version
  155445. */
  155446. static readonly Version: number;
  155447. /**
  155448. * Observers registered here will be executed when a new plane was added to the session
  155449. */
  155450. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155451. /**
  155452. * Observers registered here will be executed when a plane is no longer detected in the session
  155453. */
  155454. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155455. /**
  155456. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155457. * This can execute N times every frame
  155458. */
  155459. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155460. /**
  155461. * construct a new Plane Detector
  155462. * @param _xrSessionManager an instance of xr Session manager
  155463. * @param _options configuration to use when constructing this feature
  155464. */
  155465. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155466. /**
  155467. * detach this feature.
  155468. * Will usually be called by the features manager
  155469. *
  155470. * @returns true if successful.
  155471. */
  155472. detach(): boolean;
  155473. /**
  155474. * Dispose this feature and all of the resources attached
  155475. */
  155476. dispose(): void;
  155477. protected _onXRFrame(frame: XRFrame): void;
  155478. private _init;
  155479. private _updatePlaneWithXRPlane;
  155480. /**
  155481. * avoiding using Array.find for global support.
  155482. * @param xrPlane the plane to find in the array
  155483. */
  155484. private findIndexInPlaneArray;
  155485. }
  155486. }
  155487. declare module BABYLON {
  155488. /**
  155489. * Options interface for the background remover plugin
  155490. */
  155491. export interface IWebXRBackgroundRemoverOptions {
  155492. /**
  155493. * Further background meshes to disable when entering AR
  155494. */
  155495. backgroundMeshes?: AbstractMesh[];
  155496. /**
  155497. * flags to configure the removal of the environment helper.
  155498. * If not set, the entire background will be removed. If set, flags should be set as well.
  155499. */
  155500. environmentHelperRemovalFlags?: {
  155501. /**
  155502. * Should the skybox be removed (default false)
  155503. */
  155504. skyBox?: boolean;
  155505. /**
  155506. * Should the ground be removed (default false)
  155507. */
  155508. ground?: boolean;
  155509. };
  155510. /**
  155511. * don't disable the environment helper
  155512. */
  155513. ignoreEnvironmentHelper?: boolean;
  155514. }
  155515. /**
  155516. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155517. */
  155518. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155519. /**
  155520. * read-only options to be used in this module
  155521. */
  155522. readonly options: IWebXRBackgroundRemoverOptions;
  155523. /**
  155524. * The module's name
  155525. */
  155526. static readonly Name: string;
  155527. /**
  155528. * The (Babylon) version of this module.
  155529. * This is an integer representing the implementation version.
  155530. * This number does not correspond to the WebXR specs version
  155531. */
  155532. static readonly Version: number;
  155533. /**
  155534. * registered observers will be triggered when the background state changes
  155535. */
  155536. onBackgroundStateChangedObservable: Observable<boolean>;
  155537. /**
  155538. * constructs a new background remover module
  155539. * @param _xrSessionManager the session manager for this module
  155540. * @param options read-only options to be used in this module
  155541. */
  155542. constructor(_xrSessionManager: WebXRSessionManager,
  155543. /**
  155544. * read-only options to be used in this module
  155545. */
  155546. options?: IWebXRBackgroundRemoverOptions);
  155547. /**
  155548. * attach this feature
  155549. * Will usually be called by the features manager
  155550. *
  155551. * @returns true if successful.
  155552. */
  155553. attach(): boolean;
  155554. /**
  155555. * detach this feature.
  155556. * Will usually be called by the features manager
  155557. *
  155558. * @returns true if successful.
  155559. */
  155560. detach(): boolean;
  155561. /**
  155562. * Dispose this feature and all of the resources attached
  155563. */
  155564. dispose(): void;
  155565. protected _onXRFrame(_xrFrame: XRFrame): void;
  155566. private _setBackgroundState;
  155567. }
  155568. }
  155569. declare module BABYLON {
  155570. /**
  155571. * Options for the controller physics feature
  155572. */
  155573. export class IWebXRControllerPhysicsOptions {
  155574. /**
  155575. * Should the headset get its own impostor
  155576. */
  155577. enableHeadsetImpostor?: boolean;
  155578. /**
  155579. * Optional parameters for the headset impostor
  155580. */
  155581. headsetImpostorParams?: {
  155582. /**
  155583. * The type of impostor to create. Default is sphere
  155584. */
  155585. impostorType: number;
  155586. /**
  155587. * the size of the impostor. Defaults to 10cm
  155588. */
  155589. impostorSize?: number | {
  155590. width: number;
  155591. height: number;
  155592. depth: number;
  155593. };
  155594. /**
  155595. * Friction definitions
  155596. */
  155597. friction?: number;
  155598. /**
  155599. * Restitution
  155600. */
  155601. restitution?: number;
  155602. };
  155603. /**
  155604. * The physics properties of the future impostors
  155605. */
  155606. physicsProperties?: {
  155607. /**
  155608. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155609. * Note that this requires a physics engine that supports mesh impostors!
  155610. */
  155611. useControllerMesh?: boolean;
  155612. /**
  155613. * The type of impostor to create. Default is sphere
  155614. */
  155615. impostorType?: number;
  155616. /**
  155617. * the size of the impostor. Defaults to 10cm
  155618. */
  155619. impostorSize?: number | {
  155620. width: number;
  155621. height: number;
  155622. depth: number;
  155623. };
  155624. /**
  155625. * Friction definitions
  155626. */
  155627. friction?: number;
  155628. /**
  155629. * Restitution
  155630. */
  155631. restitution?: number;
  155632. };
  155633. /**
  155634. * the xr input to use with this pointer selection
  155635. */
  155636. xrInput: WebXRInput;
  155637. }
  155638. /**
  155639. * Add physics impostor to your webxr controllers,
  155640. * including naive calculation of their linear and angular velocity
  155641. */
  155642. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155643. private readonly _options;
  155644. private _attachController;
  155645. private _controllers;
  155646. private _debugMode;
  155647. private _delta;
  155648. private _headsetImpostor?;
  155649. private _headsetMesh?;
  155650. private _lastTimestamp;
  155651. private _tmpQuaternion;
  155652. private _tmpVector;
  155653. /**
  155654. * The module's name
  155655. */
  155656. static readonly Name: string;
  155657. /**
  155658. * The (Babylon) version of this module.
  155659. * This is an integer representing the implementation version.
  155660. * This number does not correspond to the webxr specs version
  155661. */
  155662. static readonly Version: number;
  155663. /**
  155664. * Construct a new Controller Physics Feature
  155665. * @param _xrSessionManager the corresponding xr session manager
  155666. * @param _options options to create this feature with
  155667. */
  155668. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155669. /**
  155670. * @hidden
  155671. * enable debugging - will show console outputs and the impostor mesh
  155672. */
  155673. _enablePhysicsDebug(): void;
  155674. /**
  155675. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155676. * @param xrController the controller to add
  155677. */
  155678. addController(xrController: WebXRInputSource): void;
  155679. /**
  155680. * attach this feature
  155681. * Will usually be called by the features manager
  155682. *
  155683. * @returns true if successful.
  155684. */
  155685. attach(): boolean;
  155686. /**
  155687. * detach this feature.
  155688. * Will usually be called by the features manager
  155689. *
  155690. * @returns true if successful.
  155691. */
  155692. detach(): boolean;
  155693. /**
  155694. * Get the headset impostor, if enabled
  155695. * @returns the impostor
  155696. */
  155697. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155698. /**
  155699. * Get the physics impostor of a specific controller.
  155700. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155701. * @param controller the controller or the controller id of which to get the impostor
  155702. * @returns the impostor or null
  155703. */
  155704. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155705. /**
  155706. * Update the physics properties provided in the constructor
  155707. * @param newProperties the new properties object
  155708. */
  155709. setPhysicsProperties(newProperties: {
  155710. impostorType?: number;
  155711. impostorSize?: number | {
  155712. width: number;
  155713. height: number;
  155714. depth: number;
  155715. };
  155716. friction?: number;
  155717. restitution?: number;
  155718. }): void;
  155719. protected _onXRFrame(_xrFrame: any): void;
  155720. private _detachController;
  155721. }
  155722. }
  155723. declare module BABYLON {
  155724. /**
  155725. * A babylon interface for a "WebXR" feature point.
  155726. * Represents the position and confidence value of a given feature point.
  155727. */
  155728. export interface IWebXRFeaturePoint {
  155729. /**
  155730. * Represents the position of the feature point in world space.
  155731. */
  155732. position: Vector3;
  155733. /**
  155734. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155735. */
  155736. confidenceValue: number;
  155737. }
  155738. /**
  155739. * The feature point system is used to detect feature points from real world geometry.
  155740. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155741. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155742. */
  155743. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155744. private _enabled;
  155745. private _featurePointCloud;
  155746. /**
  155747. * The module's name
  155748. */
  155749. static readonly Name: string;
  155750. /**
  155751. * The (Babylon) version of this module.
  155752. * This is an integer representing the implementation version.
  155753. * This number does not correspond to the WebXR specs version
  155754. */
  155755. static readonly Version: number;
  155756. /**
  155757. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155758. * Will notify the observers about which feature points have been added.
  155759. */
  155760. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155761. /**
  155762. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155763. * Will notify the observers about which feature points have been updated.
  155764. */
  155765. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155766. /**
  155767. * The current feature point cloud maintained across frames.
  155768. */
  155769. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155770. /**
  155771. * construct the feature point system
  155772. * @param _xrSessionManager an instance of xr Session manager
  155773. */
  155774. constructor(_xrSessionManager: WebXRSessionManager);
  155775. /**
  155776. * Detach this feature.
  155777. * Will usually be called by the features manager
  155778. *
  155779. * @returns true if successful.
  155780. */
  155781. detach(): boolean;
  155782. /**
  155783. * Dispose this feature and all of the resources attached
  155784. */
  155785. dispose(): void;
  155786. /**
  155787. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155788. */
  155789. protected _onXRFrame(frame: XRFrame): void;
  155790. /**
  155791. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155792. */
  155793. private _init;
  155794. }
  155795. }
  155796. declare module BABYLON {
  155797. /**
  155798. * Configuration interface for the hand tracking feature
  155799. */
  155800. export interface IWebXRHandTrackingOptions {
  155801. /**
  155802. * The xrInput that will be used as source for new hands
  155803. */
  155804. xrInput: WebXRInput;
  155805. /**
  155806. * Configuration object for the joint meshes
  155807. */
  155808. jointMeshes?: {
  155809. /**
  155810. * Should the meshes created be invisible (defaults to false)
  155811. */
  155812. invisible?: boolean;
  155813. /**
  155814. * A source mesh to be used to create instances. Defaults to a sphere.
  155815. * This mesh will be the source for all other (25) meshes.
  155816. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155817. */
  155818. sourceMesh?: Mesh;
  155819. /**
  155820. * Should the source mesh stay visible. Defaults to false
  155821. */
  155822. keepOriginalVisible?: boolean;
  155823. /**
  155824. * Scale factor for all instances (defaults to 2)
  155825. */
  155826. scaleFactor?: number;
  155827. /**
  155828. * Should each instance have its own physics impostor
  155829. */
  155830. enablePhysics?: boolean;
  155831. /**
  155832. * If enabled, override default physics properties
  155833. */
  155834. physicsProps?: {
  155835. friction?: number;
  155836. restitution?: number;
  155837. impostorType?: number;
  155838. };
  155839. /**
  155840. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155841. */
  155842. handMesh?: AbstractMesh;
  155843. };
  155844. }
  155845. /**
  155846. * Parts of the hands divided to writs and finger names
  155847. */
  155848. export const enum HandPart {
  155849. /**
  155850. * HandPart - Wrist
  155851. */
  155852. WRIST = "wrist",
  155853. /**
  155854. * HandPart - The THumb
  155855. */
  155856. THUMB = "thumb",
  155857. /**
  155858. * HandPart - Index finger
  155859. */
  155860. INDEX = "index",
  155861. /**
  155862. * HandPart - Middle finger
  155863. */
  155864. MIDDLE = "middle",
  155865. /**
  155866. * HandPart - Ring finger
  155867. */
  155868. RING = "ring",
  155869. /**
  155870. * HandPart - Little finger
  155871. */
  155872. LITTLE = "little"
  155873. }
  155874. /**
  155875. * Representing a single hand (with its corresponding native XRHand object)
  155876. */
  155877. export class WebXRHand implements IDisposable {
  155878. /** the controller to which the hand correlates */
  155879. readonly xrController: WebXRInputSource;
  155880. /** the meshes to be used to track the hand joints */
  155881. readonly trackedMeshes: AbstractMesh[];
  155882. /**
  155883. * Hand-parts definition (key is HandPart)
  155884. */
  155885. handPartsDefinition: {
  155886. [key: string]: number[];
  155887. };
  155888. /**
  155889. * Populate the HandPartsDefinition object.
  155890. * This is called as a side effect since certain browsers don't have XRHand defined.
  155891. */
  155892. private generateHandPartsDefinition;
  155893. /**
  155894. * Construct a new hand object
  155895. * @param xrController the controller to which the hand correlates
  155896. * @param trackedMeshes the meshes to be used to track the hand joints
  155897. */
  155898. constructor(
  155899. /** the controller to which the hand correlates */
  155900. xrController: WebXRInputSource,
  155901. /** the meshes to be used to track the hand joints */
  155902. trackedMeshes: AbstractMesh[]);
  155903. /**
  155904. * Update this hand from the latest xr frame
  155905. * @param xrFrame xrFrame to update from
  155906. * @param referenceSpace The current viewer reference space
  155907. * @param scaleFactor optional scale factor for the meshes
  155908. */
  155909. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155910. /**
  155911. * Get meshes of part of the hand
  155912. * @param part the part of hand to get
  155913. * @returns An array of meshes that correlate to the hand part requested
  155914. */
  155915. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155916. /**
  155917. * Dispose this Hand object
  155918. */
  155919. dispose(): void;
  155920. }
  155921. /**
  155922. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155923. */
  155924. export class WebXRHandTracking extends WebXRAbstractFeature {
  155925. /**
  155926. * options to use when constructing this feature
  155927. */
  155928. readonly options: IWebXRHandTrackingOptions;
  155929. private static _idCounter;
  155930. /**
  155931. * The module's name
  155932. */
  155933. static readonly Name: string;
  155934. /**
  155935. * The (Babylon) version of this module.
  155936. * This is an integer representing the implementation version.
  155937. * This number does not correspond to the WebXR specs version
  155938. */
  155939. static readonly Version: number;
  155940. /**
  155941. * This observable will notify registered observers when a new hand object was added and initialized
  155942. */
  155943. onHandAddedObservable: Observable<WebXRHand>;
  155944. /**
  155945. * This observable will notify its observers right before the hand object is disposed
  155946. */
  155947. onHandRemovedObservable: Observable<WebXRHand>;
  155948. private _hands;
  155949. /**
  155950. * Creates a new instance of the hit test feature
  155951. * @param _xrSessionManager an instance of WebXRSessionManager
  155952. * @param options options to use when constructing this feature
  155953. */
  155954. constructor(_xrSessionManager: WebXRSessionManager,
  155955. /**
  155956. * options to use when constructing this feature
  155957. */
  155958. options: IWebXRHandTrackingOptions);
  155959. /**
  155960. * Check if the needed objects are defined.
  155961. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155962. */
  155963. isCompatible(): boolean;
  155964. /**
  155965. * attach this feature
  155966. * Will usually be called by the features manager
  155967. *
  155968. * @returns true if successful.
  155969. */
  155970. attach(): boolean;
  155971. /**
  155972. * detach this feature.
  155973. * Will usually be called by the features manager
  155974. *
  155975. * @returns true if successful.
  155976. */
  155977. detach(): boolean;
  155978. /**
  155979. * Dispose this feature and all of the resources attached
  155980. */
  155981. dispose(): void;
  155982. /**
  155983. * Get the hand object according to the controller id
  155984. * @param controllerId the controller id to which we want to get the hand
  155985. * @returns null if not found or the WebXRHand object if found
  155986. */
  155987. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155988. /**
  155989. * Get a hand object according to the requested handedness
  155990. * @param handedness the handedness to request
  155991. * @returns null if not found or the WebXRHand object if found
  155992. */
  155993. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155994. protected _onXRFrame(_xrFrame: XRFrame): void;
  155995. private _attachHand;
  155996. private _detachHand;
  155997. }
  155998. }
  155999. declare module BABYLON {
  156000. /**
  156001. * The motion controller class for all microsoft mixed reality controllers
  156002. */
  156003. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156004. protected readonly _mapping: {
  156005. defaultButton: {
  156006. valueNodeName: string;
  156007. unpressedNodeName: string;
  156008. pressedNodeName: string;
  156009. };
  156010. defaultAxis: {
  156011. valueNodeName: string;
  156012. minNodeName: string;
  156013. maxNodeName: string;
  156014. };
  156015. buttons: {
  156016. "xr-standard-trigger": {
  156017. rootNodeName: string;
  156018. componentProperty: string;
  156019. states: string[];
  156020. };
  156021. "xr-standard-squeeze": {
  156022. rootNodeName: string;
  156023. componentProperty: string;
  156024. states: string[];
  156025. };
  156026. "xr-standard-touchpad": {
  156027. rootNodeName: string;
  156028. labelAnchorNodeName: string;
  156029. touchPointNodeName: string;
  156030. };
  156031. "xr-standard-thumbstick": {
  156032. rootNodeName: string;
  156033. componentProperty: string;
  156034. states: string[];
  156035. };
  156036. };
  156037. axes: {
  156038. "xr-standard-touchpad": {
  156039. "x-axis": {
  156040. rootNodeName: string;
  156041. };
  156042. "y-axis": {
  156043. rootNodeName: string;
  156044. };
  156045. };
  156046. "xr-standard-thumbstick": {
  156047. "x-axis": {
  156048. rootNodeName: string;
  156049. };
  156050. "y-axis": {
  156051. rootNodeName: string;
  156052. };
  156053. };
  156054. };
  156055. };
  156056. /**
  156057. * The base url used to load the left and right controller models
  156058. */
  156059. static MODEL_BASE_URL: string;
  156060. /**
  156061. * The name of the left controller model file
  156062. */
  156063. static MODEL_LEFT_FILENAME: string;
  156064. /**
  156065. * The name of the right controller model file
  156066. */
  156067. static MODEL_RIGHT_FILENAME: string;
  156068. profileId: string;
  156069. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156070. protected _getFilenameAndPath(): {
  156071. filename: string;
  156072. path: string;
  156073. };
  156074. protected _getModelLoadingConstraints(): boolean;
  156075. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156076. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156077. protected _updateModel(): void;
  156078. }
  156079. }
  156080. declare module BABYLON {
  156081. /**
  156082. * The motion controller class for oculus touch (quest, rift).
  156083. * This class supports legacy mapping as well the standard xr mapping
  156084. */
  156085. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156086. private _forceLegacyControllers;
  156087. private _modelRootNode;
  156088. /**
  156089. * The base url used to load the left and right controller models
  156090. */
  156091. static MODEL_BASE_URL: string;
  156092. /**
  156093. * The name of the left controller model file
  156094. */
  156095. static MODEL_LEFT_FILENAME: string;
  156096. /**
  156097. * The name of the right controller model file
  156098. */
  156099. static MODEL_RIGHT_FILENAME: string;
  156100. /**
  156101. * Base Url for the Quest controller model.
  156102. */
  156103. static QUEST_MODEL_BASE_URL: string;
  156104. profileId: string;
  156105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156106. protected _getFilenameAndPath(): {
  156107. filename: string;
  156108. path: string;
  156109. };
  156110. protected _getModelLoadingConstraints(): boolean;
  156111. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156112. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156113. protected _updateModel(): void;
  156114. /**
  156115. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156116. * between the touch and touch 2.
  156117. */
  156118. private _isQuest;
  156119. }
  156120. }
  156121. declare module BABYLON {
  156122. /**
  156123. * The motion controller class for the standard HTC-Vive controllers
  156124. */
  156125. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156126. private _modelRootNode;
  156127. /**
  156128. * The base url used to load the left and right controller models
  156129. */
  156130. static MODEL_BASE_URL: string;
  156131. /**
  156132. * File name for the controller model.
  156133. */
  156134. static MODEL_FILENAME: string;
  156135. profileId: string;
  156136. /**
  156137. * Create a new Vive motion controller object
  156138. * @param scene the scene to use to create this controller
  156139. * @param gamepadObject the corresponding gamepad object
  156140. * @param handedness the handedness of the controller
  156141. */
  156142. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156143. protected _getFilenameAndPath(): {
  156144. filename: string;
  156145. path: string;
  156146. };
  156147. protected _getModelLoadingConstraints(): boolean;
  156148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156150. protected _updateModel(): void;
  156151. }
  156152. }
  156153. declare module BABYLON {
  156154. /**
  156155. * A cursor which tracks a point on a path
  156156. */
  156157. export class PathCursor {
  156158. private path;
  156159. /**
  156160. * Stores path cursor callbacks for when an onchange event is triggered
  156161. */
  156162. private _onchange;
  156163. /**
  156164. * The value of the path cursor
  156165. */
  156166. value: number;
  156167. /**
  156168. * The animation array of the path cursor
  156169. */
  156170. animations: Animation[];
  156171. /**
  156172. * Initializes the path cursor
  156173. * @param path The path to track
  156174. */
  156175. constructor(path: Path2);
  156176. /**
  156177. * Gets the cursor point on the path
  156178. * @returns A point on the path cursor at the cursor location
  156179. */
  156180. getPoint(): Vector3;
  156181. /**
  156182. * Moves the cursor ahead by the step amount
  156183. * @param step The amount to move the cursor forward
  156184. * @returns This path cursor
  156185. */
  156186. moveAhead(step?: number): PathCursor;
  156187. /**
  156188. * Moves the cursor behind by the step amount
  156189. * @param step The amount to move the cursor back
  156190. * @returns This path cursor
  156191. */
  156192. moveBack(step?: number): PathCursor;
  156193. /**
  156194. * Moves the cursor by the step amount
  156195. * If the step amount is greater than one, an exception is thrown
  156196. * @param step The amount to move the cursor
  156197. * @returns This path cursor
  156198. */
  156199. move(step: number): PathCursor;
  156200. /**
  156201. * Ensures that the value is limited between zero and one
  156202. * @returns This path cursor
  156203. */
  156204. private ensureLimits;
  156205. /**
  156206. * Runs onchange callbacks on change (used by the animation engine)
  156207. * @returns This path cursor
  156208. */
  156209. private raiseOnChange;
  156210. /**
  156211. * Executes a function on change
  156212. * @param f A path cursor onchange callback
  156213. * @returns This path cursor
  156214. */
  156215. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156216. }
  156217. }
  156218. declare module BABYLON {
  156219. /** @hidden */
  156220. export var blurPixelShader: {
  156221. name: string;
  156222. shader: string;
  156223. };
  156224. }
  156225. declare module BABYLON {
  156226. /** @hidden */
  156227. export var pointCloudVertexDeclaration: {
  156228. name: string;
  156229. shader: string;
  156230. };
  156231. }
  156232. // Mixins
  156233. interface Window {
  156234. mozIndexedDB: IDBFactory;
  156235. webkitIndexedDB: IDBFactory;
  156236. msIndexedDB: IDBFactory;
  156237. webkitURL: typeof URL;
  156238. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156239. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156240. WebGLRenderingContext: WebGLRenderingContext;
  156241. MSGesture: MSGesture;
  156242. CANNON: any;
  156243. AudioContext: AudioContext;
  156244. webkitAudioContext: AudioContext;
  156245. PointerEvent: any;
  156246. Math: Math;
  156247. Uint8Array: Uint8ArrayConstructor;
  156248. Float32Array: Float32ArrayConstructor;
  156249. mozURL: typeof URL;
  156250. msURL: typeof URL;
  156251. VRFrameData: any; // WebVR, from specs 1.1
  156252. DracoDecoderModule: any;
  156253. setImmediate(handler: (...args: any[]) => void): number;
  156254. }
  156255. interface HTMLCanvasElement {
  156256. requestPointerLock(): void;
  156257. msRequestPointerLock?(): void;
  156258. mozRequestPointerLock?(): void;
  156259. webkitRequestPointerLock?(): void;
  156260. /** Track wether a record is in progress */
  156261. isRecording: boolean;
  156262. /** Capture Stream method defined by some browsers */
  156263. captureStream(fps?: number): MediaStream;
  156264. }
  156265. interface CanvasRenderingContext2D {
  156266. msImageSmoothingEnabled: boolean;
  156267. }
  156268. interface MouseEvent {
  156269. mozMovementX: number;
  156270. mozMovementY: number;
  156271. webkitMovementX: number;
  156272. webkitMovementY: number;
  156273. msMovementX: number;
  156274. msMovementY: number;
  156275. }
  156276. interface Navigator {
  156277. mozGetVRDevices: (any: any) => any;
  156278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156281. webkitGetGamepads(): Gamepad[];
  156282. msGetGamepads(): Gamepad[];
  156283. webkitGamepads(): Gamepad[];
  156284. }
  156285. interface HTMLVideoElement {
  156286. mozSrcObject: any;
  156287. }
  156288. interface Math {
  156289. fround(x: number): number;
  156290. imul(a: number, b: number): number;
  156291. }
  156292. interface WebGLRenderingContext {
  156293. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156294. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156295. vertexAttribDivisor(index: number, divisor: number): void;
  156296. createVertexArray(): any;
  156297. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156298. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156299. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156300. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156301. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156302. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156303. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156304. // Queries
  156305. createQuery(): WebGLQuery;
  156306. deleteQuery(query: WebGLQuery): void;
  156307. beginQuery(target: number, query: WebGLQuery): void;
  156308. endQuery(target: number): void;
  156309. getQueryParameter(query: WebGLQuery, pname: number): any;
  156310. getQuery(target: number, pname: number): any;
  156311. MAX_SAMPLES: number;
  156312. RGBA8: number;
  156313. READ_FRAMEBUFFER: number;
  156314. DRAW_FRAMEBUFFER: number;
  156315. UNIFORM_BUFFER: number;
  156316. HALF_FLOAT_OES: number;
  156317. RGBA16F: number;
  156318. RGBA32F: number;
  156319. R32F: number;
  156320. RG32F: number;
  156321. RGB32F: number;
  156322. R16F: number;
  156323. RG16F: number;
  156324. RGB16F: number;
  156325. RED: number;
  156326. RG: number;
  156327. R8: number;
  156328. RG8: number;
  156329. UNSIGNED_INT_24_8: number;
  156330. DEPTH24_STENCIL8: number;
  156331. MIN: number;
  156332. MAX: number;
  156333. /* Multiple Render Targets */
  156334. drawBuffers(buffers: number[]): void;
  156335. readBuffer(src: number): void;
  156336. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156337. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156338. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156339. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156340. // Occlusion Query
  156341. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156342. ANY_SAMPLES_PASSED: number;
  156343. QUERY_RESULT_AVAILABLE: number;
  156344. QUERY_RESULT: number;
  156345. }
  156346. interface WebGLProgram {
  156347. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156348. }
  156349. interface EXT_disjoint_timer_query {
  156350. QUERY_COUNTER_BITS_EXT: number;
  156351. TIME_ELAPSED_EXT: number;
  156352. TIMESTAMP_EXT: number;
  156353. GPU_DISJOINT_EXT: number;
  156354. QUERY_RESULT_EXT: number;
  156355. QUERY_RESULT_AVAILABLE_EXT: number;
  156356. queryCounterEXT(query: WebGLQuery, target: number): void;
  156357. createQueryEXT(): WebGLQuery;
  156358. beginQueryEXT(target: number, query: WebGLQuery): void;
  156359. endQueryEXT(target: number): void;
  156360. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156361. deleteQueryEXT(query: WebGLQuery): void;
  156362. }
  156363. interface WebGLUniformLocation {
  156364. _currentState: any;
  156365. }
  156366. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156367. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156368. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156369. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156370. interface WebGLRenderingContext {
  156371. readonly RASTERIZER_DISCARD: number;
  156372. readonly DEPTH_COMPONENT24: number;
  156373. readonly TEXTURE_3D: number;
  156374. readonly TEXTURE_2D_ARRAY: number;
  156375. readonly TEXTURE_COMPARE_FUNC: number;
  156376. readonly TEXTURE_COMPARE_MODE: number;
  156377. readonly COMPARE_REF_TO_TEXTURE: number;
  156378. readonly TEXTURE_WRAP_R: number;
  156379. readonly HALF_FLOAT: number;
  156380. readonly RGB8: number;
  156381. readonly RED_INTEGER: number;
  156382. readonly RG_INTEGER: number;
  156383. readonly RGB_INTEGER: number;
  156384. readonly RGBA_INTEGER: number;
  156385. readonly R8_SNORM: number;
  156386. readonly RG8_SNORM: number;
  156387. readonly RGB8_SNORM: number;
  156388. readonly RGBA8_SNORM: number;
  156389. readonly R8I: number;
  156390. readonly RG8I: number;
  156391. readonly RGB8I: number;
  156392. readonly RGBA8I: number;
  156393. readonly R8UI: number;
  156394. readonly RG8UI: number;
  156395. readonly RGB8UI: number;
  156396. readonly RGBA8UI: number;
  156397. readonly R16I: number;
  156398. readonly RG16I: number;
  156399. readonly RGB16I: number;
  156400. readonly RGBA16I: number;
  156401. readonly R16UI: number;
  156402. readonly RG16UI: number;
  156403. readonly RGB16UI: number;
  156404. readonly RGBA16UI: number;
  156405. readonly R32I: number;
  156406. readonly RG32I: number;
  156407. readonly RGB32I: number;
  156408. readonly RGBA32I: number;
  156409. readonly R32UI: number;
  156410. readonly RG32UI: number;
  156411. readonly RGB32UI: number;
  156412. readonly RGBA32UI: number;
  156413. readonly RGB10_A2UI: number;
  156414. readonly R11F_G11F_B10F: number;
  156415. readonly RGB9_E5: number;
  156416. readonly RGB10_A2: number;
  156417. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156418. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156419. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156420. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156421. readonly DEPTH_COMPONENT32F: number;
  156422. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156423. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156424. 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;
  156425. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156426. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156427. readonly TRANSFORM_FEEDBACK: number;
  156428. readonly INTERLEAVED_ATTRIBS: number;
  156429. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156430. createTransformFeedback(): WebGLTransformFeedback;
  156431. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156432. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156433. beginTransformFeedback(primitiveMode: number): void;
  156434. endTransformFeedback(): void;
  156435. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156436. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156437. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156438. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156439. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156440. }
  156441. interface ImageBitmap {
  156442. readonly width: number;
  156443. readonly height: number;
  156444. close(): void;
  156445. }
  156446. interface WebGLQuery extends WebGLObject {
  156447. }
  156448. declare var WebGLQuery: {
  156449. prototype: WebGLQuery;
  156450. new(): WebGLQuery;
  156451. };
  156452. interface WebGLSampler extends WebGLObject {
  156453. }
  156454. declare var WebGLSampler: {
  156455. prototype: WebGLSampler;
  156456. new(): WebGLSampler;
  156457. };
  156458. interface WebGLSync extends WebGLObject {
  156459. }
  156460. declare var WebGLSync: {
  156461. prototype: WebGLSync;
  156462. new(): WebGLSync;
  156463. };
  156464. interface WebGLTransformFeedback extends WebGLObject {
  156465. }
  156466. declare var WebGLTransformFeedback: {
  156467. prototype: WebGLTransformFeedback;
  156468. new(): WebGLTransformFeedback;
  156469. };
  156470. interface WebGLVertexArrayObject extends WebGLObject {
  156471. }
  156472. declare var WebGLVertexArrayObject: {
  156473. prototype: WebGLVertexArrayObject;
  156474. new(): WebGLVertexArrayObject;
  156475. };
  156476. // Type definitions for WebVR API
  156477. // Project: https://w3c.github.io/webvr/
  156478. // Definitions by: six a <https://github.com/lostfictions>
  156479. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156480. interface VRDisplay extends EventTarget {
  156481. /**
  156482. * Dictionary of capabilities describing the VRDisplay.
  156483. */
  156484. readonly capabilities: VRDisplayCapabilities;
  156485. /**
  156486. * z-depth defining the far plane of the eye view frustum
  156487. * enables mapping of values in the render target depth
  156488. * attachment to scene coordinates. Initially set to 10000.0.
  156489. */
  156490. depthFar: number;
  156491. /**
  156492. * z-depth defining the near plane of the eye view frustum
  156493. * enables mapping of values in the render target depth
  156494. * attachment to scene coordinates. Initially set to 0.01.
  156495. */
  156496. depthNear: number;
  156497. /**
  156498. * An identifier for this distinct VRDisplay. Used as an
  156499. * association point in the Gamepad API.
  156500. */
  156501. readonly displayId: number;
  156502. /**
  156503. * A display name, a user-readable name identifying it.
  156504. */
  156505. readonly displayName: string;
  156506. readonly isConnected: boolean;
  156507. readonly isPresenting: boolean;
  156508. /**
  156509. * If this VRDisplay supports room-scale experiences, the optional
  156510. * stage attribute contains details on the room-scale parameters.
  156511. */
  156512. readonly stageParameters: VRStageParameters | null;
  156513. /**
  156514. * Passing the value returned by `requestAnimationFrame` to
  156515. * `cancelAnimationFrame` will unregister the callback.
  156516. * @param handle Define the hanle of the request to cancel
  156517. */
  156518. cancelAnimationFrame(handle: number): void;
  156519. /**
  156520. * Stops presenting to the VRDisplay.
  156521. * @returns a promise to know when it stopped
  156522. */
  156523. exitPresent(): Promise<void>;
  156524. /**
  156525. * Return the current VREyeParameters for the given eye.
  156526. * @param whichEye Define the eye we want the parameter for
  156527. * @returns the eye parameters
  156528. */
  156529. getEyeParameters(whichEye: string): VREyeParameters;
  156530. /**
  156531. * Populates the passed VRFrameData with the information required to render
  156532. * the current frame.
  156533. * @param frameData Define the data structure to populate
  156534. * @returns true if ok otherwise false
  156535. */
  156536. getFrameData(frameData: VRFrameData): boolean;
  156537. /**
  156538. * Get the layers currently being presented.
  156539. * @returns the list of VR layers
  156540. */
  156541. getLayers(): VRLayer[];
  156542. /**
  156543. * Return a VRPose containing the future predicted pose of the VRDisplay
  156544. * when the current frame will be presented. The value returned will not
  156545. * change until JavaScript has returned control to the browser.
  156546. *
  156547. * The VRPose will contain the position, orientation, velocity,
  156548. * and acceleration of each of these properties.
  156549. * @returns the pose object
  156550. */
  156551. getPose(): VRPose;
  156552. /**
  156553. * Return the current instantaneous pose of the VRDisplay, with no
  156554. * prediction applied.
  156555. * @returns the current instantaneous pose
  156556. */
  156557. getImmediatePose(): VRPose;
  156558. /**
  156559. * The callback passed to `requestAnimationFrame` will be called
  156560. * any time a new frame should be rendered. When the VRDisplay is
  156561. * presenting the callback will be called at the native refresh
  156562. * rate of the HMD. When not presenting this function acts
  156563. * identically to how window.requestAnimationFrame acts. Content should
  156564. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156565. * asynchronously from other displays and at differing refresh rates.
  156566. * @param callback Define the eaction to run next frame
  156567. * @returns the request handle it
  156568. */
  156569. requestAnimationFrame(callback: FrameRequestCallback): number;
  156570. /**
  156571. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156572. * Repeat calls while already presenting will update the VRLayers being displayed.
  156573. * @param layers Define the list of layer to present
  156574. * @returns a promise to know when the request has been fulfilled
  156575. */
  156576. requestPresent(layers: VRLayer[]): Promise<void>;
  156577. /**
  156578. * Reset the pose for this display, treating its current position and
  156579. * orientation as the "origin/zero" values. VRPose.position,
  156580. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156581. * updated when calling resetPose(). This should be called in only
  156582. * sitting-space experiences.
  156583. */
  156584. resetPose(): void;
  156585. /**
  156586. * The VRLayer provided to the VRDisplay will be captured and presented
  156587. * in the HMD. Calling this function has the same effect on the source
  156588. * canvas as any other operation that uses its source image, and canvases
  156589. * created without preserveDrawingBuffer set to true will be cleared.
  156590. * @param pose Define the pose to submit
  156591. */
  156592. submitFrame(pose?: VRPose): void;
  156593. }
  156594. declare var VRDisplay: {
  156595. prototype: VRDisplay;
  156596. new(): VRDisplay;
  156597. };
  156598. interface VRLayer {
  156599. leftBounds?: number[] | Float32Array | null;
  156600. rightBounds?: number[] | Float32Array | null;
  156601. source?: HTMLCanvasElement | null;
  156602. }
  156603. interface VRDisplayCapabilities {
  156604. readonly canPresent: boolean;
  156605. readonly hasExternalDisplay: boolean;
  156606. readonly hasOrientation: boolean;
  156607. readonly hasPosition: boolean;
  156608. readonly maxLayers: number;
  156609. }
  156610. interface VREyeParameters {
  156611. /** @deprecated */
  156612. readonly fieldOfView: VRFieldOfView;
  156613. readonly offset: Float32Array;
  156614. readonly renderHeight: number;
  156615. readonly renderWidth: number;
  156616. }
  156617. interface VRFieldOfView {
  156618. readonly downDegrees: number;
  156619. readonly leftDegrees: number;
  156620. readonly rightDegrees: number;
  156621. readonly upDegrees: number;
  156622. }
  156623. interface VRFrameData {
  156624. readonly leftProjectionMatrix: Float32Array;
  156625. readonly leftViewMatrix: Float32Array;
  156626. readonly pose: VRPose;
  156627. readonly rightProjectionMatrix: Float32Array;
  156628. readonly rightViewMatrix: Float32Array;
  156629. readonly timestamp: number;
  156630. }
  156631. interface VRPose {
  156632. readonly angularAcceleration: Float32Array | null;
  156633. readonly angularVelocity: Float32Array | null;
  156634. readonly linearAcceleration: Float32Array | null;
  156635. readonly linearVelocity: Float32Array | null;
  156636. readonly orientation: Float32Array | null;
  156637. readonly position: Float32Array | null;
  156638. readonly timestamp: number;
  156639. }
  156640. interface VRStageParameters {
  156641. sittingToStandingTransform?: Float32Array;
  156642. sizeX?: number;
  156643. sizeY?: number;
  156644. }
  156645. interface Navigator {
  156646. getVRDisplays(): Promise<VRDisplay[]>;
  156647. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156648. }
  156649. interface Window {
  156650. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156651. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156652. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156653. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156654. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156655. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156656. }
  156657. interface Gamepad {
  156658. readonly displayId: number;
  156659. }
  156660. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156661. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156662. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156663. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156664. type XRHandedness = "none" | "left" | "right";
  156665. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156666. type XREye = "none" | "left" | "right";
  156667. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156668. interface XRSpace extends EventTarget {}
  156669. interface XRRenderState {
  156670. depthNear?: number;
  156671. depthFar?: number;
  156672. inlineVerticalFieldOfView?: number;
  156673. baseLayer?: XRWebGLLayer;
  156674. }
  156675. interface XRInputSource {
  156676. handedness: XRHandedness;
  156677. targetRayMode: XRTargetRayMode;
  156678. targetRaySpace: XRSpace;
  156679. gripSpace: XRSpace | undefined;
  156680. gamepad: Gamepad | undefined;
  156681. profiles: Array<string>;
  156682. hand: XRHand | undefined;
  156683. }
  156684. interface XRSessionInit {
  156685. optionalFeatures?: string[];
  156686. requiredFeatures?: string[];
  156687. }
  156688. interface XRSession {
  156689. addEventListener: Function;
  156690. removeEventListener: Function;
  156691. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156692. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156693. requestAnimationFrame: Function;
  156694. end(): Promise<void>;
  156695. renderState: XRRenderState;
  156696. inputSources: Array<XRInputSource>;
  156697. // hit test
  156698. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156699. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156700. // legacy AR hit test
  156701. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156702. // legacy plane detection
  156703. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156704. }
  156705. interface XRReferenceSpace extends XRSpace {
  156706. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156707. onreset: any;
  156708. }
  156709. type XRPlaneSet = Set<XRPlane>;
  156710. type XRAnchorSet = Set<XRAnchor>;
  156711. interface XRFrame {
  156712. session: XRSession;
  156713. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156714. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156715. // AR
  156716. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156717. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156718. // Anchors
  156719. trackedAnchors?: XRAnchorSet;
  156720. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156721. // Planes
  156722. worldInformation: {
  156723. detectedPlanes?: XRPlaneSet;
  156724. };
  156725. // Hand tracking
  156726. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156727. }
  156728. interface XRViewerPose extends XRPose {
  156729. views: Array<XRView>;
  156730. }
  156731. interface XRPose {
  156732. transform: XRRigidTransform;
  156733. emulatedPosition: boolean;
  156734. }
  156735. interface XRWebGLLayerOptions {
  156736. antialias?: boolean;
  156737. depth?: boolean;
  156738. stencil?: boolean;
  156739. alpha?: boolean;
  156740. multiview?: boolean;
  156741. framebufferScaleFactor?: number;
  156742. }
  156743. declare var XRWebGLLayer: {
  156744. prototype: XRWebGLLayer;
  156745. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156746. };
  156747. interface XRWebGLLayer {
  156748. framebuffer: WebGLFramebuffer;
  156749. framebufferWidth: number;
  156750. framebufferHeight: number;
  156751. getViewport: Function;
  156752. }
  156753. declare class XRRigidTransform {
  156754. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156755. position: DOMPointReadOnly;
  156756. orientation: DOMPointReadOnly;
  156757. matrix: Float32Array;
  156758. inverse: XRRigidTransform;
  156759. }
  156760. interface XRView {
  156761. eye: XREye;
  156762. projectionMatrix: Float32Array;
  156763. transform: XRRigidTransform;
  156764. }
  156765. interface XRInputSourceChangeEvent {
  156766. session: XRSession;
  156767. removed: Array<XRInputSource>;
  156768. added: Array<XRInputSource>;
  156769. }
  156770. interface XRInputSourceEvent extends Event {
  156771. readonly frame: XRFrame;
  156772. readonly inputSource: XRInputSource;
  156773. }
  156774. // Experimental(er) features
  156775. declare class XRRay {
  156776. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156777. origin: DOMPointReadOnly;
  156778. direction: DOMPointReadOnly;
  156779. matrix: Float32Array;
  156780. }
  156781. declare enum XRHitTestTrackableType {
  156782. "point",
  156783. "plane",
  156784. "mesh",
  156785. }
  156786. interface XRHitResult {
  156787. hitMatrix: Float32Array;
  156788. }
  156789. interface XRTransientInputHitTestResult {
  156790. readonly inputSource: XRInputSource;
  156791. readonly results: Array<XRHitTestResult>;
  156792. }
  156793. interface XRHitTestResult {
  156794. getPose(baseSpace: XRSpace): XRPose | undefined;
  156795. // When anchor system is enabled
  156796. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156797. }
  156798. interface XRHitTestSource {
  156799. cancel(): void;
  156800. }
  156801. interface XRTransientInputHitTestSource {
  156802. cancel(): void;
  156803. }
  156804. interface XRHitTestOptionsInit {
  156805. space: XRSpace;
  156806. entityTypes?: Array<XRHitTestTrackableType>;
  156807. offsetRay?: XRRay;
  156808. }
  156809. interface XRTransientInputHitTestOptionsInit {
  156810. profile: string;
  156811. entityTypes?: Array<XRHitTestTrackableType>;
  156812. offsetRay?: XRRay;
  156813. }
  156814. interface XRAnchor {
  156815. anchorSpace: XRSpace;
  156816. delete(): void;
  156817. }
  156818. interface XRPlane {
  156819. orientation: "Horizontal" | "Vertical";
  156820. planeSpace: XRSpace;
  156821. polygon: Array<DOMPointReadOnly>;
  156822. lastChangedTime: number;
  156823. }
  156824. interface XRJointSpace extends XRSpace {}
  156825. interface XRJointPose extends XRPose {
  156826. radius: number | undefined;
  156827. }
  156828. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156829. readonly length: number;
  156830. [index: number]: XRJointSpace;
  156831. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156832. readonly WRIST: number;
  156833. readonly THUMB_METACARPAL: number;
  156834. readonly THUMB_PHALANX_PROXIMAL: number;
  156835. readonly THUMB_PHALANX_DISTAL: number;
  156836. readonly THUMB_PHALANX_TIP: number;
  156837. readonly INDEX_METACARPAL: number;
  156838. readonly INDEX_PHALANX_PROXIMAL: number;
  156839. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156840. readonly INDEX_PHALANX_DISTAL: number;
  156841. readonly INDEX_PHALANX_TIP: number;
  156842. readonly MIDDLE_METACARPAL: number;
  156843. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156844. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156845. readonly MIDDLE_PHALANX_DISTAL: number;
  156846. readonly MIDDLE_PHALANX_TIP: number;
  156847. readonly RING_METACARPAL: number;
  156848. readonly RING_PHALANX_PROXIMAL: number;
  156849. readonly RING_PHALANX_INTERMEDIATE: number;
  156850. readonly RING_PHALANX_DISTAL: number;
  156851. readonly RING_PHALANX_TIP: number;
  156852. readonly LITTLE_METACARPAL: number;
  156853. readonly LITTLE_PHALANX_PROXIMAL: number;
  156854. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156855. readonly LITTLE_PHALANX_DISTAL: number;
  156856. readonly LITTLE_PHALANX_TIP: number;
  156857. }
  156858. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156859. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156860. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156861. interface XRSession {
  156862. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156863. }
  156864. interface XRFrame {
  156865. featurePointCloud? : Array<number>;
  156866. }